|
@@ -4,50 +4,117 @@ import android.content.Intent;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.view.LayoutInflater;
|
|
|
+import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.GridLayout;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.edufound.reader.R;
|
|
|
import com.edufound.reader.activity.SmallFullVideoActivity;
|
|
|
+import com.edufound.reader.apiserver.UserApiServerImpl;
|
|
|
+import com.edufound.reader.base.BaseActivity;
|
|
|
import com.edufound.reader.base.BasePresenter;
|
|
|
+import com.edufound.reader.bean.FansBean;
|
|
|
+import com.edufound.reader.bean.HttpResultBean;
|
|
|
+import com.edufound.reader.bean.HttpResultDataListBean;
|
|
|
+import com.edufound.reader.bean.MyInfoBean;
|
|
|
+import com.edufound.reader.bean.UserRecordBean;
|
|
|
import com.edufound.reader.contract.OthersRecordContract;
|
|
|
import com.edufound.reader.model.CharacterFragmentModel;
|
|
|
import com.edufound.reader.model.OthersRecordModel;
|
|
|
import com.edufound.reader.util.GlideUtils;
|
|
|
import com.edufound.reader.util.SizeUtils;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
+import com.okhttplib.HttpInfo;
|
|
|
+import com.okhttplib.callback.Callback;
|
|
|
import com.orhanobut.logger.Logger;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.View> implements OthersRecordContract.Presenter {
|
|
|
|
|
|
|
|
|
OthersRecordModel mModel;
|
|
|
- List<Object> mDataList;
|
|
|
+ UserApiServerImpl mUserApi;
|
|
|
+ List<UserRecordBean> mDataList;
|
|
|
+ int onceLoadCount = 10;
|
|
|
int mListStart = 0;
|
|
|
- int mListEnd = 6;
|
|
|
+ int mListEnd = onceLoadCount;
|
|
|
|
|
|
public OthersRecordPresenter() {
|
|
|
mModel = new OthersRecordModel();
|
|
|
- mDataList = new ArrayList<>();
|
|
|
- for (int i = 0; i < 20; i++) {
|
|
|
- mDataList.add("i=" + i);
|
|
|
- }
|
|
|
+ mUserApi = new UserApiServerImpl();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public void initGridLayout(GridLayout gridLayout, FrameLayout norecordlayout) {
|
|
|
+ gridLayout.setRowCount(2);
|
|
|
+ setGridData(gridLayout, norecordlayout);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void setGridItemView(GridLayout gridLayout, int index) {
|
|
|
+ if (mView == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ View view = LayoutInflater.from(mView.getActivity()).inflate(R.layout.adapter_item_record_user, null);
|
|
|
+ UserRecordBean.UserRead reader = mDataList.get(index).getUserRead();
|
|
|
+ ImageView imgIcon = view.findViewById(R.id.adapter_item_record_user_icon);
|
|
|
+ TextView name = view.findViewById(R.id.adapter_item_record_user_name);
|
|
|
+ ImageView imgDel = view.findViewById(R.id.adapter_item_record_user_del);
|
|
|
+ ImageView imgPriv = view.findViewById(R.id.adapter_item_record_user_priv);
|
|
|
+ TextView lookAmount = view.findViewById(R.id.adapter_item_record_user_look_num);
|
|
|
+ TextView likeAmount = view.findViewById(R.id.adapter_item_record_user_thumb_num);
|
|
|
+ TextView commentAmount = view.findViewById(R.id.adapter_item_record_user_comment_num);
|
|
|
+ TextView favoritesAmount = view.findViewById(R.id.adapter_item_record_user_start_num);
|
|
|
+ FrameLayout checkLayout = view.findViewById(R.id.adapter_item_record_user_examine_layout);
|
|
|
+ GlideUtils.loadRoundCircleImage(mView.getActivity(), reader.getCoverImg(), imgIcon, SizeUtils.dp2px(mView.getActivity(), 20));
|
|
|
+ name.setText(reader.getTitle() + "--" + index);
|
|
|
+ lookAmount.setText(reader.getPlayAmount());
|
|
|
+ likeAmount.setText(reader.getLikeAmount());
|
|
|
+ commentAmount.setText(reader.getCommentAmount());
|
|
|
+ favoritesAmount.setText(reader.getFavoritesAmount());
|
|
|
+ imgDel.setVisibility(View.GONE);
|
|
|
+ imgPriv.setVisibility(View.GONE);
|
|
|
+ checkLayout.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ mView.addUiClick(view, o -> {
|
|
|
+ Intent intent = new Intent(mView.getActivity(), SmallFullVideoActivity.class);
|
|
|
+ intent.putExtra("index", index + "");
|
|
|
+ mView.getActivity().startActivity(intent);
|
|
|
+ });
|
|
|
+
|
|
|
+ checkLayout.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ GridLayout.LayoutParams params = new GridLayout.LayoutParams(new FrameLayout.LayoutParams(SizeUtils.dp2px(mView.getActivity(), 415), SizeUtils.dp2px(mView.getActivity(), 290)));
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void setGridData(GridLayout gridLayout, FrameLayout norecordlayout) {
|
|
|
if (mDataList == null || mDataList.size() <= 0) {
|
|
|
norecordlayout.setVisibility(View.VISIBLE);
|
|
|
gridLayout.setVisibility(View.GONE);
|
|
|
return;
|
|
|
}
|
|
|
- norecordlayout.setVisibility(View.GONE);
|
|
|
- gridLayout.setRowCount(2);
|
|
|
+ if (mListEnd > mDataList.size()) {
|
|
|
+ mListEnd = mDataList.size();
|
|
|
+ }
|
|
|
int timeCount = 0;
|
|
|
for (int j = mListStart; j < mListEnd; j++) {
|
|
|
timeCount++;
|
|
@@ -55,16 +122,65 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
message.obj = gridLayout;
|
|
|
message.what = OthersRecordModel.LOAD_GRID;
|
|
|
message.arg1 = j;
|
|
|
+ Logger.e("int j=" + j);
|
|
|
otherRecordHandler.sendMessageDelayed(message, 50 * timeCount);
|
|
|
}
|
|
|
mListStart = mListEnd;
|
|
|
- if (mListEnd + 6 > mDataList.size()) {
|
|
|
+ if (mListEnd + onceLoadCount > mDataList.size()) {
|
|
|
mListEnd = mDataList.size();
|
|
|
} else {
|
|
|
- mListEnd = mListEnd + 6;
|
|
|
+ mListEnd = mListEnd + onceLoadCount;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getOtherRecordList(String uid) {
|
|
|
+ mModel.getOtherRecordList(mView.getActivity(), uid, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ HttpResultBean<HttpResultDataListBean<UserRecordBean>> bean = info.getRetDetail(new TypeToken<HttpResultBean<HttpResultDataListBean<UserRecordBean>>>() {
|
|
|
+ }.getType());
|
|
|
+ mDataList = bean.getData().getList();
|
|
|
+ mView.getOtherRecordSuccess();
|
|
|
+ mView.loadMoreItem();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doFollow(String uid) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("uid", uid);
|
|
|
+ String json = ((BaseActivity) mView.getActivity()).getGson().toJson(map);
|
|
|
+ Logger.e("json:" + json);
|
|
|
+ mModel.doFollow(mView.getActivity(), json, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("关注接口成功:" + info.getRetDetail());
|
|
|
+ HttpResultBean<FansBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<FansBean>>() {
|
|
|
+ }.getType());
|
|
|
+ if (bean.getData().getStatus().equals("NORMAL")) {
|
|
|
+ //已关注状态
|
|
|
+ mView.doFollowSuccess(true);
|
|
|
+ } else if (bean.getData().getStatus().equals("DEL")) {
|
|
|
+ //未关注状态
|
|
|
+ mView.doFollowSuccess(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("关注接口失败:" + info.getRetDetail());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onDestory(GridLayout layout) {
|
|
|
otherRecordHandler.removeMessages(CharacterFragmentModel.LOAD_GRID);
|
|
@@ -74,29 +190,24 @@ public class OthersRecordPresenter extends BasePresenter<OthersRecordContract.Vi
|
|
|
mView = null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void getOtherUserInfo(String uid) {
|
|
|
+ mUserApi.getOtherUserInfo(mView.getActivity(), uid, 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.setLeftUserInfo(bean.getData());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
|
|
|
- private void setGridItemView(GridLayout gridLayout, int index) {
|
|
|
- if (mView == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- View view = LayoutInflater.from(mView.getActivity()).inflate(R.layout.adapter_item_record_authority, null);
|
|
|
- ImageView imgIcon = view.findViewById(R.id.adapter_item_record_authority_icon);
|
|
|
- TextView name = view.findViewById(R.id.adapter_item_record_authority_name);
|
|
|
- GlideUtils.loadRoundCircleImage(mView.getActivity(), "http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640", imgIcon, SizeUtils.dp2px(mView.getActivity(), 20));
|
|
|
- mView.addUiClick(view, o -> {
|
|
|
- Intent intent = new Intent(mView.getActivity(), SmallFullVideoActivity.class);
|
|
|
- intent.putExtra("index", index + "");
|
|
|
- mView.getActivity().startActivity(intent);
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- name.setText("当前第:" + index + "个");
|
|
|
- GridLayout.LayoutParams params = new GridLayout.LayoutParams(new FrameLayout.LayoutParams(SizeUtils.dp2px(mView.getActivity(), 415), SizeUtils.dp2px(mView.getActivity(), 290)));
|
|
|
- params.setMargins(SizeUtils.dp2px(mView.getActivity(), 10), SizeUtils.dp2px(mView.getActivity(), 10), SizeUtils.dp2px(mView.getActivity(), 10), SizeUtils.dp2px(mView.getActivity(), 10));
|
|
|
- view.setLayoutParams(params);
|
|
|
- gridLayout.addView(view);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Handler otherRecordHandler = new Handler(new Handler.Callback() {
|
|
|
@Override
|
|
|
public boolean handleMessage(Message msg) {
|