[add]分享列表callback-加载更多
This commit is contained in:
@@ -21,22 +21,22 @@ import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventItemEnum;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventLoadMoreItem;
|
||||
import com.zhidao.mogo.module.event.panel.fragment.EventPanelFragment;
|
||||
import com.zhidao.mogo.module.event.panel.listener.AdapterCallback;
|
||||
import com.zhidao.mogo.module.event.panel.presenter.ShareEventsPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private Context context;
|
||||
private ShareEventsPresenter presenter;
|
||||
private ArrayList dataArrayList;
|
||||
private final LayoutInflater shareLayoutInflater;
|
||||
private IMogoServiceApis mApis;
|
||||
private AdapterCallback callback;
|
||||
|
||||
|
||||
public ShareEventAdapter(Context context, ArrayList dataArrayList, ShareEventsPresenter presenter) {
|
||||
public ShareEventAdapter(Context context, ArrayList dataArrayList, AdapterCallback callback) {
|
||||
this.context = context;
|
||||
this.dataArrayList = dataArrayList;
|
||||
this.presenter = presenter;
|
||||
this.callback = callback;
|
||||
shareLayoutInflater = LayoutInflater.from(context);
|
||||
mApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||
}
|
||||
@@ -157,9 +157,9 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Object item = dataArrayList.get(position);
|
||||
if (item instanceof ShareEventDescription) {
|
||||
if (item instanceof ShareEventDescription.ResultBean.EnthusiasmIndexBean) {
|
||||
return ShareEventItemEnum.ITEM_TYPE_NUM_DES;
|
||||
} else if (item instanceof ShareEventItem) {
|
||||
} else if (item instanceof ShareEventItem.ResultBean.PageBean.ContentBean) {
|
||||
return ShareEventItemEnum.ITEM_TYPE_SHARE_LIST;
|
||||
} else if (item instanceof ShareEventLoadMoreItem) {
|
||||
return ((ShareEventLoadMoreItem) dataArrayList.get(position)).getViewType();
|
||||
@@ -231,11 +231,9 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
presenter.getMoreShareEventList();
|
||||
callback.loadMoreShareEventList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventItemEnum;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventLoadMoreItem;
|
||||
import com.zhidao.mogo.module.event.panel.listener.AdapterCallback;
|
||||
import com.zhidao.mogo.module.event.panel.network.HostConstant;
|
||||
import com.zhidao.mogo.module.event.panel.network.EventApiService;
|
||||
import com.zhidao.mogo.module.event.panel.network.ShareEventParameter;
|
||||
@@ -32,47 +33,46 @@ import com.zhidao.mogo.module.event.panel.presenter.ShareEventsPresenter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareEventsPresenter> {
|
||||
public class ShareEventsFragment extends MvpFragment implements AdapterCallback {
|
||||
|
||||
private static final String TAG = "ShareEventsFragment";
|
||||
private RecyclerView recyclerView;
|
||||
private View view;
|
||||
private ShareEventAdapter adapter;
|
||||
private ArrayList dataArrayList = new ArrayList();
|
||||
private EventApiService eventApiService;
|
||||
private int pageNum = 1;
|
||||
private View emptyView;
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(2);
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
Log.d(TAG, "getLayoutId");
|
||||
return R.layout.module_event_panel_share_recylerview;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
Log.d(TAG, "initViews");
|
||||
initRecyclerView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.module_event_panel_share_recylerview, container, false);
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
emptyView = inflater.inflate(R.layout.module_event_panel_share_empty, container, false);
|
||||
initRecyclerView();
|
||||
initData();
|
||||
return view;
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView = view.findViewById(R.id.road_case_share_list);
|
||||
adapter = new ShareEventAdapter(getActivity(), dataArrayList, createPresenter());
|
||||
recyclerView = mRootView.findViewById(R.id.road_case_share_list);
|
||||
adapter = new ShareEventAdapter(getActivity(), dataArrayList, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
LinearLayoutManager linearLayoutManager =
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
@@ -83,7 +83,7 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getContext());
|
||||
this.eventApiService = network.create(EventApiService.class, HostConstant.getNetHost());
|
||||
|
||||
// getShareEventDescription();
|
||||
getShareEventDescription();
|
||||
getShareEventList(pageNum, 10);
|
||||
}
|
||||
|
||||
@@ -108,11 +108,13 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
adapter.notifyDataSetChanged();
|
||||
Log.d(TAG, "热心指数---:" + resultData.getResult().getEnthusiasmIndex());
|
||||
}
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -168,11 +170,13 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
dataArrayList.add(item);
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -192,8 +196,12 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
@NonNull
|
||||
@Override
|
||||
protected ShareEventsPresenter createPresenter() {
|
||||
Log.d(TAG, "createPresenter");
|
||||
return new ShareEventsPresenter(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadMoreShareEventList() {
|
||||
getShareEventList(pageNum + 1, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidao.mogo.module.event.panel.listener;
|
||||
|
||||
public interface AdapterCallback {
|
||||
//分享列表加载更多
|
||||
public void loadMoreShareEventList();
|
||||
}
|
||||
@@ -3,14 +3,10 @@ package com.zhidao.mogo.module.event.panel.presenter;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.zhidao.mogo.module.event.panel.fragment.ShareEventsFragment;
|
||||
import com.zhidao.mogo.module.event.panel.listener.AdapterCallback;
|
||||
|
||||
public class ShareEventsPresenter extends Presenter <ShareEventsFragment>{
|
||||
public ShareEventsPresenter(IView view) {
|
||||
super((ShareEventsFragment) view);
|
||||
}
|
||||
|
||||
public void getMoreShareEventList(){
|
||||
mView.getShareEventList(mView.getPageNum()+1,10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal">
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/event_share_load_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:text="没有更多了"
|
||||
android:textColor="#000000"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
Reference in New Issue
Block a user