private void refreshIndicator(int pageNo) { int firstPageCount = ((GiftKeyBoardAdapter) mAdapter).getFirstPageCount(); // int secondPageCount = ((GiftKeyBoardAdapter)mAdapter).getSecondPageCount(); if (!forChat) { int index = 0; if (pageNo < firstPageCount) { index = 0; } else { index = 1; } if (index == 0) { mRadioGroup.check(0); } else { mRadioGroup.check(1); } mIndicator.setCurrentItem(pageNo); initUserPageSendGift(index); mIndicatorForChat.setVisibility(View.GONE); } else { mIndicatorForChat.setCurrentItem(pageNo); mIndicator.setVisibility(View.GONE); } }
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); } }