diff --git a/common/src/main/java/com/yunbao/common/adapter/SudGameSearchHistoryListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudGameSearchHistoryListAdapter.java new file mode 100644 index 000000000..dae3a224e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/SudGameSearchHistoryListAdapter.java @@ -0,0 +1,75 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +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.common.R; +import com.yunbao.common.interfaces.OnItemClickListener; + +import java.util.ArrayList; +import java.util.List; + +public class SudGameSearchHistoryListAdapter extends RecyclerView.Adapter { + private List mList; + private Context mContext; + private OnItemClickListener onItemClickListener; + + public SudGameSearchHistoryListAdapter(Context mContext) { + this.mContext = mContext; + mList = new ArrayList<>(); + } + + public void setList(List list) { + this.mList = list; + notifyDataSetChanged(); + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_search_history, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + holder.setData(mList.get(position)); + } + + @Override + public int getItemCount() { + return Math.min(mList.size(), 5); + } + + public List getList() { + return mList; + } + + public class ViewHolder extends RecyclerView.ViewHolder { + TextView nameView; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + nameView = itemView.findViewById(R.id.history); + + } + + public void setData(String name) { + nameView.setText(name); + nameView.setOnClickListener(v -> { + if(onItemClickListener!=null){ + onItemClickListener.onItemClick(name,0); + } + }); + } + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/SudGameSearchRoomListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudGameSearchRoomListAdapter.java new file mode 100644 index 000000000..eb595f474 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/SudGameSearchRoomListAdapter.java @@ -0,0 +1,34 @@ +package com.yunbao.common.adapter; + +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class SudGameSearchRoomListAdapter extends RecyclerView.Adapter { + + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return null; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + + } + + @Override + public int getItemCount() { + return 0; + } + + public class ViewHolder extends RecyclerView.ViewHolder{ + + public ViewHolder(@NonNull View itemView) { + super(itemView); + } + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java new file mode 100644 index 000000000..5b5f927a4 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java @@ -0,0 +1,47 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.SudRoomListModel; +import com.yunbao.common.views.SudGameListViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class SudHomeGameListAdapter extends RecyclerView.Adapter { + private Context mContext; + private List mList; + + public SudHomeGameListAdapter(Context mContext) { + this.mContext = mContext; + mList=new ArrayList<>(); + } + + public void setList(List mList) { + this.mList = mList; + notifyDataSetChanged(); + } + + @NonNull + @Override + public SudGameListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new SudGameListViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_home_sud_game_list, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull SudGameListViewHolder holder, int position) { + holder.setData(mList.get(position)); + } + + @Override + public int getItemCount() { + return mList.size(); + } + +} diff --git a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java index b143f7cc0..03d6da008 100644 --- a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java @@ -36,15 +36,24 @@ public class CreateSudGamePopup extends BottomPopupView { private EditText roomName, gameSill; private long interactionID = 0; private String id; + private boolean isHomeView; public CreateSudGamePopup(@NonNull Context context, List child) { super(context); customSidebarChildModels = child; } + public CreateSudGamePopup setHomeView(boolean homeView) { + isHomeView = homeView; + return this; + } + // 返回自定义弹窗的布局 @Override protected int getImplLayoutId() { + if (isHomeView) { + return R.layout.dialog_home_create_sud_game; + } return R.layout.dialog_create_sud_game; } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java index c61116fdb..7f0571bcb 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java @@ -1,7 +1,9 @@ package com.yunbao.common.dialog; import android.content.Context; +import android.content.DialogInterface; import android.text.TextUtils; +import android.widget.PopupMenu; import android.widget.TextView; import androidx.annotation.NonNull; @@ -35,6 +37,7 @@ public class SudGameListSelectPopup extends AttachPopupView { private SudTitleSelectAdapter sudTitleSelectAdapter; private long interactionID = 0; + private DialogInterface.OnDismissListener onDismissListener; private String mSill; public SudGameListSelectPopup(@NonNull Context context, int type, List child, long interactionID) { @@ -44,6 +47,11 @@ public class SudGameListSelectPopup extends AttachPopupView { this.interactionID = interactionID; } + public SudGameListSelectPopup setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { + this.onDismissListener = onDismissListener; + return this; + } + public SudGameListSelectPopup(@NonNull Context context, int mType, String sill) { super(context); this.mType = mType; @@ -161,4 +169,12 @@ public class SudGameListSelectPopup extends AttachPopupView { } }); } + + @Override + protected void onDismiss() { + super.onDismiss(); + if(onDismissListener!=null){ + onDismissListener.onDismiss(null); + } + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java new file mode 100644 index 000000000..c1ad7bd8e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java @@ -0,0 +1,180 @@ +package com.yunbao.common.dialog; + +import android.content.Context; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSONArray; +import com.lxj.xpopup.XPopup; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.CommonAppContext; +import com.yunbao.common.R; +import com.yunbao.common.adapter.SudGameListAdapter; +import com.yunbao.common.adapter.SudGameSearchHistoryListAdapter; +import com.yunbao.common.adapter.SudHomeGameListAdapter; +import com.yunbao.common.bean.CreateSudRoomModel; +import com.yunbao.common.bean.SudRoomListModel; +import com.yunbao.common.event.SudRoomListModelEvent; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.SpUtil; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.views.LiveSudGamePopup; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; + +public class SudGameSearchDialogPopup extends AbsDialogPopupWindow { + private static final String SP_HISTORY = "sud_game_search_history"; + private EditText editSearch; + private RecyclerView listHistory, listRoom; + private View history; + + private SudGameSearchHistoryListAdapter historyListAdapter; + private SudHomeGameListAdapter sudGameListAdapter; + + public SudGameSearchDialogPopup(@NonNull Context context) { + super(context); + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.moveUpToKeyboard(false); + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_home_search_sud_game; + } + + @Override + protected void onCreate() { + super.onCreate(); + editSearch = findViewById(R.id.edit_search); + listHistory = findViewById(R.id.list_history); + listRoom = findViewById(R.id.list_room); + history = findViewById(R.id.layout_history); + findViewById(R.id.layout_history_empty).setVisibility(GONE); + + GridLayoutManager manager = (GridLayoutManager) listHistory.getLayoutManager(); + if (manager != null) { + manager.setReverseLayout(true); + } + + historyListAdapter = new SudGameSearchHistoryListAdapter(mContext); + sudGameListAdapter = new SudHomeGameListAdapter(mContext); + historyListAdapter.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(String bean, int position) { + editSearch.setText(bean); + } + }); + listRoom.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.VERTICAL,false)); + listRoom.setAdapter(sudGameListAdapter); + listHistory.setAdapter(historyListAdapter); + initHistoryData(); + switchList(true); + + editSearch.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + String value = s.toString(); + if (!StringUtil.isEmpty(value)) { + search(value); + } else { + switchList(true); + } + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + } + + private void initHistoryData() { + String value = SpUtil.getStringValue(SP_HISTORY); + List historyList = new ArrayList<>(); + if (!StringUtil.isEmpty(value)) { + historyList = JSONArray.parseArray(value, String.class); + } + historyListAdapter.setList(historyList); + } + + private void search(String value) { + LiveNetManager.get(mContext) + .searchRoomList("0", "0,0", "0", value, 0, new HttpCallback>() { + @Override + public void onSuccess(List data) { + switchList(false); + sudGameListAdapter.setList(data); + } + + @Override + public void onError(String error) { + + } + }); + } + + private void switchList(boolean isHistory) { + if (isHistory) { + history.setVisibility(VISIBLE); + listRoom.setVisibility(GONE); + } else { + listRoom.setVisibility(VISIBLE); + history.setVisibility(GONE); + } + } + + @Override + protected void onDismiss() { + super.onDismiss(); + String value = editSearch.getText().toString(); + if (!StringUtil.isEmpty(value)) { + List list = historyListAdapter.getList(); + if (list.size() >= 5) { + list.remove(0); + } + list.add(value); + SpUtil.setStringValue(SP_HISTORY, JSONArray.toJSONString(list)); + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameListEvent(SudRoomListModelEvent event) { + CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel(); + createSudRoomModel.setSudGameId(event.getModel().getSudGameId()); + createSudRoomModel.setSudGameRoomId(event.getModel().getSudGameRoomId()); + createSudRoomModel.setAvatar(event.getModel().getAvatar()); + createSudRoomModel.setRoomName(event.getModel().getRoomName()); + createSudRoomModel.setSudGameName(event.getModel().getSudGameName()); + new XPopup.Builder(getContext()) + .enableDrag(false) + .dismissOnTouchOutside(false) + .dismissOnBackPressed(false) + .asCustom(new LiveSudGamePopup(getContext(), createSudRoomModel)) + .show(); + dialog.dismiss(); + } +} 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 10a7ec9c9..5257a3bf2 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1004,6 +1004,19 @@ public interface PDLiveApi { @Query("liveuid") String liveUid, @Query("page") int page ); + /** + * 获取游戏房列表 - 搜索 + * + */ + @GET("/api/public/?service=Sudgameserver.getRoomList") + Observable>> searchRoomList( + @Query("sud_game_id") String sudGameId, + @Query("threshold") String threshold, + @Query("room_holder_type") String roomHolderType, + @Query("liveuid") String liveUid, + @Query("search") String search, + @Query("page") int page + ); } 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 d6b338e12..6434bfb3a 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 @@ -2261,6 +2261,28 @@ public class LiveNetManager { } }).isDisposed(); } + public void searchRoomList(String sudGameId, String threshold, String roomHolderType, String search, int page, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .searchRoomList(sudGameId,threshold,roomHolderType,"0",search,page) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } /** * 直播间取消网络请求 diff --git a/common/src/main/res/drawable/bg_home_search_input.xml b/common/src/main/res/drawable/bg_home_search_input.xml new file mode 100644 index 000000000..b4b9326fb --- /dev/null +++ b/common/src/main/res/drawable/bg_home_search_input.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_home_search_not.xml b/common/src/main/res/drawable/bg_home_search_not.xml new file mode 100644 index 000000000..cfea71ab5 --- /dev/null +++ b/common/src/main/res/drawable/bg_home_search_not.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_home_sud_list_btn.xml b/common/src/main/res/drawable/bg_home_sud_list_btn.xml new file mode 100644 index 000000000..1a215bf24 --- /dev/null +++ b/common/src/main/res/drawable/bg_home_sud_list_btn.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_home_sud_list_sill.xml b/common/src/main/res/drawable/bg_home_sud_list_sill.xml new file mode 100644 index 000000000..89348f16a --- /dev/null +++ b/common/src/main/res/drawable/bg_home_sud_list_sill.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_item_search_history.xml b/common/src/main/res/drawable/bg_item_search_history.xml new file mode 100644 index 000000000..db8fdd66e --- /dev/null +++ b/common/src/main/res/drawable/bg_item_search_history.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_live_sud_list_input_home.xml b/common/src/main/res/drawable/bg_live_sud_list_input_home.xml new file mode 100644 index 000000000..e5080b3ae --- /dev/null +++ b/common/src/main/res/drawable/bg_live_sud_list_input_home.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_home_create_sud_game.xml b/common/src/main/res/layout/dialog_home_create_sud_game.xml new file mode 100644 index 000000000..0142ad6d5 --- /dev/null +++ b/common/src/main/res/layout/dialog_home_create_sud_game.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_home_search_sud_game.xml b/common/src/main/res/layout/dialog_home_search_sud_game.xml new file mode 100644 index 000000000..248c65025 --- /dev/null +++ b/common/src/main/res/layout/dialog_home_search_sud_game.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_home_sud_game_list.xml b/common/src/main/res/layout/item_home_sud_game_list.xml new file mode 100644 index 000000000..78cb44d55 --- /dev/null +++ b/common/src/main/res/layout/item_home_sud_game_list.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_search_history.xml b/common/src/main/res/layout/item_search_history.xml new file mode 100644 index 000000000..218e8c74e --- /dev/null +++ b/common/src/main/res/layout/item_search_history.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/background_home_sud_game_list.png b/common/src/main/res/mipmap-xxhdpi/background_home_sud_game_list.png new file mode 100644 index 000000000..7bafd8d60 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/background_home_sud_game_list.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_home_game_search.png b/common/src/main/res/mipmap-xxhdpi/ic_home_game_search.png new file mode 100644 index 000000000..2486b2100 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_home_game_search.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_add.png b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_add.png new file mode 100644 index 000000000..4bc72ab6c Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_add.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_arrow.png b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_arrow.png new file mode 100644 index 000000000..6edb5affb Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_arrow.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_ranking.png b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_ranking.png new file mode 100644 index 000000000..8db6a0922 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_ranking.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_search.png b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_search.png new file mode 100644 index 000000000..9132e40f6 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_home_interactive_game_search.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/bg_main_home_sub_game.png b/common/src/main/res/mipmap-xxxhdpi/bg_main_home_sub_game.png new file mode 100644 index 000000000..8a126df5c Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/bg_main_home_sub_game.png differ diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index fc726adaf..f1ed036e2 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -1211,7 +1211,7 @@ Limited ride And limited avatar frame None Return to account Popularity Red packet - Red packets + Game Popular red packets amount Diamonds diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index f3721d6bd..e1348b3b2 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1206,7 +1206,7 @@ 退回賬戶 攢人氣紅包 - 紅包專區 + 遊戲專區 攢人氣紅包 金額 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index d3839869a..6fab24f5e 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1205,7 +1205,7 @@ 退回賬戶 攢人氣紅包 - 紅包專區 + 遊戲專區 攢人氣紅包 金額 @@ -1313,4 +1313,5 @@ 主播: 是否使用試用劵 使用鑽石 + 搜索房間 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 7808238ad..4fc1ae04f 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1206,7 +1206,7 @@ 退回賬戶 攢人氣紅包 - 紅包專區 + 遊戲專區 攢人氣紅包 價值 去充值> diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 728b2f78b..11fa8cf6c 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1212,7 +1212,7 @@ Limited ride And limited avatar frame None Return to account Popularity Red packet - Red packets + Game Popular red packets amount Diamonds @@ -1344,4 +1344,7 @@ Limited ride And limited avatar frame 玩家 %s人組隊中,一起來玩吧 %s人在綫 + 搜索房間 + 搜索历史 + 請輸入您要搜索的房主昵稱、房主ID或房間名 diff --git a/config.gradle b/config.gradle index 70d7f4fb4..83b9f5375 100644 --- a/config.gradle +++ b/config.gradle @@ -26,5 +26,6 @@ ext { //是否上报异常日志 isUploadLog : true, //是否打包成插件包模式 - isPluginModel : true, ] + isPluginModel : true, + ] } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java new file mode 100644 index 000000000..67f45b39c --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java @@ -0,0 +1,334 @@ +package com.yunbao.main.views; + +import android.animation.ObjectAnimator; +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.graphics.Outline; +import android.graphics.drawable.Drawable; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewOutlineProvider; +import android.view.animation.LinearInterpolator; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.GlideException; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.target.DrawableImageViewTarget; +import com.bumptech.glide.request.target.Target; +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.enums.PopupPosition; +import com.ms.banner.Banner; +import com.ms.banner.listener.OnBannerClickListener; +import com.umeng.analytics.MobclickAgent; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.activity.WebViewActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.BannerBean; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.LiveClassBean; +import com.yunbao.common.bean.WeekListBean; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.dialog.CreateSudGamePopup; +import com.yunbao.common.dialog.SudGameListSelectPopup; +import com.yunbao.common.dialog.SudGameSearchDialogPopup; +import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.event.RoomHolderTypeEvent; +import com.yunbao.common.event.SudGameListEvent; +import com.yunbao.common.event.SudGameListSillEvent; +import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.LiveClassManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.LiveRoomCheckLivePresenter; +import com.yunbao.common.utils.MicStatusManager; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.CustomViewHolder; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.utils.LiveStorge; +import com.yunbao.live.views.LiveRoomViewHolder; +import com.yunbao.main.R; +import com.yunbao.main.activity.MainActivity; +import com.yunbao.main.adapter.MainHomeLiveAdapter; +import com.yunbao.main.adapter.MainHomeLivesClassAdapter; +import com.yunbao.main.http.MainHttpConsts; +import com.yunbao.main.http.MainHttpUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by cxf on 2018/9/22. + * MainActivity 首页 游戏 + */ + +public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { + + private CommonRefreshView mRefreshView; + private ImageView roomGameArrow, roomSillArrow, houseOwnerArrow; + private TextView gameTitle, sillTitle, houseOwnerTitle; + private long interactionID = 0; + private List customSidebarChildModels = new ArrayList<>(); + private String mSill = "0,0", mSillName, roomHolderType = "0", roomHolderTypeName; + private long animDuration = 500; + private String id = "0"; + + public MainHomeGameViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + Bus.getOn(this); + } + + @Override + protected int getLayoutId() { + return R.layout.view_main_home_sud_game_list; + } + + + @Override + public void init() { + + initData(); + roomGameArrow = (ImageView) findViewById(R.id.room_game_arrow); + roomSillArrow = (ImageView) findViewById(R.id.room_sill_arrow); + houseOwnerArrow = (ImageView) findViewById(R.id.house_owner_arrow); + gameTitle = (TextView) findViewById(R.id.game_title); + sillTitle = (TextView) findViewById(R.id.room_sill_text); + houseOwnerTitle = (TextView) findViewById(R.id.house_owner_text); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_room_game), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 0f, 90f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.interactive_game_room_game)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(mContext, 0, customSidebarChildModels, interactionID) + .setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + closeAnimSudGameListEvent(); + } + }) + ) + .show(); + + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.room_sill), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomSillArrow, "rotation", 0f, 90f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.room_sill)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(mContext, 1, mSillName).setOnDismissListener(dialog -> { + closeAnimSudGameListSillEvent(); + })) + .show(); + + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.house_owner), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 0f, 90f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.house_owner)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(mContext, 2, roomHolderTypeName).setOnDismissListener(dialog -> { + closeAnimRoomHolderTypeEvent(); + })) + .show(); + + + } + }); + + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_add), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new XPopup.Builder(mContext) + .enableDrag(false) + .asCustom(new CreateSudGamePopup(mContext, customSidebarChildModels).setHomeView(true)) + + .show(); + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.search), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new SudGameSearchDialogPopup(mContext).showDialog(); + } + }); + + LiveNetManager.get(mContext) + .getCustomSidebarInfo("1", new HttpCallback>() { + @Override + public void onSuccess(List data) { + for (CustomSidebarInfoModel datum : data) { + if (datum.getType().equals("6")) { + customSidebarChildModels = datum.getChild(); + return; + } + } + } + + @Override + public void onError(String error) { + + } + }); + } + + private void initData() { + + } + + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameListEvent(SudGameListEvent event) { + interactionID = event.getInteractionID(); + gameTitle.setText(event.getTitle().substring(0, 2)); + id = event.getId(); + initData(); + closeAnimSudGameListEvent(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameListSillEvent(SudGameListSillEvent event) { + mSill = event.getSill(); + mSillName = event.getSillName(); + if (TextUtils.equals("0,0", mSill)) { + sillTitle.setText(mSillName); + } else { + sillTitle.setText(mSillName.substring(0, mSillName.length() - 2)); + } + closeAnimSudGameListSillEvent(); + initData(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onRoomHolderTypeEvent(RoomHolderTypeEvent event) { + roomHolderType = event.getRoomHolderType(); + roomHolderTypeName = event.getRoomHolderTypeName(); + houseOwnerTitle.setText(roomHolderTypeName); + initData(); + closeAnimRoomHolderTypeEvent(); + } + + private void closeAnimSudGameListEvent() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 90f, 0f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + } + + private void closeAnimSudGameListSillEvent() { + ObjectAnimator backAnimator = ObjectAnimator.ofFloat(roomSillArrow, "rotation", 90f, 0f); + backAnimator.setDuration(animDuration); + backAnimator.setInterpolator(new LinearInterpolator()); + backAnimator.start(); + } + + private void closeAnimRoomHolderTypeEvent() { + ObjectAnimator backAnimator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 90f, 0f); + backAnimator.setDuration(animDuration); + backAnimator.setInterpolator(new LinearInterpolator()); + backAnimator.start(); + } + + + @Override + public void onItemClick(LiveBean bean, int position) { + + } + + + @Override + public void loadData() { + + } + + @Override + public void release() { + Bus.getOff(this); + } + + @Override + public void onDestroy() { + super.onDestroy(); + release(); + } + + //显示顶部商城tab时,显示底部tabGroup + @Subscribe(threadMode = ThreadMode.MAIN) + public void onUpdata(String str) { + if ("Updata".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + mRefreshView.mRecyclerView.scrollToPosition(0); + } + } else if ("blacklist".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + } + } + } + + @Override + public void onResume() { + super.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + } +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index c96c1f535..5b9027da2 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -18,7 +18,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { private MainHomeFollLiveViewHolder mainHomeFollLiveViewHolder; private MainHomeLiveViewHolder mainHomeLiveViewHolder; private MainHomeRecomLiveViewHolder mainHomeRecomLiveViewHolder; - private MainHomeRedPacketLiveViewHolder mainHomeRedPacketLiveViewHolder; + private MainHomeGameViewHolder mainHomeGameLiveViewHolder; private final String mPageName = "home_page"; private ImageView img_trophy; @@ -85,8 +85,8 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { vh = mainHomeRecomLiveViewHolder; } else if (position == 3) { - mainHomeRedPacketLiveViewHolder = new MainHomeRedPacketLiveViewHolder(mContext, parent); - vh = mainHomeRedPacketLiveViewHolder; + mainHomeGameLiveViewHolder = new MainHomeGameViewHolder(mContext, parent); + vh = mainHomeGameLiveViewHolder; } diff --git a/main/src/main/res/layout/view_main_home_sud_game_list.xml b/main/src/main/res/layout/view_main_home_sud_game_list.xml new file mode 100644 index 000000000..87a6e9a7e --- /dev/null +++ b/main/src/main/res/layout/view_main_home_sud_game_list.xml @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +