diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java index 163370dab..778925c63 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java @@ -128,7 +128,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2; import com.yizhuan.xchat_android_core.im.game.ImGameInfo; import com.yizhuan.xchat_android_core.im.game.ImGameMode; -import com.yizhuan.xchat_android_core.initial.bean.BoxInfo; import com.yizhuan.xchat_android_core.magic.bean.MagicInfo; import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; @@ -1485,13 +1484,11 @@ public class HomePartyRoomFragment extends BaseMvpFragment { - if (hide != null && !hide) { - TreasureBoxActivity.start(getActivity()); - } else { - onClickBox(); - } - }); +// if (!GoldBoxHelper.isShowDiamondBox()) { +// TreasureBoxActivity.start(getActivity()); +// } else { + onClickBox(); +// } break; case R.id.iv_dragon_start_button: if (AvRoomDataManager.get().haveStartDragon) { @@ -1539,7 +1536,7 @@ public class HomePartyRoomFragment extends BaseMvpFragment { if (type == 0) {// 幸运许愿池(默认) TreasureBoxActivity.start(getActivity()); @@ -2588,18 +2585,17 @@ public class HomePartyRoomFragment extends BaseMvpFragment { if (hide != null && !hide) { @@ -2610,12 +2606,12 @@ public class HomePartyRoomFragment extends BaseMvpFragment { - GlideApp.with(BasicConfig.INSTANCE.getAppContext()) - .load(icon) + + GlideApp.with(BasicConfig.INSTANCE.getAppContext()) + .load(GoldBoxHelper.getBoxIcon()) .error(R.drawable.icon_room_treasure_box) .into(gameBinding.ivTreasureBox); - }); + } } else { gameBinding.ivTreasureBoxCp.setVisibility(View.GONE); diff --git a/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java b/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java index 26e149500..80ca4a823 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/presenter/AvRoomPresenter.java @@ -9,6 +9,7 @@ import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; +import com.coorchice.library.utils.LogUtils; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -66,6 +67,7 @@ import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack; import com.yizhuan.xchat_android_library.rxbus.RxBus; import com.yizhuan.xchat_android_library.threadmgr.ThreadPoolManager; import com.yizhuan.xchat_android_library.utils.ListUtils; +import com.yizhuan.xchat_android_library.utils.LogUtil; import org.greenrobot.eventbus.EventBus; @@ -133,6 +135,7 @@ public class AvRoomPresenter extends BaseMvpPresenter { } //我们自己服务端信息 AvRoomDataManager.get().mCurrentRoomInfo = roomInfo; + AvRoomDataManager.get().mBoxSwitchVo = roomInfo.boxSwitchVo; // 第一次进房,离开模式下更新本地房主位ui AvRoomDataManager.get().nick = roomInfo.getNick(); diff --git a/app/src/main/res/drawable/selector_choose_box_bg.xml b/app/src/main/res/drawable/selector_choose_box_bg.xml new file mode 100644 index 000000000..1ae6f0e6f --- /dev/null +++ b/app/src/main/res/drawable/selector_choose_box_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/fragment/ChooseTreasureBoxDialogFragment.java b/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/fragment/ChooseTreasureBoxDialogFragment.java index e41ba06ef..79abe3bf8 100644 --- a/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/fragment/ChooseTreasureBoxDialogFragment.java +++ b/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/fragment/ChooseTreasureBoxDialogFragment.java @@ -9,6 +9,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -16,6 +17,7 @@ import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.fragment.app.DialogFragment; +import com.coorchice.library.utils.LogUtils; import com.yizhuan.erban.R; import com.yizhuan.erban.ui.webview.DialogWebViewActivity; import com.yizhuan.treasure_box.bean.BoxOpenStatusInfo; @@ -24,6 +26,8 @@ import com.yizhuan.xchat_android_core.UriProvider; import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; import com.yizhuan.xchat_android_core.statistic.StatisticManager; import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol; +import com.yizhuan.xchat_android_library.utils.LogUtil; +import com.yizhuan.xchat_android_library.utils.TimeUtils; import io.reactivex.SingleObserver; import io.reactivex.disposables.Disposable; @@ -34,6 +38,16 @@ public class ChooseTreasureBoxDialogFragment extends DialogFragment implements V private OnTreasureBoxChooseListener onTreasureBoxChooseListener; + private TextView tvOpenTime; + + private String mOpenTime; + + private TextView mTvOpenHonour; + + public ChooseTreasureBoxDialogFragment(String openTime) { + this.mOpenTime = openTime; + } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -50,9 +64,25 @@ public class ChooseTreasureBoxDialogFragment extends DialogFragment implements V super.onViewCreated(view, savedInstanceState); clBoxNormal = view.findViewById(R.id.cl_box_normal); clBoxHonour = view.findViewById(R.id.cl_box_honour); + tvOpenTime = view.findViewById(R.id.tv_open_time); + mTvOpenHonour = view.findViewById(R.id.tv_open_honour); view.findViewById(R.id.iv_close).setOnClickListener(this); clBoxNormal.setOnClickListener(this); clBoxHonour.setOnClickListener(this); + tvOpenTime.setText("限时 "+ mOpenTime); + int currentTime = TimeUtils.getTime24(); + int startTime = Integer.parseInt(mOpenTime.substring(0,mOpenTime.indexOf("-")).replace(":","")); + int endTime = Integer.parseInt(mOpenTime.substring(mOpenTime.indexOf("-") + 1).replace(":","")); + LogUtils.e("startTime"+startTime); + LogUtils.e("endTime"+endTime); + LogUtils.e("当前小时"+TimeUtils.getTime24()); + LogUtils.e("范围:"+TimeUtils.getTimeLimit(17,59,13,20)); +// LogUtils.e("范围:"+TimeUtils.getTimeLimit()); + if (TimeUtils.getTimeLimit(10,10,18,20)){ + mTvOpenHonour.setEnabled(true); + }else { + mTvOpenHonour.setEnabled(false); + } view.findViewById(R.id.ll_get_key).setOnClickListener(v -> DialogWebViewActivity.start(getContext(), UriProvider.getBoxKey())); } diff --git a/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/widget/GoldBoxHelper.java b/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/widget/GoldBoxHelper.java index a3bf1775f..481b16922 100644 --- a/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/widget/GoldBoxHelper.java +++ b/app/src/module_treasure_box/java/com/yizhuan/erban/treasure_box/widget/GoldBoxHelper.java @@ -25,7 +25,7 @@ public class GoldBoxHelper { } if (myInfo != null && levelVo != null) { //1.审核模式 2.全局隐藏 3. 用户等级小于后台配置等级 都需要隐藏开箱子 - isHide = MarketVerifyModel.get().isMarketChecking() || !boxInfo.isOpenBoxSwitch() + isHide = MarketVerifyModel.get().isMarketChecking() || !AvRoomDataManager.get().mBoxSwitchVo.isOpenBoxSwitch() || levelVo.getExperLevelSeq() < boxInfo.getOpenBoxSwitchLevelNo() || AvRoomDataManager.get().isOpenPureMode(); } return Single.just(isHide); @@ -52,11 +52,16 @@ public class GoldBoxHelper { // }); // } - public static Single isShowDiamondBox() { - return InitialModel.get().getBoxInfo().flatMap(boxInfo -> Single.just(boxInfo.isDiamondBoxSwitch())); + public static boolean isShowDiamondBox() { + return AvRoomDataManager.get().mBoxSwitchVo.isDiamondBoxSwitch(); } - public static Single getBoxIcon() { - return InitialModel.get().getBoxInfo().flatMap(boxInfo -> Single.just(boxInfo.getOpenBoxIcon())); + public static String getBoxIcon() { + return AvRoomDataManager.get().mBoxSwitchVo.getOpenBoxIcon(); } + + public static String getBoxOpenTime(){ + return AvRoomDataManager.get().mBoxSwitchVo.getDiamondBoxOpenTime(); + } + } diff --git a/app/src/module_treasure_box/res/drawable-xhdpi/choose_box_bg_disable.png b/app/src/module_treasure_box/res/drawable-xhdpi/choose_box_bg_disable.png new file mode 100644 index 000000000..e93dcc06d Binary files /dev/null and b/app/src/module_treasure_box/res/drawable-xhdpi/choose_box_bg_disable.png differ diff --git a/app/src/module_treasure_box/res/layout/fragment_choose_treasure_box_dialog.xml b/app/src/module_treasure_box/res/layout/fragment_choose_treasure_box_dialog.xml index c7e9f7c56..3b67b378f 100644 --- a/app/src/module_treasure_box/res/layout/fragment_choose_treasure_box_dialog.xml +++ b/app/src/module_treasure_box/res/layout/fragment_choose_treasure_box_dialog.xml @@ -114,15 +114,28 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/iv_title_honour" /> + CREATOR = new Creator() { + @Override + public BoxSwitchVo createFromParcel(Parcel in) { + return new BoxSwitchVo(in); + } + + @Override + public BoxSwitchVo[] newArray(int size) { + return new BoxSwitchVo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + + @Override + public String toString() { + return "BoxInfo{" + + "openBoxSwitch=" + openBoxSwitch + + ", diamondBoxSwitch=" + diamondBoxSwitch + + ", openBoxIcon='" + openBoxIcon + '\'' + + ", diamondBoxOpenTime='" + diamondBoxOpenTime + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java index 2eeac115b..07310ae03 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java @@ -4,7 +4,6 @@ package com.yizhuan.xchat_android_core.room.bean; import android.os.Parcel; import android.os.Parcelable; -import com.yizhuan.xchat_android_core.initial.bean.BoxInfo; import com.yizhuan.xchat_android_core.room.game.GameInfo; import java.io.Serializable; @@ -91,7 +90,7 @@ public class RoomInfo implements Parcelable,Serializable { public GameInfo roomGame; - public BoxInfo boxSwitchVo; + public BoxSwitchVo boxSwitchVo; private String singingMusicName; // 限制类型 @@ -155,13 +154,11 @@ public class RoomInfo implements Parcelable,Serializable { // */ // private String badge; + @Override public String toString() { return "RoomInfo{" + "uid=" + uid + - "limitType=" + limitType + - "isOpengame=" + isOpenGame + - "roomGame=" + roomGame + ", officeUser=" + officeUser + ", roomId=" + roomId + ", title='" + title + '\'' + @@ -186,7 +183,11 @@ public class RoomInfo implements Parcelable,Serializable { ", background=" + background + ", hasKTVPriv=" + hasKTVPriv + ", isOpenKTV=" + isOpenKTV + + ", isOpenGame=" + isOpenGame + + ", roomGame=" + roomGame + + ", boxSwitchVo=" + boxSwitchVo + ", singingMusicName='" + singingMusicName + '\'' + + ", limitType='" + limitType + '\'' + ", roomModeType=" + roomModeType + ", isPermitRoom=" + isPermitRoom + ", showGiftValue=" + showGiftValue + @@ -229,6 +230,7 @@ public class RoomInfo implements Parcelable,Serializable { gender = in.readInt(); hideFlag = in.readInt(); closeScreenFlag = in.readInt(); + boxSwitchVo = in.readParcelable(BoxSwitchVo.class.getClassLoader()); } @Override @@ -265,6 +267,7 @@ public class RoomInfo implements Parcelable,Serializable { dest.writeString(nick); dest.writeInt(hideFlag); dest.writeInt(closeScreenFlag); + dest.writeParcelable(boxSwitchVo, flags); } @Override @@ -528,4 +531,7 @@ public class RoomInfo implements Parcelable,Serializable { '}'; } } + + + } diff --git a/library/src/main/java/com/yizhuan/xchat_android_library/utils/TimeUtils.java b/library/src/main/java/com/yizhuan/xchat_android_library/utils/TimeUtils.java index 3511faadf..728924794 100644 --- a/library/src/main/java/com/yizhuan/xchat_android_library/utils/TimeUtils.java +++ b/library/src/main/java/com/yizhuan/xchat_android_library/utils/TimeUtils.java @@ -10,8 +10,10 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.IllegalFormatException; import java.util.Locale; +import java.util.TimeZone; /** * Created by Zhanghuiping on 14/6/5. @@ -815,4 +817,68 @@ public class TimeUtils { return currYear == cacheYear; } + + + /** + * 获得系统时间 年、月、日、小时、分钟 + * @return HashMap + */ + public static int getTime24(){ + Calendar calendar=Calendar.getInstance(); + String hour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)); + String minute = String.valueOf(calendar.get(Calendar.MINUTE)); + return Integer.parseInt(hour +minute); + } + + public static boolean getTimeLimit(int start_hour,int start_minute,int end_hour,int end_minute) { + SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA); + SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA); + hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间 + mm.setTimeZone(TimeZone.getTimeZone("GMT+08")); + Date date = new Date(); + String hour = hh.format(date); + String minute = mm.format(date); + final int start = start_hour * start_minute;// 起始时间 8:00的分钟数 + final int end = end_hour * end_minute;// 结束时间 19:00的分钟数 + int minuteOfDay = Integer.parseInt(hour) * 60 + Integer.parseInt(minute); + Log.i("stf", "--hour:minute-->" + hour + ":" + minute); + LogUtil.print("start" +start); + LogUtil.print("end" +end); + LogUtil.print("minuteOfDay" +minuteOfDay); + if (minuteOfDay >= start && minuteOfDay <= end) { + LogUtil.print("工作时间内" + hour + ":" + minute); + return true; + } else { + if (start > end){ + if (minuteOfDay >= start || minuteOfDay <= end){ + return true; + } + } + LogUtil.print( "工作时间外" + hour + ":" + minute); + return false; + } + } + + + +// public static boolean getTimeLimit() { +// SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA); +// SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA); +// hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间 +// mm.setTimeZone(TimeZone.getTimeZone("GMT+08")); +// Date date = new Date(); +// String hour = hh.format(date); +// String minute = mm.format(date); +// final int start = 8 * 60;// 起始时间 8:00的分钟数 +// final int end = 19 * 60;// 结束时间 19:00的分钟数 +// int minuteOfDay = Integer.parseInt(hour) * 60 + Integer.parseInt(minute); +// Log.i("stf", "--hour:minute-->" + hour + ":" + minute); +// if (minuteOfDay >= start && minuteOfDay <= end) { +// LogUtil.print("工作时间内" + hour + ":" + minute); +// return true; +// } else { +// LogUtil.print( "工作时间外" + hour + ":" + minute); +// return false; +// } +// } }