diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveDataHistoryAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveDataHistoryAdapter.java new file mode 100644 index 000000000..637d1655b --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/LiveDataHistoryAdapter.java @@ -0,0 +1,87 @@ +package com.yunbao.common.adapter; + +import static com.yunbao.common.utils.StringUtil.isEmpty; + +import android.annotation.SuppressLint; +import android.content.Context; +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.yunbao.common.R; +import com.yunbao.common.bean.LiveDataHistoryBean; +import com.yunbao.common.bean.LiveDataHistoryBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ClipPathCircleImage; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by cxf on 2019/4/22. + */ + +public class LiveDataHistoryAdapter extends RecyclerView.Adapter { + + private Context mContext; + private List mList; + private LayoutInflater mInflater; + + public LiveDataHistoryAdapter(Context context, List list) { + mContext = context; + mInflater = LayoutInflater.from(context); + mList = list; + } + + public void setDataCollection(List data) { + if (data == null) { + data = new ArrayList(); + } + this.mList = data; + this.notifyDataSetChanged(); + } + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(R.layout.live_data_history_item, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh holder, @SuppressLint("RecyclerView") int position) { + if (isEmpty() || mList.isEmpty()) { + return; + } + holder.time.setText(mList.get(position).getAddtime().substring(0,9)+"\n"+mList.get(position).getAddtime().substring(10)); + holder.giftTypeName.setText(mList.get(position).getAction()); + holder.giftName.setText(mList.get(position).getGiftname()); + holder.income.setText(String.valueOf(mList.get(position).getAnchor_profit_coin())); + + } + + @Override + public int getItemCount() { + return mList.size(); + } + + class Vh extends RecyclerView.ViewHolder { + private TextView time; + private TextView giftTypeName; + private TextView giftName; + private TextView income; + + public Vh(@NonNull View itemView) { + super(itemView); + time = itemView.findViewById(R.id.time); + giftTypeName = itemView.findViewById(R.id.giftTypeName); + giftName = itemView.findViewById(R.id.giftName); + income = itemView.findViewById(R.id.income); + } + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/LiveDataHistoryBean.java b/common/src/main/java/com/yunbao/common/bean/LiveDataHistoryBean.java new file mode 100644 index 000000000..2dfadc99b --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/LiveDataHistoryBean.java @@ -0,0 +1,52 @@ +package com.yunbao.common.bean; + +/** + * 直播数据 + */ +public class LiveDataHistoryBean extends BaseModel { + private String giftid; + private String anchor_profit_coin; + private String addtime; + private String giftname; + private String action; + + public String getGiftid() { + return giftid; + } + + public void setGiftid(String giftid) { + this.giftid = giftid; + } + + public String getAnchor_profit_coin() { + return anchor_profit_coin; + } + + public void setAnchor_profit_coin(String anchor_profit_coin) { + this.anchor_profit_coin = anchor_profit_coin; + } + + public String getAddtime() { + return addtime; + } + + public void setAddtime(String addtime) { + this.addtime = addtime; + } + + public String getGiftname() { + return giftname; + } + + public void setGiftname(String giftname) { + this.giftname = giftname; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } +} diff --git a/common/src/main/java/com/yunbao/common/fragment/LiveDataHistoryFragment.java b/common/src/main/java/com/yunbao/common/fragment/LiveDataHistoryFragment.java new file mode 100644 index 000000000..8a9040794 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/fragment/LiveDataHistoryFragment.java @@ -0,0 +1,111 @@ +package com.yunbao.common.fragment; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.yunbao.common.R; +import com.yunbao.common.adapter.LiveDataHistoryAdapter; +import com.yunbao.common.bean.LiveDataHistoryBean; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.ToastUtil; + +import java.util.ArrayList; +import java.util.List; + +import io.rong.imkit.widget.refresh.SmartRefreshLayout; +import io.rong.imkit.widget.refresh.api.RefreshLayout; +import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener; +import io.rong.imkit.widget.refresh.listener.OnRefreshListener; +import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader; + +public class LiveDataHistoryFragment extends BaseFragment { + SmartRefreshLayout mRefreshLayout; + RecyclerView mList; + Context mContext; + LiveDataHistoryAdapter adapter; + List list = new ArrayList<>(); + int mPageCount = 1;//页数 + + @Override + public View createView(LayoutInflater inflater, ViewGroup container) { + return inflater.inflate(R.layout.live_data_history_list_fragment, container, false); + } + + @Override + protected void initVariables(Bundle bundle) { + + } + + @Override + protected void initViews(Bundle savedInstanceState, View contentView) { + initView(contentView); + initRefreshView(); + } + + @Override + protected void loadData() { + initData(); + } + + public LiveDataHistoryFragment(Context context) { + this.mContext = context; + } + + private void initView(View view) { + mRefreshLayout = view.findViewById(R.id.rc_refresh); + mList = view.findViewById(R.id.rc_conversation_list); + LinearLayoutManager layoutManager = new LinearLayoutManager(this.getActivity()); + mList.setLayoutManager(layoutManager); + mList.setItemViewCacheSize(0); + } + + protected void initRefreshView() { + mRefreshLayout.setNestedScrollingEnabled(false); + mRefreshLayout.setRefreshHeader(new RongRefreshHeader(getContext())); + mRefreshLayout.setRefreshFooter(new RongRefreshHeader(getContext())); + mRefreshLayout.setEnableLoadMore(false); + mRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + mPageCount = 1; + initData(); + } + }); + mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() { + public void onLoadMore(@NonNull RefreshLayout refreshLayout) { + mPageCount++; + initData(); + } + }); + adapter = new LiveDataHistoryAdapter(mContext,list); + mList.setAdapter(adapter); + } + + private void initData() { + CommonHttpUtil.getLiveDataHistoryList("","",new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info != null) { + JSONObject obj = JSON.parseObject(info[0]); + if(){ + + } + list = JSON.parseArray(obj.getString("data"), LiveDataHistoryBean.class); + adapter.setDataCollection(list); + mRefreshLayout.finishRefresh(true); + } else { + ToastUtil.show(msg); + } + } + }); + } +} diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index bcfc0e1e9..becf86858 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -723,6 +723,16 @@ public class CommonHttpUtil { .execute(callback); } + /** + *获取聊天列表用户在线状态 + * @param callback + */ + public static void getLiveDataHistoryList(String stream,String page,HttpCallback callback) { + HttpClient.getInstance().get("live.getLiveGiftList", "live.getLiveGiftList") + .params("stream",stream) + .params("page",page) + .execute(callback); + } } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index dc454ac73..db1e00906 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -4244,7 +4244,6 @@ public class LiveNetManager { return MultipartBody.Part.createFormData("file", file.getName(), requestBody); } - public void getSwToken( HttpCallback callback) { API.get().pdLiveApi(mContext) .getSwToken() @@ -4266,10 +4265,8 @@ public class LiveNetManager { } } }).isDisposed(); - } - /** * 获取开播提示信息 */ @@ -4293,7 +4290,6 @@ public class LiveNetManager { }).isDisposed(); } - /** * 直播间取消网络请求 */ diff --git a/common/src/main/res/layout/live_data_history_item.xml b/common/src/main/res/layout/live_data_history_item.xml new file mode 100644 index 000000000..57a501085 --- /dev/null +++ b/common/src/main/res/layout/live_data_history_item.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/live_data_history_list_fragment.xml b/common/src/main/res/layout/live_data_history_list_fragment.xml new file mode 100644 index 000000000..3f8c0771b --- /dev/null +++ b/common/src/main/res/layout/live_data_history_list_fragment.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/src/main/res/values-en-rUS/strings.xml b/common/src/main/res/values-en-rUS/strings.xml index 5800e22aa..0d41255bd 100644 --- a/common/src/main/res/values-en-rUS/strings.xml +++ b/common/src/main/res/values-en-rUS/strings.xml @@ -1479,4 +1479,6 @@ Limited ride And limited avatar frame Interaction Broadcaster Rights Live streaming tools + 本場數據 + 禮物記錄 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 97c718129..44796e2e8 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1609,5 +1609,7 @@ 互動 主播權益 直播工具 + 本場數據 + 禮物記錄 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index a2806ad80..753e45b32 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1417,5 +1417,7 @@ Limited ride And limited avatar frame Interaction Broadcaster Rights Live streaming tools + 本場數據 + 禮物記錄 diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveDataInfoDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveDataInfoDialog.java index 018ff8462..7a7987c08 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveDataInfoDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveDataInfoDialog.java @@ -1,32 +1,67 @@ package com.yunbao.live.dialog; import android.content.Context; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.TextPaint; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; +import android.text.style.ImageSpan; +import android.util.Log; +import android.view.View; import android.widget.ImageView; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; +import androidx.viewpager2.adapter.FragmentStateAdapter; +import androidx.viewpager2.widget.ViewPager2; import com.lxj.xpopup.XPopup; import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.fragment.AbsMainMessageChatListFragment; +import com.yunbao.common.fragment.BaseFragment; +import com.yunbao.common.fragment.LiveDataHistoryFragment; +import com.yunbao.common.fragment.MainMessageChatListFragment; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.AppManager; +import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.ViewPageIndicatorUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.adapter.LiveDataInfoRecyclerAdapter; import com.yunbao.live.bean.LiveDataInfoModel; +import net.lucode.hackware.magicindicator.MagicIndicator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView; + import java.util.ArrayList; import java.util.List; public class LiveDataInfoDialog extends AbsDialogPopupWindow { - private ImageView img; private RecyclerView recyclerView; private LiveDataInfoRecyclerAdapter adapter; private List list; private String liveUid; + private ViewPager2 viewPager; + private MagicIndicator mIndicator; + private List fragmentList = new ArrayList<>(); + public LiveDataInfoDialog(@NonNull Context context) { super(context); } @@ -52,8 +87,75 @@ public class LiveDataInfoDialog extends AbsDialogPopupWindow { @Override protected void onCreate() { super.onCreate(); - img = findViewById(R.id.live_data_img); - img.setImageResource(R.mipmap.icon_free_pk_waring); + final String[] titles = new String[]{WordUtil.getNewString(R.string.live_data_now_data), WordUtil.getNewString(R.string.live_data_gift_history)}; + fragmentList.add(new LiveDataHistoryFragment(mContext)); + fragmentList.add(new LiveDataHistoryFragment(mContext)); + + mIndicator = findViewById(R.id.indicator); + viewPager = findViewById(R.id.viewPager); + + viewPager.setAdapter(new FragmentStateAdapter((FragmentActivity) AppManager.getInstance().getMainActivity()) { + + @Override + public int getItemCount() { + return fragmentList.size(); + } + + @NonNull + @Override + public Fragment createFragment(int i) { + return fragmentList.get(i); + } + }); + viewPager.setCurrentItem(1); + viewPager.setUserInputEnabled(false); + + CommonNavigator commonNavigator = new CommonNavigator(mContext); + commonNavigator.setAdjustMode(true); + commonNavigator.setAdapter(new CommonNavigatorAdapter() { + + @Override + public int getCount() { + return titles.length; + } + + @Override + public IPagerTitleView getTitleView(Context context, final int index) { + SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context); + simplePagerTitleView.setNormalColor(Color.parseColor("#777777")); + simplePagerTitleView.setSelectedColor(Color.parseColor("#333333")); + simplePagerTitleView.setText(titles[index]); + simplePagerTitleView.setTextSize(15); + simplePagerTitleView.getPaint().setFakeBoldText(true); + simplePagerTitleView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (viewPager != null) { + viewPager.setCurrentItem(index); + } + } + }); + return simplePagerTitleView; + } + + @Override + public IPagerIndicator getIndicator(Context context) { + LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context); + linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT); + linePagerIndicator.setXOffset(DpUtil.dp2px(5)); + linePagerIndicator.setRoundRadius(DpUtil.dp2px(2)); + linePagerIndicator.setColors(Color.parseColor("#EB6FFF"), Color.parseColor("#FF83C6")); + return linePagerIndicator; + } + }); + mIndicator.setNavigator(commonNavigator); + ViewPageIndicatorUtils.bind(mIndicator, viewPager, new ViewPager2.OnPageChangeCallback() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + super.onPageScrolled(position, positionOffset, positionOffsetPixels); + } + }); + recyclerView = findViewById(R.id.live_data_list); adapter = new LiveDataInfoRecyclerAdapter(getContext()); recyclerView.setAdapter(adapter); @@ -62,22 +164,22 @@ public class LiveDataInfoDialog extends AbsDialogPopupWindow { private void initData() { list = new ArrayList<>(); - list.add(new LiveDataInfoModel("#00FFFF",getContext().getString(R.string.live_data_coin),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel("#FFF69F",getContext().getString(R.string.live_data_gold),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_accept),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_enter),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_attention),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_attention_rate),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_fan_group),getContext().getString(R.string.live_data_loading))); - list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_fan_group_rate),getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel("#00FFFF", getContext().getString(R.string.live_data_coin), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel("#FFF69F", getContext().getString(R.string.live_data_gold), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_accept), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_enter), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_attention), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_attention_rate), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_fan_group), getContext().getString(R.string.live_data_loading))); + list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_fan_group_rate), getContext().getString(R.string.live_data_loading))); adapter.setList(list); LiveNetManager.get(getContext()) .getLiveData(liveUid, new HttpCallback() { @Override public void onSuccess(com.yunbao.common.bean.LiveDataInfoModel data) { list.clear(); - list.add(new LiveDataInfoModel("#00FFFF",getContext().getString(R.string.live_data_coin), data.getTotalCoin() + "")); - list.add(new LiveDataInfoModel("#FFF69F",getContext().getString(R.string.live_data_gold), data.getTotalGold() + "")); + list.add(new LiveDataInfoModel("#00FFFF", getContext().getString(R.string.live_data_coin), data.getTotalCoin() + "")); + list.add(new LiveDataInfoModel("#FFF69F", getContext().getString(R.string.live_data_gold), data.getTotalGold() + "")); list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_accept), data.getAcceptNum() + "")); list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_enter), data.getEnterNum() + "")); list.add(new LiveDataInfoModel(getContext().getString(R.string.live_data_attention), data.getAttentionNum() + "")); diff --git a/live/src/main/res/layout/dialog_live_data.xml b/live/src/main/res/layout/dialog_live_data.xml index 32b2fd304..b31ba7282 100644 --- a/live/src/main/res/layout/dialog_live_data.xml +++ b/live/src/main/res/layout/dialog_live_data.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="#000002"> + + +