diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 255462408..9924cf37a 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -338,4 +338,34 @@ public interface PDLiveApi { @Query("GroupId") String GroupId, @Query("stream") String stream ); + + /** + * 获取转盘整蛊列表 + */ + @GET("/api/public/?service=Prank.getAnchorPrankTurntable") + Observable>> getAnchorPrankTurntable( + @Query("anchor_id") String anchor_id + ); + /** + * 提交整蛊 + */ + @GET("/api/public/?service=Prank.setAnchorPrankTurntable") + Observable>> setAnchorPrankTurntable( + @Query("anchor_id") String anchor_id, + @Query("coin") String coin, + @Query("turntable_one") String turntable_one, + @Query("turntable_two") String turntable_two, + @Query("turntable_three") String turntable_three, + @Query("turntable_four") String turntable_four, + @Query("turntable_five") String turntable_five, + @Query("turntable_six") String turntable_six, + @Query("status") String status + ); + /** + * 转盘整蛊结束后调用的接口 + */ + @GET("/api/public/?service=Prank.endPrankTurntable") + Observable>> endPrankTurntable( + @Query("anchor_id") String anchor_id + ); } 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 e35962d1d..73411c166 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 @@ -33,6 +33,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; +import retrofit2.http.Query; /** @@ -501,6 +502,54 @@ public class LiveNetManager { }); } + public void getAnchorPrankTurntable(String mLiveUid, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getAnchorPrankTurntable(mLiveUid) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + + public void setAnchorPrankTurntable(String mLiveUid, String coin, + String turntable_one, + String turntable_two, + String turntable_three, + String turntable_four, + String turntable_five, + String turntable_six, + String status, + HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getAnchorPrankTurntable(mLiveUid) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/live/src/main/java/com/yunbao/live/adapter/LivePrankRecyclerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LivePrankRecyclerAdapter.java new file mode 100644 index 000000000..dd4fae038 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LivePrankRecyclerAdapter.java @@ -0,0 +1,99 @@ +package com.yunbao.live.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.live.R; +import com.yunbao.live.bean.PrankTurntableBean; + +import java.util.List; + +public class LivePrankRecyclerAdapter extends RecyclerView.Adapter { + private Context mContext; + private List list; + + public LivePrankRecyclerAdapter(Context mContext) { + this.mContext = mContext; + } + + public void setList(List list) { + this.list = list; + } + + @NonNull + @Override + public PrankRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new PrankRecyclerViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_live_prank_turntable_config, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull PrankRecyclerViewHolder holder, int position) { + holder.setDate(list.get(position)); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public static class PrankRecyclerViewHolder extends RecyclerView.ViewHolder { + private TextView title; + private TextView probability; + private EditText context; + + public PrankRecyclerViewHolder(@NonNull View itemView) { + super(itemView); + title = itemView.findViewById(R.id.prank_turntable_title); + probability = itemView.findViewById(R.id.prank_turntable_probability); + context = itemView.findViewById(R.id.prank_turntable_val); + } + + public void setDate(PrankTurntableBean bean) { + title.setText(getChineseNum(bean.getId())); + probability.setText(getProbability(bean.getId())); + context.setText(bean.getContext()); + } + + private String getChineseNum(int id) { + switch (id) { + case 1: + return "一"; + case 2: + return "二"; + case 3: + return "三"; + case 4: + return "四"; + case 5: + return "五"; + case 6: + return "六"; + } + return ""; + } + + private String getProbability(int id) { + switch (id) { + case 1: + return "抽取幾率:40%"; + case 2: + return "抽取幾率:30%"; + case 3: + return "抽取幾率:15%"; + case 4: + return "抽取幾率:10%"; + case 5: + return "抽取幾率:4%"; + default: + return "抽取幾率:1%"; + } + } + } +} diff --git a/live/src/main/java/com/yunbao/live/bean/PrankHttpTurntableBean.java b/live/src/main/java/com/yunbao/live/bean/PrankHttpTurntableBean.java new file mode 100644 index 000000000..23142068c --- /dev/null +++ b/live/src/main/java/com/yunbao/live/bean/PrankHttpTurntableBean.java @@ -0,0 +1,30 @@ +package com.yunbao.live.bean; + +import com.google.gson.annotations.SerializedName; +import com.yunbao.common.bean.BaseModel; + +public class PrankHttpTurntableBean extends BaseModel { + @SerializedName("id") + private int id; + @SerializedName("anchor_id") + private String anchor_id; + @SerializedName("coin") + private long coin; + @SerializedName("hope_coin") + private long hopeCoin; + @SerializedName("turntable_one") + private String turntable1; + @SerializedName("turntable_two") + private String turntable2; + @SerializedName("turntable_three") + private String turntable3; + @SerializedName("turntable_four") + private String turntable4; + @SerializedName("turntable_five") + private String turntable5; + @SerializedName("turntable_six") + private String turntable6; + @SerializedName("status") + private int status; + +} diff --git a/live/src/main/java/com/yunbao/live/bean/PrankTurntableBean.java b/live/src/main/java/com/yunbao/live/bean/PrankTurntableBean.java new file mode 100644 index 000000000..cb36417df --- /dev/null +++ b/live/src/main/java/com/yunbao/live/bean/PrankTurntableBean.java @@ -0,0 +1,24 @@ +package com.yunbao.live.bean; + +import com.yunbao.common.bean.BaseModel; + +public class PrankTurntableBean extends BaseModel { + private int id; + private String context; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java index 80fa313eb..d19d9e572 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java @@ -15,13 +15,15 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.tabs.TabLayout; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.live.R; +import com.yunbao.live.adapter.LivePrankRecyclerAdapter; -public class LivePrankDialogFragment extends AbsDialogFragment { +public class LivePrankDialogFragment extends AbsDialogFragment implements View.OnClickListener { private TabLayout mTabLayout; private View mTurntableConfigLayout; private ImageView mTurntableConfigImageView; private TextView mCoinTextView; private RecyclerView mPrankRecyclerView; + private LivePrankRecyclerAdapter recyclerAdapter; @Override protected int getLayoutId() { @@ -61,5 +63,15 @@ public class LivePrankDialogFragment extends AbsDialogFragment { mCoinTextView = (TextView) findViewById(R.id.switch2_btn); mPrankRecyclerView = (RecyclerView) findViewById(R.id.prank_config); mPrankRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)); + recyclerAdapter = new LivePrankRecyclerAdapter(mContext); + mPrankRecyclerView.setAdapter(recyclerAdapter); + } + private void initData(){ + + } + + @Override + public void onClick(View v) { + } } diff --git a/live/src/main/res/layout/item_live_prank_turntable_config.xml b/live/src/main/res/layout/item_live_prank_turntable_config.xml index b9982456e..39b41c8b1 100644 --- a/live/src/main/res/layout/item_live_prank_turntable_config.xml +++ b/live/src/main/res/layout/item_live_prank_turntable_config.xml @@ -39,6 +39,7 @@ android:textColor="#FFFFFF" android:textColorHint="#8C8C8C" android:textSize="10sp" + app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/prank_turntable_title" /> \ No newline at end of file