Пример #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
      mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
    }

    mSelectedColor = Utils.resolveColor(getActivity(), R.attr.colorAccent);
    mRegularColor = Utils.resolveColor(getActivity(), android.R.attr.textColorPrimary);
  }
Пример #2
0
  private void setupHeader(View view) {
    View addAccountFrame = ((ViewStub) view.findViewById(R.id.addAccountStub)).inflate();
    ((ImageView) addAccountFrame.findViewById(R.id.icon))
        .getDrawable()
        .mutate()
        .setColorFilter(mRegularColor, PorterDuff.Mode.SRC_ATOP);

    mAccountsFrame = (LinearLayout) view.findViewById(R.id.accountsFrame);
    mAccountsFrame
        .findViewById(R.id.addAccountFrame)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                showAccountAddDialog();
              }
            });
    ImageButton dropdown = (ImageButton) view.findViewById(R.id.dropdown);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
      dropdown.setBackgroundResource(Utils.resolveDrawable(getActivity(), R.attr.menu_selector));
    dropdown.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (v.getTag() == null) {
              ((ImageButton) v).setImageResource(R.drawable.ic_uparrow);
              v.setTag("GOUP");
              View root = getView();
              if (root != null) {
                ((TextView) root.findViewById(R.id.accountHeader)).setText(R.string.accounts);
                root.findViewById(R.id.accountsFrame).setVisibility(View.VISIBLE);
                root.findViewById(R.id.list).setVisibility(View.GONE);
              }
            } else {
              ((ImageButton) v).setImageResource(R.drawable.ic_downarrow);
              v.setTag(null);
              View root = getView();
              if (root != null) {
                ((TextView) root.findViewById(R.id.accountHeader)).setText(R.string.local);
                root.findViewById(R.id.accountsFrame).setVisibility(View.GONE);
                root.findViewById(R.id.list).setVisibility(View.VISIBLE);
              }
            }
          }
        });
  }