Skip to content

Commit

Permalink
Merge pull request #12 from Fueled/rename-itemHandler
Browse files Browse the repository at this point in the history
Rename `ItemHandler` to `ItemPresenter`
  • Loading branch information
Hussein Aladeen authored Feb 27, 2018
2 parents a638446 + f25f2ea commit fcadf14
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</intent-filter>
</activity>
<activity android:name=".hearder.HearderFooterActivity"/>
<activity android:name=".handler.ItemHandlerActivity"/>
<activity android:name=".handler.ItemPresenterActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.view.MenuItem;

import com.fueled.reclaim.ItemsViewAdapter;
import com.fueled.reclaim.samples.handler.ItemHandlerActivity;
import com.fueled.reclaim.samples.handler.ItemPresenterActivity;
import com.fueled.reclaim.samples.hearder.HearderFooterActivity;

import java.util.ArrayList;
Expand Down Expand Up @@ -66,7 +66,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
case R.id.handlerMenu:
startActivity(new Intent(this, ItemHandlerActivity.class));
startActivity(new Intent(this, ItemPresenterActivity.class));
finish();
return true;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.fueled.reclaim.BaseItem;
import com.fueled.reclaim.BaseViewHolder;
import com.fueled.reclaim.ItemHandlerProvider;
import com.fueled.reclaim.ItemPresenterProvider;
import com.fueled.reclaim.samples.ExampleType;


Expand All @@ -15,16 +15,16 @@
* Created by julienFueled on 9/12/16.
* Copyright (c) 2016 Fueled. All rights reserved.
*/
public class HandledItem extends BaseItem<Class<? extends AppCompatActivity>, SampleHandler, HandledItem.ViewHolder> {
public class HandledItem extends BaseItem<Class<? extends AppCompatActivity>, SamplePresenter, HandledItem.ViewHolder> {

/**
* Constructor to use when creating a new card.
*
* @param data the data object for the card
* @param itemHandlerProvider the object responsible for providing the correct handler for this
* @param itemPresenterProvider the object responsible for providing the correct handler for this
*/
public HandledItem(Class<? extends AppCompatActivity> data, ItemHandlerProvider<SampleHandler> itemHandlerProvider) {
super(data, itemHandlerProvider);
public HandledItem(Class<? extends AppCompatActivity> data, ItemPresenterProvider<SamplePresenter> itemPresenterProvider) {
super(data, itemPresenterProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.fueled.reclaim.ItemHandlerProvider;
import com.fueled.reclaim.ItemPresenterProvider;
import com.fueled.reclaim.ItemsViewAdapter;
import com.fueled.reclaim.samples.MainActivity;
import com.fueled.reclaim.samples.R;
Expand All @@ -19,8 +19,8 @@
* Created by julienFueled on 9/12/16.
* Copyright (c) 2016 Fueled. All rights reserved.
*/
public class ItemHandlerActivity extends AppCompatActivity implements
ItemHandlerProvider<SampleHandler>, SampleHandler {
public class ItemPresenterActivity extends AppCompatActivity implements
ItemPresenterProvider<SamplePresenter>, SamplePresenter {

private RecyclerView recyclerView;
private ItemsViewAdapter adapter;
Expand Down Expand Up @@ -49,7 +49,7 @@ protected void onResume() {
}

@Override
public SampleHandler getItemHandler() {
public SamplePresenter getItemPresenter() {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Created by julienFueled on 9/12/16.
* Copyright (c) 2016 Fueled. All rights reserved.
*/
public interface SampleHandler {
public interface SamplePresenter {

void goToActivity(Class<? extends AppCompatActivity> activity);
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 08 18:21:21 GMT 2017
#Mon Feb 26 10:20:35 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ BastItem class has 3 parameters:
```java
public class PlanetItem extends BaseItem<String, Void, PlanetItem.ViewHolder> {

public PlanetItem(String data, ItemHandlerProvider<Void> itemHandlerProvider) {
super(data, itemHandlerProvider);
public PlanetItem(String data, ItemPresenterProvider<Void> itemPresenterProvider) {
super(data, itemPresenterProvider);
}

@Override
Expand Down Expand Up @@ -111,14 +111,14 @@ recyclerView.setAdapter(adapter);
## Interaction between item object and other components
More often then not, each item of a list contains interation with other component of your application; starting a new Activity, triggering an HTTP call, updating other UI component etc...

In that you can pass a `ItemHandler` object to your item. This `ItemHandler` can be an Activity, a Fragment, a helper class etc...
In that you can pass a `ItemPresenter` object to your item. This `ItemPresenter` can be an Activity, a Fragment, a helper class etc...

**Caution: the object passed to the construtor of your item needs to implement [ItemHandlerProvider](reclaim/src/main/java/com/fueled/reclaim/ItemHandlerProvider.java) and not the ItemHandler itself.**
**Caution: the object passed to the construtor of your item needs to implement [ItemPresenterProvider](reclaim/src/main/java/com/fueled/reclaim/ItemPresenterProvider.java) and not the ItemPresenter itself.**

```java
public class HandledItem extends BaseItem<Class<? extends AppCompatActivity>, SampleHandler, HandledItem.ViewHolder> {
public HandledItem(Class<? extends AppCompatActivity> data, ItemHandlerProvider<SampleHandler> itemHandlerProvider) {
super(data, itemHandlerProvider);
public HandledItem(Class<? extends AppCompatActivity> data, ItemPresenterProvider<SampleHandler> itemPresenterProvider) {
super(data, itemPresenterProvider);
}

@Override
Expand All @@ -140,7 +140,7 @@ public class HandledItem extends BaseItem<Class<? extends AppCompatActivity>, Sa
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getitemHandler().goToActivity(activity);
getitemPresenter().goToActivity(activity);
}
});
}
Expand All @@ -164,7 +164,7 @@ public class HandledItem extends BaseItem<Class<? extends AppCompatActivity>, Sa
in the activity:

```java
public class ItemHandlerActivity extends AppCompatActivity implements ItemHandlerProvider<SampleHandler>, SampleHandler {
public class ItemPresenterActivity extends AppCompatActivity implements ItemPresenterProvider<SampleHandler>, SampleHandler {
RecyclerView recyclerView;
ItemsViewAdapter adapter;

Expand Down Expand Up @@ -193,7 +193,7 @@ public class ItemHandlerActivity extends AppCompatActivity implements ItemHandle
}

@Override
public SampleHandler getItemHandler() {
public SampleHandler getItemPresenter() {
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion reclaim/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.github.fueled'
version = '1.1.2'
version = '1.2.0'

android {
compileSdkVersion compileSdk
Expand Down
12 changes: 6 additions & 6 deletions reclaim/src/main/java/com/fueled/reclaim/BaseItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public abstract class BaseItem<T1, T2, T3 extends BaseViewHolder> {

protected int layoutId;
protected ItemHandlerProvider<T2> itemHandlerProvider;
protected ItemPresenterProvider<T2> itemPresenterProvider;

private T1 data;
private T3 viewHolder;
Expand All @@ -23,13 +23,13 @@ public abstract class BaseItem<T1, T2, T3 extends BaseViewHolder> {
* Constructor to use when creating a new Item.
*
* @param data the data object for the Item
* @param itemHandlerProvider the object responsible for providing the correct handler for this
* @param itemPresenterProvider the object responsible for providing the correct handler for this
* item
*/
public BaseItem(T1 data, ItemHandlerProvider<T2> itemHandlerProvider) {
public BaseItem(T1 data, ItemPresenterProvider<T2> itemPresenterProvider) {
this.layoutId = getLayoutId();
this.data = data;
this.itemHandlerProvider = itemHandlerProvider;
this.itemPresenterProvider = itemPresenterProvider;
}

/**
Expand Down Expand Up @@ -125,8 +125,8 @@ public void setItemData(T1 data) {
*/
public T2 getItemHandler() {
T2 itemHandler = null;
if (itemHandlerProvider != null) {
itemHandler = itemHandlerProvider.getItemHandler();
if (itemPresenterProvider != null) {
itemHandler = itemPresenterProvider.getItemPresenter();
}

return itemHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Created by [email protected] on 02/03/2016.
* Copyright (c) 2016 Fueled. All rights reserved.
*/
public interface ItemHandlerProvider<T> {
public interface ItemPresenterProvider<T> {

T getItemHandler();
T getItemPresenter();
}

0 comments on commit fcadf14

Please sign in to comment.