直播间修改底部菜单修改
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package com.yunbao.common.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.ActiveModel;
|
||||
import com.yunbao.common.views.FunGamesViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FunGamesAdapter extends RecyclerView.Adapter {
|
||||
private List<ActiveModel> activeModels = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View funGameView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_fun_games, parent, false);
|
||||
return new FunGamesViewHolder(funGameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof FunGamesViewHolder) {
|
||||
FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder;
|
||||
funGamesViewHolder.showView(activeModels.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return activeModels.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据源
|
||||
*
|
||||
* @param mActiveModels
|
||||
*/
|
||||
public void addData(List<ActiveModel> mActiveModels) {
|
||||
activeModels.clear();
|
||||
activeModels.addAll(mActiveModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
72
common/src/main/java/com/yunbao/common/bean/ActiveModel.java
Normal file
72
common/src/main/java/com/yunbao/common/bean/ActiveModel.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 活动
|
||||
*/
|
||||
public class ActiveModel extends BaseModel {
|
||||
/**
|
||||
* active_id : 3
|
||||
* active_name : 闖關熱戀
|
||||
* active_img : https://qny.shayucm.com/chuangguan.png
|
||||
* active_src : h5/activity/PassionateLove/index.html
|
||||
* show_type : 0
|
||||
*/
|
||||
|
||||
@SerializedName("active_id")
|
||||
private String activeId = "";
|
||||
@SerializedName("active_name")
|
||||
private String activeName = "";
|
||||
@SerializedName("active_img")
|
||||
private String activeImg = "";
|
||||
@SerializedName("active_src")
|
||||
private String activeSrc = "";
|
||||
@SerializedName("show_type")
|
||||
private String showType = "";
|
||||
|
||||
public String getActiveId() {
|
||||
return activeId;
|
||||
}
|
||||
|
||||
public ActiveModel setActiveId(String activeId) {
|
||||
this.activeId = activeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActiveName() {
|
||||
return activeName;
|
||||
}
|
||||
|
||||
public ActiveModel setActiveName(String activeName) {
|
||||
this.activeName = activeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActiveImg() {
|
||||
return activeImg;
|
||||
}
|
||||
|
||||
public ActiveModel setActiveImg(String activeImg) {
|
||||
this.activeImg = activeImg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActiveSrc() {
|
||||
return activeSrc;
|
||||
}
|
||||
|
||||
public ActiveModel setActiveSrc(String activeSrc) {
|
||||
this.activeSrc = activeSrc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getShowType() {
|
||||
return showType;
|
||||
}
|
||||
|
||||
public ActiveModel setShowType(String showType) {
|
||||
this.showType = showType;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.FunGamesAdapter;
|
||||
import com.yunbao.common.bean.ActiveModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 直播间合计弹窗
|
||||
*/
|
||||
public class LiveTotalDialog extends AbsDialogFragment {
|
||||
private RecyclerView funGamesList;
|
||||
private FunGamesAdapter gamesAdapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_live_total;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDialogStyle() {
|
||||
return R.style.dialog2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canCancel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
funGamesList = (RecyclerView) findViewById(R.id.fun_games_list);
|
||||
gamesAdapter = new FunGamesAdapter();
|
||||
funGamesList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
funGamesList.setAdapter(gamesAdapter);
|
||||
LiveNetManager.get(getContext())
|
||||
.getActiveList(new HttpCallback<List<ActiveModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ActiveModel> data) {
|
||||
if (!isDetached())
|
||||
gamesAdapter.addData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setWindowAttributes(Window window) {
|
||||
window.setWindowAnimations(R.style.bottomToTopAnim);
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
params.gravity = Gravity.BOTTOM;
|
||||
window.setAttributes(params);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yunbao.common.http;
|
||||
|
||||
import com.yunbao.common.bean.ActiveModel;
|
||||
import com.yunbao.common.bean.AnchorRecommendModel;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.FaceBookUpModel;
|
||||
@@ -141,4 +142,10 @@ public interface PDLiveApi {
|
||||
Observable<ResponseModel<List<SlideInBannerModel>>> getHot(
|
||||
@Query("p") int page
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取活动
|
||||
*/
|
||||
@GET("/api/public/?service=Active.getActiveList")
|
||||
Observable<ResponseModel<List<ActiveModel>>> getActiveList();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.yunbao.common.http.live;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.yunbao.common.bean.ActiveModel;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.ResponseModel;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.List;
|
||||
@@ -136,4 +136,20 @@ public class LiveNetManager {
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动列表
|
||||
*/
|
||||
public void getActiveList(HttpCallback<List<ActiveModel>> callback) {
|
||||
API.get().pdLiveApi(mContext).getActiveList()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(listResponseModel -> {
|
||||
if (callback != null)
|
||||
callback.onSuccess(listResponseModel.getData().getInfo());
|
||||
}, throwable -> {
|
||||
if (callback != null)
|
||||
callback.onError(throwable.getMessage());
|
||||
}).isDisposed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.ActiveModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
public class FunGamesViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView funGamePic;
|
||||
private TextView funGameName;
|
||||
|
||||
public FunGamesViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
funGamePic = itemView.findViewById(R.id.fun_game_pic);
|
||||
funGameName = itemView.findViewById(R.id.fun_game_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据
|
||||
*
|
||||
* @param model 数据模型
|
||||
*/
|
||||
public void showView(ActiveModel model) {
|
||||
ImgLoader.display(itemView.getContext(), model.getActiveImg(), funGamePic);
|
||||
funGameName.setText(model.getActiveName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user