diff --git a/OneToOne/src/main/AndroidManifest.xml b/OneToOne/src/main/AndroidManifest.xml index 243b7dd71..b7bfb6f79 100644 --- a/OneToOne/src/main/AndroidManifest.xml +++ b/OneToOne/src/main/AndroidManifest.xml @@ -139,7 +139,7 @@ android:name=".activity.WebViewActivity" android:windowSoftInputMode="stateHidden|adjustResize" /> fragments = new ArrayList<>(); + + + @Override + protected int getLayoutId() { + return R.layout.activity_main_list; + } + + @Override + protected void main(Bundle savedInstanceState) { + mDay = findViewById(R.id.btn_day); + mWeek = findViewById(R.id.btn_week); + viewPager = findViewById(R.id.view_pager); + dslTabLayout = findViewById(R.id.dslTabLayout); + radioGroup = findViewById(R.id.radioGroup); + + ViewPager2Delegate.Companion.install(viewPager, dslTabLayout, false); + + fragments.add(new HomeRankFragment(HomeRankFragment.TYPE_CHARM));//魅力 + fragments.add(new HomeRankFragment(HomeRankFragment.TYPE_WEALTH)); //财富 + viewPager.setAdapter(new FragmentStateAdapter(this) { + @NonNull + @Override + public Fragment createFragment(int position) { + fragments.get(position).setAppbarListener(new OnAppbarListener() { + @Override + public void onShow(boolean isShow) { + if (isShow) { + radioGroup.setVisibility(View.VISIBLE); + } else { + radioGroup.setVisibility(View.INVISIBLE); + } + } + }); + return fragments.get(position); + } + + @Override + public int getItemCount() { + return fragments.size(); + } + }); + mDay.setOnClickListener(v -> { + setRadioColor(mDay, mWeek); + }); + mWeek.setOnClickListener(v -> { + setRadioColor(mWeek, mDay); + }); + } + + private void setRadioColor(RadioButton select, RadioButton unSelect) { + select.setTextColor(Color.parseColor("#FFFFFF")); + unSelect.setTextColor(Color.parseColor("#666666")); + select.setBackgroundResource(R.drawable.bg_home_rank_day_select); + unSelect.setBackgroundResource(R.drawable.bg_home_rank_day); + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/HomeRankFragment.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/HomeRankFragment.java new file mode 100644 index 000000000..06e4258c1 --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/HomeRankFragment.java @@ -0,0 +1,174 @@ +package com.shayu.onetoone.activity.fragments.home; + +import android.os.Build; +import android.os.Bundle; +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 com.google.android.material.appbar.AppBarLayout; +import com.opensource.svgaplayer.SVGAImageView; +import com.shayu.onetoone.R; +import com.shayu.onetoone.activity.fragments.BaseFragment; +import com.shayu.onetoone.adapter.HomeRecommendListAdapter; +import com.shayu.onetoone.bean.HomeRankBean; +import com.shayu.onetoone.bean.UserBean; +import com.shayu.onetoone.listener.OnAppbarListener; +import com.yanzhenjie.recyclerview.SwipeRecyclerView; +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.custom.MyRadioButton; +import com.yunbao.common.utils.ToastUtil; + +import pl.droidsonroids.gif.GifImageView; + +public class HomeRankFragment extends BaseFragment { + public static final int TYPE_CHARM = 0; + public static final int TYPE_WEALTH = 1; + private AppBarLayout rootView; + private OnAppbarListener appbarListener; + private SwipeRecyclerView mRecyclerView; + HomeRecommendListAdapter adapter; + private int type; + + public HomeRankFragment(int type) { + super(); + this.type = type; + } + + public void setAppbarListener(OnAppbarListener appbarListener) { + this.appbarListener = appbarListener; + } + + @Override + public void initView(View itemView) { + rootView = findViewById(R.id.rootView); + mRecyclerView = findViewById(R.id.recyclerView); + adapter = new HomeRecommendListAdapter(getContext()); + mRecyclerView.setAdapter(adapter); + + rootView.addOnOffsetChangedListener(new AppBarLayout.BaseOnOffsetChangedListener() { + @Override + public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { + if (appbarListener != null) { + if (verticalOffset == 0) { + appbarListener.onShow(true); + } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) { + appbarListener.onShow(false); + } + } + } + }); + } + + @Override + public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_home_ranking, container, false); + } + private void initData(){ + + } + + class HeadView { + View mItem1; + View mItem2; + View mItem3; + GifImageView liveing1; + GifImageView liveing2; + GifImageView liveing3; + ImageView mAvatar1; + ImageView mAvatar2; + ImageView mAvatar3; + TextView mName1; + TextView mName2; + TextView mName3; + TextView mVotes1; + TextView mVotes2; + TextView mVotes3; + ImageView mSex1; + ImageView mSex2; + ImageView mSex3; + ImageView diamond1; + ImageView diamond2; + ImageView diamond3; + Button mBtnFollow1; + Button mBtnFollow2; + Button mBtnFollow3; + SVGAImageView svga1; + SVGAImageView svga2; + SVGAImageView svga3; + + public HeadView(View itemView) { + mItem1 = itemView.findViewById(R.id.item_1); + mItem2 = itemView.findViewById(R.id.item_2); + mItem3 = itemView.findViewById(R.id.item_3); + liveing1 = itemView.findViewById(R.id.liveing1); + liveing2 = itemView.findViewById(R.id.liveing2); + liveing3 = itemView.findViewById(R.id.liveing3); + mAvatar1 = itemView.findViewById(R.id.avatar_1); + mAvatar2 = itemView.findViewById(R.id.avatar_2); + mAvatar3 = itemView.findViewById(R.id.avatar_3); + mName1 = itemView.findViewById(R.id.name_1); + mName2 = itemView.findViewById(R.id.name_2); + mName3 = itemView.findViewById(R.id.name_3); + mVotes1 = itemView.findViewById(R.id.votes_1); + mVotes2 = itemView.findViewById(R.id.votes_2); + mVotes3 = itemView.findViewById(R.id.votes_3); + mSex1 = itemView.findViewById(R.id.sex_1); + mSex2 = itemView.findViewById(R.id.sex_2); + mSex3 = itemView.findViewById(R.id.sex_3); + diamond1 = itemView.findViewById(R.id.diamond1); + diamond2 = itemView.findViewById(R.id.diamond2); + diamond3 = itemView.findViewById(R.id.diamond3); + mBtnFollow1 = itemView.findViewById(R.id.btn_follow_1); + mBtnFollow2 = itemView.findViewById(R.id.btn_follow_2); + mBtnFollow3 = itemView.findViewById(R.id.btn_follow_3); + svga1 = itemView.findViewById(R.id.svga1); + svga2 = itemView.findViewById(R.id.svga2); + svga3 = itemView.findViewById(R.id.svga3); + } + void setData(HomeRankBean user, int position){ + getItem(position,mName1,mName2,mName3).setText(user.getUserNicename()); + getItem(position,mVotes1,mVotes2,mVotes3).setText(user.getMoney()); + if(user.isFollow()){ + getItem(position,mBtnFollow1,mBtnFollow2,mBtnFollow3).setVisibility(View.GONE); + }else{ + getItem(position,mBtnFollow1,mBtnFollow2,mBtnFollow3).setVisibility(View.VISIBLE); + } + if(user.getSex()==1) { + getItem(position, mSex1, mSex2, mSex3).setImageResource(R.mipmap.ic_message_tab_man); + }else{ + getItem(position, mSex1, mSex2, mSex3).setImageResource(R.mipmap.ic_message_tab_woman); + } + switch (position){ + case 0: + svga1.setImageResource(R.mipmap.ic_home_rank_top_1); + break; + case 1: + svga2.setImageResource(R.mipmap.ic_home_rank_top_2); + break; + case 2: + svga3.setImageResource(R.mipmap.ic_home_rank_top_3); + break; + } + + } + private T getItem(int position, T... views) { + return views[position]; + } + + private void setVisibility(int type, int position, View... views) { + if (position == -1) { + for (View view : views) { + view.setVisibility(type); + } + } else { + views[position].setVisibility(type); + } + } + + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/RecommendFragment.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/RecommendFragment.java index 1595a82ec..c3406e1d1 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/RecommendFragment.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/home/RecommendFragment.java @@ -1,5 +1,6 @@ package com.shayu.onetoone.activity.fragments.home; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -9,6 +10,7 @@ import androidx.annotation.NonNull; import com.shayu.onetoone.R; import com.shayu.onetoone.activity.fragments.BaseFragment; +import com.shayu.onetoone.activity.HomepageRankingActivity; import com.shayu.onetoone.adapter.HomeRecommendListAdapter; import com.shayu.onetoone.bean.HomeItemBean; import com.shayu.onetoone.manager.OTONetManager; @@ -33,8 +35,8 @@ public class RecommendFragment extends BaseFragment { public void initView(View itemView) { recyclerView = itemView.findViewById(R.id.recyclerView); mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout); - top=itemView.findViewById(R.id.btn_top_list); - adapter=new HomeRecommendListAdapter(getContext()); + top = itemView.findViewById(R.id.btn_top_list); + adapter = new HomeRecommendListAdapter(getContext()); recyclerView.setAdapter(adapter); mRefreshLayout.setNestedScrollingEnabled(false); mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext())); @@ -50,7 +52,8 @@ public class RecommendFragment extends BaseFragment { } }); top.setOnClickListener(view -> { - recyclerView.scrollToPosition(0); + // recyclerView.scrollToPosition(0); + startActivity(new Intent(getContext(), HomepageRankingActivity.class)); }); initData(); } @@ -62,7 +65,8 @@ public class RecommendFragment extends BaseFragment { private void onConversationListRefresh(RefreshLayout refreshLayout) { initData(); } - private void initData(){ + + private void initData() { OTONetManager.getInstance(mContext) .getHomeRecommend(new HttpCallback>() { @Override diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/message/ChatMessageFragment.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/message/ChatMessageFragment.java index a2063102d..7735a5341 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/message/ChatMessageFragment.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/fragments/message/ChatMessageFragment.java @@ -1,6 +1,10 @@ package com.shayu.onetoone.activity.fragments.message; +import static android.content.Context.CLIPBOARD_SERVICE; + import android.app.Dialog; +import android.content.ClipData; +import android.content.ClipboardManager; import android.net.Uri; import android.os.Bundle; import android.util.Log; @@ -20,10 +24,12 @@ import com.lxj.xpopup.interfaces.OnSelectListener; import com.makeramen.roundedimageview.RoundedImageView; import com.shayu.onetoone.R; import com.shayu.onetoone.adapter.MsgChatMessageListAdapter; +import com.shayu.onetoone.bean.FollowBean; import com.shayu.onetoone.bean.MessageChatAuthContent; import com.shayu.onetoone.bean.MessageChatTipsContent; import com.shayu.onetoone.bean.UserBean; import com.shayu.onetoone.dialog.BottomListDialog; +import com.shayu.onetoone.dialog.MsgChatClickDialog; import com.shayu.onetoone.dialog.TipsDialog; import com.shayu.onetoone.listener.OnCallStatusListener; import com.shayu.onetoone.listener.OnDialogClickListener; @@ -393,7 +399,19 @@ public class ChatMessageFragment extends AbsConversationFragment { targetId = getIntent().getStringExtra("targetId"); updateUserInfo(); follow.setOnClickListener(v -> { + OTONetManager.getInstance(mContext) + .follow(targetId, new HttpCallback() { + @Override + public void onSuccess(FollowBean data) { + ToastUtil.show(WordUtil.getNewString(R.string.system_tip_success)); + follow.setVisibility(View.GONE); + } + @Override + public void onError(String error) { + + } + }); }); } @@ -421,6 +439,9 @@ public class ChatMessageFragment extends AbsConversationFragment { default: status.setImageResource(R.mipmap.ic_message_msg_status_offline); } + if (data.getUser().isFollow()) { + follow.setVisibility(View.GONE); + } } @Override @@ -432,21 +453,66 @@ public class ChatMessageFragment extends AbsConversationFragment { @Override public boolean onViewLongClick(int clickType, UiMessage data) { - View position = mLinearLayoutManager.findViewByPosition(((MsgChatMessageListAdapter)mAdapter).getPosition(data.getMessageId())); + View position = mLinearLayoutManager.findViewByPosition(((MsgChatMessageListAdapter) mAdapter).getPosition(data.getMessageId())); + boolean isMy = data.getMessage().getMessageDirection() == Message.MessageDirection.SEND; + boolean isTextMessage = data.getMessage().getContent() instanceof TextMessage; + String[] list; + if (isTextMessage) { + if (isMy) { + list = new String[]{"複製", "刪除"}; + } else { + list = new String[]{"複製"}; + } + } else { + if (isMy) { + list = new String[]{"刪除"}; + } else { + list = null; + } + } + if (list == null) { + return true; + } new XPopup.Builder(getContext()) - .atView(position) // 依附于所点击的View,内部会自动判断在上方或者下方显示 - .asAttachList(new String[]{"分享", "编辑", "不带icon"}, - new int[]{R.mipmap.ic_launcher, R.mipmap.ic_launcher}, - new OnSelectListener() { + .atView(position.findViewById(R.id.rc_content)) + .hasShadowBg(false) + .positionByWindowCenter(true) + .asCustom(new MsgChatClickDialog(getActivity()) + .setList(Arrays.asList(list)) + .setOnItemClickListener(new OnItemClickListener() { @Override - public void onSelect(int position, String text) { - ToastUtil.show("click " + text); + public void onItemClick(String bean, int position) { + if (bean.equals("複製")) { + copyText(data); + } else { + delete(data); + } } - }) + })) .show(); return true; } + private void copyText(UiMessage uiMessage) { + ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE); + ClipData clipData = ClipData.newPlainText("text", uiMessage.getContentSpannable()); + cm.setPrimaryClip(clipData); + } + + private void delete(UiMessage uiMessage) { + IMCenter.getInstance().deleteMessages(Conversation.ConversationType.PRIVATE, targetId, new int[]{uiMessage.getMessageId()}, new RongIMClient.ResultCallback() { + @Override + public void onSuccess(Boolean aBoolean) { + + } + + @Override + public void onError(RongIMClient.ErrorCode e) { + + } + }); + } + @Override protected MessageListAdapter onResolveAdapter() { return new MsgChatMessageListAdapter(this); diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/message/ChatActivity.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/message/ChatActivity.java index 1331f9b7b..1849bf6e9 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/activity/message/ChatActivity.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/message/ChatActivity.java @@ -38,11 +38,6 @@ import io.rong.imkit.conversation.ConversationFragment; public class ChatActivity extends AbsOTOActivity { - @Override - protected void onCreate() { - super.onCreate(); - - } @Override protected int getLayoutId() { diff --git a/OneToOne/src/main/java/com/shayu/onetoone/adapter/HomeRecommendListAdapter.java b/OneToOne/src/main/java/com/shayu/onetoone/adapter/HomeRecommendListAdapter.java index eef188e85..baddfe3db 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/adapter/HomeRecommendListAdapter.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/adapter/HomeRecommendListAdapter.java @@ -39,12 +39,12 @@ public class HomeRecommendListAdapter extends RecyclerView.Adapter data) { diff --git a/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgChatMessageListAdapter.java b/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgChatMessageListAdapter.java index 85794af7c..161313609 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgChatMessageListAdapter.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgChatMessageListAdapter.java @@ -1,15 +1,24 @@ package com.shayu.onetoone.adapter; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + import io.rong.imkit.conversation.MessageListAdapter; import io.rong.imkit.model.UiMessage; import io.rong.imkit.widget.adapter.IViewProviderListener; +import io.rong.imkit.widget.adapter.ViewHolder; public class MsgChatMessageListAdapter extends MessageListAdapter { public MsgChatMessageListAdapter(IViewProviderListener listener) { super(listener); } + //onCreateMessageContentViewH - public void onLongClick(int messageId) { + + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return super.onCreateViewHolder(parent, viewType); } public int getPosition(int messageId) { diff --git a/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgMessageRecyclerViewAdapter.java b/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgMessageRecyclerViewAdapter.java index ff61f844c..6d0b0f6ca 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgMessageRecyclerViewAdapter.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/adapter/MsgMessageRecyclerViewAdapter.java @@ -2,6 +2,7 @@ package com.shayu.onetoone.adapter; import android.text.SpannableString; +import com.shayu.onetoone.bean.MessageChatGiftContent; import com.yanzhenjie.recyclerview.SwipeRecyclerView; import androidx.annotation.NonNull; @@ -63,6 +64,9 @@ public class MsgMessageRecyclerViewAdapter extends ConversationListAdapter { continue; } if (datum.mCore.getConversationType() == Conversation.ConversationType.PRIVATE || datum.mCore.getConversationType() == Conversation.ConversationType.SYSTEM) { + if(datum.mCore.getLatestMessage() instanceof MessageChatGiftContent){ + datum.mConversationContent=new SpannableString("[禮物]"); + } if (datum.mCore.isTop()) { top.add(datum); } else { diff --git a/OneToOne/src/main/java/com/shayu/onetoone/bean/FollowBean.java b/OneToOne/src/main/java/com/shayu/onetoone/bean/FollowBean.java new file mode 100644 index 000000000..97705b8d3 --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/bean/FollowBean.java @@ -0,0 +1,27 @@ +package com.shayu.onetoone.bean; + +import com.yunbao.common.bean.BaseModel; + +public class FollowBean extends BaseModel { + private String isattent; + private int fans_status; + + public FollowBean() { + } + + public String getIsattent() { + return isattent; + } + + public void setIsattent(String isattent) { + this.isattent = isattent; + } + + public int getFans_status() { + return fans_status; + } + + public void setFans_status(int fans_status) { + this.fans_status = fans_status; + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/bean/HomeRankBean.java b/OneToOne/src/main/java/com/shayu/onetoone/bean/HomeRankBean.java new file mode 100644 index 000000000..8c095c0a9 --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/bean/HomeRankBean.java @@ -0,0 +1,202 @@ +package com.shayu.onetoone.bean; + +import com.yunbao.common.bean.BaseModel; + +public class HomeRankBean extends BaseModel { + private String id; + private String uid; + private String money; + private int type; + private int ymd; + private int yw; + private int ym; + private long updateTime; + private long createTime; + private int isAttention;//0 未关注 1被关注 2已关注 3互相关注 + private int islive; + private String avatar; + private String avatarThumb; + private String userNicename; + private int sex; + private int level; + private int charmLevel; + private int wealthLevel; + private String icon; + private String charmIcon; + private String wealthIcon; + + public HomeRankBean() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getMoney() { + return money; + } + + public void setMoney(String money) { + this.money = money; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public int getYmd() { + return ymd; + } + + public void setYmd(int ymd) { + this.ymd = ymd; + } + + public int getYw() { + return yw; + } + + public void setYw(int yw) { + this.yw = yw; + } + + public int getYm() { + return ym; + } + + public void setYm(int ym) { + this.ym = ym; + } + + public long getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(long updateTime) { + this.updateTime = updateTime; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public int getIsAttention() { + return isAttention; + } + + public void setIsAttention(int isAttention) { + this.isAttention = isAttention; + } + + public int getIslive() { + return islive; + } + + public void setIslive(int islive) { + this.islive = islive; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getAvatarThumb() { + return avatarThumb; + } + + public void setAvatarThumb(String avatarThumb) { + this.avatarThumb = avatarThumb; + } + + public String getUserNicename() { + return userNicename; + } + + public void setUserNicename(String userNicename) { + this.userNicename = userNicename; + } + + public int getSex() { + return sex; + } + + public void setSex(int sex) { + this.sex = sex; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public int getCharmLevel() { + return charmLevel; + } + + public void setCharmLevel(int charmLevel) { + this.charmLevel = charmLevel; + } + + public int getWealthLevel() { + return wealthLevel; + } + + public void setWealthLevel(int wealthLevel) { + this.wealthLevel = wealthLevel; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getCharmIcon() { + return charmIcon; + } + + public void setCharmIcon(String charmIcon) { + this.charmIcon = charmIcon; + } + + public String getWealthIcon() { + return wealthIcon; + } + + public void setWealthIcon(String wealthIcon) { + this.wealthIcon = wealthIcon; + } + + public boolean isFollow() { + return isAttention == 2 || isAttention == 3; + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/dialog/MsgChatClickDialog.java b/OneToOne/src/main/java/com/shayu/onetoone/dialog/MsgChatClickDialog.java new file mode 100644 index 000000000..8308ac6a5 --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/dialog/MsgChatClickDialog.java @@ -0,0 +1,93 @@ +package com.shayu.onetoone.dialog; + +import android.content.Context; +import android.graphics.Color; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.AttachPopupView; +import com.lxj.xpopup.core.BubbleAttachPopupView; +import com.shayu.onetoone.R; +import com.shayu.onetoone.event.MessageMsgBusEvent; +import com.shayu.onetoone.manager.RouteManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DpUtil; + +import java.util.List; + +/** + * 聊天界面长按气泡菜单 + */ +public class MsgChatClickDialog extends AttachPopupView implements View.OnClickListener { + LinearLayout rootView; + List list; + OnItemClickListener onItemClickListener; + + public MsgChatClickDialog(@NonNull Context context) { + super(context); + } + + public MsgChatClickDialog setList(List list) { + this.list = list; + return this; + } + + public MsgChatClickDialog setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + return this; + } + + @Override + protected int getImplLayoutId() { + return R.layout.dialog_msg_chat_click; + } + + @Override + protected boolean isShowUpToTarget() { + return true; + } + + @Override + protected void onCreate() { + super.onCreate(); + isShowUp = true; + rootView = findViewById(R.id.rootView); + rootView.setGravity(Gravity.CENTER); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT); + params.gravity = Gravity.CENTER; + for (int i = 0; i < list.size(); i++) { + String item = list.get(i); + TextView textView = new TextView(getContext()); + textView.setText(item); + textView.setGravity(Gravity.CENTER); + textView.setTag(i); + textView.setTextColor(Color.WHITE); + textView.setLayoutParams(params); + textView.setOnClickListener(this); + rootView.addView(textView,params); + + TextView tmp = new TextView(getContext()); + tmp.setLayoutParams(params); + tmp.setText(" | "); + tmp.setGravity(Gravity.CENTER); + tmp.setTextColor(Color.WHITE); + rootView.addView(tmp,params); + } + rootView.removeViewAt(rootView.getChildCount()-1); + } + + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + onItemClickListener.onItemClick(((TextView) v).getText().toString(), (Integer) v.getTag()); + } + dismiss(); + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/listener/OnAppbarListener.java b/OneToOne/src/main/java/com/shayu/onetoone/listener/OnAppbarListener.java new file mode 100644 index 000000000..e414aefdb --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/listener/OnAppbarListener.java @@ -0,0 +1,5 @@ +package com.shayu.onetoone.listener; + +public interface OnAppbarListener { + void onShow(boolean isShow); +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java b/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java index 2b7c02f21..5553f53e0 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java @@ -6,6 +6,7 @@ import android.util.Log; import com.alibaba.fastjson.JSONObject; import com.shayu.onetoone.bean.AvatarBean; +import com.shayu.onetoone.bean.FollowBean; import com.shayu.onetoone.bean.GiftBean; import com.shayu.onetoone.bean.GreetBean; import com.shayu.onetoone.bean.HomeItemBean; @@ -629,6 +630,27 @@ public class OTONetManager { }).isDisposed(); } + public void follow(String toUid, HttpCallback callback) { + + API.get().otoApi(mContext) + .follow(toUid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe((Consumer>>) model -> { + if (callback != null) { + callback.onSuccess(model.getData().getInfo().get(0)); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + Log.e(TAG, "accept: ", throwable); + if (callback != null) { + callback.onError(mContext.getString(com.yunbao.common.R.string.net_error)); + } + } + }).isDisposed(); + } + private MultipartBody.Part createUploadFile(File file) { RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); return MultipartBody.Part.createFormData("file", file.getName(), requestBody); diff --git a/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java b/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java index 24e4d178b..77e1331cf 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java @@ -1,6 +1,7 @@ package com.shayu.onetoone.network; import com.shayu.onetoone.bean.AvatarBean; +import com.shayu.onetoone.bean.FollowBean; import com.shayu.onetoone.bean.GiftBean; import com.shayu.onetoone.bean.GreetBean; import com.shayu.onetoone.bean.HomeItemBean; @@ -137,6 +138,9 @@ public interface OneToOneApi { Observable>> getGiftList(); @GET("/api/public/?service=Friendappmoney.info") Observable> getPurseInfo(); + @GET("/api/public/?service=User.setAttents") + Observable>> follow(@Query("touid")String toUid); + } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/provider/MessageChatReceiveGiftItemProvider.java b/OneToOne/src/main/java/com/shayu/onetoone/provider/MessageChatReceiveGiftItemProvider.java index 06c12fe0d..bf15263bd 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/provider/MessageChatReceiveGiftItemProvider.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/provider/MessageChatReceiveGiftItemProvider.java @@ -61,8 +61,10 @@ public class MessageChatReceiveGiftItemProvider extends BaseMessageItemProvider< if (messageChatGiftContent.getSendUid().equals(IMLoginManager.get(mContext).getUserInfo().getId() + "")) { params.gravity = Gravity.END; uiMessage.setMessageDirection(Message.MessageDirection.SEND); + holder.setText(R.id.title,"送给TA"); } else { uiMessage.setMessageDirection(Message.MessageDirection.RECEIVE); + holder.setText(R.id.title,"送给你"); params.gravity = Gravity.START; } try { diff --git a/OneToOne/src/main/res/drawable/background_dbdbdb.xml b/OneToOne/src/main/res/drawable/background_dbdbdb.xml new file mode 100644 index 000000000..4b186a490 --- /dev/null +++ b/OneToOne/src/main/res/drawable/background_dbdbdb.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/OneToOne/src/main/res/drawable/background_white_up.xml b/OneToOne/src/main/res/drawable/background_white_up.xml new file mode 100644 index 000000000..baefdd552 --- /dev/null +++ b/OneToOne/src/main/res/drawable/background_white_up.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OneToOne/src/main/res/drawable/bg_home_rank_day.xml b/OneToOne/src/main/res/drawable/bg_home_rank_day.xml new file mode 100644 index 000000000..4388c8e48 --- /dev/null +++ b/OneToOne/src/main/res/drawable/bg_home_rank_day.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/OneToOne/src/main/res/drawable/bg_home_rank_day_select.xml b/OneToOne/src/main/res/drawable/bg_home_rank_day_select.xml new file mode 100644 index 000000000..dd184248f --- /dev/null +++ b/OneToOne/src/main/res/drawable/bg_home_rank_day_select.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/OneToOne/src/main/res/layout/activity_main_list.xml b/OneToOne/src/main/res/layout/activity_main_list.xml new file mode 100644 index 000000000..b72e9df56 --- /dev/null +++ b/OneToOne/src/main/res/layout/activity_main_list.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OneToOne/src/main/res/layout/dialog_msg_chat_click.xml b/OneToOne/src/main/res/layout/dialog_msg_chat_click.xml new file mode 100644 index 000000000..ae3529c54 --- /dev/null +++ b/OneToOne/src/main/res/layout/dialog_msg_chat_click.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/OneToOne/src/main/res/layout/fragment_home_ranking.xml b/OneToOne/src/main/res/layout/fragment_home_ranking.xml new file mode 100644 index 000000000..8cf82f81b --- /dev/null +++ b/OneToOne/src/main/res/layout/fragment_home_ranking.xml @@ -0,0 +1,458 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +