修改名称。
This commit is contained in:
@@ -0,0 +1,496 @@
|
||||
package com.xscm.modulemain.activity.plaza.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.ActivityDynamicDetailBinding;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.adapter.CirleListAdapter;
|
||||
import com.xscm.moduleutil.adapter.CommentAdapter;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.diff.CircleListDiffCallback;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.PlazaEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.dialog.CommentDialogFragment;
|
||||
import com.xscm.moduleutil.widget.dialog.RewardGiftDialogFragment;
|
||||
import com.xscm.modulemain.dialog.ShareDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/3
|
||||
* @description: 语圈详情
|
||||
*/
|
||||
@Route(path = ARouteConstants.DYNAMIC_DETAIL)
|
||||
public class DynamicDetailActivity extends BaseMvpActivity<CirclePresenter, ActivityDynamicDetailBinding> implements
|
||||
CircleContacts.View, CommentAdapter.OnCommentInteractionListener {
|
||||
private String zone_id;
|
||||
CirleListAdapter cirleListAdapter;
|
||||
private CommentAdapter commentAdapter;
|
||||
private int currentReplyId = 0; // 记录当前正在回复的评论ID
|
||||
private String TreplyTo = "";
|
||||
|
||||
List<CircleListBean> circleList = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.topBar.setTitle("动态详情");
|
||||
zone_id = getIntent().getStringExtra("zone_id");
|
||||
|
||||
mBinding.tvSend.setOnClickListener(this::onClick);
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
cirleListAdapter = new CirleListAdapter(CirleListAdapter.PAGE_HOME);
|
||||
mBinding.recycleView.setAdapter(cirleListAdapter);
|
||||
cirleListAdapter.setOnItemClickListener(new CirleListAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(int index, CircleListBean item) {
|
||||
MvpPre.likeZone(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(CircleListBean item) {
|
||||
// Toast.makeText(getApplicationContext(), "查看主页:" + item.getNickname(), Toast.LENGTH_SHORT).show();
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id() + "").navigation();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(int position, CircleListBean item) {
|
||||
RewardGiftDialogFragment.show(String.valueOf(item.getId()), item.getUser_id() + "", position, getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoreClick(int idx, CircleListBean item) {
|
||||
ShareDialog shareDialog = new ShareDialog(DynamicDetailActivity.this, item.getContent(), item.getShare_url(), item.getId() + "", 3, item.getUser_id() + "", item);
|
||||
shareDialog.setOnShareDataListener(new ShareDialog.OnShareDataListener() {
|
||||
|
||||
@Override
|
||||
public void onShareDataLoaded(String id) {
|
||||
MvpPre.deleteZone(idx, item);
|
||||
}
|
||||
});
|
||||
shareDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(CircleListBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(CircleListBean item) {
|
||||
CommentDialogFragment.show(String.valueOf(item.getId()), getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void onGensui(CircleListBean item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().equals("0")) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "", null);
|
||||
|
||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
for (int i = 0; i < ActivityUtils.getActivityList().size(); i++) {
|
||||
if (ActivityUtils.getActivityList().get(i) instanceof DynamicDetailActivity || ActivityUtils.getActivityList().get(i) instanceof DynamicListActivity) {
|
||||
ActivityUtils.getActivityList().get(i).finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页热门列表").withString("roomId", item.getRoom_id()).navigation();
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(DynamicDetailActivity.this, item.getUser_id() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rvComment.setLayoutManager(new LinearLayoutManager(this));
|
||||
commentAdapter = new CommentAdapter(new ArrayList<>());
|
||||
mBinding.rvComment.setAdapter(commentAdapter);
|
||||
commentAdapter.setOnCommentInteractionListener(this);
|
||||
|
||||
|
||||
// 在 initData() 中添加:
|
||||
final View rootView = findViewById(android.R.id.content);
|
||||
final View inputBar = mBinding.clInput;
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(rootView, (v, insets) -> {
|
||||
int keyboardHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
|
||||
|
||||
if (keyboardHeight > 0) {
|
||||
// 键盘弹出时,将输入栏上移
|
||||
inputBar.setTranslationY(-keyboardHeight);
|
||||
|
||||
// 安全地滚动列表(添加空列表检查)
|
||||
if (commentAdapter.getItemCount() > 0) {
|
||||
try {
|
||||
mBinding.rvComment.smoothScrollToPosition(commentAdapter.getItemCount() - 1);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// 防止意外情况
|
||||
mBinding.rvComment.scrollToPosition(commentAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 键盘收起时复位
|
||||
inputBar.setTranslationY(0);
|
||||
}
|
||||
return insets;
|
||||
});
|
||||
|
||||
|
||||
// 点击输入框自动弹出键盘
|
||||
mBinding.etInput.setOnClickListener(v -> {
|
||||
mBinding.etInput.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(mBinding.etInput, InputMethodManager.SHOW_IMPLICIT);
|
||||
});
|
||||
MvpPre.topicId(zone_id, 2);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(BaseEvent event) {
|
||||
if (event instanceof GiftRewardEvent) {
|
||||
MvpPre.getCircleDetail(((GiftRewardEvent) event).getPoints(),
|
||||
circleList.get(((GiftRewardEvent) event).getPoints()));
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(((GiftRewardEvent) event).getPoints()).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
}
|
||||
|
||||
private void onClick(View view) {
|
||||
if (view.getId() == R.id.tv_send) {
|
||||
if (mBinding.etInput.getText().toString().isEmpty()) {
|
||||
ToastUtils.showShort("请输入评论内容");
|
||||
return;
|
||||
}
|
||||
// 判断是回复还是普通评论
|
||||
if (currentReplyId != 0) {
|
||||
// 回复某条评论
|
||||
comZone(zone_id, mBinding.etInput.getText().toString(), String.valueOf(currentReplyId), TreplyTo);
|
||||
} else {
|
||||
// 普通评论
|
||||
comZone(zone_id, mBinding.etInput.getText().toString(), "0", TreplyTo);
|
||||
}
|
||||
// 清空输入框但不清除焦点,保留软键盘
|
||||
mBinding.etInput.setText("");
|
||||
mBinding.etInput.requestFocus(); // 保持焦点
|
||||
}
|
||||
}
|
||||
|
||||
private void comZone(String zoneId, String content, String pid, String replyTo) {
|
||||
MvpPre.commentZone(zoneId, content, pid, replyTo);
|
||||
mBinding.etInput.setText("");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_dynamic_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int idx, CircleListBean item, int type) {
|
||||
MvpPre.getCircleDetail(idx, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int idx, CircleListBean item, CircleListBean newItem) {
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.set(idx, newItem);
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(idx).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(index).id, PlazaEvent.DELETE_ZONE));
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
circleList.add(bean);
|
||||
cirleListAdapter.setNewData(circleList);
|
||||
MvpPre.getCommentList(zone_id, "1", "30");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
if (commentBean != null) {
|
||||
mBinding.tvNum.setText("全部评论(" + commentBean.getTotal() + ")");
|
||||
commentAdapter.updateData(commentBean.getList()); // 假设 CommentBean 包含评论列表
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
MvpPre.getCommentList(zone_id, "1", "30");
|
||||
MvpPre.getCircleDetail(0, circleList.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInputBoxShow(int id, String s, int position, String replyTo) {
|
||||
mBinding.etInput.requestFocus();
|
||||
|
||||
// 2. 自动弹出软键盘
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.showSoftInput(mBinding.etInput, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}, 200);
|
||||
|
||||
// 3. 可选:预填回复内容(如@用户)
|
||||
if (!TextUtils.isEmpty(s)) {
|
||||
mBinding.etInput.setText(s);
|
||||
mBinding.etInput.setSelection(s.length()); // 光标移至末尾
|
||||
}
|
||||
|
||||
// 4. 记录被回复的评论ID(用于后续提交)
|
||||
currentReplyId = id; // 需要在Activity中声明这个字段
|
||||
TreplyTo = replyTo;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetaleClick(int id, int position) {
|
||||
deleteComment1(id, position);
|
||||
// MvpPre.deleteComment(id+"");
|
||||
}
|
||||
|
||||
private void deleteComment1(int commentId, int position) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(this,
|
||||
"提示",
|
||||
"确定要删除此评论吗?",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.deleteComment(String.valueOf(commentId));
|
||||
// 移除数据(假设 commentAdapter 是你的 RecyclerView 适配器)
|
||||
// commentAdapter.removeItem(position);
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommentLongClick(CommentBean.CommentDetailsBean comment, CommentBean.CommentDetailsBean.Replies reply, int position) {
|
||||
String[] options;
|
||||
if (comment.getUser_id() == SpUtil.getUserId()) {
|
||||
options = new String[]{"复制", "删除", "回复", "取消"};
|
||||
} else {
|
||||
if (reply != null) {
|
||||
if (reply.getUser_id() == SpUtil.getUserId()) {
|
||||
options = new String[]{"复制", "删除", "回复", "取消"};
|
||||
} else {
|
||||
options = new String[]{"复制", "回复", "取消"};
|
||||
}
|
||||
} else {
|
||||
options = new String[]{"复制", "回复", "取消"};
|
||||
}
|
||||
}
|
||||
|
||||
// new AlertDialog.Builder(this)
|
||||
// .setItems(options, (dialog, which) -> {
|
||||
// switch (which) {
|
||||
// case 0: // 复制
|
||||
// copyComment(comment.getContent());
|
||||
// break;
|
||||
// case 1: // 删除
|
||||
// deleteComment(comment.getId(), position);
|
||||
// break;
|
||||
// case 2: // 回复
|
||||
// onInputBoxShow(comment.getId(), "", position,"");
|
||||
// break;
|
||||
// case 3: // 取消
|
||||
// dialog.dismiss();
|
||||
// break;
|
||||
// }
|
||||
// })
|
||||
// .setCancelable(true)
|
||||
// .create()
|
||||
// .show();
|
||||
|
||||
// 创建底部对话框
|
||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
|
||||
View dialogView = getLayoutInflater().inflate(com.xscm.moduleutil.R.layout.dialog_bottom_sheet_actions, null);
|
||||
|
||||
// 初始化视图
|
||||
LinearLayout container = dialogView.findViewById(com.xscm.moduleutil.R.id.ll_options_container);
|
||||
|
||||
// 动态添加选项
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
TextView textView = new TextView(this);
|
||||
textView.setText(options[i]);
|
||||
textView.setTextSize(16);
|
||||
textView.setPadding(
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_16),
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_14),
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_16),
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_14)
|
||||
);
|
||||
|
||||
// 设置点击效果
|
||||
textView.setBackgroundResource(com.xscm.moduleutil.R.drawable.bg_bottom_sheet_item);
|
||||
final int optionIndex = i;
|
||||
textView.setOnClickListener(v -> {
|
||||
handleOptionClick(optionIndex, comment, reply, position);
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
container.addView(textView);
|
||||
|
||||
// 添加分割线(除了最后一个)
|
||||
if (i < options.length - 1) {
|
||||
View divider = new View(this);
|
||||
divider.setBackgroundColor(ContextCompat.getColor(this, com.xscm.moduleutil.R.color.color_FFEEEEEE));
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_1)
|
||||
);
|
||||
divider.setLayoutParams(params);
|
||||
container.addView(divider);
|
||||
}
|
||||
}
|
||||
|
||||
bottomSheetDialog.setContentView(dialogView);
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
|
||||
private void handleOptionClick(int optionIndex, CommentBean.CommentDetailsBean comment, CommentBean.CommentDetailsBean.Replies reply, int position) {
|
||||
if (comment.getUser_id() == SpUtil.getUserId() || reply != null) {
|
||||
// 当前用户的评论选项
|
||||
switch (optionIndex) {
|
||||
case 0: // 复制
|
||||
if (reply != null) {
|
||||
copyComment(reply.getContent());
|
||||
} else {
|
||||
copyComment(comment.getContent());
|
||||
}
|
||||
break;
|
||||
case 1: // 删除
|
||||
if (reply != null) {
|
||||
// deleteComment(reply.getId(), position);
|
||||
deleteComment1(reply.getId(), position);
|
||||
} else {
|
||||
// deleteComment(comment.getId(), position);
|
||||
deleteComment1(comment.getId(), position);
|
||||
}
|
||||
break;
|
||||
case 2: // 回复
|
||||
if (reply != null) {
|
||||
onInputBoxShow(reply.getPid(), "", position, reply.getReply_to_user() + "");
|
||||
} else {
|
||||
onInputBoxShow(comment.getId(), "", position, "");
|
||||
}
|
||||
break;
|
||||
// 取消选项不需要处理
|
||||
}
|
||||
} else {
|
||||
// 其他用户的评论选项
|
||||
switch (optionIndex) {
|
||||
case 0: // 复制
|
||||
if (reply != null) {
|
||||
copyComment(reply.getContent());
|
||||
} else {
|
||||
copyComment(comment.getContent());
|
||||
}
|
||||
break;
|
||||
case 1: // 回复
|
||||
if (reply != null) {
|
||||
onInputBoxShow(reply.getPid(), "", position, reply.getReply_to_user() + "");
|
||||
} else {
|
||||
onInputBoxShow(comment.getId(), "", position, "");
|
||||
}
|
||||
break;
|
||||
// 取消选项不需要处理
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 具体操作方法
|
||||
private void copyComment(String content) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("comment", content);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(this, "已复制", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private void deleteComment(int commentId, int position) {
|
||||
// 调用删除API
|
||||
MvpPre.deleteComment(String.valueOf(commentId));
|
||||
// 临时移除数据
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package com.xscm.modulemain.activity.plaza.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.LeadingMarginSpan;
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.ActivityDynamicListBinding;
|
||||
import com.xscm.modulemain.activity.user.activity.UserHomepageActivity;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.adapter.CirleListAdapter;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.diff.CircleListDiffCallback;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.PlazaEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.widget.dialog.RewardGiftDialogFragment;
|
||||
import com.xscm.modulemain.dialog.ShareDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/3
|
||||
* @description: 广场中顶部的热议点击进入的列表展示
|
||||
*/
|
||||
@Route(path = ARouteConstants.CIRCLE_LIST)
|
||||
public class DynamicListActivity extends BaseMvpActivity<CirclePresenter, ActivityDynamicListBinding> implements CircleContacts.View {
|
||||
|
||||
private HeatedBean heatedBean;
|
||||
CirleListAdapter cirleListAdapter;
|
||||
private List<CircleListBean> circleList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
heatedBean = getIntent().getParcelableExtra("heatedBean");
|
||||
mBinding.topBar.setTitle(heatedBean.getTitle());
|
||||
|
||||
MvpPre.topicId(heatedBean.getTopic_id(), 1);
|
||||
|
||||
|
||||
ImageUtils.loadHeadCC(heatedBean.getPic(), mBinding.ivAvatar);
|
||||
mBinding.tvTitle.setText(heatedBean.getTitle());
|
||||
mBinding.tvDescription.setText(heatedBean.getCount() + "条动态");
|
||||
SpannableString spannableString = new SpannableString(heatedBean.getContent());
|
||||
spannableString.setSpan(new LeadingMarginSpan.Standard(36), 0, heatedBean.getContent().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mBinding.tvContent.setText(spannableString);
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
cirleListAdapter = new CirleListAdapter(CirleListAdapter.PAGE_HOME);
|
||||
mBinding.recycleView.setAdapter(cirleListAdapter);
|
||||
cirleListAdapter.setOnItemClickListener(new CirleListAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(int index, CircleListBean item) {
|
||||
MvpPre.likeZone(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(CircleListBean item) {
|
||||
Intent intent = new Intent(DynamicListActivity.this, UserHomepageActivity.class);
|
||||
intent.putExtra("userId", item.getUser_id() + "");
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(int position, CircleListBean item) {
|
||||
RewardGiftDialogFragment.show(String.valueOf(item.getId()), item.getUser_id() + "", position, getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoreClick(int idx, CircleListBean item) {
|
||||
ShareDialog shareDialog = new ShareDialog(DynamicListActivity.this, item.getContent(), item.getShare_url(), item.getId() + "", 3, item.getUser_id() + "", item);
|
||||
shareDialog.setOnShareDataListener(new ShareDialog.OnShareDataListener() {
|
||||
|
||||
@Override
|
||||
public void onShareDataLoaded(String id) {
|
||||
MvpPre.deleteZone(idx, item);
|
||||
}
|
||||
});
|
||||
shareDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(CircleListBean item) {
|
||||
Intent intent = new Intent(DynamicListActivity.this, DynamicDetailActivity.class);
|
||||
intent.putExtra("zone_id", item.getId() + "");
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(CircleListBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGensui(CircleListBean item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().equals("0")) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "", null);
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(DynamicListActivity.this, item.getUser_id() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_dynamic_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
if (list == null || list.isEmpty())
|
||||
return;
|
||||
// if (page == 1){
|
||||
// circleList.clear();
|
||||
// }
|
||||
//
|
||||
// List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
// circleList.addAll(list);
|
||||
//
|
||||
// DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
// cirleListAdapter.setNewDiffData(diffResult,circleList);
|
||||
circleList.addAll(list);
|
||||
cirleListAdapter.setNewData(circleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int index, CircleListBean item, int type) {
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
// 更新列表中的单个数据项(仅更新特定字段)
|
||||
if (cirleListAdapter != null && bean != null) {
|
||||
List<CircleListBean> dataList = cirleListAdapter.getData();
|
||||
if (dataList != null) {
|
||||
// 查找并更新对应的项
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
CircleListBean item = dataList.get(i);
|
||||
// 根据ID匹配需要更新的项
|
||||
if (item.getId() == bean.getId()) {
|
||||
// 只更新特定字段
|
||||
item.setRewards_num(bean.getRewards_num());
|
||||
// 可以继续更新其他需要的字段
|
||||
// 局部刷新该位置的数据
|
||||
cirleListAdapter.notifyItemChanged(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(BaseEvent event) {
|
||||
if (event instanceof GiftRewardEvent) {
|
||||
MvpPre.getCircleDetail(((GiftRewardEvent) event).getPoints(),
|
||||
circleList.get(((GiftRewardEvent) event).getPoints()));
|
||||
if (ActivityUtils.getTopActivity() instanceof DynamicListActivity){
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(((GiftRewardEvent) event).getPoints()).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
} else if (event instanceof PlazaEvent) {
|
||||
CircleListBean item = null;
|
||||
int index = 0;
|
||||
for (int i = 0; i < circleList.size(); i++) {
|
||||
if (circleList.get(i).getId() == ((PlazaEvent) event).getMsgId()) {
|
||||
item = circleList.get(i);
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item == null || ActivityUtils.getTopActivity() instanceof DynamicListActivity)
|
||||
return;
|
||||
|
||||
switch (((PlazaEvent) event).getType()) {
|
||||
case PlazaEvent.MODIFY_ZONE:
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
break;
|
||||
case PlazaEvent.DELETE_ZONE:
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
if (index != 0) {
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int index, CircleListBean item, CircleListBean newItem) {
|
||||
if (ActivityUtils.getTopActivity() instanceof DynamicListActivity){
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(index).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.set(index, newItem);
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
if (ActivityUtils.getTopActivity() instanceof DynamicListActivity){
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(index).id, PlazaEvent.DELETE_ZONE));
|
||||
}
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
if (index != 0) {
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package com.xscm.modulemain.activity.plaza.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.MultiSelectAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivityReleaseBinding;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.luck.picture.lib.basic.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.ReleaseContract;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.ReleasePresenter;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.adapter.UserPhotoWallAdapter;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.GlideEngine;
|
||||
import com.xscm.moduleutil.utils.PermissionDescriptionHelper;
|
||||
import com.xscm.moduleutil.utils.location.LocationProvider;
|
||||
import com.xscm.moduleutil.utils.location.LocationServiceFactory;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
import com.xscm.moduleutil.widget.img.FullScreenUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/5/28
|
||||
* @description: 发布动态
|
||||
*/
|
||||
public class ReleaseActivity extends BaseMvpActivity<ReleasePresenter, ActivityReleaseBinding> implements ReleaseContract.View {
|
||||
UserPhotoWallAdapter mUserPhotoWallAdapter;
|
||||
List<String> list=new ArrayList<>();
|
||||
private List<String> uploadedUrls = new ArrayList<>();//真实图片地址
|
||||
final int maxNum = 1200;
|
||||
private List<String> topicId=new ArrayList<>();
|
||||
private String city1;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.topBar.setTitle("动态发布");
|
||||
|
||||
mBinding.tvSz.setText("0/" + maxNum);
|
||||
mBinding.etG.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (s.length() == maxNum) {
|
||||
mBinding.tvSz.setText("您输入的字数已超过限制");
|
||||
} else {
|
||||
mBinding.tvSz.setText((maxNum - s.length()) + "/" + maxNum);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rvPhotoWall.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
mBinding.rvPhotoWall.setAdapter(mUserPhotoWallAdapter = new UserPhotoWallAdapter());
|
||||
mUserPhotoWallAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
||||
@Override
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
String item = list.get(position);
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_close) {
|
||||
uploadedUrls.remove(item);
|
||||
updateAdapterData();
|
||||
} else {
|
||||
if (item.equals(UserPhotoWallAdapter.ADD_PHOTO)) {
|
||||
int maxSelectable = 9 - uploadedUrls.size();
|
||||
if (maxSelectable > 0) {
|
||||
// 点击的是"+"'号,启动图片选择
|
||||
startChoosePhoto(1, PictureConfig.CHOOSE_REQUEST, false, maxSelectable);
|
||||
} else {
|
||||
ToastUtils.showShort("最多只能选择9张图片");
|
||||
}
|
||||
// 点击的是“+”号,启动图片选择
|
||||
// startChoosePhoto(1, PictureConfig.CHOOSE_REQUEST, false, 9);
|
||||
} else {
|
||||
// 查看大图或其他操作
|
||||
// 查看大图或其他操作
|
||||
FullScreenUtil.showFullScreenDialog(ReleaseActivity.this, position, list);
|
||||
}
|
||||
}
|
||||
|
||||
// int id = view.getId();
|
||||
// UserImgList item = mUserPhotoWallAdapter.getItem(position);
|
||||
// if (id == com.qxcm.moduleutil.R.id.iv_close) {
|
||||
//// MvpPre.deletePhoto(item.getId(), position);
|
||||
// } else {
|
||||
// if ("0".equals(item.getId())) {
|
||||
// startChoosePhoto(PictureMimeType.ofImage(), PictureConfig.REQUEST_CAMERA, true, 9);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
});
|
||||
mUserPhotoWallAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
mUserPhotoWallAdapter.setLongClickPos(position);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
updateAdapterData(); // 初始化时更新适配器数据
|
||||
list = new ArrayList<>();
|
||||
list.add("ADD_PHOTO"); // 最后一项是“添加图片”
|
||||
mUserPhotoWallAdapter.setNewData(list);
|
||||
mUserPhotoWallAdapter.setDelete(true);
|
||||
|
||||
mBinding.rl1.setOnClickListener(this::onClick);
|
||||
mBinding.tvFb.setOnClickListener(this::onClick);
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
PermissionDescriptionHelper.addPermissionDescription(false, (ViewGroup) mBinding.getRoot(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION});
|
||||
// 请求定位权限
|
||||
ActivityCompat.requestPermissions(
|
||||
(Activity) this,
|
||||
new String[]{
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
},
|
||||
1001 // 自定义常量,比如 1001
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
LocationProvider provider = LocationServiceFactory.createBestProvider(this);
|
||||
provider.getLastKnownLocation(this, new LocationProvider.LocationCallback() {
|
||||
@Override
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
city1=city;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
Toast.makeText(ReleaseActivity.this, "定位失败:" + errorMessage, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvFb, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvFb.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
//更新适配器数据的方法
|
||||
private void updateAdapterData() {
|
||||
list.clear();
|
||||
list.addAll(uploadedUrls); // 添加真实图片
|
||||
list.add(UserPhotoWallAdapter.ADD_PHOTO); // 最后加上 ADD_PHOTO
|
||||
mUserPhotoWallAdapter.setNewData(list);
|
||||
}
|
||||
private void onClick(View view) {
|
||||
if (view.getId() == R.id.rl_1) {
|
||||
dialog();
|
||||
}else if (view.getId()==R.id.tv_fb){
|
||||
if (mBinding.tvFb.getText().toString().equals("正在发布...")){
|
||||
ToastUtils.showShort("请勿重复发布");
|
||||
return;
|
||||
}
|
||||
if (mBinding.etG.getText().toString().isEmpty()){
|
||||
ToastUtils.showShort("请输入发布内容");
|
||||
return;
|
||||
}
|
||||
mBinding.tvFb.setText( "正在发布...");
|
||||
MvpPre.publishZone(TextUtils.join(",", uploadedUrls),mBinding.etG.getText().toString(),TextUtils.join(",", topicId),"",city1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void dialog() {
|
||||
MvpPre.topicList("1","30");
|
||||
}
|
||||
|
||||
private void startChoosePhoto(int mimeType, int requestCode, boolean isVideo, int type) {
|
||||
|
||||
PictureSelector.create(this)
|
||||
.openGallery(mimeType)
|
||||
.isGif(isVideo)
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.setPermissionDescriptionListener(PermissionDescriptionHelper.createListener())
|
||||
.setMaxSelectNum(type)
|
||||
.isPreviewImage(true)
|
||||
.isDisplayCamera(false)
|
||||
.setOutputCameraDir(Constants.FILE_PATH)
|
||||
.isOriginalSkipCompress(true)
|
||||
|
||||
.forResult(requestCode); //结果回调onActivityResult code
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
switch (requestCode) {
|
||||
case PictureConfig.CHOOSE_REQUEST:
|
||||
List<LocalMedia> localMediaList = PictureSelector.obtainSelectorList(data);
|
||||
|
||||
if (localMediaList != null && !localMediaList.isEmpty()) {
|
||||
List<File> imageFiles = new ArrayList<>();
|
||||
for (LocalMedia media : localMediaList) {
|
||||
String path = media.isCompressed() ? media.getCompressPath() : media.getRealPath();
|
||||
imageFiles.add(new File(path));
|
||||
}
|
||||
size = uploadedUrls.size();
|
||||
// 开始批量上传
|
||||
MvpPre.batchUploadFiles(imageFiles, 0); // 第二个参数是你原来的 type
|
||||
|
||||
}
|
||||
// if (localMedia != null && localMedia.size() != 0) {
|
||||
// LocalMedia imgMedia = localMedia.get(0);
|
||||
// String url;
|
||||
// if (imgMedia.isCompressed()) {
|
||||
// url = imgMedia.getCompressPath();
|
||||
// } else {
|
||||
// url = imgMedia.getRealPath();
|
||||
// }
|
||||
// MvpPre.uploadFile(new File(url), 0);
|
||||
// }
|
||||
break;
|
||||
case PictureConfig.REQUEST_CAMERA:
|
||||
List<LocalMedia> localMedia1 = PictureSelector.obtainSelectorList(data);
|
||||
if (localMedia1 != null && localMedia1.size() != 0) {
|
||||
LocalMedia imgMedia = localMedia1.get(0);
|
||||
// MvpPre.uploadFile(new File(imgMedia.getRealPath()), 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_release;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReleasePresenter bindPresenter() {
|
||||
return new ReleasePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topicList(List<HeatedBean> list) {
|
||||
// 示例数据
|
||||
// List<String> topics = Arrays.asList("话题1", "话题2", "话题3", "话题4");
|
||||
|
||||
List<String> topics = new ArrayList<>();
|
||||
for (HeatedBean bean : list) {
|
||||
topics.add(bean.getTitle());
|
||||
}
|
||||
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(this);
|
||||
dialog.setContentView(R.layout.bottom_sheet_recyclerview);
|
||||
View bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
||||
if (bottomSheet != null) {
|
||||
bottomSheet.setBackgroundResource(android.R.color.transparent); // 设置为透明
|
||||
}
|
||||
RecyclerView recyclerView = dialog.findViewById(R.id.rv_options);
|
||||
TextView btnCancel = dialog.findViewById(R.id.btn_cancel);
|
||||
TextView btnConfirm = dialog.findViewById(R.id.btn_confirm);
|
||||
btnConfirm.setTextColor(ColorManager.getInstance().getPrimaryColorInt());
|
||||
|
||||
assert recyclerView != null;
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
MultiSelectAdapter adapter = new MultiSelectAdapter(list);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
btnCancel.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
btnConfirm.setOnClickListener(v -> {
|
||||
topicId=new ArrayList<>();
|
||||
List<HeatedBean> selectedTopics = adapter.getSelectedItems();
|
||||
// 返回结果给调用页面(可使用接口或 onActivityResult 等方式)
|
||||
Log.d("Selected Topics", selectedTopics.toString());
|
||||
List<String> selectedTopicIds = new ArrayList<>();
|
||||
for (HeatedBean topic : selectedTopics) {
|
||||
selectedTopicIds.add(topic.getTitle());
|
||||
}
|
||||
|
||||
for (HeatedBean topic : selectedTopics){
|
||||
topicId.add(topic.getTopic_id());
|
||||
}
|
||||
// 示例:更新 UI
|
||||
((TextView)findViewById(R.id.tv_ht)).setText("已选:" + TextUtils.join(",", selectedTopicIds));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
int size=0;
|
||||
@Override
|
||||
public void upLoadSuccess(String url, int type, int index, int total) {
|
||||
if (index >= 0 && index < uploadedUrls.size()) {
|
||||
uploadedUrls.add(index, url); // 插入到对应位置
|
||||
} else {
|
||||
uploadedUrls.add(url); // 添加到最后
|
||||
}
|
||||
|
||||
if (uploadedUrls.size() == total+size) {
|
||||
updateAdapterData(); // 所有图片上传完成,更新适配器数据
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishSuccess() {
|
||||
mBinding.etG.setText( "立即发布");
|
||||
ToastUtils.showShort("发布成功");
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
PermissionDescriptionHelper.removePermissionDescription((ViewGroup) mBinding.getRoot());
|
||||
if (requestCode == 1001) {
|
||||
LocationProvider provider = LocationServiceFactory.createBestProvider(this);
|
||||
provider.getLastKnownLocation(this, new LocationProvider.LocationCallback() {
|
||||
@Override
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
Toast.makeText(ReleaseActivity.this, "当前位置:" + city, Toast.LENGTH_SHORT).show();
|
||||
city1=city;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
Toast.makeText(ReleaseActivity.this, "定位失败:", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xscm.modulemain.activity.plaza.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CircleContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
|
||||
void setCategories(List<HeatedBean> list);
|
||||
|
||||
void getCircleList(List<CircleListBean> list);
|
||||
|
||||
void setExpandColumn(List<ExpandColumnBean> list);
|
||||
|
||||
void setLikeZone(int index,CircleListBean item,int type);
|
||||
|
||||
void setCircleDetail(CircleListBean bean);
|
||||
|
||||
void getCommentList(CommentBean commentBean);
|
||||
void commentZone();
|
||||
void finishComment();
|
||||
|
||||
void getCircleDetail(int index,CircleListBean item,CircleListBean newItem);
|
||||
|
||||
void deleteZone(int index);
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void getCategories();
|
||||
|
||||
void getCircleList(String page,String page_limit);
|
||||
|
||||
void getExpandColumn(String type,String page,String page_limit);//获取扩列数据
|
||||
|
||||
void likeZone(int index,CircleListBean item);
|
||||
|
||||
void getCircleDetail(int index,CircleListBean item);
|
||||
|
||||
void topicId(String topic_id,int type);//type:这是让区分是什么地方获得数据,type=1:动态列表,type=2:动态详情
|
||||
|
||||
void deleteZone(int index,CircleListBean item);
|
||||
|
||||
void getCommentList(String id,String page,String page_limit);
|
||||
void commentZone(String id,String content,String pid,String reply_to);
|
||||
|
||||
void deleteComment(String id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.modulemain.activity.plaza.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ReleaseContract {
|
||||
public interface View extends IView<Activity> {
|
||||
void topicList(List<HeatedBean> list);
|
||||
void upLoadSuccess(String url, int type, int index, int total);
|
||||
|
||||
void publishSuccess();
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void topicList(String page, String page_limit);
|
||||
|
||||
void uploadFile(File file, int type,int index,int sice);
|
||||
|
||||
void publishZone(String images,String content,String topic_id,String room_id,String ip);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
package com.xscm.modulemain.activity.plaza.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.activity.plaza.activity.DynamicListActivity;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.adapter.CirleCategoryBannerAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentCircleCategoryBinding;
|
||||
import com.xscm.modulemain.dialog.ShareDialog;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.adapter.CirleListAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.BaseListData;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.diff.CircleListDiffCallback;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.PlazaEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.widget.dialog.RewardGiftDialogFragment;
|
||||
import com.zhpan.bannerview.indicator.DrawableIndicator;
|
||||
import com.zhpan.indicator.base.IIndicator;
|
||||
import com.zhpan.indicator.enums.IndicatorSlideMode;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 语圈中的发现界面
|
||||
*/
|
||||
public class CircleCategoryFragment extends BaseMvpFragment<CirclePresenter, FragmentCircleCategoryBinding> implements CircleContacts.View {
|
||||
CirleCategoryBannerAdapter cirleCategoryBannerAdapter;
|
||||
CirleListAdapter cirleListAdapter;
|
||||
private int page = 1;
|
||||
private String pageLimit = "10";
|
||||
|
||||
private List<CircleListBean> circleList = new ArrayList<>();
|
||||
|
||||
public static CircleCategoryFragment newInstance() {
|
||||
return new CircleCategoryFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
page = 1;
|
||||
MvpPre.getCategories();
|
||||
MvpPre.getCircleList("1", pageLimit);
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
protected void initView() {
|
||||
cirleCategoryBannerAdapter = new CirleCategoryBannerAdapter();
|
||||
mBinding.bannerViewPager
|
||||
.setPageMargin(1)
|
||||
.setScrollDuration(0)
|
||||
.setRevealWidth(0, 0)
|
||||
.setIndicatorVisibility(View.VISIBLE)
|
||||
.setIndicatorView(getVectorDrawableIndicator())
|
||||
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
|
||||
.setAdapter(cirleCategoryBannerAdapter)
|
||||
.setAutoPlay(false);
|
||||
|
||||
mBinding.constraintLayout.setVisibility(View.GONE);
|
||||
cirleCategoryBannerAdapter.setOnItemClickListener((view, data, position) -> {
|
||||
// 示例:跳转到房间详情页
|
||||
if (data != null) {
|
||||
Intent intent = new Intent(getActivity(), DynamicListActivity.class);
|
||||
intent.putExtra("heatedBean", data);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
cirleListAdapter = new CirleListAdapter(CirleListAdapter.PAGE_HOME);
|
||||
mBinding.recycleView.setAdapter(cirleListAdapter);
|
||||
cirleListAdapter.setOnItemClickListener(new CirleListAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(int position, CircleListBean item) {
|
||||
MvpPre.likeZone(position, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(CircleListBean item) {
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id() + "").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(int position, CircleListBean item) {//打赏
|
||||
RewardGiftDialogFragment.show(String.valueOf(item.getId()), item.getUser_id() + "", position, getChildFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoreClick(int idx, CircleListBean item) {//点击点点,分享等
|
||||
ShareDialog shareDialog = new ShareDialog(getContext(), item.getContent(), item.getShare_url(), item.getId() + "", 3, item.getUser_id() + "", item);
|
||||
shareDialog.setOnShareDataListener(new ShareDialog.OnShareDataListener() {
|
||||
|
||||
@Override
|
||||
public void onShareDataLoaded(String id) {
|
||||
MvpPre.deleteZone(idx, item);
|
||||
}
|
||||
});
|
||||
shareDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(CircleListBean item) {
|
||||
ARouter.getInstance().build(ARouteConstants.DYNAMIC_DETAIL).withString("zone_id", item.getId() + "").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(CircleListBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGensui(CircleListBean item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().equals("0")) {
|
||||
if (getActivity() instanceof MainActivity) {
|
||||
((MainActivity) getActivity()).isShowLoading(true);
|
||||
}
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), item.getRoom_id(), "", null);
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(getActivity(), item.getUser_id() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getCircleList(page + "", pageLimit);
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
circleList.clear();
|
||||
cirleListAdapter.notifyDataSetChanged();
|
||||
MvpPre.getCircleList(page + "", pageLimit);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(BaseEvent event) {
|
||||
if (event instanceof GiftRewardEvent) {
|
||||
MvpPre.getCircleDetail(((GiftRewardEvent) event).getPoints(),
|
||||
circleList.get(((GiftRewardEvent) event).getPoints()));
|
||||
} else if (event instanceof PlazaEvent) {
|
||||
CircleListBean item = null;
|
||||
int index = 0;
|
||||
for (int i = 0; i < circleList.size(); i++) {
|
||||
if (circleList.get(i).getId() == ((PlazaEvent) event).getMsgId()) {
|
||||
item = circleList.get(i);
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item == null)
|
||||
return;
|
||||
switch (((PlazaEvent) event).getType()) {
|
||||
case PlazaEvent.MODIFY_ZONE:
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
break;
|
||||
case PlazaEvent.DELETE_ZONE:
|
||||
if (circleList.size() == 1) {
|
||||
circleList.clear();
|
||||
cirleListAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
MvpPre.getCategories();
|
||||
break;
|
||||
case PlazaEvent.ADD_ZONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IIndicator getVectorDrawableIndicator() {
|
||||
int dp6 = getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_6);
|
||||
return new DrawableIndicator(getContext())
|
||||
.setIndicatorGap(getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_2_5))
|
||||
.setIndicatorDrawable(com.xscm.moduleutil.R.drawable.banner_indicator_nornal, com.xscm.moduleutil.R.drawable.banner_indicator_focus)
|
||||
.setIndicatorSize(getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_13), dp6, getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_13), dp6);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_circle_category;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
public void newAddRefresh() {
|
||||
page = 1;
|
||||
circleList.clear();
|
||||
MvpPre.getCircleList(page + "", pageLimit);
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
// 将原始数据拆分为多个子列表,每个子列表最多包含4个元素
|
||||
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
||||
// 添加到 bannerViewPager 的是分页后的列表
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
if (list == null || list.isEmpty())
|
||||
return;
|
||||
if (page == 1) {
|
||||
circleList.addAll(list);
|
||||
cirleListAdapter.setNewData(circleList);
|
||||
} else {
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.addAll(list);
|
||||
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int index, CircleListBean item, int type) {
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int index, CircleListBean item, CircleListBean newItem) {
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.set(index, newItem);
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
// 更新列表中的单个数据项(仅更新特定字段)
|
||||
if (cirleListAdapter != null && bean != null) {
|
||||
List<CircleListBean> dataList = cirleListAdapter.getData();
|
||||
if (dataList != null) {
|
||||
// 查找并更新对应的项
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
CircleListBean item = dataList.get(i);
|
||||
// 根据ID匹配需要更新的项
|
||||
if (item.getId() == bean.getId()) {
|
||||
// 只更新特定字段
|
||||
item.setRewards_num(bean.getRewards_num());
|
||||
// 可以继续更新其他需要的字段
|
||||
// 局部刷新该位置的数据
|
||||
cirleListAdapter.notifyItemChanged(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
if (circleList.size() == 1) {
|
||||
circleList.clear();
|
||||
cirleListAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
// 拆分函数
|
||||
private <T> List<List<T>> splitListIntoChunks(List<T> list, int chunkSize) {
|
||||
List<List<T>> chunks = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
chunks.add(list.subList(i, Math.min(i + chunkSize, list.size())));
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private List<BaseListData<HeatedBean>> baseListData(List<HeatedBean> list, int chunkSize) {
|
||||
List<BaseListData<HeatedBean>> baseListData = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
BaseListData<HeatedBean> baseListData1 = new BaseListData<>();
|
||||
baseListData1.setData(list.subList(i, Math.min(i + chunkSize, list.size())));
|
||||
baseListData.add(baseListData1);
|
||||
}
|
||||
return baseListData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.xscm.modulemain.activity.plaza.fragment;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.plaza.activity.ReleaseActivity;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.databinding.FragmentCircleBinding;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.bean.MyBagBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*语圈
|
||||
*/
|
||||
public class CircleFragment extends BaseMvpFragment<CirclePresenter, FragmentCircleBinding> implements CircleContacts.View {
|
||||
private List<MyBagBean> list;
|
||||
|
||||
public static final int RELEASE_CODE = 1010;
|
||||
private MyFragmentPagerAdapter adapter;
|
||||
|
||||
public static CircleFragment newInstance () {
|
||||
return new CircleFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData () {
|
||||
list=new ArrayList<>();
|
||||
list.add(new MyBagBean("发现", "1"));
|
||||
list.add(new MyBagBean("扩列", "2"));
|
||||
adapter = new MyFragmentPagerAdapter(getChildFragmentManager(), list);
|
||||
mBinding.viewPager.setAdapter(adapter);
|
||||
mBinding.tabLayout.setViewPager(mBinding.viewPager);
|
||||
mBinding.tabLayout.setCurrentTab(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView () {
|
||||
mBinding.ivRelease.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
private void onClick(View view) {
|
||||
if (view.getId()==R.id.iv_release){//发布
|
||||
startActivityForResult(new Intent(getContext(), ReleaseActivity.class),RELEASE_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode==RELEASE_CODE){
|
||||
adapter.refreshCircleCategoryData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener () {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId () {
|
||||
return R.layout.fragment_circle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter () {
|
||||
return new CirclePresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int idx,CircleListBean item,int type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int idx,CircleListBean item, CircleListBean newItem) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
|
||||
}
|
||||
|
||||
private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private List<MyBagBean> list;
|
||||
private SparseArray<Fragment> fragments = new SparseArray<>();
|
||||
|
||||
public MyFragmentPagerAdapter(FragmentManager fm, List<MyBagBean> list) {
|
||||
super(fm);
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
MyBagBean model = list.get(position);
|
||||
Fragment fragment = fragments.get(position);
|
||||
if (fragment == null) {
|
||||
if (model.getMyBagType().equals("1")) {
|
||||
fragment = CircleCategoryFragment.newInstance();
|
||||
} else {
|
||||
fragment = ExpandColumnFragment.newInstance();
|
||||
}
|
||||
fragments.put(position, fragment);
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void refreshCircleCategoryData() {
|
||||
CircleCategoryFragment circleCategoryFragments = (CircleCategoryFragment) fragments.get(0);
|
||||
circleCategoryFragments.newAddRefresh();
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
MyBagBean model = list.get(position);
|
||||
return model.getMyBagTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.xscm.modulemain.activity.plaza.fragment;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.adapter.ExpandColumnAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentExpandColumnBinding;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
|
||||
import org.angmarch.views.NiceSpinner;
|
||||
import org.angmarch.views.OnSpinnerItemSelectedListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/28
|
||||
*@description: 动态中的扩列fragemnt
|
||||
*/
|
||||
public class ExpandColumnFragment extends BaseMvpFragment<CirclePresenter, FragmentExpandColumnBinding> implements CircleContacts.View {
|
||||
|
||||
private ExpandColumnAdapter expandColumnAdapter;
|
||||
private String type="2";
|
||||
private int page;
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this,getActivity());
|
||||
}
|
||||
|
||||
public static ExpandColumnFragment newInstance() {
|
||||
return new ExpandColumnFragment();
|
||||
}
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
List<String> dataset = new LinkedList<>(Arrays.asList("只看女生", "只看男生", "查看全部"));
|
||||
mBinding.niceSpinner.attachDataSource(dataset);
|
||||
mBinding.niceSpinner.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(NiceSpinner parent, View view, int position, long id) {
|
||||
// 示例使用的是 String 类型,但你的数据类型可以是任意的
|
||||
String item = (String) parent.getItemAtPosition(position);
|
||||
LogUtils.e("@@@",item);
|
||||
mBinding.niceSpinner.setText(item);
|
||||
if (item.equals("只看女生")){
|
||||
type="2";
|
||||
page=1;
|
||||
}else if (item.equals("只看男生")){
|
||||
type="1";
|
||||
page=1;
|
||||
}else {
|
||||
type="0";
|
||||
page=1;
|
||||
}
|
||||
MvpPre.getExpandColumn(type,"1", "10");
|
||||
// mBinding.niceSpinner.getItemAtPosition(position);
|
||||
}
|
||||
});
|
||||
mBinding.niceSpinner.setText("只看女生");
|
||||
mBinding.niceSpinner.setBackground(null);
|
||||
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
expandColumnAdapter = new ExpandColumnAdapter();
|
||||
mBinding.recyclerView.setAdapter(expandColumnAdapter);
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getExpandColumn(type,page + "", "10");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
// EventBus.getDefault().post(new BannerRefreshEvent());
|
||||
page = 1;
|
||||
MvpPre.getExpandColumn(type,page+"", "10");
|
||||
}
|
||||
});
|
||||
|
||||
expandColumnAdapter.setOnItemClickListener(new ExpandColumnAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(ExpandColumnBean item) {
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id()).navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDiandianClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGnsClick(ExpandColumnBean item) {
|
||||
if ( item.getRoom_id()!=0){
|
||||
if (getActivity() instanceof MainActivity){
|
||||
((MainActivity)getActivity()).isShowLoading(true);
|
||||
}
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), item.getRoom_id()+"","",null);
|
||||
}else {
|
||||
ChatLauncher.getInstance().launchC2CChat(getActivity(), item.getUser_id()+"");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
page=1;
|
||||
MvpPre.getExpandColumn(type,"1", "10");
|
||||
}
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_expand_column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
if (type.equals("2")) {
|
||||
if (page == 1) {
|
||||
expandColumnAdapter.setNewData(new ArrayList<>());
|
||||
expandColumnAdapter.setNewData(list);
|
||||
} else {
|
||||
if (list != null && list.size() > 0) {
|
||||
expandColumnAdapter.addData(list);
|
||||
}
|
||||
}
|
||||
}else if (type.equals("1")){
|
||||
if (page == 1) {
|
||||
expandColumnAdapter.setNewData(new ArrayList<>());
|
||||
expandColumnAdapter.setNewData(list);
|
||||
} else {
|
||||
if (list != null && list.size() > 0) {
|
||||
expandColumnAdapter.addData(list);
|
||||
}
|
||||
}
|
||||
|
||||
}else if (type.equals("0")){
|
||||
if (page == 1) {
|
||||
expandColumnAdapter.setNewData(new ArrayList<>());
|
||||
expandColumnAdapter.setNewData(list);
|
||||
} else {
|
||||
if (list != null && list.size() > 0) {
|
||||
expandColumnAdapter.addData(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int idx,CircleListBean item,int type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int idx,CircleListBean item, CircleListBean newItem) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package com.xscm.modulemain.activity.plaza.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CirclePresenter extends BasePresenter<CircleContacts.View> implements CircleContacts.IIndexPre {
|
||||
|
||||
CircleContacts.View mView;
|
||||
|
||||
public CirclePresenter(CircleContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCategories() {
|
||||
|
||||
api.getCategories(new BaseObserver<List<HeatedBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<HeatedBean> heatedBeanList) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setCategories(heatedBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(String page, String page_limit) {
|
||||
api.getCircleList(page,page_limit,new BaseObserver<List<CircleListBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CircleListBean> circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCircleList(circleListBeans);
|
||||
MvpRef.get().finishComment();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//获取扩列数据
|
||||
@Override
|
||||
public void getExpandColumn(String type, String page, String page_limit) {
|
||||
api.getExpandColumn(type, page, page_limit, new BaseObserver<List<ExpandColumnBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<ExpandColumnBean> expandColumnBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setExpandColumn(expandColumnBeans);
|
||||
MvpRef.get().finishComment();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void likeZone(int index,CircleListBean item) {
|
||||
api.likeZone(item.getId()+"", new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setLikeZone(index,item,2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int index,CircleListBean item) {
|
||||
api.zoneDetail(item.getId()+"", new BaseObserver<CircleListBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CircleListBean circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCircleDetail(index,item,circleListBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topicId(String topic_id,int type) {
|
||||
if (type == 1) {//这是获取动态列表
|
||||
api.topicId(topic_id, new BaseObserver<List<CircleListBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CircleListBean> circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCircleList(circleListBeans);
|
||||
}
|
||||
});
|
||||
}else if (type == 2){//这是获取动态详情
|
||||
api.zoneDetail(topic_id, new BaseObserver<CircleListBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CircleListBean circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setCircleDetail(circleListBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index,CircleListBean bean) {
|
||||
api.deleteZone(bean.getId()+"", new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().deleteZone(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(String id, String page, String page_limit) {
|
||||
api.getCommentList(id, page, page_limit, new BaseObserver<CommentBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CommentBean commentBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCommentList(commentBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone(String id, String content, String pid, String reply_to) {
|
||||
api.commentZone(id, content, pid, reply_to, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().commentZone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteComment(String id) {
|
||||
api.deleteComment(id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().commentZone();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.xscm.modulemain.activity.plaza.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.ReleaseContract;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.cos.CosUploadManager;
|
||||
import com.xscm.moduleutil.utils.oss.OSSOperUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class ReleasePresenter extends BasePresenter<ReleaseContract.View> implements ReleaseContract.IIndexPre {
|
||||
ReleaseContract.View mView;
|
||||
public ReleasePresenter(ReleaseContract.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topicList(String page, String page_limit) {
|
||||
api.topicList(page, page_limit, new BaseObserver<List<HeatedBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<HeatedBean> heatedBeanList) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().topicList(heatedBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void batchUploadFiles(List<File> files, int type) {
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
uploadFile(files.get(i), type, i, files.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(File file, int type,int index,int size) {
|
||||
// MvpRef.get().showLoadings("上传中...");
|
||||
|
||||
|
||||
|
||||
String url = OSSOperUtils.getPath(file, type);
|
||||
CosUploadManager.getInstance(CommonAppContext.getInstance()).upParameters(url,file.getPath(), new CosUploadManager.UploadCallback() {
|
||||
@Override
|
||||
public void onSuccess(String url) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().upLoadSuccess(url, type, index, size);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
ToastUtils.show("上传失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure1(IllegalStateException e) {
|
||||
ToastUtils.show("上传失败");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
// OSSOperUtils.newInstance().putObjectMethod(url, file.getPath(), new OSSOperUtils.OssCallback() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// if (isViewAttach()) {
|
||||
// if (MvpRef==null){
|
||||
// MvpRef=new WeakReference<>(mView);
|
||||
// }
|
||||
// MvpRef.get().upLoadSuccess(OSSOperUtils.AliYunOSSURLFile + url, type, index, size);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFail() {
|
||||
// if (isViewAttach()) {
|
||||
// ToastUtils.show("上传失败");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishZone(String images, String content, String topic_id, String room_id,String ip) {
|
||||
api.publishZone(images, content, topic_id, room_id,ip, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().publishSuccess();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user