|
@@ -49,6 +49,7 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
List<UserRecordBean> mDataList;
|
|
|
int mListStart = 0;
|
|
|
int mListEnd = 6;
|
|
|
+ int curPosition = 0;
|
|
|
|
|
|
public MyTabFragmentPresenter(Context context) {
|
|
|
mContext = context;
|
|
@@ -100,116 +101,6 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDestory(GridLayout layout) {
|
|
|
- BackPageReceiver.unRegisterReceiver(mView.getActivity());
|
|
|
- if (mUserFragmentHandler != null) {
|
|
|
- mUserFragmentHandler.removeMessages(MyTabFragmentModel.LOAD_GRID);
|
|
|
- mUserFragmentHandler = null;
|
|
|
- }
|
|
|
- layout.removeAllViews();
|
|
|
- layout = null;
|
|
|
- mView = null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void getMyRecords() {
|
|
|
- mModel.getMyRecords(mView.getActivity(), new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- HttpResultBean<List<UserRecordBean>> bean = info.getRetDetail(new TypeToken<HttpResultBean<List<UserRecordBean>>>() {
|
|
|
- }.getType());
|
|
|
- mDataList = bean.getData();
|
|
|
- mView.loadMoreItem();
|
|
|
- mView.setRecordSize(mDataList.size());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
- Logger.e("获取我的朗读列表错误:" + info.getRetDetail());
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void getMyInfo() {
|
|
|
- Logger.e("获取个人信息");
|
|
|
- if (mView == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- mModel.getMyInfo(mView.getActivity(), new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- Logger.e("获取用户中心信息接口成功:" + info.getRetDetail());
|
|
|
- HttpResultBean<MyInfoBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<MyInfoBean>>() {
|
|
|
- }.getType());
|
|
|
- mView.setUserInfo(bean.getData());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void getIsBuy() {
|
|
|
- mOrderApi.isBuy(mView.getActivity(), new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
- }.getType());
|
|
|
- if (Boolean.valueOf(bean.getData())) {
|
|
|
-
|
|
|
- } else {
|
|
|
- Logger.e("没有购买");
|
|
|
- }
|
|
|
-// mView.getIsBuySuccess(Boolean.valueOf(bean.getData()));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void getAuth() {
|
|
|
- mOrderApi.getAuth(mView.getActivity(), new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
- }.getType());
|
|
|
- mView.getIsBuySuccess(bean.getData());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void changeMyRecordStatusById(String json) {
|
|
|
- mModel.changeMyRecordStatusById(mView.getActivity(), json, new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- Logger.e("改变状态成功:" + info.getRetDetail());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
- Logger.e("改变状态失败");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
private void setGridItemView(GridLayout gridLayout, int index) {
|
|
|
|
|
|
if (mView == null) {
|
|
@@ -263,7 +154,8 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
public void onAnimationEnd(Animator animator) {
|
|
|
gridLayout.removeView(view);
|
|
|
mView.loadMoreItem();
|
|
|
- mView.setRecordSize(mDataList.size() - 1);
|
|
|
+ mDataList.remove(index);
|
|
|
+ mView.setRecordSize(mDataList.size());
|
|
|
changeMyRecordStatusById("{\"id\": " + reader.getId() + ", \t\"status\": \"DEL\" }");
|
|
|
|
|
|
}
|
|
@@ -289,13 +181,16 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
} else if (reader.getStatus().equals("NORMAL")) {
|
|
|
imgPriv.setImageResource(R.drawable.adapter_item_record_pub);
|
|
|
}
|
|
|
+ view.setTag(imgPriv);
|
|
|
mView.addUiClick(imgPriv, o -> {
|
|
|
if (reader.getStatus().equals("DISABLE")) {
|
|
|
//当前是隐藏状态,需要公开
|
|
|
+ curPosition = index;
|
|
|
changeMyRecordStatusById("{\"id\": " + reader.getId() + ", \t\"status\": \"NORMAL\" }");
|
|
|
imgPriv.setImageResource(R.drawable.adapter_item_record_pub);
|
|
|
} else if (reader.getStatus().equals("NORMAL")) {
|
|
|
//当前正常状态,需要隐藏
|
|
|
+ curPosition = index;
|
|
|
changeMyRecordStatusById("{\"id\": " + reader.getId() + ", \t\"status\": \"DISABLE\" }");
|
|
|
imgPriv.setImageResource(R.drawable.adapter_item_record_pri);
|
|
|
}
|
|
@@ -304,6 +199,7 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
Bundle bundle = new Bundle();
|
|
|
bundle.putString("index", index + "");
|
|
|
bundle.putString("dataJson", "getmmkv");
|
|
|
+ bundle.putString("intoPage", "MyTab");
|
|
|
//数据太多了。直接传不过去,通过MMKV写一下再读一下
|
|
|
MMKVUtil.getInstance().encode("video_data", ((BaseActivity) mView.getActivity()).getGson().toJson(mDataList));
|
|
|
((BaseActivity) mView.getActivity()).toNextActivity(SmallFullVideoActivity.class, bundle);
|
|
@@ -321,6 +217,115 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
gridLayout.addView(view);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onDestory(GridLayout layout) {
|
|
|
+ BackPageReceiver.unRegisterReceiver(mView.getActivity());
|
|
|
+ if (mUserFragmentHandler != null) {
|
|
|
+ mUserFragmentHandler.removeMessages(MyTabFragmentModel.LOAD_GRID);
|
|
|
+ mUserFragmentHandler = null;
|
|
|
+ }
|
|
|
+ layout.removeAllViews();
|
|
|
+ layout = null;
|
|
|
+ mView = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getMyRecords() {
|
|
|
+ mModel.getMyRecords(mView.getActivity(), new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<List<UserRecordBean>> bean = info.getRetDetail(new TypeToken<HttpResultBean<List<UserRecordBean>>>() {
|
|
|
+ }.getType());
|
|
|
+ mDataList = bean.getData();
|
|
|
+ mView.loadMoreItem();
|
|
|
+ mView.setRecordSize(mDataList.size());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("获取我的朗读列表错误:" + info.getRetDetail());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getMyInfo() {
|
|
|
+ if (mView == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mModel.getMyInfo(mView.getActivity(), new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<MyInfoBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<MyInfoBean>>() {
|
|
|
+ }.getType());
|
|
|
+ mView.setUserInfo(bean.getData());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getIsBuy() {
|
|
|
+ mOrderApi.isBuy(mView.getActivity(), new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
+ }.getType());
|
|
|
+ if (Boolean.valueOf(bean.getData())) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Logger.e("没有购买");
|
|
|
+ }
|
|
|
+// mView.getIsBuySuccess(Boolean.valueOf(bean.getData()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getAuth() {
|
|
|
+ mOrderApi.getAuth(mView.getActivity(), new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
+ }.getType());
|
|
|
+ mView.getIsBuySuccess(bean.getData());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changeMyRecordStatusById(String json) {
|
|
|
+ mModel.changeMyRecordStatusById(mView.getActivity(), json, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<UserRecordBean.UserRead> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserRecordBean.UserRead>>() {
|
|
|
+ }.getType());
|
|
|
+ mDataList.get(curPosition).getUserRead().setStatus(bean.getData().getStatus());
|
|
|
+ mView.changeRecordStatusSuccess(curPosition, bean.getData().getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("改变状态失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Handler mUserFragmentHandler = new Handler(new Handler.Callback() {
|
|
|
@Override
|
|
@@ -339,10 +344,8 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
BackPageReceiver.onBackPage backListener = new BackPageReceiver.onBackPage() {
|
|
|
@Override
|
|
|
public void pageBack(Intent intent) {
|
|
|
- Logger.e("收到数据了");
|
|
|
if (intent.getAction().equals(BackPageReceiver.BACK_HOME_REF_USER_INFO)) {
|
|
|
//刷新一下用户信息
|
|
|
- Logger.e("刷新用户数据");
|
|
|
getMyInfo();
|
|
|
}
|
|
|
|
|
@@ -353,40 +356,4 @@ public class MyTabFragmentPresenter extends BasePresenter<MyTabFragmentContract.
|
|
|
}
|
|
|
|
|
|
|
|
|
-////平均分item,rv的itemdecoration
|
|
|
-//class GridSpaceItemDecoration extends RecyclerView.ItemDecoration {
|
|
|
-//
|
|
|
-// private int mSpanCount;//横条目数量
|
|
|
-// private int mRowSpacing;//行间距
|
|
|
-// private int mColumnSpacing;// 列间距
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * @param spanCount 列数
|
|
|
-// * @param rowSpacing 行间距
|
|
|
-// * @param columnSpacing 列间距
|
|
|
-// */
|
|
|
-// public GridSpaceItemDecoration(int spanCount, int rowSpacing, int columnSpacing) {
|
|
|
-// this.mSpanCount = spanCount;
|
|
|
-// this.mRowSpacing = rowSpacing;
|
|
|
-// this.mColumnSpacing = columnSpacing;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
|
|
-// int position = parent.getChildAdapterPosition(view); // 获取view 在adapter中的位置。
|
|
|
-// int column = position % mSpanCount; // view 所在的列
|
|
|
-//
|
|
|
-// // 列间距
|
|
|
-// outRect.left = mColumnSpacing;
|
|
|
-//
|
|
|
-// // 如果position > 行数,说明不是在第一行,则不指定行高,其他行的上间距为 top=mRowSpacing
|
|
|
-// if (position >= mSpanCount) {
|
|
|
-// outRect.top = mRowSpacing; // item top
|
|
|
-// }
|
|
|
-//
|
|
|
-//// if ((position % 2) != 0) {
|
|
|
-//// outRect.top = mRowSpacing + SizeUtils.dp2px(Consts.getmApplicAtion(), 50);
|
|
|
-//// }
|
|
|
-// }
|
|
|
-//}
|
|
|
|