89 lines
2.6 KiB
Java
89 lines
2.6 KiB
Java
package com.yunbao.common.dialog;
|
||
|
||
import android.content.Context;
|
||
|
||
import androidx.annotation.NonNull;
|
||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||
import androidx.recyclerview.widget.RecyclerView;
|
||
|
||
import com.lxj.xpopup.core.BottomPopupView;
|
||
import com.yunbao.common.R;
|
||
import com.yunbao.common.adapter.LiveNewRolerPopupAdapter;
|
||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||
import com.yunbao.common.event.LiveNewRoleEvent;
|
||
import com.yunbao.common.http.live.LiveNetManager;
|
||
import com.yunbao.common.utils.Bus;
|
||
import com.yunbao.common.utils.ToastUtil;
|
||
import com.yunbao.common.utils.WordUtil;
|
||
|
||
import org.greenrobot.eventbus.Subscribe;
|
||
import org.greenrobot.eventbus.ThreadMode;
|
||
|
||
import java.util.List;
|
||
|
||
//游戏弹窗
|
||
public class LiveNewRolePopup extends BottomPopupView {
|
||
private boolean showRed = false;
|
||
|
||
public LiveNewRolePopup(@NonNull Context context, boolean showRed) {
|
||
super(context);
|
||
mContext = context;
|
||
this.showRed = showRed;
|
||
}
|
||
|
||
private RecyclerView drawerList;
|
||
private LiveNewRolerPopupAdapter adapter;
|
||
private Context mContext;
|
||
|
||
// 返回自定义弹窗的布局
|
||
@Override
|
||
protected int getImplLayoutId() {
|
||
return R.layout.dialog_live_new_role;
|
||
}
|
||
|
||
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||
@Override
|
||
protected void onCreate() {
|
||
super.onCreate();
|
||
Bus.getOn(this);
|
||
initView();
|
||
initDate();
|
||
|
||
}
|
||
|
||
private void initDate() {
|
||
LiveNetManager.get(mContext)
|
||
.getCustomSidebarInfo("1", new com.yunbao.common.http.base.HttpCallback<List<CustomSidebarInfoModel>>() {
|
||
@Override
|
||
public void onSuccess(List<CustomSidebarInfoModel> data) {
|
||
adapter.updateData(data);
|
||
}
|
||
|
||
@Override
|
||
public void onError(String error) {
|
||
ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
|
||
}
|
||
});
|
||
}
|
||
|
||
private void initView() {
|
||
drawerList = findViewById(R.id.drawerList);
|
||
adapter = new LiveNewRolerPopupAdapter(mContext, showRed);
|
||
drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||
drawerList.setAdapter(adapter);
|
||
}
|
||
|
||
@Override
|
||
protected void onDismiss() {
|
||
Bus.getOff(this);
|
||
|
||
super.onDismiss();
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onLiveNewRoleEvent(LiveNewRoleEvent event) {
|
||
dismiss();
|
||
}
|
||
|
||
}
|