256 lines
7.4 KiB
Java
256 lines
7.4 KiB
Java
package com.xscm.modulemain.dialog;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.view.Gravity;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
|
|
|
import com.xscm.modulemain.R;
|
|
import com.xscm.modulemain.databinding.DialogRoomWheatGiftBinding;
|
|
import com.hjq.toast.ToastUtils;
|
|
import com.xscm.moduleutil.adapter.GiftTwoDetailsFragment;
|
|
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
|
import com.xscm.moduleutil.bean.GiftLabelBean;
|
|
import com.xscm.moduleutil.bean.GiftNumBean;
|
|
import com.xscm.moduleutil.bean.GiftPackBean;
|
|
import com.xscm.moduleutil.bean.GiftPackListCount;
|
|
import com.xscm.moduleutil.bean.RewardUserBean;
|
|
import com.xscm.moduleutil.bean.RoomWheatEvent;
|
|
import com.xscm.moduleutil.bean.RoonGiftModel;
|
|
import com.xscm.moduleutil.bean.WalletBean;
|
|
import com.xscm.moduleutil.bean.room.RoomAuction;
|
|
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
|
import com.xscm.moduleutil.event.GiftDoubleClickEvent;
|
|
import com.xscm.moduleutil.event.GiftUserRefreshEvent;
|
|
import com.xscm.moduleutil.event.RoomGiftGiveEvent;
|
|
import com.xscm.moduleutil.presenter.RewardGiftContacts;
|
|
import com.xscm.moduleutil.presenter.RewardGiftPresenter;
|
|
import com.xscm.moduleutil.utils.ColorManager;
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
*@author qx
|
|
*@data 2025/6/17
|
|
*@description: 设置插队礼物
|
|
*/
|
|
public class RoomWheatGiftSettingFragment extends BaseMvpDialogFragment<RewardGiftPresenter, DialogRoomWheatGiftBinding> implements RewardGiftContacts.View {
|
|
private RoonGiftModel roonGiftModel = null;
|
|
private List<Fragment> fragmentList = new ArrayList<>();
|
|
private List<GiftNumBean> mGiftNumList;
|
|
private String roomId;
|
|
|
|
@Override
|
|
protected RewardGiftPresenter bindPresenter() {
|
|
return new RewardGiftPresenter(this, getActivity());
|
|
}
|
|
|
|
public static void show(String id, FragmentManager fragmentManager) {
|
|
RoomWheatGiftSettingFragment dialogFragment = new RoomWheatGiftSettingFragment();
|
|
Bundle args = new Bundle();
|
|
args.putString("roomId", id); // 可选:传递参数
|
|
dialogFragment.setArguments(args);
|
|
dialogFragment.show(fragmentManager, "RewardGiftDialogFragment");
|
|
}
|
|
|
|
@Override
|
|
public void onAttach(@NonNull Context context) {
|
|
super.onAttach(context);
|
|
roomId = getArguments().getString("roomId");
|
|
}
|
|
|
|
@Override
|
|
protected void initDialogStyle(Window window) {
|
|
super.initDialogStyle(window);
|
|
window.setGravity(Gravity.BOTTOM);
|
|
}
|
|
|
|
@Override
|
|
public void onStart() {
|
|
super.onStart();
|
|
Window window = getDialog().getWindow();
|
|
if (window != null) {
|
|
// 设置固定高度为 500dp
|
|
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
|
int heightInDp = (int) (screenHeight * 0.5f);
|
|
;
|
|
// int heightInPx = (int) (heightInDp * getResources().getDisplayMetrics().density);
|
|
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, heightInDp);
|
|
|
|
// 可选:设置动画样式(从底部弹出)
|
|
window.setWindowAnimations(com.xscm.moduleutil.R.style.CommonShowDialogBottom);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void initData() {
|
|
// MvpPre.getGiftList("0",3);
|
|
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), fragmentList));
|
|
|
|
}
|
|
|
|
@Override
|
|
protected void initView() {
|
|
|
|
mBinding.tvWheatQx.setOnClickListener(this::onClisk);
|
|
mBinding.tvWheatQd.setOnClickListener(this::onClisk);
|
|
|
|
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvWheatQd, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
|
mBinding.tvWheatQd.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
|
}
|
|
|
|
private void onClisk(View view1) {
|
|
if (view1.getId() == R.id.tv_wheat_qd) {
|
|
giveGift("1");
|
|
} else if (view1.getId() == R.id.tv_wheat_qx) {
|
|
dismiss();
|
|
}
|
|
}
|
|
|
|
private String giftNumber = "";
|
|
private RoomGiftGiveEvent roomGiftGiveEvent;
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
public void onGiftDoubleClickEvent(GiftDoubleClickEvent event) {
|
|
getSelectedGift();
|
|
giveGift("1");
|
|
}
|
|
|
|
|
|
@Override
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
public void userRefresh(GiftUserRefreshEvent event) {
|
|
roonGiftModel = event.gift;
|
|
}
|
|
|
|
private int getSelectedGift() {
|
|
int currentItem = mBinding.viewPager.getCurrentItem();
|
|
GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem);
|
|
roonGiftModel = fragment.getGiftList();
|
|
return currentItem;
|
|
}
|
|
|
|
private void giveGift(String num) {
|
|
getSelectedGift();
|
|
int currentItem = mBinding.viewPager.getCurrentItem();
|
|
if (currentItem < 1) {
|
|
if (roonGiftModel == null) {
|
|
ToastUtils.show("请选择礼物");
|
|
return;
|
|
}
|
|
|
|
} else {
|
|
if (roonGiftModel == null) {
|
|
ToastUtils.show("请选择礼物");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (currentItem == 0) {
|
|
//礼物打赏
|
|
giftNumber = num;
|
|
MvpPre.setRoomApply(roomId, roonGiftModel.getGift_id(),roonGiftModel.getGift_price());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected int getLayoutId() {
|
|
return R.layout.dialog_room_wheat_gift;
|
|
}
|
|
|
|
@Override
|
|
public void getRewardList(List<RewardUserBean> rewardUserBeanList) {
|
|
}
|
|
|
|
@Override
|
|
public void getGiftLabel(List<GiftLabelBean> giftLabelBeans) {
|
|
}
|
|
|
|
@Override
|
|
public void setGiftList(List<RoonGiftModel> roonGiftModels, int type) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void giveGift() {
|
|
// dismiss();
|
|
}
|
|
|
|
@Override
|
|
public void wallet(WalletBean walletBean) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void reward_zone() {
|
|
EventBus.getDefault().post(new RoomWheatEvent());
|
|
dismiss();
|
|
}
|
|
|
|
@Override
|
|
public void roomAuctionJoin(RoomAuction.AuctionListBean auctionListBean) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void giftPack(List<GiftPackBean> giftPackBean) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void getGiftPack(String s) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void getGiftPackListCount(GiftPackListCount giftPackListCount) {
|
|
|
|
}
|
|
|
|
private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
|
|
|
private List<Fragment> fragmentList;
|
|
|
|
|
|
public MyFragmentPagerAdapter(FragmentManager fm, List<Fragment> fragmentList) {
|
|
super(fm);
|
|
this.fragmentList = fragmentList;
|
|
}
|
|
|
|
@Override
|
|
public Fragment getItem(int position) {
|
|
Fragment fragment = GiftTwoDetailsFragment.newInstance("1", 0,"");
|
|
fragmentList.add(fragment); // 保存 Fragment 实例
|
|
return fragment;
|
|
}
|
|
|
|
@Override
|
|
public int getCount() {
|
|
return 1;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public CharSequence getPageTitle(int position) {
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |