private void configMinimizedViewLayoutParams(LoopMeBannerView bannerView) {
   LayoutParams lp = (LayoutParams) bannerView.getLayoutParams();
   lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
   lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
   lp.bottomMargin = mMinimizedMode.getMarginBottom();
   lp.rightMargin = mMinimizedMode.getMarginRight();
   bannerView.setLayoutParams(lp);
 }
Пример #2
0
  /** @Description 初始化界面控件 有点庞大 todo */
  private void initView() {
    // 绑定布局资源(注意放所有资源初始化之前)
    LayoutInflater.from(this).inflate(R.layout.tt_activity_message, topContentView);

    // TOP_CONTENT_VIEW
    setLeftButton(R.drawable.tt_top_back);
    setLeftText(getResources().getString(R.string.top_left_back));
    setRightButton(R.drawable.tt_top_right_group_manager);
    topLeftBtn.setOnClickListener(this);
    letTitleTxt.setOnClickListener(this);
    topRightBtn.setOnClickListener(this);

    // 列表控件(开源PTR)
    lvPTR = (PullToRefreshListView) this.findViewById(R.id.message_list);
    textView_new_msg_tip = (TextView) findViewById(R.id.tt_new_msg_tip);
    lvPTR
        .getRefreshableView()
        .addHeaderView(
            LayoutInflater.from(this)
                .inflate(R.layout.tt_messagelist_header, lvPTR.getRefreshableView(), false));
    Drawable loadingDrawable = getResources().getDrawable(R.drawable.pull_to_refresh_indicator);
    final int indicatorWidth =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 29, getResources().getDisplayMetrics());
    loadingDrawable.setBounds(new Rect(0, indicatorWidth, 0, indicatorWidth));
    lvPTR.getLoadingLayoutProxy().setLoadingDrawable(loadingDrawable);
    lvPTR.getRefreshableView().setCacheColorHint(Color.WHITE);
    lvPTR.getRefreshableView().setSelector(new ColorDrawable(Color.WHITE));
    lvPTR.getRefreshableView().setOnTouchListener(lvPTROnTouchListener);
    adapter = new MessageAdapter(this);
    lvPTR.setAdapter(adapter);
    lvPTR.setOnRefreshListener(this);
    lvPTR.setOnScrollListener(
        new PauseOnScrollListener(ImageLoader.getInstance(), true, true) {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            switch (scrollState) {
              case AbsListView.OnScrollListener.SCROLL_STATE_IDLE:
                if (view.getLastVisiblePosition() == (view.getCount() - 1)) {
                  textView_new_msg_tip.setVisibility(View.GONE);
                }
                break;
            }
          }
        });
    textView_new_msg_tip.setOnClickListener(this);

    // 界面底部输入框布局
    sendBtn = (TextView) this.findViewById(R.id.send_message_btn);
    recordAudioBtn = (Button) this.findViewById(R.id.record_voice_btn);
    audioInputImg = (ImageView) this.findViewById(R.id.voice_btn);
    messageEdt = (CustomEditView) this.findViewById(R.id.message_text);
    RelativeLayout.LayoutParams messageEdtParam = (LayoutParams) messageEdt.getLayoutParams();
    messageEdtParam.addRule(RelativeLayout.LEFT_OF, R.id.show_emo_btn);
    messageEdtParam.addRule(RelativeLayout.RIGHT_OF, R.id.voice_btn);
    keyboardInputImg = (ImageView) this.findViewById(R.id.show_keyboard_btn);
    addPhotoBtn = (ImageView) this.findViewById(R.id.show_add_photo_btn);
    addEmoBtn = (ImageView) this.findViewById(R.id.show_emo_btn);
    messageEdt.setOnFocusChangeListener(msgEditOnFocusChangeListener);
    messageEdt.setOnClickListener(this);
    messageEdt.addTextChangedListener(this);
    addPhotoBtn.setOnClickListener(this);
    addEmoBtn.setOnClickListener(this);
    keyboardInputImg.setOnClickListener(this);
    audioInputImg.setOnClickListener(this);
    recordAudioBtn.setOnTouchListener(this);
    sendBtn.setOnClickListener(this);
    initSoundVolumeDlg();

    // OTHER_PANEL_VIEW
    addOthersPanelView = findViewById(R.id.add_others_panel);
    LayoutParams params = (LayoutParams) addOthersPanelView.getLayoutParams();
    if (keyboardHeight > 0) {
      params.height = keyboardHeight;
      addOthersPanelView.setLayoutParams(params);
    }
    View takePhotoBtn = findViewById(R.id.take_photo_btn);
    View takeCameraBtn = findViewById(R.id.take_camera_btn);
    takePhotoBtn.setOnClickListener(this);
    takeCameraBtn.setOnClickListener(this);

    // EMO_LAYOUT
    emoLayout = (LinearLayout) findViewById(R.id.emo_layout);
    LayoutParams paramEmoLayout = (LayoutParams) emoLayout.getLayoutParams();
    if (keyboardHeight > 0) {
      paramEmoLayout.height = keyboardHeight;
      emoLayout.setLayoutParams(paramEmoLayout);
    }
    emoGridView = (EmoGridView) findViewById(R.id.emo_gridview);
    yayaEmoGridView = (YayaEmoGridView) findViewById(R.id.yaya_emo_gridview);
    emoRadioGroup = (RadioGroup) findViewById(R.id.emo_tab_group);
    emoGridView.setOnEmoGridViewItemClick(onEmoGridViewItemClick);
    emoGridView.setAdapter();
    yayaEmoGridView.setOnEmoGridViewItemClick(yayaOnEmoGridViewItemClick);
    yayaEmoGridView.setAdapter();
    emoRadioGroup.setOnCheckedChangeListener(emoOnCheckedChangeListener);

    // LOADING
    View view = LayoutInflater.from(MessageActivity.this).inflate(R.layout.tt_progress_ly, null);
    progressbar = (MGProgressbar) view.findViewById(R.id.tt_progress);
    LayoutParams pgParms =
        new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    pgParms.bottomMargin = 50;
    addContentView(view, pgParms);

    // ROOT_LAYOUT_LISTENER
    baseRoot.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
  }