diff --git a/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java index 027340dd4..09ab3af55 100644 --- a/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java @@ -1,6 +1,8 @@ package com.yunbao.common.adapter; +import android.annotation.SuppressLint; import android.content.Context; +import android.graphics.drawable.Drawable; import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -8,29 +10,43 @@ import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.R; import com.yunbao.common.bean.SudRoomListModel; -import com.yunbao.common.views.SudGameListViewHolder; +import com.yunbao.common.views.NewSudGameListViewHolder; public class SudGameListAdapter extends RefreshAdapter { private boolean isHome = false; + private final Drawable[] bgList = new Drawable[6]; + + @SuppressLint("UseCompatLoadingForDrawables") public SudGameListAdapter(Context context, boolean isHome) { super(context); this.isHome = isHome; + + bgList[0] = mContext.getDrawable(R.drawable.grid_item_bg_1); + bgList[1] = mContext.getDrawable(R.drawable.grid_item_bg_2); + bgList[2] = mContext.getDrawable(R.drawable.grid_item_bg_3); + bgList[3] = mContext.getDrawable(R.drawable.grid_item_bg_4); + bgList[4] = mContext.getDrawable(R.drawable.grid_item_bg_5); + bgList[5] = mContext.getDrawable(R.drawable.grid_item_bg_6); } @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - if (isHome){ + /*if (isHome){ return new SudGameListViewHolder(mInflater.inflate(R.layout.item_home_sud_game_list, parent, false)); }else { return new SudGameListViewHolder(mInflater.inflate(R.layout.item_sud_game_list, parent, false)); - } + }*/ + + return new NewSudGameListViewHolder(mInflater.inflate(R.layout.item_new_game_room, parent, false)); + } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - SudGameListViewHolder sudGameListViewHolder = (SudGameListViewHolder) holder; + NewSudGameListViewHolder sudGameListViewHolder = (NewSudGameListViewHolder) holder; + sudGameListViewHolder.itemView.setBackground(bgList[position % 6]); sudGameListViewHolder.setData(mList.get(position),isHome); } } diff --git a/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java b/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java index ca6cab442..d30f2bf20 100644 --- a/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java +++ b/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java @@ -36,6 +36,16 @@ public class CustomSidebarChildModel extends BaseModel { private String isShow; @SerializedName("sud_game_is_new") private String sudGameIsNew; + @SerializedName("is_click") + private boolean isClick; + + public boolean isClick() { + return isClick; + } + + public void setClick(boolean click) { + isClick = click; + } public String getSudGameIsNew() { return sudGameIsNew; diff --git a/common/src/main/java/com/yunbao/common/custom/CommonRefreshView.java b/common/src/main/java/com/yunbao/common/custom/CommonRefreshView.java index 4da3fbca8..613b793aa 100644 --- a/common/src/main/java/com/yunbao/common/custom/CommonRefreshView.java +++ b/common/src/main/java/com/yunbao/common/custom/CommonRefreshView.java @@ -412,6 +412,10 @@ public class CommonRefreshView extends FrameLayout implements View.OnClickListen } } + public void addItemDecoration(RecyclerView.ItemDecoration gridSpacingItemDecoration) { + mRecyclerView.addItemDecoration(gridSpacingItemDecoration); + } + public interface DataHelperNew { void loadData(int p); diff --git a/common/src/main/java/com/yunbao/common/views/NewSudGameListViewHolder.java b/common/src/main/java/com/yunbao/common/views/NewSudGameListViewHolder.java new file mode 100644 index 000000000..ef1c5b301 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/NewSudGameListViewHolder.java @@ -0,0 +1,239 @@ +package com.yunbao.common.views; + +import android.app.Dialog; +import android.os.Handler; +import android.text.TextUtils; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSON; +import com.google.gson.Gson; +import com.lxj.xpopup.XPopup; +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.R; +import com.yunbao.common.bean.CreateSudRoomModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.SudGameScoreBean; +import com.yunbao.common.bean.SudRoomListModel; +import com.yunbao.common.event.LiveOpenSudRoomEvent; +import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; +import com.yunbao.common.event.SudGameListDissMissEvent; +import com.yunbao.common.event.SudGameListRefreshEvent; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.RandomSudGameManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.LiveRoomCheckLivePresenter; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import java.util.Locale; + +public class NewSudGameListViewHolder extends RecyclerView.ViewHolder { + private RoundedImageView mAvatar; + private TextView roomName, playerWeAre, playerWeAre2, goldenBeanNumber; + private ImageView sex, gold_coin; + + public NewSudGameListViewHolder(@NonNull View itemView) { + super(itemView); + mAvatar = itemView.findViewById(R.id.avatar); + roomName = itemView.findViewById(R.id.room_name); + playerWeAre = itemView.findViewById(R.id.player_we_are); + playerWeAre2 = itemView.findViewById(R.id.player_we_are_2); + + goldenBeanNumber = itemView.findViewById(R.id.golden_bean_number); + + gold_coin = itemView.findViewById(R.id.gold_coin); + sex = itemView.findViewById(R.id.sex); + + } + + public void setData(SudRoomListModel model, boolean isHome) { + ImgLoader.display(itemView.getContext(), model.getAvatar(), mAvatar); + roomName.setText(model.getRoomName()); + playerWeAre.setText(String.format(itemView.getContext().getString(R.string.interactive_game_player_we_are_4), model.getPlayerTotal())); + playerWeAre2.setText(String.format(itemView.getContext().getString(R.string.interactive_game_player_we_are_3), model.getTotal())); + goldenBeanNumber.setText(model.getGoldenBeanNumber()); + if (TextUtils.equals(model.getSex(), "1")) { + ImgLoader.display(itemView.getContext(), R.mipmap.man, sex); + } else if (TextUtils.equals(model.getSex(), "2")) { + ImgLoader.display(itemView.getContext(), R.mipmap.girl, sex); + } + if (TextUtils.equals(model.getCurrencyType(), "2")) { + ImgLoader.display(itemView.getContext(), R.mipmap.icon_collectibles, gold_coin); + } else { + ImgLoader.display(itemView.getContext(), R.mipmap.gold_coin, gold_coin); + } + ViewClicksAntiShake.clicksAntiShake(itemView, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + LiveNetManager.get(itemView.getContext()).checkRoomStatus(model.getId(), new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(CreateSudRoomModel data) { + if (TextUtils.equals(data.getRoomStatus(), "0")) { + if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("房间不存在"); + } else { + ToastUtil.show("The room does not exist"); + } + Bus.get().post(new SudGameListRefreshEvent()); + } else { + if (TextUtils.equals(model.getIsActivity(), "1")) { + LiveNetManager.get(mAvatar.getContext()) + .getScore(model.getSudGameRoomId(), new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(SudGameScoreBean data) { + if(data.getGolden_bean_remaining_balance()!=1){ + RandomSudGameManager.getManager().showNotActivityTicketDialog(itemView.getContext(), true, new DialogUitl.SimpleCallback2() { + @Override + public void onCancelClick() { + + } + + @Override + public void onConfirmClick(Dialog dialog, String content) { + toGame(model, isHome, true); + } + }); + return; + } + toGame(model, isHome, true); + } + + @Override + public void onError(String error) { + + } + }); + } else { + toGame(model, isHome, false); + } + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + + + } + }); + } + + private void toGame(SudRoomListModel model, boolean isHome,boolean isActivity) { + + + CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel(); + createSudRoomModel.setSudGameId(model.getSudGameId()); + createSudRoomModel.setSudGameRoomId(model.getSudGameRoomId()); + createSudRoomModel.setAvatar(model.getAvatar()); + createSudRoomModel.setRoomName(model.getRoomName()); + createSudRoomModel.setSudGameName(model.getSudGameName()); + if (isHome) { + if (TextUtils.equals(model.getLiveUid(), "0")) { + if (CommonAppConfig.getInstance().getConfig().isSw()) { + RouteUtil.forwardSwSudGameActivity(new Gson().toJson(createSudRoomModel), isActivity,false, isHome); + } else { + RouteUtil.forwardRySudGameActivity(new Gson().toJson(createSudRoomModel), true, isHome); + } + } else { + String yes = "是"; + if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + yes = "是"; + } else { + yes = "Yes"; + } + new XPopup.Builder(itemView.getContext()) + .asCustom(new HintCustomPopup(itemView.getContext(), + itemView.getContext().getString(R.string.interactive_game_search_room_currently_live), + itemView.getContext().getString(R.string.interactive_game_search_room_broadcast_room)) + .setLiveOpenOk(yes) + .setLiveOpenCancel(itemView.getContext().getString(R.string.interactive_game_search_room_bhe_game)) + .setCallBack(new HintCustomPopup.HintCustomCallBack() { + @Override + public void onSure() { + LiveHttpUtil.getLiveInfo(model.getLiveUid() + "", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + @Override + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw); + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + LiveNetManager.get(mAvatar.getContext()) + .getScore(model.getSudGameRoomId(), new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(SudGameScoreBean data) { + if(data.getGolden_bean_remaining_balance()!=1){ + RandomSudGameManager.getManager().showNotActivityTicketDialog(itemView.getContext(), true, new DialogUitl.SimpleCallback2() { + @Override + public void onCancelClick() { + + } + + @Override + public void onConfirmClick(Dialog dialog, String content) { + Bus.get().post(new LiveOpenSudRoomEvent().setActivity(isActivity).setCreateSudRoomModel(createSudRoomModel)); + } + }); + return; + } + Bus.get().post(new LiveOpenSudRoomEvent().setActivity(isActivity).setCreateSudRoomModel(createSudRoomModel)); + } + + @Override + public void onError(String error) { + + } + }); + } + }, 1500); + } + + @Override + public void onCheckError(String contextError) { + + } + }); + } else { + RouteUtil.forwardUserHome(itemView.getContext(), model.getLiveUid(), 0); + } + } + }); + } + + @Override + public void onCancel() { + if (CommonAppConfig.getInstance().getConfig().isSw()) { + RouteUtil.forwardSwSudGameActivity(new Gson().toJson(createSudRoomModel), isActivity,false, isHome); + } else { + RouteUtil.forwardRySudGameActivity(new Gson().toJson(createSudRoomModel), true, isHome); + } + } + })).show(); + + } + + } else { + Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setActivityGame(isActivity).setCreateSudRoomModel(createSudRoomModel)); + Bus.get().post(new SudGameListDissMissEvent()); + } + } +} diff --git a/common/src/main/res/drawable/grid_item_bg_1.xml b/common/src/main/res/drawable/grid_item_bg_1.xml new file mode 100644 index 000000000..d7cfcdf10 --- /dev/null +++ b/common/src/main/res/drawable/grid_item_bg_1.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/grid_item_bg_2.xml b/common/src/main/res/drawable/grid_item_bg_2.xml new file mode 100644 index 000000000..b53d6fe99 --- /dev/null +++ b/common/src/main/res/drawable/grid_item_bg_2.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/grid_item_bg_3.xml b/common/src/main/res/drawable/grid_item_bg_3.xml new file mode 100644 index 000000000..52fae2082 --- /dev/null +++ b/common/src/main/res/drawable/grid_item_bg_3.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/grid_item_bg_4.xml b/common/src/main/res/drawable/grid_item_bg_4.xml new file mode 100644 index 000000000..e466115d2 --- /dev/null +++ b/common/src/main/res/drawable/grid_item_bg_4.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/grid_item_bg_5.xml b/common/src/main/res/drawable/grid_item_bg_5.xml new file mode 100644 index 000000000..5fbe3f5e6 --- /dev/null +++ b/common/src/main/res/drawable/grid_item_bg_5.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/grid_item_bg_6.xml b/common/src/main/res/drawable/grid_item_bg_6.xml new file mode 100644 index 000000000..046ad052d --- /dev/null +++ b/common/src/main/res/drawable/grid_item_bg_6.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/white_alpa_shape.xml b/common/src/main/res/drawable/white_alpa_shape.xml new file mode 100644 index 000000000..fba9c9756 --- /dev/null +++ b/common/src/main/res/drawable/white_alpa_shape.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_new_game_room.xml b/common/src/main/res/layout/item_new_game_room.xml new file mode 100644 index 000000000..4b5e4c0ea --- /dev/null +++ b/common/src/main/res/layout/item_new_game_room.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxxhdpi/girl.webp b/common/src/main/res/mipmap-xxxhdpi/girl.webp new file mode 100644 index 000000000..6550cac47 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/girl.webp differ diff --git a/common/src/main/res/mipmap-xxxhdpi/image.webp b/common/src/main/res/mipmap-xxxhdpi/image.webp new file mode 100644 index 000000000..875f53fa7 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/image.webp differ diff --git a/common/src/main/res/mipmap-xxxhdpi/man.webp b/common/src/main/res/mipmap-xxxhdpi/man.webp new file mode 100644 index 000000000..31407ee89 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/man.webp differ diff --git a/common/src/main/res/mipmap-xxxhdpi/people.webp b/common/src/main/res/mipmap-xxxhdpi/people.webp new file mode 100644 index 000000000..27921cb64 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/people.webp differ diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index e325ac19b..f7667fcef 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1319,6 +1319,7 @@ 確定添加 互動遊戲 房間列表 + 娛樂遊戲 游戲: 所有 門檻: @@ -1339,7 +1340,9 @@ 5K以上金豆 玩家 %s人組隊中,一起來玩吧 + %s 正在遊戲 %s人在綫 + 在線人數%s人,快加入吧 搜索房間 搜索历史 請輸入您要搜索的房主昵稱、房主ID或房間名 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 07a65815f..28142c211 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1326,6 +1326,7 @@ Add Interactive Games Room list + Recreation Game Game: All Threshold: @@ -1346,7 +1347,9 @@ Above 5K beans User In a team of %s people, let\'s play together~ + %s Be playing %s people online + There are %s people online. Join us Search for room Search History Search for room: Please enter the owner\'s name, owner ID, or room name you want to search for. diff --git a/main/src/main/java/com/yunbao/main/adapter/NewGameRoomTopAdapter.java b/main/src/main/java/com/yunbao/main/adapter/NewGameRoomTopAdapter.java new file mode 100644 index 000000000..74215fee3 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/NewGameRoomTopAdapter.java @@ -0,0 +1,136 @@ +package com.yunbao.main.adapter; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.Glide; +import com.yunbao.common.bean.BattlePassPoints; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.main.R; + +import java.util.ArrayList; +import java.util.List; + +public class NewGameRoomTopAdapter extends RecyclerView.Adapter { + private final Context mContext; + private List customSidebarChildModels = new ArrayList<>(); + + OnItemClickListener onItemClickListener; + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + public NewGameRoomTopAdapter(Context mContext) { + this.mContext = mContext; + } + + @SuppressLint("NotifyDataSetChanged") + public void setList(List mList) { + if (mList == null) { + return; + } + this.customSidebarChildModels.clear(); + this.customSidebarChildModels.addAll(mList); + + CustomSidebarChildModel allBean = new CustomSidebarChildModel(); + allBean.setId("0"); + allBean.setClick(true); + + this.customSidebarChildModels.add(0,allBean); + notifyDataSetChanged(); + } + + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + if (viewType == 0) { + return new NewGameRoomTopNormalViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_game_room_type_1, parent, false)); + } else { + return new NewGameRoomTopSelectedViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_game_room_type_2, parent, false)); + + } + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + CustomSidebarChildModel data = this.customSidebarChildModels.get(position); + if (holder instanceof NewGameRoomTopNormalViewHolder) { + if (position == 0) { + ((NewGameRoomTopNormalViewHolder) holder).itemName.setText(mContext.getString(com.yunbao.common.R.string.interactive_game_room_all)); + Glide.with(mContext).load(R.mipmap.game).into(((NewGameRoomTopNormalViewHolder) holder).itemImage); + } else { + ((NewGameRoomTopNormalViewHolder) holder).itemName.setText(data.getTitle()); + Glide.with(mContext).load(data.getIcon()).into(((NewGameRoomTopNormalViewHolder) holder).itemImage); + } + + } else if (holder instanceof NewGameRoomTopSelectedViewHolder) { + if (position == 0) { + ((NewGameRoomTopSelectedViewHolder) holder).itemName.setText(mContext.getString(com.yunbao.common.R.string.interactive_game_room_all)); + Glide.with(mContext).load(R.mipmap.game).into(((NewGameRoomTopSelectedViewHolder) holder).itemImage); + } else { + ((NewGameRoomTopSelectedViewHolder) holder).itemName.setText(data.getTitle()); + Glide.with(mContext).load(data.getIcon()).into(((NewGameRoomTopSelectedViewHolder) holder).itemImage); + } + } + + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int currentPosition = holder.getAdapterPosition(); + for (int i = 0; i < customSidebarChildModels.size(); i++) { + customSidebarChildModels.get(i).setClick(i == currentPosition); + notifyDataSetChanged(); + } + + onItemClickListener.onItemClick(data,currentPosition); + } + }); + + } + + @Override + public int getItemCount() { + return customSidebarChildModels.size(); + } + + @Override + public int getItemViewType(int position) { + if (this.customSidebarChildModels.get(position).isClick()) { + return 1; + } + return 0; + } +} + +class NewGameRoomTopNormalViewHolder extends RecyclerView.ViewHolder { + ImageView itemImage; + TextView itemName; + + public NewGameRoomTopNormalViewHolder(@NonNull View itemView) { + super(itemView); + itemImage = itemView.findViewById(R.id.item_image); + itemName = itemView.findViewById(R.id.item_name); + } +} + +class NewGameRoomTopSelectedViewHolder extends RecyclerView.ViewHolder { + ImageView itemImage; + TextView itemName; + + public NewGameRoomTopSelectedViewHolder(@NonNull View itemView) { + super(itemView); + itemImage = itemView.findViewById(R.id.item_image); + itemName = itemView.findViewById(R.id.item_name); + } +} diff --git a/main/src/main/java/com/yunbao/main/views/GridSpacingItemDecoration.java b/main/src/main/java/com/yunbao/main/views/GridSpacingItemDecoration.java new file mode 100644 index 000000000..337c25ceb --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/GridSpacingItemDecoration.java @@ -0,0 +1,42 @@ +package com.yunbao.main.views; + +import android.graphics.Rect; +import android.view.View; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration { + + private final int spanCount; + private final int spacing; + private final boolean includeEdge; + + public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) { + this.spanCount = spanCount; + this.spacing = spacing; + this.includeEdge = includeEdge; + } + + @Override + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { + int position = parent.getChildAdapterPosition(view); // item position + int column = position % spanCount; // item column + + if (includeEdge) { + outRect.left = spacing - column * spacing / spanCount; + outRect.right = (column + 1) * spacing / spanCount; + + if (position < spanCount) { // top edge + outRect.top = spacing; + } + outRect.bottom = spacing; // item bottom + } else { + outRect.left = column * spacing / spanCount; + outRect.right = spacing - (column + 1) * spacing / spanCount; + + if (position >= spanCount) { + outRect.top = spacing; // item top + } + } + } +} \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java index 605e2e89f..b26147dd8 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java @@ -11,7 +11,9 @@ import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.TextView; +import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.google.gson.Gson; import com.lxj.xpopup.XPopup; @@ -46,6 +48,9 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.LiveSudGameHistoryPopup; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; +import com.yunbao.main.adapter.NewGameRoomTopAdapter; + +import net.lucode.hackware.magicindicator.buildins.UIUtil; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -62,8 +67,8 @@ import java.util.Locale; public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { private CommonRefreshView mRefreshView; - private ImageView roomGameArrow, roomSillArrow, houseOwnerArrow; - private TextView gameTitle, sillTitle, houseOwnerTitle; + private ImageView roomSillArrow, houseOwnerArrow; + private TextView sillTitle, houseOwnerTitle; private long interactionID = 0; private List customSidebarChildModels = new ArrayList<>(); private String mSill = "0,0,0", mSillName, roomHolderType = "0", roomHolderTypeName; @@ -71,6 +76,9 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement private String id = "0"; private SudGameListAdapter sudGameListAdapter; private AbsActivity context; + private RecyclerView topRecyclerView; + private NewGameRoomTopAdapter newGameRoomTopAdapter; + public MainHomeGameViewHolder(AbsActivity context, ViewGroup parentView) { super(context, parentView); @@ -80,7 +88,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement @Override protected int getLayoutId() { - return R.layout.view_main_home_sud_game_list; + return R.layout.new_gram_room; } @@ -91,14 +99,30 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement mSill = "0,0,0"; roomHolderType = "0"; id = "0"; - roomGameArrow = (ImageView) findViewById(R.id.room_game_arrow); + + topRecyclerView = (RecyclerView) findViewById(R.id.game_type_recyclerview); + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); + linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); + topRecyclerView.setLayoutManager(linearLayoutManager); + newGameRoomTopAdapter = new NewGameRoomTopAdapter(mContext); + topRecyclerView.setAdapter(newGameRoomTopAdapter); + newGameRoomTopAdapter.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(CustomSidebarChildModel bean, int position) { + id = bean.getId(); + mRefreshView.initData(); + } + }); + 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); mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView); - mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + mRefreshView.setLayoutManager(new GridLayoutManager(mContext, 2)); + int dip2px = UIUtil.dip2px(mContext, 10); + mRefreshView.addItemDecoration(new GridSpacingItemDecoration(2, dip2px, false)); + sudGameListAdapter = new SudGameListAdapter(mContext, true); mRefreshView.setLoadMoreEnable(true); mRefreshView.setRecyclerViewAdapter(sudGameListAdapter); @@ -150,7 +174,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement }); mRefreshView.initData(); mRefreshView.setEmptyLayoutId(R.layout.sud_no_data); - ViewClicksAntiShake.clicksAntiShake(findViewById(com.yunbao.common.R.id.random_start), new ViewClicksAntiShake.ViewClicksCallBack() { + /* ViewClicksAntiShake.clicksAntiShake(findViewById(com.yunbao.common.R.id.random_start), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { LiveNetManager.get(mContext) @@ -198,8 +222,8 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement } - }); - ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_room_game), new ViewClicksAntiShake.ViewClicksCallBack() { + });*/ + /* ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_room_game), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 0f, 90f); @@ -223,7 +247,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement } - }); + });*/ ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.room_sill), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { @@ -298,6 +322,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement for (CustomSidebarInfoModel datum : data) { if (datum.getType().equals("6")) { customSidebarChildModels = datum.getChild(); + newGameRoomTopAdapter.setList(customSidebarChildModels); return; } } @@ -308,7 +333,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement } }); - ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_rule), new ViewClicksAntiShake.ViewClicksCallBack() { + /* ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_rule), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { new XPopup.Builder(mContext) @@ -316,7 +341,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement .maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34)) .asCustom(new SudGameRulePopup(mContext)).show(); } - }); + });*/ } private void initData() { @@ -324,28 +349,6 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement } - @Subscribe(threadMode = ThreadMode.MAIN) - public void onSudGameListEvent(SudGameListEvent event) { - interactionID = event.getInteractionID(); - if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - gameTitle.setText(event.getTitle()); - } else { - if (event.getTitle().contains("All")) { - gameTitle.setText("All"); - } else { - if ((event.getTitle().length() > 6)) { - gameTitle.setText(event.getTitle()); - } else { - gameTitle.setText(event.getTitle()); - } - - } - } - - id = event.getId(); - mRefreshView.initData(); - closeAnimSudGameListEvent(); - } @Subscribe(threadMode = ThreadMode.MAIN) public void onSudGameListSillEvent(SudGameListSillEvent event) { @@ -369,12 +372,6 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement 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); diff --git a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java index d70964312..470212fca 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMeViewHolder.java @@ -403,6 +403,15 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi case 17: RouteUtil.forwardActivity(RouteUtil.PATH_FEEDBACK_ACTIVITY); break; + + case 100: + // 精彩短劇 + + break; + case 101: + // 消息中心 + + break; } } else { //21 在线客服 diff --git a/main/src/main/res/drawable/white_alpa_shape.xml b/main/src/main/res/drawable/white_alpa_shape.xml new file mode 100644 index 000000000..fba9c9756 --- /dev/null +++ b/main/src/main/res/drawable/white_alpa_shape.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/item_game_room_type_1.xml b/main/src/main/res/layout/item_game_room_type_1.xml new file mode 100644 index 000000000..a990ca1dd --- /dev/null +++ b/main/src/main/res/layout/item_game_room_type_1.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + diff --git a/main/src/main/res/layout/item_game_room_type_2.xml b/main/src/main/res/layout/item_game_room_type_2.xml new file mode 100644 index 000000000..f5770328a --- /dev/null +++ b/main/src/main/res/layout/item_game_room_type_2.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/item_new_game_room.xml b/main/src/main/res/layout/item_new_game_room.xml new file mode 100644 index 000000000..a0bc25112 --- /dev/null +++ b/main/src/main/res/layout/item_new_game_room.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/new_gram_room.xml b/main/src/main/res/layout/new_gram_room.xml index 8b4848512..462dbc2f4 100644 --- a/main/src/main/res/layout/new_gram_room.xml +++ b/main/src/main/res/layout/new_gram_room.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="240dp" android:scaleType="fitXY" - android:src="@mipmap/bg1" + android:src="@mipmap/bg" app:layout_constraintTop_toTopOf="parent" tools:ignore="ContentDescription" /> @@ -21,7 +21,7 @@ android:layout_height="wrap_content" android:layout_marginStart="17dp" android:layout_marginTop="52dp" - android:text="@string/interactive_game_room_list" + android:text="@string/interactive_game_room_list_new" android:textColor="#000" android:textSize="19sp" app:layout_constraintStart_toStartOf="parent" @@ -168,9 +168,13 @@ android:layout_marginTop="15dp" android:id="@+id/refreshView" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_marginStart="15dp" + android:layout_marginEnd="15dp" + android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/select_game_type" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"/> + \ No newline at end of file diff --git a/main/src/main/res/layout/view_main_encourage.xml b/main/src/main/res/layout/view_main_encourage.xml index 7a7ab6015..70431ca2b 100644 --- a/main/src/main/res/layout/view_main_encourage.xml +++ b/main/src/main/res/layout/view_main_encourage.xml @@ -4,6 +4,7 @@ android:layout_height="match_parent"> + + \ No newline at end of file diff --git a/main/src/main/res/mipmap-xxxhdpi/bg.webp b/main/src/main/res/mipmap-xxxhdpi/bg.webp new file mode 100644 index 000000000..b41896abe Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/bg.webp differ diff --git a/main/src/main/res/mipmap-xxxhdpi/game.webp b/main/src/main/res/mipmap-xxxhdpi/game.webp new file mode 100644 index 000000000..a4269b4b1 Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/game.webp differ diff --git a/main/src/main/res/mipmap-xxxhdpi/girl.webp b/main/src/main/res/mipmap-xxxhdpi/girl.webp new file mode 100644 index 000000000..6550cac47 Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/girl.webp differ diff --git a/main/src/main/res/mipmap-xxxhdpi/man.webp b/main/src/main/res/mipmap-xxxhdpi/man.webp new file mode 100644 index 000000000..31407ee89 Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/man.webp differ