-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d71bdc
commit 333cfc4
Showing
16 changed files
with
224 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/wisdomlanna/www/dagger2_mvp_example/ui/base/adapter/BaseItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ava/com/wisdomlanna/www/dagger2_mvp_example/ui/base/adapter/loadmore/LoadmoreAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.loadmore; | ||
|
||
import android.view.ViewGroup; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItem; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItemType; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseListAdapter; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseViewHolder; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.progress.ProgressHolder; | ||
|
||
import java.util.List; | ||
|
||
public abstract class LoadmoreAdapter<VH extends BaseViewHolder, P extends LoadmoreAdapterInterface.Presenter> | ||
extends BaseListAdapter<VH, P> | ||
implements LoadmoreAdapterInterface.Adapter { | ||
|
||
private OnLoadMoreListener loadMoreListener; | ||
|
||
public void setOnLoadMoreListener(OnLoadMoreListener listener) { | ||
this.loadMoreListener = listener; | ||
} | ||
|
||
public void setItems(List<BaseItem> items, boolean isNextItemAvailable) { | ||
getPresenter().setItems(items, isNextItemAvailable); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public VH onCreateViewHolder(ViewGroup parent, int viewType) { | ||
if (viewType == BaseItemType.TYPE_PROGRESS) { | ||
return (VH) new ProgressHolder(parent); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(VH holder, int position) { | ||
if (getItemViewType(position) == BaseItemType.TYPE_PROGRESS) { | ||
if (loadMoreListener != null) { | ||
loadMoreListener.onLoadMore(); | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...isdomlanna/www/dagger2_mvp_example/ui/base/adapter/loadmore/LoadmoreAdapterInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.loadmore; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItem; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseListAdapterInterface; | ||
|
||
import java.util.List; | ||
|
||
public interface LoadmoreAdapterInterface { | ||
|
||
interface Adapter extends BaseListAdapterInterface.Adapter { | ||
} | ||
|
||
interface Presenter<A extends LoadmoreAdapterInterface.Adapter> | ||
extends BaseListAdapterInterface.Presenter<A> { | ||
void setItems(List<BaseItem> items, boolean isNextItemAvailable); | ||
} | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
...isdomlanna/www/dagger2_mvp_example/ui/base/adapter/loadmore/LoadmoreAdapterPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.loadmore; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItem; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItemType; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseListAdapterPresenter; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.progress.ProgressItem; | ||
|
||
import java.util.List; | ||
|
||
public abstract class LoadmoreAdapterPresenter<A extends LoadmoreAdapterInterface.Adapter> | ||
extends BaseListAdapterPresenter<A> implements LoadmoreAdapterInterface.Presenter<A> { | ||
|
||
private boolean isNextItemAvailable; | ||
|
||
@Override | ||
public int getItemViewType(int pos) { | ||
if (pos >= super.getItemCount()) { | ||
return BaseItemType.TYPE_PROGRESS; | ||
} | ||
return super.getItemViewType(pos); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
int count = super.getItemCount(); | ||
if (isNextItemAvailable) { | ||
count++; | ||
} | ||
return count; | ||
} | ||
|
||
|
||
@Override | ||
public BaseItem getItem(int pos) { | ||
if (pos >= super.getItemCount()) { | ||
return new ProgressItem(); | ||
} | ||
return super.getItem(pos); | ||
} | ||
|
||
@Override | ||
public void setItems(List<BaseItem> items, boolean isNextItemAvailable) { | ||
super.setItems(items); | ||
this.isNextItemAvailable = isNextItemAvailable; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...java/com/wisdomlanna/www/dagger2_mvp_example/ui/base/adapter/progress/ProgressHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.progress; | ||
|
||
import android.view.ViewGroup; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.R; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseViewHolder; | ||
|
||
public class ProgressHolder extends BaseViewHolder { | ||
|
||
public ProgressHolder(ViewGroup viewGroup) { | ||
super(viewGroup, R.layout.holder_progress); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/java/com/wisdomlanna/www/dagger2_mvp_example/ui/base/adapter/progress/ProgressItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.progress; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItem; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseItemType; | ||
|
||
public class ProgressItem extends BaseItem { | ||
public ProgressItem() { | ||
super(BaseItemType.TYPE_PROGRESS); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ain/java/com/wisdomlanna/www/dagger2_mvp_example/ui/showlist/adapter/ShowListAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.showlist.adapter; | ||
|
||
import android.view.ViewGroup; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseListAdapter; | ||
|
||
public class ShowListAdapter extends BaseListAdapter<ShowListViewHolder, ShowListPresenterInterface.Presenter> | ||
implements ShowListPresenterInterface.Adapter { | ||
|
||
@Override | ||
public ShowListPresenterInterface.Presenter createPresenter() { | ||
return ShowListAdapterPresenter.create(); | ||
} | ||
|
||
@Override | ||
public ShowListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(ShowListViewHolder holder, int position) { | ||
|
||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return 0; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...com/wisdomlanna/www/dagger2_mvp_example/ui/showlist/adapter/ShowListAdapterPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.showlist.adapter; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseListAdapterPresenter; | ||
|
||
class ShowListAdapterPresenter extends BaseListAdapterPresenter<ShowListPresenterInterface.Adapter> | ||
implements ShowListPresenterInterface.Presenter { | ||
|
||
public static ShowListPresenterInterface.Presenter create() { | ||
return new ShowListAdapterPresenter(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...m/wisdomlanna/www/dagger2_mvp_example/ui/showlist/adapter/ShowListPresenterInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.showlist.adapter; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseListAdapterInterface; | ||
|
||
class ShowListPresenterInterface { | ||
|
||
interface Adapter extends BaseListAdapterInterface.Adapter { | ||
|
||
} | ||
|
||
interface Presenter extends BaseListAdapterInterface.Presenter<ShowListPresenterInterface.Adapter> { | ||
|
||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../java/com/wisdomlanna/www/dagger2_mvp_example/ui/showlist/adapter/ShowListViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.ui.showlist.adapter; | ||
|
||
import android.view.ViewGroup; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.adapter.BaseViewHolder; | ||
|
||
class ShowListViewHolder extends BaseViewHolder { | ||
|
||
public ShowListViewHolder(ViewGroup parent, int layout) { | ||
super(parent, layout); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.CardView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:clipChildren="false" | ||
android:clickable="true" | ||
android:layout_marginEnd="@dimen/default_padding_margin_small" | ||
app:cardPreventCornerOverlap="false" | ||
app:cardUseCompatPadding="true"> | ||
|
||
<ProgressBar | ||
android:layout_margin="@dimen/default_padding_margin" | ||
android:layout_gravity="center" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"/> | ||
|
||
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters