Merge branch 'live_anchor_6.4.8'
This commit is contained in:
@@ -866,7 +866,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
|
||||
|
||||
private void showTaskDialog() {
|
||||
final Dialog dialog = new Dialog(LiveActivity.this, com.yunbao.live.R.style.dialog);
|
||||
dialog.setContentView(R.layout.dialog_task);
|
||||
dialog.setContentView(R.layout.dialog_live_task);
|
||||
dialog.setCancelable(true);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
|
||||
|
||||
@@ -673,7 +673,9 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
}
|
||||
bundle.putBoolean(Constants.HAS_GAME, hasGame);
|
||||
bundle.putInt("leave", leave);
|
||||
bundle.putString("liveUid", mLiveUid);
|
||||
bundle.putBoolean("isPk", isDRPK == 1 || PKing || mLivePushViewHolder.isPking());
|
||||
bundle.putLong("liveTime", mLiveAnchorViewHolder.getmAnchorLiveTime());
|
||||
bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen());
|
||||
fragment.setArguments(bundle);
|
||||
fragment.setFunctionClickListener(this);
|
||||
@@ -937,9 +939,11 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
if (code == 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
JSONObject datas = obj.getJSONObject("data");
|
||||
|
||||
SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid, mSocketRyClient);
|
||||
|
||||
try {
|
||||
SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid, mSocketRyClient);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (mLiveEndViewHolder == null) {
|
||||
mLiveEndViewHolder = new LiveEndViewHolder(mContext, mRoot, mLiveBean.getUid());
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
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.live.R;
|
||||
import com.yunbao.live.bean.LiveDataInfoModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveDataInfoRecyclerAdapter extends RecyclerView.Adapter<LiveDataInfoRecyclerAdapter.LiveDataHolder> {
|
||||
private Context mContext;
|
||||
private List<LiveDataInfoModel> list=new ArrayList<>();
|
||||
|
||||
public LiveDataInfoRecyclerAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<LiveDataInfoModel> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LiveDataHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new LiveDataHolder(LayoutInflater.from(mContext).inflate(R.layout.item_live_data, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LiveDataHolder holder, int position) {
|
||||
holder.setData(list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public static class LiveDataHolder extends RecyclerView.ViewHolder {
|
||||
private TextView title, data;
|
||||
|
||||
public LiveDataHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.item_title);
|
||||
data = itemView.findViewById(R.id.item_data);
|
||||
}
|
||||
|
||||
public void setData(LiveDataInfoModel model) {
|
||||
if (model.getColor() != null) {
|
||||
data.setText(Html.fromHtml("<font color='" + model.getColor() + "'>" + model.getData() + "</font>"));
|
||||
} else {
|
||||
data.setText(model.getData());
|
||||
}
|
||||
title.setText(model.getTitle());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.LiveTaskModel;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveTaskRecyclerAdapter extends RecyclerView.Adapter<LiveTaskRecyclerAdapter.TaskHolder> {
|
||||
|
||||
private Context mContext;
|
||||
private List<LiveTaskModel.Task> tasks = new ArrayList<>();
|
||||
|
||||
public LiveTaskRecyclerAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setTasks(List<LiveTaskModel.Task> tasks) {
|
||||
this.tasks = tasks;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TaskHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == LiveTaskModel.TASK_TYPE_TIP) {
|
||||
return new TaskHolder(new TextView(mContext));
|
||||
} else {
|
||||
return new TaskHolder(LayoutInflater.from(mContext).inflate(R.layout.item_live_task, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return tasks.get(position).getType();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TaskHolder holder, int position) {
|
||||
holder.setDate(tasks.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tasks.size();
|
||||
}
|
||||
|
||||
|
||||
public static class TaskHolder extends RecyclerView.ViewHolder {
|
||||
private TextView title;
|
||||
private TextView complete;
|
||||
private TextView hot;
|
||||
private TextView xp;
|
||||
private ImageView hotIcon;
|
||||
private ImageView xpIcon;
|
||||
|
||||
public TaskHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
if (itemView instanceof TextView) {
|
||||
title = (TextView) itemView;
|
||||
title.setTextColor(Color.parseColor("#B3B3B3"));
|
||||
title.setTextSize(12);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMarginStart(DpUtil.dp2px(27));
|
||||
params.setMargins(DpUtil.dp2px(27), DpUtil.dp2px(16), 0, DpUtil.dp2px(16));
|
||||
title.setLayoutParams(params);
|
||||
} else {
|
||||
title = itemView.findViewById(R.id.item_task_title);
|
||||
complete = itemView.findViewById(R.id.item_task_complete);
|
||||
hot = itemView.findViewById(R.id.item_task_hot);
|
||||
xp = itemView.findViewById(R.id.item_task_xp);
|
||||
hotIcon = itemView.findViewById(R.id.item_task_hot_img);
|
||||
xpIcon = itemView.findViewById(R.id.item_task_xp_img);
|
||||
hotIcon.setImageResource(R.mipmap.dialog_task_hot);
|
||||
xpIcon.setImageResource(R.mipmap.dialog_task_star);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDate(LiveTaskModel.Task task) {
|
||||
title.setText(task.getTaskName());
|
||||
if (task.getType() == LiveTaskModel.TASK_TYPE_TIP) {
|
||||
return;
|
||||
}
|
||||
if (task.getStatus() || task.getNowValue() >= task.getTaskNum()) {
|
||||
task.setNowValue(task.getTaskNum());
|
||||
}
|
||||
title.setText(String.format("%s (%s/%s)",
|
||||
task.getTaskName(),
|
||||
task.getNowValue(),
|
||||
task.getTaskNum())
|
||||
);
|
||||
if (task.getNowValue() == task.getTaskNum()) {
|
||||
task.setStatus(1);
|
||||
}
|
||||
complete.setText(task.getStatus() ? R.string.live_task_item_complete_true : R.string.live_task_item_complete_false);
|
||||
complete.setBackgroundResource(task.getStatus() ? R.drawable.background_6cbe53 : R.drawable.background_595959);
|
||||
hot.setText(Html.fromHtml("<font color='#B3B3B3'>" + WordUtil.getString(R.string.live_task_item_hot) + "</font>  <font color='#F09FC2'>" + task.getHot() + "</font>"));
|
||||
xp.setText(Html.fromHtml("<font color='#B3B3B3'>" + WordUtil.getString(R.string.live_task_item_xp) + "</font>  <font color='#FFF69F'>" + task.getExp() + "</font>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.yunbao.live.bean;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
public class LiveDataInfoModel extends BaseModel {
|
||||
private String color;
|
||||
private String title;
|
||||
private String data;
|
||||
|
||||
public LiveDataInfoModel(String color, String title, String data) {
|
||||
this.color = color;
|
||||
this.title = title;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public LiveDataInfoModel(String title, String data) {
|
||||
this.title = title;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public LiveDataInfoModel() {
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.dialog.AbsDialogPopupWindow;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveDataInfoRecyclerAdapter;
|
||||
import com.yunbao.live.bean.LiveDataInfoModel;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveDataInfoDialog extends AbsDialogPopupWindow {
|
||||
private ImageView img;
|
||||
private RecyclerView recyclerView;
|
||||
private LiveDataInfoRecyclerAdapter adapter;
|
||||
private List<LiveDataInfoModel> list;
|
||||
private String liveUid;
|
||||
|
||||
public LiveDataInfoDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public LiveDataInfoDialog(@NonNull Context context, String liveUid) {
|
||||
super(context);
|
||||
this.liveUid = liveUid;
|
||||
}
|
||||
|
||||
public void setLiveUid(String liveUid) {
|
||||
this.liveUid = liveUid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindLayoutId() {
|
||||
return R.layout.dialog_live_data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
img = findViewById(R.id.live_data_img);
|
||||
img.setImageResource(R.mipmap.icon_free_pk_waring);
|
||||
recyclerView = findViewById(R.id.live_data_list);
|
||||
adapter = new LiveDataInfoRecyclerAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
list = new ArrayList<>();
|
||||
list.add(new LiveDataInfoModel("#00FFFF", WordUtil.getString(R.string.live_data_coin), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel("#FFF69F", WordUtil.getString(R.string.live_data_gold), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_accept), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_enter), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_attention), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_attention_rate), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_fan_group), WordUtil.getString(R.string.live_data_loading)));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_fan_group_rate), WordUtil.getString(R.string.live_data_loading)));
|
||||
adapter.setList(list);
|
||||
LiveNetManager.get(getContext())
|
||||
.getLiveData(liveUid, new HttpCallback<com.yunbao.common.bean.LiveDataInfoModel>() {
|
||||
@Override
|
||||
public void onSuccess(com.yunbao.common.bean.LiveDataInfoModel data) {
|
||||
list.clear();
|
||||
list.add(new LiveDataInfoModel("#00FFFF", WordUtil.getString(R.string.live_data_coin), data.getTotalCoin() + ""));
|
||||
list.add(new LiveDataInfoModel("#FFF69F", WordUtil.getString(R.string.live_data_gold), data.getTotalGold() + ""));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_accept), data.getAcceptNum() + ""));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_enter), data.getEnterNum() + ""));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_attention), data.getAttentionNum() + ""));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_attention_rate), data.getAttentionNumRate() + ""));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_fan_group), data.getFanGroupNum() + ""));
|
||||
list.add(new LiveDataInfoModel(WordUtil.getString(R.string.live_data_fan_group_rate), data.getFanGroupNumRate() + ""));
|
||||
adapter.setList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,21 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import static com.yunbao.common.Constants.*;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_BEAUTY;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_CAMERA;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_DR;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_LINK_MIC;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_MIC;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_RANDOM_PK;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_WISHLIST;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_WKS;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_ZG;
|
||||
import static com.yunbao.common.Constants.LIVE_FUNC_ZSLK;
|
||||
import static com.yunbao.common.Constants.LIVE_ROBOT;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@@ -10,10 +23,12 @@ import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.LiveAnchorMessageCustomPopup;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.interfaces.LiveFunctionClickListener;
|
||||
@@ -29,7 +44,9 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
private LiveFunctionClickListener mFunctionClickListener;
|
||||
private int leave = 0;
|
||||
private boolean isPk;
|
||||
private TextView mLiveTimeTextView;//主播的直播时长
|
||||
|
||||
private String liveUid;
|
||||
|
||||
// boolean isRy = false;
|
||||
@Override
|
||||
@@ -70,6 +87,8 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
leave = bundle.getInt("leave", 0);
|
||||
isPk = bundle.getBoolean("isPk", false);
|
||||
// isRy = bundle.getBoolean("isRy", false);
|
||||
mAnchorLiveTime = bundle.getLong("liveTime");
|
||||
liveUid = bundle.getString("liveUid");
|
||||
}
|
||||
mWishView = findViewById(R.id.live_tool_wish);
|
||||
mPrankView = findViewById(R.id.live_tool_prank);
|
||||
@@ -81,7 +100,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
mMultiPkView = findViewById(R.id.live_tool_multi_pk);
|
||||
mMicView = findViewById(R.id.live_tool_mic);
|
||||
mRandomPk = findViewById(R.id.live_tool_random_pk);
|
||||
|
||||
mLiveTimeTextView = (TextView) findViewById(R.id.live_time);
|
||||
mWishView.setOnClickListener(this);
|
||||
mPrankView.setOnClickListener(this);
|
||||
mWksView.setOnClickListener(this);
|
||||
@@ -92,6 +111,10 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
mMultiPkView.setOnClickListener(this);
|
||||
mMicView.setOnClickListener(this);
|
||||
mRandomPk.setOnClickListener(this);
|
||||
findViewById(R.id.message_linear).setOnClickListener(this);
|
||||
findViewById(R.id.broadcast_data).setOnClickListener(this);
|
||||
findViewById(R.id.anchor_task).setOnClickListener(this);
|
||||
|
||||
findViewById(R.id.live_tool_robot).setOnClickListener(this);
|
||||
|
||||
if (leave == 0) {
|
||||
@@ -101,7 +124,9 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
((ImageView) mLeaveView.findViewById(R.id.live_tool_leave_img)).setImageResource(R.mipmap.icon_leave_p);
|
||||
((TextView) mLeaveView.findViewById(R.id.live_tool_leave_text)).setText(R.string.live_zslk1);
|
||||
}
|
||||
|
||||
mLiveRoomHandler = new LiveRoomHandler();
|
||||
mLiveTimeTextView.setText(StringUtil.getDurationText(mAnchorLiveTime));
|
||||
startAnchorLiveTime();
|
||||
}
|
||||
|
||||
public void setFunctionClickListener(LiveFunctionClickListener functionClickListener) {
|
||||
@@ -146,9 +171,74 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
mFunctionClickListener.onClick(LIVE_FUNC_MIC);
|
||||
} else if (id == R.id.live_tool_random_pk) {
|
||||
mFunctionClickListener.onClick(LIVE_FUNC_RANDOM_PK);
|
||||
}else if (id==R.id.live_tool_robot){
|
||||
} else if (id == R.id.live_tool_robot) {
|
||||
mFunctionClickListener.onClick(LIVE_ROBOT);
|
||||
dismiss();
|
||||
} else if (id == R.id.message_linear) {
|
||||
new XPopup.Builder(getContext())
|
||||
.asCustom(new LiveAnchorMessageCustomPopup(getContext(), liveUid))
|
||||
.show();
|
||||
dismiss();
|
||||
} else if (id == R.id.broadcast_data) {
|
||||
//主播数据
|
||||
new LiveDataInfoDialog(mContext, liveUid).showDialog();
|
||||
dismiss();
|
||||
} else if (id == R.id.anchor_task) {
|
||||
//主播任务
|
||||
taskDialog = new LiveTaskDialog(mContext);
|
||||
taskDialog.setLiveUid(liveUid);
|
||||
taskDialog.updateLiveTimer(mAnchorLiveTime);
|
||||
taskDialog.showDialog();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private final int WHAT_ANCHOR_LIVE_TIME = 3;//直播间主播计时
|
||||
private LiveRoomHandler mLiveRoomHandler;
|
||||
private long mAnchorLiveTime;//主播直播时间
|
||||
private LiveTaskDialog taskDialog;
|
||||
|
||||
/**
|
||||
* 主播显示直播时间
|
||||
*/
|
||||
private void showAnchorLiveTime() {
|
||||
if (mLiveTimeTextView != null) {
|
||||
mAnchorLiveTime += 1000;
|
||||
mLiveTimeTextView.setText(StringUtil.getDurationText(mAnchorLiveTime));
|
||||
startAnchorLiveTime();
|
||||
}
|
||||
}
|
||||
|
||||
public void startAnchorLiveTime() {
|
||||
if (mLiveRoomHandler != null) {
|
||||
mLiveRoomHandler.sendEmptyMessageAtTime(WHAT_ANCHOR_LIVE_TIME, getNextTime(1000));
|
||||
}
|
||||
}
|
||||
|
||||
private class LiveRoomHandler extends Handler {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
switch (msg.what) {
|
||||
|
||||
case WHAT_ANCHOR_LIVE_TIME:
|
||||
showAnchorLiveTime();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
|
||||
private long getNextTime(int time) {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
if (time < 1000) {
|
||||
return now + time;
|
||||
}
|
||||
return now + time + -now % 1000;
|
||||
}
|
||||
}
|
||||
|
||||
267
live/src/main/java/com/yunbao/live/dialog/LiveTaskDialog.java
Normal file
267
live/src/main/java/com/yunbao/live/dialog/LiveTaskDialog.java
Normal file
@@ -0,0 +1,267 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.bean.LiveTaskModel;
|
||||
import com.yunbao.common.dialog.AbsDialogPopupWindow;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveTaskRecyclerAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 主播直播任务弹框
|
||||
*/
|
||||
public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
private TextView newStarTime;
|
||||
private ImageView newStarImg;
|
||||
private ImageView taskInfoImg;
|
||||
private ImageView tipImg;
|
||||
private TabLayout tabLayout;
|
||||
|
||||
private ViewPager2 viewPager;
|
||||
|
||||
|
||||
private TabLayoutMediator mediator;
|
||||
|
||||
|
||||
private Context mContext;
|
||||
String liveUid;
|
||||
int liveTimer;
|
||||
|
||||
public LiveTaskDialog(Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
builder.enableDrag(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindLayoutId() {
|
||||
return R.layout.dialog_live_task;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
initView();
|
||||
}
|
||||
|
||||
public void setLiveUid(String liveUid) {
|
||||
this.liveUid = liveUid;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
newStarTime = findViewById(R.id.task_new_star_time);
|
||||
newStarImg = findViewById(R.id.live_task_banner1);
|
||||
taskInfoImg = findViewById(R.id.live_task_banner2);
|
||||
tipImg = findViewById(R.id.live_task_tip);
|
||||
tabLayout = findViewById(R.id.live_task_menu);
|
||||
viewPager = findViewById(R.id.live_task_viewpager);
|
||||
initImgView();
|
||||
createTask();
|
||||
|
||||
}
|
||||
|
||||
private void initImgView() {
|
||||
newStarImg.setImageResource(R.mipmap.dialog_task_new_star);
|
||||
taskInfoImg.setImageResource(R.mipmap.dialog_task_info);
|
||||
tipImg.setImageResource(R.mipmap.icon_guize);
|
||||
tipImg.setOnClickListener(v -> new LiveTaskInfoDialog(mContext).showDialog());
|
||||
}
|
||||
|
||||
private void initTabLayout(LiveTaskModel model) {
|
||||
TabLayout.Tab liveTaskTag = tabLayout.newTab();
|
||||
TabLayout.Tab userTaskTag = tabLayout.newTab();
|
||||
liveTaskTag.setText(R.string.live_task_tab1);
|
||||
userTaskTag.setText(R.string.live_task_tab2);
|
||||
tabLayout.addTab(liveTaskTag);
|
||||
tabLayout.addTab(userTaskTag);
|
||||
|
||||
viewPager.setAdapter(new FragmentStateAdapter(((AppCompatActivity) mContext).getSupportFragmentManager(), getLifecycle()) {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
TaskFragment fragment = new TaskFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("position", position + 1);
|
||||
bundle.putInt("liveTimer", liveTimer);
|
||||
bundle.putString("liveUid", liveUid);
|
||||
bundle.putSerializable("data", model);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mediator = new TabLayoutMediator(tabLayout, viewPager, true, new TabLayoutMediator.TabConfigurationStrategy() {
|
||||
@Override
|
||||
public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
|
||||
if (position == 0) {
|
||||
tab.setText(R.string.live_task_tab1);
|
||||
} else {
|
||||
tab.setText(R.string.live_task_tab2);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
mediator.attach();
|
||||
}
|
||||
|
||||
private void updateMainUi(LiveTaskModel.NewUser task) {
|
||||
if (task.isNew()) {
|
||||
newStarImg.setVisibility(VISIBLE);
|
||||
newStarTime.setVisibility(VISIBLE);
|
||||
newStarTime.setText(task.getEndTime());
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog loadDialog;
|
||||
|
||||
private void createTask() {
|
||||
loadDialog = DialogUitl.loadingDialog(getContext());
|
||||
loadDialog.show();
|
||||
LiveNetManager.get(getContext())
|
||||
.getLiveTask(1, liveUid, new HttpCallback<LiveTaskModel>() {
|
||||
@Override
|
||||
public void onSuccess(LiveTaskModel data) {
|
||||
Log.i("直播任务", "onSuccess: " + data);
|
||||
updateMainUi(data.getUser());
|
||||
initTabLayout(data);
|
||||
if (loadDialog != null) {
|
||||
loadDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("直播任务", "onError: " + error);
|
||||
if (loadDialog != null) {
|
||||
loadDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateLiveTimer(long time) {
|
||||
liveTimer = (int) time / (1000 * 60);
|
||||
/*TaskFragment fragment = (TaskFragment) ((AppCompatActivity) mContext).getSupportFragmentManager().findFragmentByTag("f0");
|
||||
if (fragment != null) {
|
||||
fragment.adapter.updateTimer(liveTimer);
|
||||
}*/
|
||||
}
|
||||
|
||||
public static class TaskFragment extends Fragment {
|
||||
private RecyclerView taskList;
|
||||
private LiveTaskRecyclerAdapter adapter;
|
||||
private int position;
|
||||
private int liveTimer;
|
||||
private String liveUid;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return new RecyclerView(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
this.position = getArguments().getInt("position", -1);
|
||||
this.liveTimer = getArguments().getInt("liveTimer", -1);
|
||||
this.liveUid = getArguments().getString("liveUid", "0");
|
||||
taskList = (RecyclerView) view;
|
||||
initTaskList();
|
||||
if (position == 2) {
|
||||
createTask(position);
|
||||
} else {
|
||||
update((LiveTaskModel) getArguments().getSerializable("data"), 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void initTaskList() {
|
||||
adapter = new LiveTaskRecyclerAdapter(getContext());
|
||||
taskList.setAdapter(adapter);
|
||||
taskList.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
|
||||
}
|
||||
|
||||
private void createTask(int type) {
|
||||
LiveNetManager.get(getContext())
|
||||
.getLiveTask(type, liveUid, new HttpCallback<LiveTaskModel>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(LiveTaskModel data) {
|
||||
Log.i("直播任务", "onSuccess: " + data);
|
||||
update(data, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("直播任务", "onError: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void update(LiveTaskModel data, int type) {
|
||||
LiveTaskModel.Task task = new LiveTaskModel.Task();
|
||||
LiveTaskModel.Task task2 = new LiveTaskModel.Task();
|
||||
if (type == 1) {
|
||||
task.setTaskName(WordUtil.getString(R.string.live_task_no1));
|
||||
task2.setTaskName(WordUtil.getString(R.string.live_task_no2));
|
||||
} else {
|
||||
task.setTaskName(WordUtil.getString(R.string.live_task_fans_no1));
|
||||
task2.setTaskName(WordUtil.getString(R.string.live_task_fans_no2));
|
||||
}
|
||||
task.setType(LiveTaskModel.TASK_TYPE_TIP);
|
||||
task2.setType(LiveTaskModel.TASK_TYPE_TIP);
|
||||
List<LiveTaskModel.Task> task1 = new ArrayList<>();
|
||||
task1.add(task);
|
||||
task1.addAll(data.getList().get(0));
|
||||
if (type == 1) {
|
||||
for (LiveTaskModel.Task tk : task1) {
|
||||
tk.setNowValue(liveTimer);
|
||||
}
|
||||
}
|
||||
task1.add(task2);
|
||||
task1.addAll(data.getList().get(1));
|
||||
adapter.setTasks(task1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.dialog.AbsDialogPopupWindow;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
public class LiveTaskInfoDialog extends AbsDialogPopupWindow {
|
||||
public LiveTaskInfoDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindLayoutId() {
|
||||
return R.layout.dialog_live_task_info;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
ImageView back = findViewById(R.id.live_task_info_back);
|
||||
back.setImageResource(R.mipmap.icon_back);
|
||||
back.setOnClickListener(v -> dismiss());
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -25,6 +26,7 @@ import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
@@ -38,6 +40,7 @@ import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
@@ -63,6 +66,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
|
||||
@@ -76,7 +80,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
private EditText mEditTitle;
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private File mAvatarFile;
|
||||
private TextView mLiveClass;
|
||||
private TextView mLiveClass, anchorAgreement;
|
||||
private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
|
||||
private TextView mLiveWishListTextView;//心愿单TextView
|
||||
private int mLiveClassID;//直播频道id
|
||||
@@ -88,9 +92,10 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
private LiveClassBean classBean;
|
||||
private FaceManager manager;
|
||||
private TextView faceTextView;//提示人脸未检测到的TextView
|
||||
private ImageView imgClarity;
|
||||
private ImageView imgClarity, selectorProtocol;
|
||||
private int selectClarity = 1;
|
||||
private LiveOpenCustomPopup liveOpenCustomPopup;
|
||||
private boolean selector = true;
|
||||
|
||||
public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
|
||||
super(context, parentView, liveSdk);
|
||||
@@ -112,7 +117,9 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
public void init() {
|
||||
mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
|
||||
imgClarity = (ImageView) findViewById(R.id.img_clarity);
|
||||
selectorProtocol = (ImageView) findViewById(R.id.selector_protocol);
|
||||
liveClarity = (TextView) findViewById(R.id.live_clarity);
|
||||
anchorAgreement = (TextView) findViewById(R.id.anchor_agreement);
|
||||
mRootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -121,6 +128,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
});
|
||||
|
||||
mAvatar = (ConstraintLayout) findViewById(R.id.avatar);
|
||||
mAvatar.setOnClickListener(this);
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
@@ -186,6 +194,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
findViewById(R.id.btn_start_live).setOnClickListener(this);
|
||||
findViewById(R.id.btn_wishlist).setOnClickListener(this);
|
||||
findViewById(R.id.btn_horizontally).setOnClickListener(this);
|
||||
findViewById(R.id.anchor_agreement_layout).setOnClickListener(this);
|
||||
|
||||
if (manager != null) {
|
||||
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
|
||||
@@ -271,6 +280,19 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
.asCustom(liveClarityCustomPopup)
|
||||
.show();
|
||||
});
|
||||
String keywordHtml2 = "</font><font color='#FF8D41'size='42px'>" + mContext.getString(R.string.anchor_hint) + "</font>";
|
||||
String contextHtml = "<font color='#ffffff'size='42px'>" + mContext.getString(R.string.anchor_agreement) + "</font>";
|
||||
anchorAgreement.setText(Html.fromHtml(contextHtml + keywordHtml2));
|
||||
selectorProtocol.setPressed(true);
|
||||
selectorProtocol.setSelected(true);
|
||||
selector = selectorProtocol.isSelected();
|
||||
selectorProtocol.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selector = !selector;
|
||||
selectorProtocol.setSelected(selector);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setSelectClarity(int selectClarity) {
|
||||
@@ -357,6 +379,10 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
} else if (i == R.id.btn_room_type) {
|
||||
chooseLiveType();
|
||||
} else if (i == R.id.btn_start_live) {
|
||||
if (!selector) {
|
||||
ToastUtil.show(R.string.anchor_agreement_hint);
|
||||
return;
|
||||
}
|
||||
if (mLiveClassID == 0) {
|
||||
ToastUtil.show(R.string.live_choose_live_class);
|
||||
return;
|
||||
@@ -524,6 +550,21 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new LiveRobotSettingCustomPopup(mContext))
|
||||
.show();
|
||||
} else if (i == R.id.anchor_agreement_layout) {
|
||||
String ct = Locale.getDefault().getLanguage();
|
||||
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
|
||||
StringBuffer url = new StringBuffer();
|
||||
url.append(CommonAppConfig.HOST);
|
||||
if (TextUtils.equals(ct, "zh")) {
|
||||
url.append("/index.php?g=portal&m=page&a=index&id=66");
|
||||
} else {
|
||||
url.append("/index.php?g=portal&m=page&a=index&id=67");
|
||||
}
|
||||
url.append("&uid=")
|
||||
.append(model.getId())
|
||||
.append("&token=")
|
||||
.append(model.getToken());
|
||||
RouteUtil.forwardLiveZhuangBanActivity(url.toString(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,9 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
super(context, parentView);
|
||||
|
||||
}
|
||||
public long getmAnchorLiveTime() {
|
||||
return mAnchorLiveTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
|
||||
Reference in New Issue
Block a user