Skip to content

Commit

Permalink
更新EasyRecyclerView
Browse files Browse the repository at this point in the history
  • Loading branch information
Jude95 committed Feb 2, 2016
1 parent 9c35d6a commit fe7c1d4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Beam 是一套基于MVP模式的快速开发框架。定义了一套开发规范。并提供了基于这套规范的Activity,Fragment,Presenter,Model等父类及控件和API等,完成APP开发过程中大量繁琐工作。

##依赖
`compile 'com.jude:beam:2.6.2'`
`compile 'com.jude:beam:2.6.5'`

##MVP概念
MVP模式在Android开发中的使用越来越流行,它十分适合Android。最好先看看[本框架对MVP的理解](http://www.jianshu.com/p/ed2aa9546c2c)
Expand Down
4 changes: 2 additions & 2 deletions beam/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.jude:easyrecyclerview:3.3.4'
compile 'com.jude:easyrecyclerview:3.3.5'
compile 'io.reactivex:rxandroid:1.0.1'
}

Expand All @@ -31,7 +31,7 @@ ext {
gitUrl = 'https://github.com/Jude95/RequestVolley'


libraryVersion = '2.6.2'//版本号
libraryVersion = '2.6.5'//版本号
libraryName = 'beam'//项目名字,没什么用
libraryDescription = 'A framwork for Android'//项目描述,没什么用

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void onCreate(Bundle savedInstanceState) {
createRecycler();
findRecycler();
initList();
if (mListConfig.mStartWithProgress) mListView.setAdapterWithProgress(mAdapter = getPresenter().createDataAdapter());
if (mListConfig.mStartWithProgress&&!getPresenter().inited) mListView.setAdapterWithProgress(mAdapter = getPresenter().createDataAdapter());
else mListView.setAdapter(mAdapter = getPresenter().createDataAdapter());
initAdapter();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.ViewGroup;

import com.jude.beam.bijection.Presenter;
Expand All @@ -21,18 +20,21 @@ public class BeamListActivityPresenter<T extends BeamListActivity,M> extends Pre
implements RecyclerArrayAdapter.OnLoadMoreListener,SwipeRefreshLayout.OnRefreshListener{
DataAdapter mAdapter;
int page = 0;
boolean inited = false;
Subscriber<List<M>> mRefreshSubscriber = new Subscriber<List<M>>() {
@Override
public void onCompleted() {
}

@Override
public void onError(Throwable e) {
inited = true;
getView().showError();
}

@Override
public void onNext(List<M> ms) {
inited = true;
getAdapter().clear();
getAdapter().addAll(ms);
page = 1;
Expand All @@ -46,7 +48,6 @@ public void onStart() {
@Override
protected void onCreate(T view, Bundle savedState) {
super.onCreate(view, savedState);
Log.i("beam","F"+(getView()==null)+(view==null));

}

Expand All @@ -58,11 +59,13 @@ public void onCompleted() {

@Override
public void onError(Throwable e) {
inited = true;
getAdapter().pauseMore();
}

@Override
public void onNext(List<M> ms) {
inited = true;
getAdapter().addAll(ms);
page++;
}
Expand All @@ -85,7 +88,6 @@ public Subscriber<List<M>> getMoreSubscriber(){
}

DataAdapter createDataAdapter(){
Log.i("beam","F"+(getView()==null));
return mAdapter = new DataAdapter(getView());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public abstract class BeamListFragment<T extends BeamListFragmentPresenter, M> e
private ListConfig mListConfig;
private EasyRecyclerView mListView;
private BeamListFragmentPresenter.DataAdapter mAdapter;

public EasyRecyclerView getListView() {
return mListView;
}
Expand All @@ -41,7 +40,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
createRecycler(container);
findRecycler();
initList();
if (mListConfig.mStartWithProgress) mListView.setAdapterWithProgress(mAdapter = getPresenter().createDataAdapter());
if (mListConfig.mStartWithProgress&&!getPresenter().inited) mListView.setAdapterWithProgress(mAdapter = getPresenter().createDataAdapter());
else mListView.setAdapter(mAdapter = getPresenter().createDataAdapter());
initAdapter();
return mRootView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class BeamListFragmentPresenter<T extends BeamListFragment,M> extends Pre
SwipeRefreshLayout.OnRefreshListener {
DataAdapter mAdapter;
int page = 0;
boolean inited = false;

Subscriber<List<M>> mRefreshSubscriber = new Subscriber<List<M>>() {
@Override
public void onCompleted() {
Expand All @@ -28,12 +30,14 @@ public void onCompleted() {

@Override
public void onError(Throwable e) {
inited = true;
getView().stopRefresh();
getView().showError();
}

@Override
public void onNext(List<M> ms) {
inited = true;
getAdapter().clear();
getAdapter().addAll(ms);
page = 1;
Expand All @@ -47,11 +51,13 @@ public void onCompleted() {

@Override
public void onError(Throwable e) {
inited = true;
getAdapter().pauseMore();
}

@Override
public void onNext(List<M> ms) {
inited = true;
getAdapter().addAll(ms);
page++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void setDefaultListConfig(ListConfig config){
boolean mContainerEmptyAble = true;
boolean mContainerErrorAble = true;
boolean mPaddingNavigationBarAble = false;
boolean mStartWithProgress = false;
boolean mStartWithProgress = true;

View mContainerLayoutView;
int mContainerLayoutRes = 0;
Expand Down

0 comments on commit fe7c1d4

Please sign in to comment.