|
@@ -35,16 +35,19 @@ import com.edufound.reader.util.EfunboxUtil;
|
|
|
import com.edufound.reader.util.GlideUtils;
|
|
|
import com.edufound.reader.util.MMKVUtil;
|
|
|
import com.edufound.reader.util.SizeUtils;
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
import com.okhttplib.HttpInfo;
|
|
|
import com.okhttplib.callback.Callback;
|
|
|
import com.orhanobut.logger.Logger;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
|
|
public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.View> implements OthersRecordContract.Presenter {
|
|
@@ -57,6 +60,9 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
int mListStart = 0;
|
|
|
int mListEnd = onceLoadCount;
|
|
|
String backRecordId = null;
|
|
|
+ final int START_SMALLFULLVIDEO = 0x2231;
|
|
|
+ String refVideoId = null;
|
|
|
+ int startIndex = 0;
|
|
|
|
|
|
public OthersRecordPresenter() {
|
|
|
mModel = new OthersRecordModel();
|
|
@@ -75,7 +81,7 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void setGridItemView(GridLayout gridLayout, int index) {
|
|
|
+ private void setGridItemView(GridLayout gridLayout, int index, int gridIndex) {
|
|
|
if (mView == null) {
|
|
|
return;
|
|
|
}
|
|
@@ -102,6 +108,7 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
checkLayout.setVisibility(View.GONE);
|
|
|
|
|
|
mView.addUiClick(view, o -> {
|
|
|
+ startIndex = index;
|
|
|
Bundle bundle = new Bundle();
|
|
|
bundle.putString("index", index + "");
|
|
|
bundle.putString("dataJson", "getmmkv");
|
|
@@ -112,8 +119,10 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
MMKVUtil.getInstance().removeKey("video_data");
|
|
|
String json = ((BaseActivity) mView.getActivity()).getGson().toJson(mDataList);
|
|
|
MMKVUtil.getInstance().encode("video_data", json);
|
|
|
+ refVideoId = mDataList.get(index).getUserRead().getId();
|
|
|
+ Logger.e("refVideoId:" + refVideoId);
|
|
|
// bundle.putString("dataJson", ((BaseActivity) mView.getActivity()).getGson().toJson(mDataList));
|
|
|
- ((BaseActivity) mView.getActivity()).toNextActivity(SmallFullVideoActivity.class, bundle);
|
|
|
+ ((BaseActivity) mView.getActivity()).toNextActivityForResult(SmallFullVideoActivity.class, bundle, START_SMALLFULLVIDEO);
|
|
|
} catch (Exception e) {
|
|
|
Logger.e("报错数据:" + mDataList);
|
|
|
e.printStackTrace();
|
|
@@ -132,7 +141,11 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
params.setMargins(SizeUtils.dp2px(mView.getActivity(), 10), 0, SizeUtils.dp2px(mView.getActivity(), 20), SizeUtils.dp2px(mView.getActivity(), 30));
|
|
|
view.setLayoutParams(params);
|
|
|
gridLayout.setOrientation(GridLayout.VERTICAL);
|
|
|
- gridLayout.addView(view);
|
|
|
+ if (gridIndex != -1) {
|
|
|
+ gridLayout.addView(view, gridIndex);
|
|
|
+ } else {
|
|
|
+ gridLayout.addView(view);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -231,6 +244,46 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
+ switch (requestCode) {
|
|
|
+ case START_SMALLFULLVIDEO:
|
|
|
+ //刷新refVideoId的数据
|
|
|
+ mModel.getReadInfo(mView.getActivity(), refVideoId, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<UserRecordBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserRecordBean>>() {
|
|
|
+ }.getType());
|
|
|
+ if (bean.getSuccess() && bean.getCode().equals("200")) {
|
|
|
+ if (otherRecordHandler == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ otherRecordHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (mDataList != null) {
|
|
|
+ mDataList.remove(startIndex);
|
|
|
+ mDataList.add(startIndex, bean.getData());
|
|
|
+ if (mView.mGetGridLayout() != null) {
|
|
|
+ mView.mGetGridLayout().removeView(mView.mGetGridLayout().getChildAt(startIndex));
|
|
|
+ setGridItemView(mView.mGetGridLayout(), startIndex, startIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 50);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("获取单独的失败了:" + info.getRetDetail());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void onDestory(GridLayout layout) {
|
|
|
|
|
|
otherRecordHandler.removeMessages(CharacterFragmentModel.LOAD_GRID);
|
|
@@ -262,7 +315,7 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
public boolean handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
|
case OthersRecordModel.LOAD_GRID:
|
|
|
- setGridItemView((GridLayout) msg.obj, msg.arg1);
|
|
|
+ setGridItemView((GridLayout) msg.obj, msg.arg1, -1);
|
|
|
break;
|
|
|
default:
|
|
|
throw new IllegalStateException("Unexpected value: " + msg.what);
|
|
@@ -271,4 +324,5 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
}
|