@Override public void onClick(View v) { GiftInfo info = GiftInfoManager.getChoosedGiftInfo(); if (info != null) { if (fragment != null) { fragment.doSendGift(String.valueOf(info.id)); GiftInfoManager.reduceSpecialGift(info.id); refreshGiftState(); } } else { ToastUtil.showToast(mContext, "请选择要赠送的礼物"); } }
private void initUserPageSendGift(int index) { if (index == 0) { mGiftTip.setText(getContext().getString(R.string.send_gift_tip)); } else { int crownId = (Integer) (MemoryDataCenter.getInstance().get(MemoryDataCenter.CURRENT_COMPARE_CROWNID)); GiftInfo expensive = GiftInfoManager.getMostExpensiveCrown(); if (crownId == 0) { mGiftTip.setText(getContext().getString(R.string.to_send_crown)); } else if (expensive == null) { mGiftTip.setText(getContext().getString(R.string.send_huanguan_tip, "")); } else if (expensive.id == crownId) { mGiftTip.setText(getContext().getString(R.string.send_huanguan_most, expensive.name)); } else { mGiftTip.setText(getContext().getString(R.string.send_huanguan_tip, expensive.name)); } } }
public void renderView() { mGiftTip.setVisibility(View.INVISIBLE); mIndicator.setVisibility(View.GONE); mRadioGroup.setVisibility(View.INVISIBLE); mTxtSend.setVisibility(View.INVISIBLE); mLoading.setVisibility(View.VISIBLE); // SpecialGift[] specialGifts = (SpecialGift[]) // MemoryDataCenter.getInstance().get(MemoryDataCenter.SPECIALGIFTS); // if(GiftInfoManager.getInstance().initData()){ mGiftTip.setVisibility(View.VISIBLE); mRadioGroup.setVisibility(View.VISIBLE); mTxtSend.setVisibility(View.VISIBLE); mLoading.setVisibility(View.INVISIBLE); mGroupNames = GiftInfoManager.getGroupNames(); mAdapter = new GiftKeyBoardAdapter(mContext, mGroupNames, forChat); mViewPager.setAdapter(mAdapter); // 初始化 int firstPageCount = ((GiftKeyBoardAdapter) mAdapter).getFirstPageCount(); int secondPageCount = ((GiftKeyBoardAdapter) mAdapter).getSecondPageCount(); if (!forChat) { if (firstPageCount + secondPageCount > 1) { mIndicator.setVisibility(View.VISIBLE); mIndicator.setCount(firstPageCount + secondPageCount); mIndicator.setCurrentItem(0); } mIndicatorForChat.setVisibility(View.GONE); } else { mIndicator.setVisibility(View.GONE); if (firstPageCount + secondPageCount > 1) { mIndicatorForChat.setVisibility(View.VISIBLE); mIndicatorForChat.setCount(firstPageCount + secondPageCount); mIndicatorForChat.setCurrentItem(0); } } if (mGroupNames.length >= 2) { mRadioGroup.setVisibility(View.VISIBLE); mRadioGroup.removeAllViews(); rlp = new RadioGroup.LayoutParams(0, LayoutParams.MATCH_PARENT); rlp.weight = 1.0f; for (int i = 0; i < mGroupNames.length; i++) { RadioButton rb = (RadioButton) ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.view_item_radio_button, null); if (i == 0) { rb.setChecked(true); } rb.setId(i); rb.setText(mGroupNames[i]); mRadioGroup.addView(rb, rlp); rb.setOnClickListener(listener); } mRadioGroup.check(0); } // } if (forChat) { mGiftTip.setVisibility(View.GONE); mMarginLayout.setVisibility(View.GONE); mBottomLayout.setVisibility(View.GONE); } else { initUserPageSendGift(0); } }