直播任务对接接口
This commit is contained in:
@@ -673,6 +673,7 @@ 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());
|
||||
@@ -938,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());
|
||||
|
||||
@@ -18,18 +18,19 @@ 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> tasks;
|
||||
private List<LiveTaskModel.Task> tasks = new ArrayList<>();
|
||||
|
||||
public LiveTaskRecyclerAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setTasks(List<LiveTaskModel> tasks) {
|
||||
public void setTasks(List<LiveTaskModel.Task> tasks) {
|
||||
this.tasks = tasks;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@@ -91,15 +92,26 @@ public class LiveTaskRecyclerAdapter extends RecyclerView.Adapter<LiveTaskRecycl
|
||||
}
|
||||
}
|
||||
|
||||
public void setDate(LiveTaskModel task) {
|
||||
title.setText(task.getTitle());
|
||||
public void setDate(LiveTaskModel.Task task) {
|
||||
title.setText(task.getTaskName());
|
||||
if (task.getType() == LiveTaskModel.TASK_TYPE_TIP) {
|
||||
return;
|
||||
}
|
||||
complete.setText(task.isComplete() ? R.string.live_task_item_complete_true : R.string.live_task_item_complete_false);
|
||||
complete.setBackgroundResource(task.isComplete() ? 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.getXp() + "</font>"));
|
||||
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>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
private boolean isPk;
|
||||
private TextView mLiveTimeTextView;//主播的直播时长
|
||||
|
||||
private String liveUid;
|
||||
|
||||
// boolean isRy = false;
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -86,6 +88,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
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);
|
||||
@@ -182,13 +185,18 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
|
||||
dismiss();
|
||||
} else if (id == R.id.anchor_task) {
|
||||
//主播任务
|
||||
new LiveTaskDialog(mContext).showDialog();
|
||||
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;
|
||||
|
||||
/**
|
||||
* 主播显示直播时间
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.yunbao.live.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;
|
||||
@@ -22,6 +23,9 @@ 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.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveTaskRecyclerAdapter;
|
||||
@@ -46,11 +50,12 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
|
||||
|
||||
private Context mContext;
|
||||
String liveUid;
|
||||
int liveTimer;
|
||||
|
||||
public LiveTaskDialog(Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,6 +74,9 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
initView();
|
||||
}
|
||||
|
||||
public void setLiveUid(String liveUid) {
|
||||
this.liveUid = liveUid;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
newStarTime = findViewById(R.id.task_new_star_time);
|
||||
@@ -77,11 +85,8 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
tipImg = findViewById(R.id.live_task_tip);
|
||||
tabLayout = findViewById(R.id.live_task_menu);
|
||||
viewPager = findViewById(R.id.live_task_viewpager);
|
||||
|
||||
newStarTime.setText("新秀主播時效截止至 2023/1/01 12:00");
|
||||
|
||||
initImgView();
|
||||
initTabLayout();
|
||||
createTask();
|
||||
|
||||
}
|
||||
|
||||
@@ -112,7 +117,9 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
public Fragment createFragment(int position) {
|
||||
TaskFragment fragment = new TaskFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("position", position);
|
||||
bundle.putInt("position", position + 1);
|
||||
bundle.putInt("liveTimer", liveTimer);
|
||||
bundle.putString("liveUid", liveUid);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
@@ -133,12 +140,47 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
mediator.attach();
|
||||
}
|
||||
|
||||
private void updateMainUi(LiveTaskModel.NewUser task) {
|
||||
if (task.isNew()) {
|
||||
newStarImg.setVisibility(VISIBLE);
|
||||
newStarTime.setVisibility(VISIBLE);
|
||||
newStarTime.setText(task.getEndTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createTask() {
|
||||
LiveNetManager.get(getContext())
|
||||
.getLiveTask(1, liveUid, new HttpCallback<LiveTaskModel>() {
|
||||
@Override
|
||||
public void onSuccess(LiveTaskModel data) {
|
||||
Log.i("直播任务", "onSuccess: " + data);
|
||||
updateMainUi(data.getUser());
|
||||
initTabLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("直播任务", "onError: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateLiveTimer(long time) {
|
||||
liveTimer = (int) ((time % (1000 * 60 * 60)) / (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 List<LiveTaskModel> tasks;
|
||||
private int position;
|
||||
private int liveTimer;
|
||||
private String liveUid;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -150,9 +192,11 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
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();
|
||||
createTask();
|
||||
createTask(position);
|
||||
}
|
||||
|
||||
private void initTaskList() {
|
||||
@@ -161,39 +205,45 @@ public class LiveTaskDialog extends AbsDialogPopupWindow {
|
||||
taskList.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
|
||||
}
|
||||
|
||||
private void createTask() {
|
||||
tasks = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
LiveTaskModel model = new LiveTaskModel();
|
||||
if (i == 0) {
|
||||
model.setType(LiveTaskModel.TASK_TYPE_TIP);
|
||||
model.setTitle(WordUtil.getString(R.string.live_task_no1));
|
||||
} else {
|
||||
model.setType(LiveTaskModel.TASK_TYPE_ITEM);
|
||||
model.setTitle("开播测试标题");
|
||||
}
|
||||
model.setTask(30);
|
||||
model.setXp(3000);
|
||||
model.setHot(5000);
|
||||
tasks.add(model);
|
||||
private void createTask(int type) {
|
||||
LiveNetManager.get(getContext())
|
||||
.getLiveTask(type, liveUid, new HttpCallback<LiveTaskModel>() {
|
||||
boolean debug = true;
|
||||
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
LiveTaskModel model = new LiveTaskModel();
|
||||
if (i == 0) {
|
||||
model.setType(LiveTaskModel.TASK_TYPE_TIP);
|
||||
model.setTitle(WordUtil.getString(R.string.live_task_no2));
|
||||
} else {
|
||||
model.setType(LiveTaskModel.TASK_TYPE_ITEM);
|
||||
model.setTitle("PK测试标题");
|
||||
}
|
||||
model.setTask(30);
|
||||
model.setXp(3000);
|
||||
model.setHot(5000);
|
||||
tasks.add(model);
|
||||
@Override
|
||||
public void onSuccess(LiveTaskModel data) {
|
||||
Log.i("直播任务", "onSuccess: " + data);
|
||||
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.get(1).setTaskNum(3);
|
||||
task1.get(1).setTaskName("*" + task1.get(1).getTaskName());
|
||||
}
|
||||
task1.add(task2);
|
||||
task1.addAll(data.getList().get(1));
|
||||
adapter.setTasks(task1);
|
||||
}
|
||||
|
||||
}
|
||||
adapter.setTasks(tasks);
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("直播任务", "onError: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@
|
||||
android:id="@+id/task_new_star_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -37,6 +38,7 @@
|
||||
android:layout_marginTop="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/task_new_star_time"
|
||||
@@ -78,6 +80,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/live_task_banner2"
|
||||
tools:srcCompat="@mipmap/icon_guize" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/live_task_viewpager"
|
||||
android:layout_width="0dp"
|
||||
@@ -85,7 +88,7 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/live_task_menu"/>
|
||||
app:layout_constraintTop_toBottomOf="@+id/live_task_menu" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -20,6 +20,8 @@
|
||||
<string name="live_mic_max">The number of voices has reached 3, and no more can be added.</string>
|
||||
<string name="live_task_no1">當日連續開播時長(分鐘)</string>
|
||||
<string name="live_task_no2">當日累計PK次數(不限模式)</string>
|
||||
<string name="live_task_fans_no1">當日累積新增關註粉絲</string>
|
||||
<string name="live_task_fans_no2">當日累積新增粉絲團成員</string>
|
||||
<string name="live_task_tab1">直播互動</string>
|
||||
<string name="live_task_tab2">粉絲增漲</string>
|
||||
<string name="live_task_info_title">主播任務特別說明</string>
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
<string name="free_pk_num_null" translatable="false">PK次數已用完</string>
|
||||
<string name="live_task_no1">當日連續開播時長(分鐘)</string>
|
||||
<string name="live_task_no2">當日累計PK次數(不限模式)</string>
|
||||
<string name="live_task_fans_no1">當日累積新增關註粉絲</string>
|
||||
<string name="live_task_fans_no2">當日累積新增粉絲團成員</string>
|
||||
<string name="live_task_tab1">直播互動</string>
|
||||
<string name="live_task_tab2">粉絲增漲</string>
|
||||
<string name="live_task_info_title">主播任務特別說明</string>
|
||||
|
||||
Reference in New Issue
Block a user