This commit is contained in:
Martin
2024-08-14 17:38:20 +08:00
parent 54ee2fb0b7
commit af8ac39e9c
12 changed files with 552 additions and 18 deletions

View File

@@ -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<LiveDataHistoryAdapter.Vh> {
private Context mContext;
private List<LiveDataHistoryBean> mList;
private LayoutInflater mInflater;
public LiveDataHistoryAdapter(Context context, List<LiveDataHistoryBean> list) {
mContext = context;
mInflater = LayoutInflater.from(context);
mList = list;
}
public void setDataCollection(List<LiveDataHistoryBean> 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);
}
}
}

View File

@@ -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;
}
}

View File

@@ -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<LiveDataHistoryBean> 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);
}
}
});
}
}

View File

@@ -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);
}
}

View File

@@ -4244,7 +4244,6 @@ public class LiveNetManager {
return MultipartBody.Part.createFormData("file", file.getName(), requestBody);
}
public void getSwToken( HttpCallback<SwTokenModel> callback) {
API.get().pdLiveApi(mContext)
.getSwToken()
@@ -4266,10 +4265,8 @@ public class LiveNetManager {
}
}
}).isDisposed();
}
/**
* 获取开播提示信息
*/
@@ -4293,7 +4290,6 @@ public class LiveNetManager {
}).isDisposed();
}
/**
* 直播间取消网络请求
*/

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rc_conversation_item"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:textColor="#92949A"
android:textSize="12dp"
tools:text="2022-06-15\n16:26:15" />
<TextView
android:id="@+id/giftTypeName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center"
android:textColor="#92949A"
android:textSize="12dp"
tools:text="分類" />
<TextView
android:id="@+id/giftName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center"
android:textColor="#92949A"
android:textSize="12dp"
tools:text="禮物" />
<TextView
android:id="@+id/income"
android:layout_width="0dp"
android:layout_marginEnd="20dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.7"
android:ellipsize="end"
android:gravity="end|center"
android:textColor="#92949A"
android:textSize="12dp"
tools:text="10000" />
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/titleLayout"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="30dp">
<TextView
android:id="@+id/time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="時間"
android:gravity="center_vertical"
android:textColor="#FFFFFF"
android:textSize="14dp" />
<TextView
android:id="@+id/giftTypeName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="14dp"
tools:text="分類" />
<TextView
android:id="@+id/giftName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="14dp"
tools:text="禮物" />
<TextView
android:id="@+id/income"
android:layout_width="0dp"
android:layout_marginEnd="20dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.7"
android:gravity="end|center"
android:textColor="#FFFFFF"
android:textSize="14dp"
tools:text="10000" />
</LinearLayout>
<View
android:id="@+id/line"
android:layout_marginTop="10dp"
android:layout_below="@+id/titleLayout"
android:layout_width="match_parent"
android:background="#525252"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_height="0.5dp"/>
<io.rong.imkit.widget.refresh.SmartRefreshLayout
android:id="@+id/rc_refresh"
android:layout_marginStart="16dp"
android:layout_below="@+id/line"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rc_conversation_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
tools:listitem="@layout/live_data_history_item" />
</io.rong.imkit.widget.refresh.SmartRefreshLayout>
</RelativeLayout>

View File

@@ -1479,4 +1479,6 @@ Limited ride And limited avatar frame</string>
<string name="live_interaction_Interaction">Interaction</string>
<string name="live_interaction_broadcaster_rights">Broadcaster Rights</string>
<string name="live_interaction_tools">Live streaming tools</string>
<string name="live_data_now_data">本場數據</string>
<string name="live_data_gift_history">禮物記錄</string>
</resources>

View File

@@ -1609,5 +1609,7 @@
<string name="live_interaction_Interaction">互動</string>
<string name="live_interaction_broadcaster_rights">主播權益</string>
<string name="live_interaction_tools">直播工具</string>
<string name="live_data_now_data">本場數據</string>
<string name="live_data_gift_history">禮物記錄</string>
</resources>

View File

@@ -1417,5 +1417,7 @@ Limited ride And limited avatar frame</string>
<string name="live_interaction_Interaction">Interaction</string>
<string name="live_interaction_broadcaster_rights">Broadcaster Rights</string>
<string name="live_interaction_tools">Live streaming tools</string>
<string name="live_data_now_data">本場數據</string>
<string name="live_data_gift_history">禮物記錄</string>
</resources>