对接语圈接口,
页面基本完成,评论完成一半,需要再调试
This commit is contained in:
@@ -121,6 +121,9 @@ dependencies {
|
||||
//下拉框 https://gitcode.com/gh_mirrors/ni/nice-spinner?utm_source=csdn_blog_hover&isLogin=1
|
||||
api(libs.com.github.arcadefire.nice.spinner)
|
||||
|
||||
//定位
|
||||
api('com.google.android.gms:play-services-location:21.0.1')
|
||||
|
||||
//腾讯im
|
||||
// api project(':tuiconversation')
|
||||
// api project(':tuichat')
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<application
|
||||
android:allowBackup="true">
|
||||
|
||||
<activity
|
||||
android:name="com.qxcm.moduleutil.activity.news.OfficialNoticeActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -33,7 +33,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().getDecorView().setBackgroundResource(R.mipmap.log_bj);
|
||||
getWindow().getDecorView().setBackgroundResource(R.mipmap.activity_bj);
|
||||
setContentView(getLayoutId());
|
||||
mBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
mBinding.setLifecycleOwner(this);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.qxcm.moduleutil.activity.news;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.qxcm.moduleutil.activity.IPresenter;
|
||||
import com.qxcm.moduleutil.activity.IView;
|
||||
import com.qxcm.moduleutil.bean.NewsDataBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NewsContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
void getOfficialNoticeList(List<NewsDataBean> newsDataBeans);
|
||||
|
||||
}
|
||||
public interface IHomePre extends IPresenter {
|
||||
|
||||
void getOfficialNotice(String page,String page_limit,String type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.qxcm.moduleutil.activity.news;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.qxcm.moduleutil.bean.NewsDataBean;
|
||||
import com.qxcm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewsPresenter extends BasePresenter<NewsContacts.View> implements NewsContacts.IHomePre {
|
||||
public NewsPresenter(NewsContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOfficialNotice(String page, String page_limit, String type) {
|
||||
// api.getOfficialNotice(page, page_limit, type, new BaseObserver<List<NewsDataBean>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<NewsDataBean> newsDataBeans) {
|
||||
// MvpRef.get().getOfficialNoticeList(newsDataBeans);
|
||||
// }
|
||||
// });
|
||||
|
||||
List<NewsDataBean> newsDataBeans= new ArrayList<>();
|
||||
if (type.equals("1")){
|
||||
for (int i = 0; i < 5; i++) {
|
||||
NewsDataBean newsDataBean = new NewsDataBean();
|
||||
newsDataBean.setId(i+"");
|
||||
newsDataBean.setTitle("系统消息"+i);
|
||||
newsDataBean.setContent("系统消息"+i);
|
||||
newsDataBean.setType("1");
|
||||
newsDataBean.setSource_id("1");
|
||||
newsDataBean.setIs_read("1");
|
||||
newsDataBean.setCreatetime("2019-09-09");
|
||||
newsDataBean.setImage("");
|
||||
newsDataBeans.add(newsDataBean);
|
||||
}
|
||||
}else {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
NewsDataBean newsDataBean = new NewsDataBean();
|
||||
newsDataBean.setId(i+"");
|
||||
newsDataBean.setTitle("官方公告"+i);
|
||||
newsDataBean.setContent("官方公告"+i);
|
||||
newsDataBean.setType("2");
|
||||
newsDataBean.setSource_id("1");
|
||||
newsDataBean.setIs_read("1");
|
||||
newsDataBean.setCreatetime("2019-09-09");
|
||||
newsDataBean.setImage("");
|
||||
newsDataBeans.add(newsDataBean);
|
||||
}
|
||||
}
|
||||
MvpRef.get().getOfficialNoticeList(newsDataBeans);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.qxcm.moduleutil.activity.news;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.qxcm.moduleutil.bean.NewsDataBean;
|
||||
import com.qxcm.moduleutil.databinding.ActivityOfficialNoticeBinding;
|
||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, ActivityOfficialNoticeBinding> implements NewsContacts.View {
|
||||
|
||||
private int page = 1;
|
||||
private BaseQuickAdapter<NewsDataBean, BaseViewHolder> mAdapter;
|
||||
private String type;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
type=getIntent().getStringExtra("type");
|
||||
if (type.equals("1")){
|
||||
mBinding.topBar.setTitle("系统消息");
|
||||
}else {
|
||||
mBinding.topBar.setTitle("官方公告");
|
||||
}
|
||||
// mBinding.smartRefreshLayout.autoRefresh();
|
||||
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getOfficialNotice(page+"", "10",type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.getOfficialNotice(page+"", "10",type);
|
||||
}
|
||||
});
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mAdapter = new BaseQuickAdapter<NewsDataBean, BaseViewHolder>(R.layout.news_rv_item_system_news) {
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, NewsDataBean item) {
|
||||
helper.setText(R.id.tv_sys_time, item.getCreatetime() );
|
||||
helper.setText(R.id.tv_sys_con, Html.fromHtml(item.getTitle()));
|
||||
if (item.getType().equals("1")){
|
||||
helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
}else if (item.getType().equals("2")){
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(GONE);
|
||||
helper.getView(R.id.ll_system_official).setVisibility(VISIBLE);
|
||||
}else {
|
||||
helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
}
|
||||
ImageUtils.loadHeadCC(item.getImage(), helper.getView(R.id.image));
|
||||
helper.getView(R.id.image).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(mAdapter);
|
||||
MvpPre.getOfficialNotice("1","10",type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_official_notice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NewsPresenter bindPresenter() {
|
||||
return new NewsPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOfficialNoticeList(List<NewsDataBean> newsDataBeans) {
|
||||
mAdapter.setNewData(newsDataBeans);
|
||||
}
|
||||
}
|
||||
@@ -6,26 +6,47 @@ import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.CircleListBean;
|
||||
import com.qxcm.moduleutil.generated.callback.OnClickListener;
|
||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||
import com.qxcm.moduleutil.widget.MyGridView;
|
||||
import com.qxcm.moduleutil.widget.img.FullScreenUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CirleListAdapter extends BaseQuickAdapter<CircleListBean, BaseViewHolder> {
|
||||
public CirleListAdapter() {
|
||||
super(R.layout.item_cirle_list);
|
||||
}
|
||||
public interface OnItemClickListener {
|
||||
void onDianzanClick(CircleListBean item);
|
||||
void onHeadImageClick(CircleListBean item);
|
||||
void onZsClick(CircleListBean item);
|
||||
|
||||
void onDiandianClick(CircleListBean item);
|
||||
|
||||
void onPinglunClick(CircleListBean item);
|
||||
}
|
||||
private OnItemClickListener mListener;
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, CircleListBean item) {
|
||||
helper.addOnClickListener(R.id.dianzan)
|
||||
helper.addOnClickListener(com.qxcm.moduleutil.R.id.dianzan)
|
||||
.addOnClickListener(R.id.dy_lookmore_tv)
|
||||
.addOnClickListener(R.id.dy_head_image)
|
||||
.addOnClickListener(R.id.dy_more_image)
|
||||
.addOnClickListener(R.id.dy_oneimage_iv);
|
||||
.addOnClickListener(R.id.dy_oneimage_iv)
|
||||
.addOnClickListener(R.id.diandian)
|
||||
.addOnClickListener(R.id.pinglun)
|
||||
.addOnClickListener(com.qxcm.moduleutil.R.id.zs);
|
||||
|
||||
//先让单图,多图,音频的布局显示
|
||||
helper.getView(R.id.dy_oneimage_iv).setVisibility(View.VISIBLE);
|
||||
@@ -36,11 +57,33 @@ public class CirleListAdapter extends BaseQuickAdapter<CircleListBean, BaseViewH
|
||||
// ARouter.getInstance().build(AroutUtil.COMMUNITY_JUBAO).withString("uid", item.getUid() + "").navigation();
|
||||
}
|
||||
});
|
||||
|
||||
// 设置点击回调
|
||||
helper.getView(com.qxcm.moduleutil.R.id.dianzan).setOnClickListener(v -> {
|
||||
if (mListener != null) mListener.onDianzanClick(item);
|
||||
});
|
||||
|
||||
helper.getView(com.qxcm.moduleutil.R.id.dy_head_image).setOnClickListener(v -> {
|
||||
if (mListener != null) mListener.onHeadImageClick(item);
|
||||
});
|
||||
|
||||
helper.getView(com.qxcm.moduleutil.R.id.zs).setOnClickListener(v -> {
|
||||
if (mListener != null) mListener.onZsClick(item);
|
||||
});
|
||||
|
||||
helper.getView(R.id.diandian).setOnClickListener(v -> {
|
||||
if (mListener != null) mListener.onDiandianClick(item);
|
||||
});
|
||||
|
||||
helper.getView(R.id.pinglun).setOnClickListener(v->{
|
||||
if (mListener != null) mListener.onPinglunClick(item);
|
||||
});
|
||||
|
||||
//昵称
|
||||
helper.setText(R.id.dy_name_text, item.getUserNickName());
|
||||
helper.setText(R.id.dy_name_text, item.getNickname());
|
||||
|
||||
//头像
|
||||
ImageUtils.loadHeadCC(item.getUserAvatar(), (ImageView) helper.getView(R.id.dy_head_image));
|
||||
ImageUtils.loadHeadCC(item.getAvatar(), (ImageView) helper.getView(R.id.dy_head_image));
|
||||
|
||||
//动态内容以富文本展示
|
||||
String content = item.getContent();
|
||||
@@ -76,39 +119,46 @@ public class CirleListAdapter extends BaseQuickAdapter<CircleListBean, BaseViewH
|
||||
TextView view = helper.getView(R.id.dy_content_tv);
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
if (item.getTitle() != null) {
|
||||
helper.setVisible(R.id.dy_more_tv, true);
|
||||
helper.setText(R.id.dy_more_tv, item.getTitle().replace("#", ""));
|
||||
}else {
|
||||
helper.setVisible(R.id.dy_more_tv, false);
|
||||
}
|
||||
//点赞
|
||||
helper.setText(R.id.dy_fabulous, item.getLike());
|
||||
// if (item.is_praise() == 1) {
|
||||
// TextView dy_fabulous = helper.getView(R.id.dy_fabulous);
|
||||
// dy_fabulous.setTextColor(mContext.getResources().getColor(R.color.dianzan2));
|
||||
// helper.setImageResource(R.id.dianzan_image, R.drawable.dongtai_hudong_yidianzan);
|
||||
// } else {
|
||||
// TextView dy_fabulous = helper.getView(R.id.dy_fabulous);
|
||||
// dy_fabulous.setTextColor(mContext.getResources().getColor(R.color.dianzan1));
|
||||
// helper.setImageResource(R.id.dianzan_image, R.drawable.dongtai_hudong_dianzan);
|
||||
// }
|
||||
helper.setText(R.id.dy_fabulous, item.getLike_num());
|
||||
if (item.getIs_like() == 1) {
|
||||
TextView dy_fabulous = helper.getView(R.id.dy_fabulous);
|
||||
helper.setImageResource(R.id.dianzan_image, R.mipmap.dongtai_hudong_yidianzan);
|
||||
} else {
|
||||
TextView dy_fabulous = helper.getView(R.id.dy_fabulous);
|
||||
helper.setImageResource(R.id.dianzan_image, com.qxcm.moduleutil.R.mipmap.dongtai_hudong_dianzan);
|
||||
}
|
||||
|
||||
if (item.getIs_room()!=null && item.getIs_room().equals("0")){
|
||||
helper.setVisible(R.id.gensui,false);
|
||||
}else {
|
||||
helper.setVisible(R.id.gensui,true);
|
||||
}
|
||||
//分享数
|
||||
helper.setText(R.id.dy_zs, item.getIsShare());
|
||||
helper.setText(R.id.dy_zs, item.getRewards_num()!=null ? item.getRewards_num() : "0");
|
||||
//评论数
|
||||
helper.setText(R.id.dy_comment, item.getComment() + "");
|
||||
|
||||
helper.setText(R.id.dy_comment, item.getComment_num() + "");
|
||||
|
||||
//时间
|
||||
|
||||
if (!item.getTime().isEmpty()) {
|
||||
if (!item.getCreatetime().isEmpty()) {
|
||||
try {
|
||||
helper.setText(R.id.dy_time_text, item.getTime());
|
||||
helper.setText(R.id.dy_time_text, "发布于:"+TimeUtils.millis2String(Long.parseLong(item.getCreatetime()) * 1000));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (item.getImages().size() != 0) {
|
||||
String[] arrIv = item.getImages().toArray(new String[item.getImages().size()]);
|
||||
if (item.getImages()!=null) {
|
||||
|
||||
String[] arrIv = item.getImages().split(",");
|
||||
// String[] arrIv = Arrays.asList(item.getImages().split(",")).toArray(new String[item.getImages().size()]);
|
||||
int length = arrIv.length;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.qxcm.moduleutil.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
import com.qxcm.moduleutil.utils.MeHeadView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentViewHolder> {
|
||||
|
||||
private List<CommentBean.CommentDetailsBean> commentList;
|
||||
|
||||
public CommentAdapter(List<CommentBean.CommentDetailsBean> commentList) {
|
||||
this.commentList = commentList;
|
||||
}
|
||||
public void updateData(List<CommentBean.CommentDetailsBean> newReplyList) {
|
||||
commentList.clear();
|
||||
commentList.addAll(newReplyList);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public CommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false);
|
||||
return new CommentViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CommentViewHolder holder, int position) {
|
||||
CommentBean.CommentDetailsBean comment = commentList.get(position);
|
||||
holder.bind(comment);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return commentList.size();
|
||||
}
|
||||
|
||||
static class CommentViewHolder extends RecyclerView.ViewHolder {
|
||||
private MeHeadView ivAvatar;
|
||||
private TextView tvNickname;
|
||||
private TextView tvContent;
|
||||
private RecyclerView rvReplies;
|
||||
private TextView btnReply;
|
||||
|
||||
public CommentViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ivAvatar = itemView.findViewById(R.id.iv_avatar);
|
||||
tvNickname = itemView.findViewById(R.id.tv_nickname);
|
||||
tvContent = itemView.findViewById(R.id.tv_content);
|
||||
// rvReplies = itemView.findViewById(R.id.rv_replies);
|
||||
btnReply = itemView.findViewById(R.id.btn_reply);
|
||||
|
||||
// 设置子评论的适配器
|
||||
// LinearLayoutManager layoutManager = new LinearLayoutManager(itemView.getContext());
|
||||
// rvReplies.setLayoutManager(layoutManager);
|
||||
// ReplyAdapter replyAdapter = new ReplyAdapter(new ArrayList<>());
|
||||
// rvReplies.setAdapter(replyAdapter);
|
||||
}
|
||||
|
||||
public void bind(CommentBean.CommentDetailsBean comment) {
|
||||
// 绑定主评论数据
|
||||
tvNickname.setText(comment.getNickname());
|
||||
tvContent.setText(comment.getContent());
|
||||
ivAvatar.setData(comment.getAvatar(), "","");
|
||||
// 加载用户头像(使用 Glide 或其他图片加载库)
|
||||
// Glide.with(itemView).load(comment.getAvatar()).into(ivAvatar);
|
||||
|
||||
// 绑定子评论数据
|
||||
// ReplyAdapter replyAdapter = (ReplyAdapter) rvReplies.getAdapter();
|
||||
// if (replyAdapter != null) {
|
||||
// replyAdapter.updateData(comment.getReplies());
|
||||
// }
|
||||
|
||||
// 点击回复按钮
|
||||
btnReply.setOnClickListener(v -> {
|
||||
// 弹出输入框让用户输入回复内容
|
||||
showReplyDialog(comment.getId());
|
||||
});
|
||||
}
|
||||
|
||||
private void showReplyDialog(int commentId) {
|
||||
// 调用弹窗逻辑,传递 commentId 和 FragmentManager
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.qxcm.moduleutil.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
public class GiftTwoAdapter extends BaseAdapter {
|
||||
private final List<RoonGiftModel> mDatas;
|
||||
private final LayoutInflater inflater;
|
||||
private final Context mContext;
|
||||
private final MyGestureDetector gestureDetector;
|
||||
private final String type;
|
||||
/**
|
||||
* 页数下标,从0开始(当前是第几页)
|
||||
*/
|
||||
private final int curIndex;
|
||||
/**
|
||||
* 每一页显示的个数
|
||||
*/
|
||||
private final int pageSize = 100;
|
||||
|
||||
public GiftTwoAdapter(Context context, List<RoonGiftModel> mDatas, int curIndex, String type) {
|
||||
inflater = LayoutInflater.from(context);
|
||||
this.mDatas = mDatas;
|
||||
this.curIndex = curIndex;
|
||||
this.mContext = context;
|
||||
this.type = type;
|
||||
this.gestureDetector = new MyGestureDetector(mContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 先判断数据集的大小是否足够显示满本页?mDatas.size() > (curIndex+1)*pageSize,
|
||||
* 如果够,则直接返回每一页显示的最大条目个数pageSize,
|
||||
* 如果不够,则有几项返回几,(mDatas.size() - curIndex * pageSize);(也就是最后一页的时候就显示剩余item)
|
||||
*/
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mDatas.size() > (curIndex + 1) * pageSize ? pageSize : (mDatas.size() - curIndex * pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoonGiftModel getItem(int position) {
|
||||
return mDatas.get(position + curIndex * pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position + (long) curIndex * pageSize;
|
||||
}
|
||||
|
||||
private static class MyGestureDetector extends GestureDetector {
|
||||
private static WeakReference<GiftTwoAdapter> sAdapter = new WeakReference<>(null);
|
||||
private static RoonGiftModel sGiftModel;
|
||||
|
||||
public void setGiftModel(GiftTwoAdapter adapter, RoonGiftModel gift) {
|
||||
sAdapter = new WeakReference<>(adapter);
|
||||
sGiftModel = gift;
|
||||
}
|
||||
|
||||
private static final SimpleOnGestureListener sSimpleOnGestureListener = new SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||
Log.d("@@", "sGiftModel"+sGiftModel.toString());
|
||||
// EventBus.getDefault().post(new RoomGiftClickEvent(sAdapter.get(), sGiftModel, 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
Log.d("@@", "sGiftModel"+sGiftModel.toString());
|
||||
// EventBus.getDefault().post(new RoomGiftClickEvent(sAdapter.get(), sGiftModel, 2));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public MyGestureDetector(Context context) {
|
||||
super(context, sSimpleOnGestureListener);
|
||||
setOnDoubleTapListener(sSimpleOnGestureListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressLint({"SetTextI18n", "ClickableViewAccessibility"})
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder viewHolder;
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.room_gv_gift_item, parent, false);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.tv_gift_name = (TextView) convertView.findViewById(R.id.tv_gift_name);
|
||||
viewHolder.tv_gift_price = (TextView) convertView.findViewById(R.id.tv_gift_price);
|
||||
viewHolder.iv_gift_pic = (ImageView) convertView.findViewById(R.id.iv_gift_pic);
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
// viewHolder.tv_gift_num = convertView.findViewById(R.id.tv_gift_num);
|
||||
// viewHolder.tv_gift_change_love_values = convertView.findViewById(R.id.tv_gift_change_love_values);
|
||||
viewHolder.item_layout.setOnTouchListener((v, event) -> {
|
||||
// gestureDetector.setGiftModel(GiftTwoAdapter.this, (RoonGiftModel) v.getTag(R.id.id_gift_tag));
|
||||
// gestureDetector.onTouchEvent(event);
|
||||
|
||||
return true;
|
||||
});
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
/*
|
||||
* 在给View绑定显示的数据时,计算正确的position = position + curIndex * pageSize,
|
||||
*/
|
||||
// viewHolder.tv_gift_num.setVisibility(type.equals("1") ? View.VISIBLE : View.INVISIBLE);
|
||||
// viewHolder.tv_gift_change_love_values.setVisibility(View.GONE);
|
||||
|
||||
RoonGiftModel giftModel = getItem(position);
|
||||
//设置礼物名字
|
||||
viewHolder.tv_gift_name.setText(giftModel.getName());
|
||||
//设置礼物价格
|
||||
String surplusTxt = giftModel.getPrice();
|
||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(surplusTxt);
|
||||
//ForegroundColorSpan 为文字前景色,BackgroundColorSpan为文字背景色
|
||||
ForegroundColorSpan redSpan = new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_FFA9A9A9));
|
||||
stringBuilder.setSpan(redSpan, surplusTxt.length(), surplusTxt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);//修改最后两个字体的颜色
|
||||
viewHolder.tv_gift_price.setText(stringBuilder);
|
||||
// viewHolder.item_layout.setTag(R.id.id_gift_tag, giftModel);
|
||||
|
||||
//加载礼物图片
|
||||
ImageUtils.loadImageView(giftModel.getPicture(), viewHolder.iv_gift_pic);
|
||||
//设置选中后的样式
|
||||
|
||||
if (giftModel.isChecked()) {//被选中
|
||||
viewHolder.cl_iv_down_on.setBackgroundResource(R.drawable.gift_x);
|
||||
viewHolder.ivDownOn.setVisibility(View.GONE);
|
||||
} else {
|
||||
viewHolder.ivDownOn.setVisibility(View.GONE);
|
||||
viewHolder.cl_iv_down_on.setBackgroundResource(0);
|
||||
}
|
||||
//设置
|
||||
// //设置礼物心动值
|
||||
// if (giftModel.getCardiac().equals("0")) {
|
||||
// viewHolder.tv_gift_change_love_values.setBackgroundResource(R.mipmap.room_gift_xin_dong_reduce);
|
||||
// viewHolder.tv_gift_change_love_values.setText(String.format("%s", giftModel.getCardiac()));
|
||||
// } else {
|
||||
// viewHolder.tv_gift_change_love_values.setBackgroundResource(R.mipmap.room_gift_xin_dong_add);
|
||||
// viewHolder.tv_gift_change_love_values.setText(String.format("+%s", giftModel.getCardiac()));
|
||||
// }
|
||||
if (giftModel.isManghe()) {
|
||||
viewHolder.tv_gift_change_love_values.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
static class ViewHolder {
|
||||
public ConstraintLayout item_layout;
|
||||
public TextView tv_gift_name, tv_gift_price, tv_gift_num;
|
||||
public ImageView iv_gift_pic;
|
||||
public TextView tv_gift_change_love_values;
|
||||
public ImageView ivDownOn;
|
||||
public ConstraintLayout cl_iv_down_on;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.qxcm.moduleutil.adapter;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.base.BaseMvpFragment;
|
||||
import com.qxcm.moduleutil.bean.GiftLabelBean;
|
||||
import com.qxcm.moduleutil.bean.RewardUserBean;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
import com.qxcm.moduleutil.databinding.RoomVpGiftBinding;
|
||||
import com.qxcm.moduleutil.presenter.RewardGiftContacts;
|
||||
import com.qxcm.moduleutil.presenter.RewardGiftPresenter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter, RoomVpGiftBinding> implements RewardGiftContacts.View {
|
||||
private String id;
|
||||
private GiftTwoAdapter mAdapter;
|
||||
private String tag;
|
||||
private int pageSize = 100;//一页显示的礼物个数
|
||||
private int pageCount;//页数
|
||||
|
||||
public static GiftTwoDetailsFragment newInstance(String type) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString("id", type);
|
||||
GiftTwoDetailsFragment fragment = new GiftTwoDetailsFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
id = arguments.getString("id");
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
// EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RewardGiftPresenter bindPresenter() {
|
||||
return new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getGiftList(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_vp_gift;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> data) {
|
||||
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
mAdapter = new GiftTwoAdapter(getActivity(), data, j, "0");
|
||||
mBinding.rvGift.setAdapter(mAdapter);
|
||||
}
|
||||
// EventBus.getDefault().post(new RoomGiftEvent(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(List<RewardUserBean> rewardUserBeanList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(List<GiftLabelBean> giftLabelBeans) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.qxcm.moduleutil.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReplyAdapter extends RecyclerView.Adapter<ReplyAdapter.ReplyViewHolder> {
|
||||
|
||||
private List<CommentBean.CommentDetailsBean.Replies> replyList;
|
||||
|
||||
public ReplyAdapter(List<CommentBean.CommentDetailsBean.Replies> replyList) {
|
||||
this.replyList = replyList;
|
||||
}
|
||||
|
||||
public void updateData(List<CommentBean.CommentDetailsBean.Replies> newReplyList) {
|
||||
replyList.clear();
|
||||
replyList.addAll(newReplyList);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ReplyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_reply, parent, false);
|
||||
return new ReplyViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ReplyViewHolder holder, int position) {
|
||||
CommentBean.CommentDetailsBean.Replies reply = replyList.get(position);
|
||||
holder.bind(reply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return replyList.size();
|
||||
}
|
||||
|
||||
static class ReplyViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView tvNickname;
|
||||
private TextView tvContent;
|
||||
|
||||
public ReplyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
// tvNickname = itemView.findViewById(R.id.tv_reply_nickname);
|
||||
// tvContent = itemView.findViewById(R.id.tv_reply_content);
|
||||
}
|
||||
|
||||
public void bind(CommentBean.CommentDetailsBean.Replies reply) {
|
||||
tvNickname.setText(reply.getNickname());
|
||||
tvContent.setText(reply.getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.qxcm.moduleutil.adapter;
|
||||
|
||||
public class RewardUserAdapter {
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.qxcm.moduleutil.adapter;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.UserImgList;
|
||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class UserPhotoWallAdapter extends BaseQuickAdapter<UserImgList, BaseViewHolder> {
|
||||
public class UserPhotoWallAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
|
||||
private boolean b = false;
|
||||
public static final String ADD_PHOTO = "ADD_PHOTO";
|
||||
private int longClickPos = -1;
|
||||
|
||||
public UserPhotoWallAdapter() {
|
||||
@@ -15,24 +17,32 @@ public class UserPhotoWallAdapter extends BaseQuickAdapter<UserImgList, BaseView
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, UserImgList item) {
|
||||
if (helper.getAdapterPosition() == 5) {
|
||||
helper.setVisible(R.id.riv_user_head, false);
|
||||
helper.setVisible(R.id.iv_close, false);
|
||||
protected void convert(BaseViewHolder helper, String item) {
|
||||
helper.setGone(R.id.iv_close, false);
|
||||
if (item.equals(ADD_PHOTO)) {
|
||||
// 显示加号图片
|
||||
helper.setImageResource(R.id.riv_user_head, com.qxcm.moduleutil.R.mipmap.add_img);
|
||||
} else {
|
||||
helper.setVisible(R.id.riv_user_head, true);
|
||||
if (!"0".equals(item.getId())) {
|
||||
ImageUtils.loadCenterCrop(item.getUrl(), helper.getView(R.id.riv_user_head));
|
||||
if (longClickPos == helper.getAdapterPosition()) {
|
||||
helper.setVisible(R.id.iv_close, true);
|
||||
} else {
|
||||
helper.setVisible(R.id.iv_close, false);
|
||||
}
|
||||
} else {
|
||||
helper.setImageResource(R.id.riv_user_head, com.qxcm.moduleutil.R.mipmap.add_img);
|
||||
helper.setGone(R.id.iv_close, false);
|
||||
}
|
||||
ImageUtils.loadCenterCrop(item, helper.getView(R.id.riv_user_head));
|
||||
}
|
||||
|
||||
// if (helper.getAdapterPosition() == 5) {
|
||||
// helper.setVisible(R.id.riv_user_head, false);
|
||||
// helper.setVisible(R.id.iv_close, false);
|
||||
// } else {
|
||||
// helper.setVisible(R.id.riv_user_head, true);
|
||||
// if (!"0".equals(item.getId())) {
|
||||
// ImageUtils.loadCenterCrop(item.getUrl(), helper.getView(R.id.riv_user_head));
|
||||
// if (longClickPos == helper.getAdapterPosition()) {
|
||||
// helper.setVisible(R.id.iv_close, true);
|
||||
// } else {
|
||||
// helper.setVisible(R.id.iv_close, false);
|
||||
// }
|
||||
// } else {
|
||||
// helper.setImageResource(R.id.riv_user_head, com.qxcm.moduleutil.R.mipmap.add_img);
|
||||
// helper.setGone(R.id.iv_close, false);
|
||||
// }
|
||||
// }
|
||||
helper.addOnClickListener(R.id.iv_close);
|
||||
helper.addOnClickListener(R.id.riv_user_head);
|
||||
helper.addOnLongClickListener(R.id.riv_user_head);
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.qxcm.moduleutil.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.activity.BaseAppCompatActivity;
|
||||
import com.qxcm.moduleutil.activity.IPresenter;
|
||||
import com.qxcm.moduleutil.activity.IView;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/29
|
||||
*@description: dialogFragement基类
|
||||
*/
|
||||
public abstract class BaseMvpDialogFragment<P extends IPresenter, VDM extends ViewDataBinding> extends DialogFragment implements IView<Activity> {
|
||||
protected VDM mBinding;
|
||||
|
||||
protected P MvpPre;
|
||||
|
||||
protected abstract P bindPresenter();
|
||||
|
||||
protected boolean setDialogWH = true;
|
||||
protected boolean isAnimation = true;
|
||||
protected boolean mGravityBOTTOM;
|
||||
|
||||
@Override
|
||||
public Activity getSelfActivity() {
|
||||
return getActivity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
// ARouter.getInstance().inject(this);
|
||||
mBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false);
|
||||
mBinding.setLifecycleOwner(this);
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
MvpPre = bindPresenter();
|
||||
if (getArguments() != null) {
|
||||
initArgs(getArguments());
|
||||
}
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
public void initArgs(Bundle arguments) {
|
||||
|
||||
}
|
||||
|
||||
protected abstract void initData();
|
||||
|
||||
protected abstract void initView();
|
||||
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getDialog() != null && setDialogWH) {
|
||||
Window window = getDialog().getWindow();
|
||||
if (mGravityBOTTOM) {
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
if (isAnimation) {
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
// window.getDecorView().setPadding(0, 0, 0, 0);
|
||||
initDialogStyle(window);
|
||||
}
|
||||
}
|
||||
|
||||
protected void initDialogStyle(Window window) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadings() {
|
||||
if (!isAdded() || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (getActivity() instanceof BaseAppCompatActivity) {
|
||||
((BaseAppCompatActivity) getActivity()).showLoading("加载中...");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadings(String content) {
|
||||
if (!isAdded() || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (getActivity() instanceof BaseAppCompatActivity) {
|
||||
((BaseAppCompatActivity) getActivity()).showLoading(content);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disLoadings() {
|
||||
if (getActivity() instanceof BaseAppCompatActivity) {
|
||||
((BaseAppCompatActivity) getActivity()).disLoading();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (mBinding != null) {
|
||||
mBinding.unbind();
|
||||
}
|
||||
if (MvpPre != null) {
|
||||
MvpPre.detachView();
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,14 @@ import com.qxcm.moduleutil.utils.config.EnvironmentEnum;
|
||||
import com.qxcm.moduleutil.utils.config.EnvironmentPrefs;
|
||||
import com.qxcm.moduleutil.widget.CommonAppConfig;
|
||||
import com.qxcm.moduleutil.widget.Constants;
|
||||
import com.qxcm.moduleutil.widget.CustomRefreshHeader;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshFooter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshHeader;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@@ -299,4 +307,27 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
return false; //未安装支付宝
|
||||
}
|
||||
}
|
||||
|
||||
//static 代码段可以防止内存泄露
|
||||
static {
|
||||
//设置全局的Header构建器
|
||||
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
|
||||
@Override
|
||||
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
|
||||
return new CustomRefreshHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header
|
||||
}
|
||||
});
|
||||
//设置全局的Footer构建器
|
||||
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
|
||||
@Override
|
||||
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
|
||||
ClassicsFooter classicsFooter = new ClassicsFooter(context);
|
||||
classicsFooter.setDrawableSize(20);
|
||||
classicsFooter.setFinishDuration(0);
|
||||
//指定为经典Footer,默认是 BallPulseFooter
|
||||
return classicsFooter;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/29
|
||||
*@description: 相册列表
|
||||
*/
|
||||
@Data
|
||||
public class AlbumBean {
|
||||
private String id;//相册id
|
||||
|
||||
private String name; //相册名称
|
||||
|
||||
private String image; //相册封面
|
||||
|
||||
private String pwd; //相册密码
|
||||
|
||||
private String read_num; //相册阅读数
|
||||
|
||||
private List<ImageList> image_list;
|
||||
@Data
|
||||
public class ImageList{
|
||||
private String id; //图片id
|
||||
private String image; //图片地址
|
||||
private String content; //图片描述
|
||||
private String createtime; //图片创建时间
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,22 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CircleListBean {
|
||||
private String id;
|
||||
private String userNickName;
|
||||
private String userAvatar;
|
||||
private String time;
|
||||
private String content;
|
||||
private List<String> images;
|
||||
private String type;
|
||||
private String comment;
|
||||
private String like;
|
||||
private String isShare;
|
||||
private int id;//语圈ID
|
||||
private int user_id;//用户ID
|
||||
private String nickname;//用户昵称
|
||||
private String avatar;//用户头像
|
||||
private int is_like;//是否点赞(0没有,1点赞)
|
||||
private int sex;//性别 1男2女
|
||||
private String content;//内容
|
||||
private String like_num;//点赞数
|
||||
private String rewards_num; //打赏金额
|
||||
private String is_room;//作者是否在房间中(1在,0不在)
|
||||
private String room_id;//作者所在房间ID (is_room =0 此值小于0 )
|
||||
private String comment_num;//评论数
|
||||
private int is_recommend;//1非推荐2推荐
|
||||
private String ip;//活跃地址
|
||||
private String images;////图片 JSON字符串 封面获取第一张
|
||||
private String createtime;//时间
|
||||
private String title;//话题
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description:评论实体
|
||||
*/
|
||||
@Data
|
||||
public class CommentBean {
|
||||
|
||||
private int total;//评论总数
|
||||
private List<CommentDetailsBean> list;
|
||||
@Data
|
||||
public static class CommentDetailsBean {
|
||||
private int id;
|
||||
private int zone_id;
|
||||
private String content;
|
||||
private int createtime;
|
||||
private int user_id;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private int is_author;
|
||||
private List<Replies> replies;
|
||||
|
||||
@Data
|
||||
public static class Replies {
|
||||
private int zone_id;
|
||||
private String content;
|
||||
private int createtime;
|
||||
private int user_id;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private int pid;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/29
|
||||
*@description: 扩列数据
|
||||
*/
|
||||
@Data
|
||||
public class ExpandColumnBean {
|
||||
private String id;
|
||||
private String sex;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private String birthday;
|
||||
private String loginip;
|
||||
private String home_bgimages;
|
||||
private int room_id;//房间id,当有参数的时候,就显示跟随,当没有的时候,就显示私信控件
|
||||
private List<String> icon;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GiftLabelBean {
|
||||
private String label;
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 礼物打赏数量
|
||||
*/
|
||||
public class GiftNumBean {
|
||||
private String number;
|
||||
private String text;
|
||||
|
||||
public GiftNumBean() {
|
||||
}
|
||||
|
||||
public GiftNumBean(String number, String text) {
|
||||
this.number = number;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,19 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 话题实体
|
||||
*/
|
||||
@Data
|
||||
public class HeatedBean {
|
||||
private String title;
|
||||
private String title_pictrue;
|
||||
private String type;
|
||||
private String title_content;
|
||||
private String title;//话题
|
||||
private String topic_id;//话题id
|
||||
private String count;//引用数量
|
||||
private String pic; //图片
|
||||
private String content;//内容
|
||||
private String id;//话题id
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NewsDataBean {
|
||||
private String id; //id
|
||||
private String title; //标题
|
||||
private String content; //内容
|
||||
private String type; //类型1系统消息 2官方公告 3活动中心
|
||||
private String source_id; //来源id
|
||||
private String is_read; //是否已读
|
||||
private String createtime;//创建时间
|
||||
private String image;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RewardUserBean {
|
||||
private String user_id;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private String is_online;
|
||||
private String total_price;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.qxcm.moduleutil.bean;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RoonGiftModel {
|
||||
private String id;
|
||||
private String name;
|
||||
private String title;
|
||||
private String all_room_push;
|
||||
private String picture;
|
||||
private String price;
|
||||
private String special;
|
||||
private String sort;
|
||||
private String type;
|
||||
private String child_type;
|
||||
private String sold;
|
||||
private String cardiac;
|
||||
private boolean isChecked;
|
||||
|
||||
private boolean can_send_self;//是否能送自己
|
||||
|
||||
public boolean isCan_send_self() {
|
||||
if ( isManghe()) {
|
||||
return true;
|
||||
}
|
||||
return can_send_self;
|
||||
}
|
||||
|
||||
public boolean isManghe() {
|
||||
return type.equals("4") || type.equals("5") || type.equals("13");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,16 @@
|
||||
package com.qxcm.moduleutil.http;
|
||||
|
||||
|
||||
import com.qxcm.moduleutil.bean.AlbumBean;
|
||||
import com.qxcm.moduleutil.bean.CircleListBean;
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
import com.qxcm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.qxcm.moduleutil.bean.GiftLabelBean;
|
||||
import com.qxcm.moduleutil.bean.HeatedBean;
|
||||
import com.qxcm.moduleutil.bean.NewsDataBean;
|
||||
import com.qxcm.moduleutil.bean.RealNameBean;
|
||||
import com.qxcm.moduleutil.bean.RewardUserBean;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
import com.qxcm.moduleutil.bean.UserBean;
|
||||
import com.qxcm.moduleutil.widget.Constants;
|
||||
|
||||
@@ -16,6 +25,7 @@ import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ApiServer {
|
||||
|
||||
@@ -72,6 +82,54 @@ public interface ApiServer {
|
||||
@POST(Constants.REAL_NAME)
|
||||
Observable<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_EXPAND_COLUMN)
|
||||
Observable<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_OFFICIAL_NOTICE)
|
||||
Observable<BaseModel<List<NewsDataBean>>> getOfficialNotice( @Field("page") String page, @Field("page_limit") String page_limit,@Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ALBUM_LIST)
|
||||
Observable<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.CREATE_ALBUM)
|
||||
Call<BaseModel<String> > createAlbum(@Field("name") String name, @Field("image") String image);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_REWARD_LIST)
|
||||
Observable<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") int page, @Field("page_limit") int page_limit);
|
||||
|
||||
@GET(Constants.GET_GIFT_LABEL)
|
||||
Observable<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
|
||||
|
||||
@GET(Constants.GIFT_LIST)//获取礼物列表
|
||||
Observable<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label);
|
||||
|
||||
@GET(Constants.TOPIC_LIST)//获取话题
|
||||
Observable<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.PUBLISH_ZONE)
|
||||
Call<BaseModel<String>> publishZone(@Field("images") String images, @Field("content") String content, @Field("topic_id") String topic_id, @Field("room_id") String room_id,@Field("ip") String ip);
|
||||
|
||||
@GET(Constants.GET_CATEGORIES)
|
||||
Observable<BaseModel<List<HeatedBean>>> getCategories();
|
||||
|
||||
@GET(Constants.GET_CIRCLE_LIST)
|
||||
Observable<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.LIKE_ZONE)
|
||||
Call<BaseModel<String>> likeZone(@Field("id") String zone_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_COMMENT_LIST)
|
||||
Observable<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.COMMENT_ZONE)
|
||||
Call<BaseModel<String>> commentZone(@Field("id") String id, @Field("content") String content, @Field("pid") String pid, @Field("reply_to") String reply_to);
|
||||
|
||||
// @FormUrlEncoded
|
||||
// @POST(Constant.URL.ADDBANK)
|
||||
|
||||
@@ -38,6 +38,10 @@ public class BaseModel<T> implements Parcelable {
|
||||
public boolean isSuccess() {
|
||||
return code == 1; // 根据实际业务码判断是否成功
|
||||
}
|
||||
|
||||
public boolean isTokenExpired() {
|
||||
return code == 301; // token过期码
|
||||
}
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.text.TextUtils;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||
import com.qxcm.moduleutil.event.LogOutEvent;
|
||||
import com.qxcm.moduleutil.utils.DialogUtils;
|
||||
import com.qxcm.moduleutil.utils.logger.Logger;
|
||||
@@ -18,6 +19,7 @@ import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2017/11/22.
|
||||
@@ -86,4 +88,28 @@ public abstract class BaseObserver<T> implements Observer<T> {
|
||||
Logger.i("onComplete");
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onNext(BaseModel<T> response) {
|
||||
// if (response.isSuccess()) {
|
||||
// onSuccess(response.getData());
|
||||
// } else if (response.isTokenExpired()) {
|
||||
// // 触发退出登录
|
||||
// handleTokenExpired();
|
||||
// } else {
|
||||
// onError(response.getMsg());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected abstract void onSuccess(T data);
|
||||
// protected abstract void onError(String msg);
|
||||
// protected abstract void onFail(String error);
|
||||
//
|
||||
// @SneakyThrows
|
||||
// private void handleTokenExpired() {
|
||||
// // 退出登录逻辑
|
||||
// ToastUtils.show("登录已过期,请重新登录");
|
||||
// // 示例:跳转到登录页
|
||||
// CommonAppContext.getInstance().clearLoginInfo();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2,16 +2,46 @@ package com.qxcm.moduleutil.http;
|
||||
|
||||
|
||||
|
||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.ObservableTransformer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class DefaultTransformer<T extends BaseModel<R>, R>
|
||||
implements ObservableTransformer<T, R> {
|
||||
public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>, T> {
|
||||
|
||||
// @Override
|
||||
// public ObservableSource<R> apply(Observable<T> upstream) {
|
||||
// return upstream.compose(SchedulerTransformer.<T>create())
|
||||
// .compose(new ErrorCheckerTransformer<T, R>());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ObservableSource<R> apply(Observable<T> upstream) {
|
||||
return upstream.compose(SchedulerTransformer.<T>create())
|
||||
.compose(new ErrorCheckerTransformer<T, R>());
|
||||
public ObservableSource<T> apply(Observable<BaseModel<T>> upstream) {
|
||||
return upstream
|
||||
.map(response -> {
|
||||
if (response.isTokenExpired()) {
|
||||
// 触发登出事件(EventBus)
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
throw new APIException(-1, "登录已过期");
|
||||
}
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
throw new APIException(response.getCode(), response.getMsg());
|
||||
}
|
||||
|
||||
return response.getData();
|
||||
})
|
||||
.onErrorResumeNext(throwable -> {
|
||||
// 可以在这里统一处理异常
|
||||
if (throwable instanceof APIException && ((APIException) throwable).getCode() == -1) {
|
||||
// 已经触发过登出事件
|
||||
}
|
||||
return Observable.error(throwable);
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,23 @@ import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.franmontiel.persistentcookiejar.ClearableCookieJar;
|
||||
import com.franmontiel.persistentcookiejar.PersistentCookieJar;
|
||||
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
|
||||
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
|
||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||
import com.qxcm.moduleutil.bean.AlbumBean;
|
||||
import com.qxcm.moduleutil.bean.CircleListBean;
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
import com.qxcm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.qxcm.moduleutil.bean.GiftLabelBean;
|
||||
import com.qxcm.moduleutil.bean.HeatedBean;
|
||||
import com.qxcm.moduleutil.bean.NewsDataBean;
|
||||
import com.qxcm.moduleutil.bean.RealNameBean;
|
||||
import com.qxcm.moduleutil.bean.RewardUserBean;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
import com.qxcm.moduleutil.bean.UserBean;
|
||||
import com.qxcm.moduleutil.presenter.BasePresenter;
|
||||
import com.qxcm.moduleutil.utils.SystemUtils;
|
||||
import com.qxcm.moduleutil.utils.logger.DataLogger;
|
||||
import com.qxcm.moduleutil.utils.logger.DataLoggingInterceptor;
|
||||
@@ -31,9 +40,11 @@ import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
|
||||
@@ -105,7 +116,8 @@ public class RetrofitClient {
|
||||
|
||||
private Retrofit provideRetrofit(OkHttpClient client) {
|
||||
return new Retrofit.Builder()
|
||||
.addConverterFactory(MyConverterFactory.create())
|
||||
.addConverterFactory(MyConverterFactory.create())/**/
|
||||
// .addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.baseUrl(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl())
|
||||
.client(client)
|
||||
@@ -200,4 +212,169 @@ public class RetrofitClient {
|
||||
public void realName(String real_name, String card_number,BaseObserver<RealNameBean> observer){
|
||||
sApiServer.realName(real_name,card_number).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
//获取扩列数据
|
||||
public void getExpandColumn(String type,String page,String page_limit,BaseObserver<List<ExpandColumnBean>> observer){
|
||||
sApiServer.getExpandColumn(type).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
//获取官方公告数据或者系统消息,根据type区分 type=1是系统消息,type=2是官方公告
|
||||
public void getOfficialNotice(String page,String page_limit,String type,BaseObserver<List<NewsDataBean>> observer){
|
||||
sApiServer.getOfficialNotice(page,page_limit,type).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void getAlbumList(String page,String page_limit,BaseObserver<List<AlbumBean>> observer){
|
||||
sApiServer.getAlbumList(page,page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void createAlbum(String name,String image,BaseObserver<String> observer) {
|
||||
sApiServer.createAlbum(name,image).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
if (response.code()==200){
|
||||
BaseModel<String> string=response.body();
|
||||
if (string!=null){
|
||||
int code=string.getCode();
|
||||
if (code==1){
|
||||
observer.onNext(string.getMsg());
|
||||
}else if (code==301){
|
||||
try {
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(string.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getRewardList(String id, int page, int page_limit,BaseObserver<List<RewardUserBean> > observer){
|
||||
sApiServer.getRewardList(id,page,page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
|
||||
}
|
||||
|
||||
public void getGiftLabel(String have_hot,BaseObserver<List<GiftLabelBean>> observer){
|
||||
sApiServer.getGiftLabel(have_hot).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void getGiftList( int type, BaseObserver<List<RoonGiftModel>> observer){
|
||||
sApiServer.getGiftList(type).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void topicList(String page,String page_limit,BaseObserver<List<HeatedBean>> observer){
|
||||
sApiServer.topicList(page,page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void publishZone(String images, String content, String topic_id, String room_id,String ip,BaseObserver<String> observer){
|
||||
|
||||
sApiServer.publishZone(images,content,topic_id,room_id,ip).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
if (response.code()==200){
|
||||
BaseModel<String> string=response.body();
|
||||
if (string!=null){
|
||||
int code=string.getCode();
|
||||
if (code==1){
|
||||
observer.onNext(string.getMsg());
|
||||
}else if (code==301){
|
||||
try {
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(string.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getCategories(BaseObserver<List<HeatedBean>> observer){//动态顶部热门话题
|
||||
sApiServer.getCategories().compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void getCircleList(String page,String page_limit,BaseObserver<List<CircleListBean>> observer){//动态列表
|
||||
sApiServer.getCircleList(page,page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void likeZone(String zone_id,BaseObserver<String> observer){
|
||||
sApiServer.likeZone(zone_id).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
if (response.code()==200){
|
||||
BaseModel<String> string=response.body();
|
||||
if (string!=null){
|
||||
int code=string.getCode();
|
||||
if (code==1){
|
||||
observer.onNext(string.getMsg());
|
||||
}else if (code==301){
|
||||
try {
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(string.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getCommentList(String id, String page, String page_limit, BaseObserver<CommentBean> observer){
|
||||
sApiServer.getCommentList(id,page,page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
|
||||
}
|
||||
|
||||
public void commentZone(String id, String content, String pid, String reply_to,BaseObserver<String> observer){
|
||||
sApiServer.commentZone(id,content,pid,reply_to).enqueue(new Callback<BaseModel<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
|
||||
if (response.code()==200){
|
||||
BaseModel<String> string=response.body();
|
||||
if (string!=null){
|
||||
int code=string.getCode();
|
||||
if (code==1){
|
||||
observer.onNext(string.getMsg());
|
||||
}else if (code==301){
|
||||
try {
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(string.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
ToastUtils.showShort("评论失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort(t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.qxcm.moduleutil.presenter;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.qxcm.moduleutil.activity.IPresenter;
|
||||
import com.qxcm.moduleutil.activity.IView;
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
|
||||
public class CommentContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getCommentList(CommentBean commentBean);
|
||||
|
||||
void commentZone();
|
||||
|
||||
}
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void getCommentList(String id,String page,String page_limit);
|
||||
void commentZone(String id,String content,String pid,String reply_to);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.qxcm.moduleutil.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
import com.qxcm.moduleutil.http.BaseObserver;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CommentPresenter extends BasePresenter<CommentContacts.View> implements CommentContacts.IIndexPre{
|
||||
public CommentPresenter(CommentContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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) {
|
||||
MvpRef.get().commentZone();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.qxcm.moduleutil.presenter;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.qxcm.moduleutil.activity.IPresenter;
|
||||
import com.qxcm.moduleutil.activity.IView;
|
||||
import com.qxcm.moduleutil.bean.GiftLabelBean;
|
||||
import com.qxcm.moduleutil.bean.RewardUserBean;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RewardGiftContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getRewardList(List<RewardUserBean> rewardUserBeanList);
|
||||
void getGiftLabel(List<GiftLabelBean> giftLabelBeans);
|
||||
|
||||
void setGiftList(List<RoonGiftModel> roonGiftModels);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void getRewardList(String id, int page, int page_limit);
|
||||
|
||||
void getGiftLabel(String have_hot);
|
||||
|
||||
void getGiftList(String id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.qxcm.moduleutil.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.qxcm.moduleutil.activity.IView;
|
||||
import com.qxcm.moduleutil.bean.GiftLabelBean;
|
||||
import com.qxcm.moduleutil.bean.RewardUserBean;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
import com.qxcm.moduleutil.http.BaseObserver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View> implements RewardGiftContacts.IIndexPre {
|
||||
|
||||
public RewardGiftPresenter(RewardGiftContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(String id, int page, int page_limit) {
|
||||
// api.getRewardList(id, page, page_limit, new BaseObserver<List<RewardUserBean>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<RewardUserBean> rewardUserBeans) {
|
||||
// MvpRef.get().getRewardList(rewardUserBeans);
|
||||
// }
|
||||
// });
|
||||
|
||||
List<RewardUserBean> rewardUserBeans = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
RewardUserBean rewardUserBean = new RewardUserBean();
|
||||
rewardUserBean.setUser_id(i + "");
|
||||
rewardUserBean.setNickname("用户" + i);
|
||||
rewardUserBean.setAvatar("https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3043859018,3877962510&fm=26&gp=0.jpg");
|
||||
rewardUserBean.setIs_online("1");
|
||||
rewardUserBean.setTotal_price("0.01");
|
||||
rewardUserBeans.add(rewardUserBean);
|
||||
}
|
||||
MvpRef.get().getRewardList(rewardUserBeans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(String have_hot) {
|
||||
// api.getGiftLabel(have_hot, new BaseObserver<List<GiftLabelBean>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<GiftLabelBean> giftLabelBeans) {
|
||||
// MvpRef.get().getGiftLabel(giftLabelBeans);
|
||||
// }
|
||||
// });
|
||||
|
||||
List<GiftLabelBean> giftLabelBeans = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
GiftLabelBean giftLabelBean = new GiftLabelBean();
|
||||
giftLabelBean.setLabel(i + "");
|
||||
giftLabelBean.setName("标签" + i);
|
||||
giftLabelBeans.add(giftLabelBean);
|
||||
}
|
||||
MvpRef.get().getGiftLabel(giftLabelBeans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String id) {
|
||||
// api.getGiftList(Integer.parseInt(id), new BaseObserver<List<RoonGiftModel>>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<RoonGiftModel> roonGiftModels) {
|
||||
// MvpRef.get().setGiftList(roonGiftModels);
|
||||
// }
|
||||
// });
|
||||
List<RoonGiftModel> roonGiftModels = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++){
|
||||
RoonGiftModel roonGiftModel = new RoonGiftModel();
|
||||
roonGiftModel.setId(i+"");
|
||||
roonGiftModel.setName("礼物"+i);
|
||||
roonGiftModel.setTitle("礼物"+i);
|
||||
roonGiftModel.setPicture("");
|
||||
roonGiftModel.setPrice(i+"");
|
||||
roonGiftModel.setSpecial("");
|
||||
roonGiftModel.setSort(i+"");
|
||||
roonGiftModel.setType("");
|
||||
roonGiftModel.setChild_type("");
|
||||
roonGiftModel.setSold(i+"");
|
||||
roonGiftModel.setCardiac(i+"");
|
||||
roonGiftModel.setCan_send_self(i%2==0);
|
||||
roonGiftModels.add(roonGiftModel);
|
||||
}
|
||||
MvpRef.get().setGiftList(roonGiftModels);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import static android.view.View.GONE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
@@ -326,6 +327,46 @@ public class ImageUtils {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载网络图片并高斯模糊,失败时加载默认图片并同样模糊
|
||||
*/
|
||||
public static void loadBlurredImageWithDefault(String url, ImageView imageView, int defaultResId, int radius) {
|
||||
if (imageView == null) return;
|
||||
|
||||
Glide.with(imageView.getContext())
|
||||
.asBitmap()
|
||||
.load(url)
|
||||
.error(defaultResId) // 加载失败时显示默认图片
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
// 对网络图或默认图都进行模糊处理
|
||||
Bitmap blurred = com.blankj.utilcode.util.ImageUtils.stackBlur(resource, radius);
|
||||
imageView.setImageBitmap(blurred);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
// 如果 errorDrawable 不为空,也可以直接用它生成 Bitmap
|
||||
if (errorDrawable instanceof BitmapDrawable) {
|
||||
Bitmap bitmap = ((BitmapDrawable) errorDrawable).getBitmap();
|
||||
Bitmap blurred = com.blankj.utilcode.util.ImageUtils.stackBlur(bitmap, radius);
|
||||
imageView.setImageBitmap(blurred);
|
||||
} else {
|
||||
// 如果不是 BitmapDrawable,尝试从资源中加载 Bitmap
|
||||
Bitmap defaultBitmap = BitmapFactory.decodeResource(imageView.getResources(), defaultResId);
|
||||
if (defaultBitmap != null) {
|
||||
Bitmap blurred = com.blankj.utilcode.util.ImageUtils.stackBlur(defaultBitmap, radius);
|
||||
imageView.setImageBitmap(blurred);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载bitmap回调
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.qxcm.moduleutil.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationCallback;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationResult;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocationUtils {
|
||||
private static final String TAG = "LocationUtils";
|
||||
private FusedLocationProviderClient fusedLocationClient;
|
||||
|
||||
public interface LocationCallbackInterface {
|
||||
void onLocationReceived(double latitude, double longitude, String city);
|
||||
void onFailed(String errorMessage);
|
||||
}
|
||||
|
||||
public LocationUtils(Context context) {
|
||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
|
||||
|
||||
}
|
||||
|
||||
private void getLastLocation() {
|
||||
}
|
||||
|
||||
public void getLastLocation(Context context,LocationCallbackInterface callback) {
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
// 请求定位权限
|
||||
ActivityCompat.requestPermissions(
|
||||
(Activity) context,
|
||||
new String[]{
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
},
|
||||
1001 // 自定义常量,比如 1001
|
||||
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
fusedLocationClient.getLastLocation()
|
||||
.addOnSuccessListener(location -> {
|
||||
if (location != null) {
|
||||
// 获取城市名称
|
||||
String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
} else {
|
||||
callback.onFailed("无法获取位置");
|
||||
}
|
||||
})
|
||||
.addOnFailureListener(e -> callback.onFailed("定位失败:" + e.getMessage()));
|
||||
}
|
||||
|
||||
public void requestLocationUpdates(Context context,LocationCallbackInterface callback) {
|
||||
LocationRequest locationRequest = LocationRequest.create();
|
||||
locationRequest.setInterval(10000); // 每10秒更新一次
|
||||
locationRequest.setFastestInterval(5000);
|
||||
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
callback.onFailed("定位权限未授予");
|
||||
return;
|
||||
}
|
||||
|
||||
fusedLocationClient.requestLocationUpdates(locationRequest, new LocationCallback() {
|
||||
@Override
|
||||
public void onLocationResult(@NonNull LocationResult locationResult) {
|
||||
if (locationResult == null) {
|
||||
callback.onFailed("无位置更新");
|
||||
return;
|
||||
}
|
||||
|
||||
for (android.location.Location location : locationResult.getLocations()) {
|
||||
String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
}
|
||||
}
|
||||
}, Looper.getMainLooper());
|
||||
}
|
||||
|
||||
private String getCityName(Context context, double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && !addresses.isEmpty()) {
|
||||
Address address = addresses.get(0);
|
||||
return address.getLocality(); // 城市名
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "地理编码失败", e);
|
||||
}
|
||||
return "未知城市";
|
||||
}
|
||||
}
|
||||
@@ -47,20 +47,21 @@ public class MeHeadView extends ConstraintLayout {
|
||||
if (!TextUtils.isEmpty(headPicture)) {
|
||||
ImageUtils.loadHeadCC(headPicture, mRiv);
|
||||
}
|
||||
// if (TextUtils.isEmpty(framePicture)) {
|
||||
// mIvSex.setVisibility(VISIBLE);
|
||||
// if (!TextUtils.isEmpty(sex)) {
|
||||
// if (UserBean.MALE.equals(sex)) {
|
||||
// mIvSex.setBackgroundResource(R.mipmap.common_ic_headportriat_boy);
|
||||
// } else {
|
||||
// mIvSex.setBackgroundResource(R.mipmap.common_ic_headportriat_girl);
|
||||
// }
|
||||
// } else {
|
||||
// mIvSex.setBackgroundResource(R.drawable.common_bg_head_white);
|
||||
// }
|
||||
// } else {
|
||||
// mIvSex.setVisibility(GONE);
|
||||
// }
|
||||
if (TextUtils.isEmpty(framePicture)) {
|
||||
mIvSex.setVisibility(VISIBLE);
|
||||
if (!TextUtils.isEmpty(sex)) {
|
||||
if (sex.equals("1")){
|
||||
mIvSex.setBackgroundResource(R.mipmap.nan);
|
||||
}else {
|
||||
mIvSex.setBackgroundResource(R.mipmap.nv);
|
||||
}
|
||||
|
||||
} else {
|
||||
mIvSex.setVisibility(GONE);
|
||||
}
|
||||
} else {
|
||||
mIvSex.setVisibility(GONE);
|
||||
}
|
||||
ImageUtils.loadImageView(framePicture, mIvFrame);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.qxcm.moduleutil.utils.location;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.location.Address;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationCallback;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationResult;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class GmsLocationProvider implements LocationProvider {
|
||||
|
||||
private static final String TAG = "GmsLocationProvider";
|
||||
private FusedLocationProviderClient fusedLocationClient;
|
||||
private LocationCallback locationCallback;
|
||||
|
||||
public GmsLocationProvider(Context context) {
|
||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void getLastKnownLocation(Context context, LocationCallback callback) {
|
||||
fusedLocationClient.getLastLocation()
|
||||
.addOnSuccessListener(location -> {
|
||||
if (location != null) {
|
||||
String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
} else {
|
||||
callback.onFailed("无法获取位置");
|
||||
}
|
||||
})
|
||||
.addOnFailureListener(e -> callback.onFailed("Google Play 定位失败:" + e.getMessage()));
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void requestLocationUpdates(Context context, LocationCallback callback) {
|
||||
this.locationCallback = new LocationCallback() {
|
||||
@Override
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
// for (android.location.Location location : locationResult.getLocations()) {
|
||||
String city1 = getCityName(context, latitude, longitude);
|
||||
callback.onLocationReceived(latitude, longitude, city1);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onLocationResult(@NonNull LocationResult locationResult) {
|
||||
// for (android.location.Location location : locationResult.getLocations()) {
|
||||
// String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
// callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
LocationRequest locationRequest = LocationRequest.create();
|
||||
locationRequest.setInterval(10000)
|
||||
.setFastestInterval(5000)
|
||||
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
|
||||
fusedLocationClient.requestLocationUpdates(locationRequest, (com.google.android.gms.location.LocationCallback) locationCallback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopLocationUpdates() {
|
||||
if (locationCallback != null) {
|
||||
fusedLocationClient.removeLocationUpdates((com.google.android.gms.location.LocationCallback) locationCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCityName(Context context, double latitude, double longitude) {
|
||||
android.location.Geocoder geocoder = new android.location.Geocoder(context, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && !addresses.isEmpty()) {
|
||||
return addresses.get(0).getLocality();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "地理编码失败", e);
|
||||
}
|
||||
return "未知城市";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.qxcm.moduleutil.utils.location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class IpLocationProvider implements LocationProvider {
|
||||
|
||||
@Override
|
||||
public void getLastKnownLocation(Context context, LocationCallback callback) {
|
||||
new FetchIpLocationTask(callback).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestLocationUpdates(Context context, LocationCallback callback) {
|
||||
getLastKnownLocation(context, callback); // 单次定位即可
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopLocationUpdates() {}
|
||||
|
||||
private static class FetchIpLocationTask extends AsyncTask<Void, Void, String> {
|
||||
private final LocationCallback callback;
|
||||
|
||||
FetchIpLocationTask(LocationCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... voids) {
|
||||
try {
|
||||
URL url = new URL("https://ip-api.com/json/");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder json = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
json.append(line);
|
||||
}
|
||||
|
||||
JSONObject obj = new JSONObject(Boolean.parseBoolean(json.toString()));
|
||||
return obj.getString("city");
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String city) {
|
||||
if (city != null && !city.isEmpty()) {
|
||||
callback.onLocationReceived(0, 0, city);
|
||||
} else {
|
||||
callback.onFailed("IP 定位失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.qxcm.moduleutil.utils.location;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public interface LocationProvider {
|
||||
void getLastKnownLocation(Context context, LocationCallback callback);
|
||||
|
||||
void requestLocationUpdates(Context context, LocationCallback callback);
|
||||
|
||||
void stopLocationUpdates();
|
||||
|
||||
interface LocationCallback {
|
||||
void onLocationReceived(double latitude, double longitude, String city);
|
||||
void onFailed(String errorMessage);
|
||||
}
|
||||
|
||||
// interface LocationCallback {
|
||||
// void onLocationReceived(double latitude, double longitude, String city);
|
||||
// void onFailed(String errorMessage);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.qxcm.moduleutil.utils.location;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class LocationServiceFactory {
|
||||
public static LocationProvider createBestProvider(Context context) {
|
||||
if (false) {
|
||||
return new GmsLocationProvider(context);
|
||||
} else {
|
||||
return new SystemLocationProvider();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isGooglePlayServicesAvailable(Context context) {
|
||||
// 实现判断逻辑,例如使用 GoogleApiAvailability
|
||||
// 或者简单尝试加载类是否存在
|
||||
try {
|
||||
Class.forName("com.google.android.gms.common.GoogleApiAvailability");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.qxcm.moduleutil.utils.location;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SystemLocationProvider implements LocationProvider {
|
||||
|
||||
private LocationManager locationManager;
|
||||
|
||||
@Override
|
||||
public void getLastKnownLocation(@NonNull Context context, @NonNull LocationCallback callback) {
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
if (locationManager == null) {
|
||||
callback.onFailed("无法获取定位服务");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(@NonNull Location location) {
|
||||
String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(@NonNull String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(@NonNull String provider) {
|
||||
fallbackToNetwork(callback, context);
|
||||
}
|
||||
}, null);
|
||||
} else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||
locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(@NonNull Location location) {
|
||||
String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(@NonNull String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(@NonNull String provider) {
|
||||
callback.onFailed("网络定位不可用");
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
callback.onFailed("GPS 和 网络定位均未启用");
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
callback.onFailed("缺少定位权限:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void fallbackToNetwork(LocationCallback callback, Context context) {
|
||||
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
// here to request the missing permissions, and then overriding
|
||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
return;
|
||||
}
|
||||
locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(@NonNull Location location) {
|
||||
String city = getCityName(context, location.getLatitude(), location.getLongitude());
|
||||
callback.onLocationReceived(location.getLatitude(), location.getLongitude(), city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(@NonNull String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(@NonNull String provider) {
|
||||
callback.onFailed("网络定位不可用");
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
callback.onFailed("GPS 不可用且网络定位也未启用");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestLocationUpdates(Context context, LocationCallback callback) {
|
||||
// 可扩展为持续监听
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopLocationUpdates() {
|
||||
// 可扩展为停止监听
|
||||
}
|
||||
|
||||
private String getCityName(Context context, double latitude, double longitude) {
|
||||
android.location.Geocoder geocoder = new android.location.Geocoder(context, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && !addresses.isEmpty()) {
|
||||
return addresses.get(0).getLocality();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "未知城市";
|
||||
}
|
||||
}
|
||||
@@ -363,5 +363,19 @@ public class Constants {
|
||||
|
||||
public static final String REAL_NAME = "/api/UserData/real_name";//调用实名认证接口
|
||||
public static final String REAL_NAME_RESULT = "/api/UserData/real_name_result";//调用实名认证接口
|
||||
public static final String GET_EXPAND_COLUMN = "/api/UserZone/expand_zone";//扩列获取数据接口
|
||||
public static final String GET_OFFICIAL_NOTICE = "/api/UserMessage/get_user_message_list";//获取消息信息
|
||||
public static final String GET_ALBUM_LIST = "/api/User/get_album_list";//相册列表
|
||||
public static final String CREATE_ALBUM = "/api/User/create_album";//创建相册
|
||||
public static final String GET_REWARD_LIST = "/api/UserZone/reward_list";//动态打赏列表
|
||||
public static final String GET_GIFT_LABEL = "/api/Gift/get_gift_label";//礼物标签
|
||||
public static final String GIFT_LIST = "/api/Gift/get_gift_list";//礼物标签
|
||||
public static final String TOPIC_LIST = "/api/UserZone/topic_list";//获取话题列表
|
||||
public static final String PUBLISH_ZONE = "/api/UserZone/publish_zone";//发布动态
|
||||
public static final String GET_CATEGORIES = "/api/UserZone/get_zone_topic";//动态引用的四条话题
|
||||
public static final String GET_CIRCLE_LIST = "/api/UserZone/zone_list";//语圈列表
|
||||
public static final String LIKE_ZONE = "/api/UserZone/like_zone";//语圈列表
|
||||
public static final String GET_COMMENT_LIST = "/api/UserZone/get_comment_list";//评论列表
|
||||
public static final String COMMENT_ZONE = "/api/UserZone/comment_zone";//评论列表
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.qxcm.moduleutil.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.utils.logger.Logger;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshHeader;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshKernel;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.constant.RefreshState;
|
||||
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
|
||||
|
||||
/**
|
||||
* 项目名称 qipao-android
|
||||
* 包名:com.qpyy.module.index.widget
|
||||
* 创建人 王欧
|
||||
* 创建时间 2020/6/30 3:55 PM
|
||||
* 描述 describe
|
||||
*/
|
||||
public class CustomRefreshHeader extends ConstraintLayout implements RefreshHeader {
|
||||
ImageView mImageView;
|
||||
AnimationDrawable mAnimationDrawable;
|
||||
|
||||
public CustomRefreshHeader(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public CustomRefreshHeader(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater.from(context).inflate(R.layout.index_header_custom_refresh, this);
|
||||
mImageView = findViewById(R.id.image);
|
||||
mAnimationDrawable = (AnimationDrawable) mImageView.getBackground();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SpinnerStyle getSpinnerStyle() {
|
||||
return SpinnerStyle.Translate;
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void setPrimaryColors(int... colors) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void onInitialized(@NonNull RefreshKernel kernel, int height, int maxDragHeight) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void onMoving(boolean isDragging, float percent, int offset, int height, int maxDragHeight) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void onReleased(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) {
|
||||
Logger.e("onReleased");
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void onStartAnimator(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) {
|
||||
Logger.e("onStartAnimator");
|
||||
//判断是否在运行
|
||||
if (!mAnimationDrawable.isRunning()) {
|
||||
//开启帧动画
|
||||
mAnimationDrawable.start();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public int onFinish(@NonNull RefreshLayout refreshLayout, boolean success) {
|
||||
if (mAnimationDrawable.isRunning()) {
|
||||
//开启帧动画
|
||||
mAnimationDrawable.stop();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void onHorizontalDrag(float percentX, int offsetX, int offsetMax) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupportHorizontalDrag() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.qxcm.moduleutil.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
|
||||
public class MarqueeTextView extends AppCompatTextView {
|
||||
|
||||
public MarqueeTextView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MarqueeTextView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
// 设置单行
|
||||
setSingleLine();
|
||||
// setMaxLines(1);
|
||||
//设置 Ellipsize,setMaxLines(1) 和 setEllipsize 冲突
|
||||
setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
//获取焦距
|
||||
setFocusable(true);
|
||||
//走马灯的重复次数,-1代表无限重复
|
||||
setMarqueeRepeatLimit(-1);
|
||||
//强制获得焦点
|
||||
setFocusableInTouchMode(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于 EditText 存在时抢占焦点
|
||||
*/
|
||||
@Override
|
||||
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
|
||||
if (focused) {
|
||||
super.onFocusChanged(focused, direction, previouslyFocusedRect);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Window与Window间焦点发生改变时的回调
|
||||
* 解决 Dialog 抢占焦点问题
|
||||
*
|
||||
* @param hasWindowFocus
|
||||
*/
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
||||
if (hasWindowFocus) {
|
||||
super.onWindowFocusChanged(hasWindowFocus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocused() {//必须重写,且返回值是true,表示始终获取焦点
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.qxcm.moduleutil.widget.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.adapter.CommentAdapter;
|
||||
import com.qxcm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.qxcm.moduleutil.bean.CommentBean;
|
||||
import com.qxcm.moduleutil.databinding.FragmentCommentDialogBinding;
|
||||
import com.qxcm.moduleutil.presenter.CommentContacts;
|
||||
import com.qxcm.moduleutil.presenter.CommentPresenter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 评论弹框
|
||||
*/
|
||||
public class CommentDialogFragment extends BaseMvpDialogFragment<CommentPresenter, FragmentCommentDialogBinding> implements CommentContacts.View {
|
||||
private int page;
|
||||
private CommentAdapter commentAdapter;
|
||||
@Override
|
||||
protected CommentPresenter bindPresenter() {
|
||||
return new CommentPresenter(this, getActivity());
|
||||
}
|
||||
public static void show(String id, FragmentManager fragmentManager) {
|
||||
CommentDialogFragment dialogFragment = new CommentDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("id", id); // 可选:传递参数
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "CommentDialogFragment");
|
||||
}
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getCommentList(getArguments().getString("id"), "1", "10");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.srl.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getCommentList(getArguments().getString("id"), page+"", "10");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
// EventBus.getDefault().post(new BannerRefreshEvent());
|
||||
page = 1;
|
||||
MvpPre.getCommentList(getArguments().getString("id"), page+"", "10");
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.tvSend.setOnClickListener(this::onClick);
|
||||
|
||||
mBinding.rvComment.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
commentAdapter = new CommentAdapter(new ArrayList<>());
|
||||
mBinding.rvComment.setAdapter(commentAdapter);
|
||||
}
|
||||
|
||||
private void onClick(View view) {
|
||||
if (view.getId()==R.id.tv_send){
|
||||
if (mBinding.etInput.getText().toString().isEmpty()){
|
||||
ToastUtils.showShort("请输入评论内容");
|
||||
return;
|
||||
}
|
||||
MvpPre.commentZone(getArguments().getString("id"), mBinding.etInput.getText().toString(), "0", "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_comment_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
if (commentBean!=null){
|
||||
mBinding.tvNum.setText("全部评论("+commentBean.getTotal()+")");
|
||||
commentAdapter.updateData(commentBean.getList()); // 假设 CommentBean 包含评论列表
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
ToastUtils.showShort("评论成功");
|
||||
MvpPre.getCommentList(getArguments().getString("id"), "1", "10");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package com.qxcm.moduleutil.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 项目名称 qipao-android
|
||||
* 包名:com.qpyy.room.widget
|
||||
* 创建人 黄强
|
||||
* 创建时间 2020/8/6 16:55
|
||||
* 描述 自定义数字键盘
|
||||
*/
|
||||
|
||||
public class KeyboardPopupWindow extends PopupWindow {
|
||||
private static final String TAG = "KeyboardPopupWindow";
|
||||
private Context context;
|
||||
private View anchorView;
|
||||
private View parentView;
|
||||
private EditText editText;
|
||||
private boolean isRandomSort = false;//数字是否随机排序
|
||||
private List<Integer> list = new ArrayList<>();
|
||||
private int[] commonButtonIds = new int[]{R.id.bt_keyboard1, R.id.bt_keyboard2, R.id.bt_keyboard3, R.id.bt_keyboard4,
|
||||
R.id.bt_keyboard5, R.id.bt_keyboard6, R.id.bt_keyboard7, R.id.bt_keyboard8, R.id.bt_keyboard9, R.id.bt_keyboard0};
|
||||
|
||||
private KeyboardCompleteListener mListener;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param anchorView
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
public KeyboardPopupWindow(Context context, View anchorView) {
|
||||
this.context = context;
|
||||
this.anchorView = anchorView;
|
||||
this.isRandomSort = isRandomSort;
|
||||
if (context == null || anchorView == null) {
|
||||
return;
|
||||
}
|
||||
initConfig();
|
||||
initView();
|
||||
Log.d(TAG, "KeyboardPopupWindow: =====================打开了自定义键盘");
|
||||
}
|
||||
|
||||
|
||||
private void initConfig() {
|
||||
setOutsideTouchable(false);
|
||||
setFocusable(false);
|
||||
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
forbidDefaultSoftKeyboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止系统默认的软键盘弹出
|
||||
*/
|
||||
private void forbidDefaultSoftKeyboard() {
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
if (android.os.Build.VERSION.SDK_INT > 10) {//4.0以上,使用反射的方式禁止系统自带的软键盘弹出
|
||||
try {
|
||||
Class<EditText> cls = EditText.class;
|
||||
Method setShowSoftInputOnFocus;
|
||||
setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
|
||||
setShowSoftInputOnFocus.setAccessible(true);
|
||||
setShowSoftInputOnFocus.invoke(editText, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新自定义的popupwindow是否outside可触摸反应:如果是不可触摸的,则显示该软键盘view
|
||||
*
|
||||
* @param isTouchable
|
||||
*/
|
||||
public void refreshKeyboardOutSideTouchable(boolean isTouchable) {
|
||||
setOutsideTouchable(isTouchable);
|
||||
if (!isTouchable) {
|
||||
show();
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
parentView = LayoutInflater.from(context).inflate(R.layout.room_custom_num_keyboard, null);
|
||||
initKeyboardView(parentView);
|
||||
setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
setContentView(parentView);
|
||||
this.setBackgroundDrawable(new BitmapDrawable());
|
||||
this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setFocusable(true);
|
||||
this.setOutsideTouchable(true);
|
||||
this.setTouchable(true);
|
||||
this.setAnimationStyle(R.style.mypopwindow_anim_style);
|
||||
}
|
||||
|
||||
private void initKeyboardView(View view) {
|
||||
//初始化编辑框
|
||||
editText = view.findViewById(R.id.et_keyboard_input);
|
||||
editText.setFocusable(false);//禁止编辑框获取焦点
|
||||
//①给数字键设置点击监听
|
||||
for (int i = 0; i < commonButtonIds.length; i++) {
|
||||
final Button button = view.findViewById(commonButtonIds[i]);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int curSelection = editText.getSelectionStart();
|
||||
int length = editText.getText().toString().length();
|
||||
if (curSelection < length) {
|
||||
String content = editText.getText().toString();
|
||||
editText.setText(content.substring(0, curSelection) + button.getText() + content.subSequence(curSelection, length));
|
||||
editText.setSelection(curSelection + 1);
|
||||
} else {
|
||||
if (length == 0 && button.getText().toString().equals("0") || equals("")) {
|
||||
return;
|
||||
}
|
||||
editText.setText(editText.getText().toString() + button.getText());
|
||||
editText.setSelection(editText.getText().toString().length());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//③给叉按键设置点击监听
|
||||
view.findViewById(R.id.rl_keyboard_cross).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int length = editText.getText().toString().length();
|
||||
int curSelection = editText.getSelectionStart();
|
||||
if (length > 0 && curSelection > 0 && curSelection <= length) {
|
||||
String content = editText.getText().toString();
|
||||
editText.setText(content.substring(0, curSelection - 1) + content.subSequence(curSelection, length));
|
||||
editText.setSelection(curSelection - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//③给叉按键设置点击监听
|
||||
view.findViewById(R.id.iv_keyboard_cross).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int length = editText.getText().toString().length();
|
||||
int curSelection = editText.getSelectionStart();
|
||||
if (length > 0 && curSelection > 0 && curSelection <= length) {
|
||||
String content = editText.getText().toString();
|
||||
editText.setText(content.substring(0, curSelection - 1) + content.subSequence(curSelection, length));
|
||||
editText.setSelection(curSelection - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//确定
|
||||
view.findViewById(R.id.bt_keyboard_ok).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.d(TAG, "onClick: 您输入的数量是:" + editText.getText().toString());
|
||||
mListener.inputComplete(editText.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void show() {
|
||||
if (!isShowing() && anchorView != null) {
|
||||
// doRandomSortOp();
|
||||
this.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机分布数字
|
||||
*/
|
||||
private void doRandomSortOp() {
|
||||
if (parentView == null) {
|
||||
return;
|
||||
}
|
||||
if (!isRandomSort) {
|
||||
for (int i = 0; i < commonButtonIds.length; i++) {
|
||||
final Button button = parentView.findViewById(commonButtonIds[i]);
|
||||
button.setText("" + i);
|
||||
}
|
||||
} else {
|
||||
list.clear();
|
||||
Random ran = new Random();
|
||||
while (list.size() < commonButtonIds.length) {
|
||||
int n = ran.nextInt(commonButtonIds.length);
|
||||
if (!list.contains(n))
|
||||
list.add(n);
|
||||
}
|
||||
for (int i = 0; i < commonButtonIds.length; i++) {
|
||||
final Button button = parentView.findViewById(commonButtonIds[i]);
|
||||
button.setText("" + list.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
this.dismiss();
|
||||
context = null;
|
||||
anchorView = null;
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
list = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addRoomPasswordListener(KeyboardCompleteListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public interface KeyboardCompleteListener {
|
||||
|
||||
void inputComplete(String inputContent);//输入完成
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.qxcm.moduleutil.widget.dialog;
|
||||
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.adapter.GiftTwoDetailsFragment;
|
||||
import com.qxcm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.qxcm.moduleutil.bean.GiftLabelBean;
|
||||
import com.qxcm.moduleutil.bean.GiftNumBean;
|
||||
import com.qxcm.moduleutil.bean.RewardUserBean;
|
||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||
import com.qxcm.moduleutil.databinding.FragmentRewardGiftDialogBinding;
|
||||
import com.qxcm.moduleutil.presenter.RewardGiftContacts;
|
||||
import com.qxcm.moduleutil.presenter.RewardGiftPresenter;
|
||||
import com.qxcm.moduleutil.utils.DialogUtils;
|
||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/5/29
|
||||
* @description: 打赏礼物的fragment
|
||||
*/
|
||||
public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPresenter, FragmentRewardGiftDialogBinding> implements RewardGiftContacts.View {
|
||||
|
||||
private BaseQuickAdapter<RewardUserBean, BaseViewHolder> adapter;
|
||||
private SelectGiftNumPopupWindow mSelectGiftNumPopupWindow;
|
||||
private KeyboardPopupWindow mKeyboardPopupWindow;
|
||||
private List<GiftNumBean> mGiftNumList;
|
||||
@Override
|
||||
protected RewardGiftPresenter bindPresenter() {
|
||||
return new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
public static void show(String id, FragmentManager fragmentManager) {
|
||||
RewardGiftDialogFragment dialogFragment = new RewardGiftDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("circle_id", id); // 可选:传递参数
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RewardGiftDialogFragment");
|
||||
}
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getRewardList("1", 1, 10);
|
||||
MvpPre.getGiftLabel("1");
|
||||
|
||||
mGiftNumList=new ArrayList<>();
|
||||
mGiftNumList.add(new GiftNumBean("20", "x20"));
|
||||
mGiftNumList.add(new GiftNumBean("15", "x15"));
|
||||
mGiftNumList.add(new GiftNumBean("10", "x10"));
|
||||
mGiftNumList.add(new GiftNumBean("5", "x5"));
|
||||
mGiftNumList.add(new GiftNumBean("1", "x1"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
adapter = new BaseQuickAdapter<RewardUserBean, BaseViewHolder>(R.layout.item_reward, null) {
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RewardUserBean item) {
|
||||
ImageUtils.loadHeadCC(item.getAvatar(), helper.getView(R.id.im_reward));
|
||||
}
|
||||
};
|
||||
|
||||
mBinding.tvGiveCoinNum.setOnClickListener(this::onClisk);
|
||||
|
||||
}
|
||||
|
||||
private void onClisk(View view1) {
|
||||
if (view1.getId()==R.id.tv_give_coin_num){
|
||||
if (mSelectGiftNumPopupWindow == null) {
|
||||
|
||||
mSelectGiftNumPopupWindow = new SelectGiftNumPopupWindow(getSelfActivity(), (adapter, view, position) -> {
|
||||
GiftNumBean giftNumBean = (GiftNumBean) adapter.getItem(position);
|
||||
if ("0".equals(giftNumBean.getNumber())) {//自定义
|
||||
mKeyboardPopupWindow = new KeyboardPopupWindow(getSelfActivity(), getView());
|
||||
mKeyboardPopupWindow.refreshKeyboardOutSideTouchable(false);//false开启键盘 ,true关闭键盘
|
||||
mKeyboardPopupWindow.addRoomPasswordListener(new KeyboardPopupWindow.KeyboardCompleteListener() {//监听自定键盘的完成
|
||||
@Override
|
||||
public void inputComplete(String inputContent) {
|
||||
mBinding.tvGiveCoinNum.setText(inputContent);
|
||||
mKeyboardPopupWindow.releaseResources();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mBinding.tvGiveCoinNum.setText(giftNumBean.getNumber());
|
||||
}
|
||||
mSelectGiftNumPopupWindow.dismiss();
|
||||
});
|
||||
}
|
||||
mSelectGiftNumPopupWindow.setData(mGiftNumList);
|
||||
mSelectGiftNumPopupWindow.showAtLocation(mBinding.tvGiveCoinNum, Gravity.BOTTOM | Gravity.RIGHT, 100, 230);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_reward_gift_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(List<RewardUserBean> rewardUserBeanList) {
|
||||
if (rewardUserBeanList != null && !rewardUserBeanList.isEmpty()) {
|
||||
mBinding.recycleView.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRewardNum.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRewardTitle.setVisibility(View.INVISIBLE);
|
||||
mBinding.tvRewardNum.setText("已有" + String.valueOf(rewardUserBeanList.size()) + "个人打赏");
|
||||
int limit = Math.min(rewardUserBeanList.size(), 6);
|
||||
List<RewardUserBean> limitedList = rewardUserBeanList.subList(0, limit);
|
||||
adapter.setNewData(limitedList);
|
||||
} else {
|
||||
adapter.setNewData(null);
|
||||
mBinding.recycleView.setVisibility(View.INVISIBLE);
|
||||
mBinding.tvRewardNum.setVisibility(View.INVISIBLE);
|
||||
mBinding.tvRewardTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(List<GiftLabelBean> giftLabelBeans) {
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), giftLabelBeans));
|
||||
mBinding.slidingTabLayout.setViewPager(mBinding.viewPager);
|
||||
mBinding.slidingTabLayout.setCurrentTab(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> roonGiftModels) {
|
||||
|
||||
}
|
||||
|
||||
private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private List<GiftLabelBean> list;
|
||||
|
||||
|
||||
public MyFragmentPagerAdapter(FragmentManager fm, List<GiftLabelBean> list) {
|
||||
super(fm);
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
GiftLabelBean model = list.get(position);
|
||||
return GiftTwoDetailsFragment.newInstance(model.getLabel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
GiftLabelBean model = list.get(position);
|
||||
return model.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.qxcm.moduleutil.widget.dialog;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.GiftNumBean;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 展示礼物打赏数量的适配器
|
||||
*/
|
||||
public class SelectGiftNumAdapter extends BaseQuickAdapter<GiftNumBean, BaseViewHolder> {
|
||||
|
||||
public SelectGiftNumAdapter() {
|
||||
super(R.layout.room_rv_item_gift_num_windows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftNumBean item) {
|
||||
// helper.setText(R.id.tv_gift_mum, item.getNumber())
|
||||
helper.setText(R.id.tv_gift_name, item.getText());
|
||||
if ("0".equals(item.getNumber())) {
|
||||
// helper.setText(R.id.tv_custom, item.getText());
|
||||
// helper.setVisible(R.id.tv_custom,true);
|
||||
// helper.setVisible(R.id.tv_gift_mum, false).
|
||||
helper.setVisible(R.id.tv_gift_name, false);
|
||||
}else {
|
||||
// helper.setVisible(R.id.tv_custom,false);
|
||||
// helper.setVisible(R.id.tv_gift_mum, false)
|
||||
helper.setVisible(R.id.tv_gift_name, true);
|
||||
}
|
||||
if("1".equals(item.getNumber())){
|
||||
helper.getView(R.id.iv_split).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.qxcm.moduleutil.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.bean.GiftNumBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 选择礼物数量窗口
|
||||
*/
|
||||
public class SelectGiftNumPopupWindow extends PopupWindow {
|
||||
private View rootView;
|
||||
private SelectGiftNumAdapter selectGiftNumAdapter;
|
||||
|
||||
public SelectGiftNumPopupWindow(Context context, BaseQuickAdapter.OnItemClickListener onItemClickListener) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
rootView = inflater.inflate(R.layout.room_window_pop_gift, null);
|
||||
RecyclerView recyclerView = rootView.findViewById(R.id.rv_gift_num_window);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.setAdapter(selectGiftNumAdapter = new SelectGiftNumAdapter());
|
||||
|
||||
selectGiftNumAdapter.setOnItemClickListener(onItemClickListener);
|
||||
setContentView(rootView);
|
||||
this.setBackgroundDrawable(new BitmapDrawable());
|
||||
this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setFocusable(true);
|
||||
this.setOutsideTouchable(true);
|
||||
this.setTouchable(true);
|
||||
this.setAnimationStyle(R.style.mypopwindow_anim_style);
|
||||
}
|
||||
|
||||
|
||||
public void setData(List<GiftNumBean> data) {
|
||||
if (selectGiftNumAdapter != null) {
|
||||
selectGiftNumAdapter.setNewData(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.qxcm.moduleutil.widget.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.qxcm.moduleutil.R;
|
||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||
import com.qxcm.moduleutil.databinding.RoomDialogShareBinding;
|
||||
import com.qxcm.moduleutil.utils.BaseBottomSheetDialog;
|
||||
|
||||
|
||||
/**
|
||||
* 房间分享弹窗
|
||||
*/
|
||||
public class ShareDialog extends BaseBottomSheetDialog<RoomDialogShareBinding> {
|
||||
|
||||
|
||||
private static final String TAG = "ShareDialog";
|
||||
|
||||
public ShareDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
Log.i(TAG, "(Start)启动了===========================ShareDialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayout() {
|
||||
return R.layout.room_dialog_share;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
Window window = getWindow();
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.dimAmount = 0.4f;
|
||||
window.setAttributes(lp);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
mBinding.tvQq.setOnClickListener(this::onClick);
|
||||
mBinding.tvWeixin.setOnClickListener(this::onClick);
|
||||
mBinding.tvClean.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
String appName = CommonAppContext.getInstance().getResources().getString(R.string.app_name);
|
||||
if (R.id.tv_qq == id) {
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.D0108, "share_way", "QQ分享");
|
||||
// ShareUtil.shareWeb((Activity) view.getContext(), URLConstants.SHARE, String.format("我在%s玩呢,大家都在玩,快来展示您的精彩", appName)
|
||||
// , appName, "", R.mipmap.ic_launcher_new, SHARE_MEDIA.QQ);
|
||||
} else if (R.id.tv_weixin == id) {
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.D0108, "share_way", "微信分享");
|
||||
// ShareUtil.shareWeb((Activity) view.getContext(), URLConstants.SHARE, String.format("我在%s玩呢,大家都在玩,快来展示您的精彩", appName)
|
||||
// , appName, "", R.mipmap.ic_launcher_new, SHARE_MEDIA.WEIXIN);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -198,15 +198,50 @@
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dy_more_image"
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/dy_more_image"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_weight="1.7"-->
|
||||
<!-- android:paddingHorizontal="5dp"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:layout_gravity="right"-->
|
||||
<!-- android:src="@mipmap/mx"-->
|
||||
<!-- android:visibility="visible" />-->
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1.7"
|
||||
android:paddingHorizontal="5dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.9"
|
||||
android:layout_gravity="right"
|
||||
android:src="@mipmap/mx"
|
||||
android:visibility="visible" />
|
||||
android:background="@drawable/bg_r43_9999"
|
||||
android:paddingHorizontal="5dp"
|
||||
android:layout_marginEnd="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dy_more_image"
|
||||
android:layout_width="@dimen/dp_14"
|
||||
android:layout_height="@dimen/dp_14"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="@dimen/dp_4"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@mipmap/hua"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dy_more_tv"
|
||||
android:layout_width="@dimen/dp_48"
|
||||
android:layout_height="@dimen/dp_18"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="萌新驾到"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="12sp"
|
||||
android:visibility="visible"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="2"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<com.qxcm.moduleutil.widget.GifAvatarOvalView
|
||||
android:id="@+id/riv"
|
||||
@@ -14,20 +15,20 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.70154"
|
||||
app:layout_constraintWidth_percent="0.90154"
|
||||
android:src="@mipmap/default_avatar"
|
||||
app:riv_oval="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_sex"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@mipmap/common_ic_headportriat_boy"
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:background="@mipmap/nan"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/riv"
|
||||
app:layout_constraintEnd_toEndOf="@id/riv"
|
||||
app:layout_constraintStart_toStartOf="@id/riv"
|
||||
app:layout_constraintTop_toTopOf="@id/riv" />
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_frame"
|
||||
|
||||
@@ -278,5 +278,6 @@
|
||||
<color name="color_caifu">#61C8FD</color>
|
||||
<color name="color_meili1">#FEE6E3</color>
|
||||
<color name="color_caifu1">#C4EBFF</color>
|
||||
|
||||
<color name="dianzan2">#FF9249FF</color>
|
||||
<color name="dianzan1">#212121</color>
|
||||
</resources>
|
||||
@@ -102,6 +102,8 @@
|
||||
<string name="payment_method">支付方式</string>
|
||||
<string name="wechat_payment">微信支付</string>
|
||||
<string name="alipay_payment">支付宝支付</string>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user