Ejemplo n.º 1
0
  private void initView() {
    appbar = (AppBar) findViewById(R.id.wall_app_bar);
    appbar.getLogoView().setImageResource(R.drawable.menu_back);
    appbar
        .getLogoView()
        .setLayoutParams(
            new RelativeLayout.LayoutParams(Utils.px2Dp(this, 56), Utils.px2Dp(this, 56)));
    appbar
        .getLogoView()
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                onBackPressed();
              }
            });
    appbar.getTextView().setVisibility(View.VISIBLE);
    appbar.getTextView().setText(R.string.wall_circle);

    mWallView = (WallView) findViewById(R.id.wall_wallView);
    header = new FrameLayout(this);
    LayoutInflater.from(this).inflate(R.layout.view_wall_header, header);
    header.setLayoutParams(new AbsListView.LayoutParams(-1, Utils.px2Dp(this, 112)));
    mWallView.setHeaderView(header);

    addBtn = (ImageView) findViewById(R.id.wall_addBtn);
    addBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), CreatePostActivity.class);
            startActivityForResult(intent, 0);
            overridePendingTransition(R.anim.slide_in_right, android.R.anim.fade_out);
          }
        });
  }
  private void checkBundle() {
    if (getIntent().getExtras() != null
        && getIntent().getExtras().containsKey(Constant.INTENT_EXTRA_KEY_TOPIC)) {
      mTopic = (Topic) getIntent().getExtras().getSerializable(Constant.INTENT_EXTRA_KEY_TOPIC);

      mAppBar
          .getMenuItemView()
          .setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  IMManager.getInstance(v.getContext())
                      .updateTopicName(etTopicName.getEditText().getText().toString(), mTopic);
                  onBackPressed();
                }
              });
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_topic);

    mAppBar = (AppBar) findViewById(R.id.edit_topic_app_bar);
    mAppBar.getLogoView().setImageResource(R.drawable.menu_back);
    mAppBar
        .getLogoView()
        .setLayoutParams(
            new RelativeLayout.LayoutParams(Utils.px2Dp(this, 56), Utils.px2Dp(this, 56)));
    mAppBar
        .getLogoView()
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                onBackPressed();
              }
            });

    mAppBar.getTextView().setVisibility(View.VISIBLE);
    mAppBar.getTextView().setText(R.string.chat_topic_edit);

    mAppBar.getMenuItemView().setVisibility(View.VISIBLE);
    mAppBar.getMenuItemView().setImageResource(R.drawable.menu_done);
    RelativeLayout.LayoutParams rlp =
        new RelativeLayout.LayoutParams(Utils.px2Dp(this, 56), Utils.px2Dp(this, 56));
    rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mAppBar.getMenuItemView().setLayoutParams(rlp);

    etTopicName = (MaterialEditText) findViewById(R.id.edit_topic_materialEditText);
    etTopicName.setLineFocusedColor(getResources().getColor(R.color.no1));
    etTopicName.setLineUnFocusedColor(getResources().getColor(R.color.no1));
    etTopicName.setLineFocusedHeight(4);
    etTopicName.setLineUnFocusedHeight(1);
    etTopicName.getEditText().setTextColor(getResources().getColor(R.color.no1));
    etTopicName.getEditText().setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    etTopicName.getEditText().setSingleLine();
    etTopicName.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);

    checkBundle();
  }