protected void setRefreshActionButtonState(boolean refreshing) {
    if (mOptionsMenu == null) {
      //	mPendingMenuRefreshState=refreshing;
      return;
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);

    if (refreshItem != null) {
      if (refreshing) {
        View actionView = MenuItemCompat.getActionView(refreshItem);
        if (actionView == null || actionView.findViewById(R.id.progress_circular_ab) == null) {
          MenuItemCompat.setActionView(refreshItem, R.layout.actionbar_indeterminate_progress);
          actionView = MenuItemCompat.getActionView(refreshItem);
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            // Framework bug https://code.google.com/p/android/issues/detail?id=162416
            ProgressBar progressBar =
                (ProgressBar) actionView.findViewById(R.id.progress_circular_ab);
            progressBar.setIndeterminate(true);
            progressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
            progressBar.setIndeterminateTintList(
                getResources().getColorStateList(R.color.action_bar_title));
            // progressBar.setBackgroundTintList(getResources().getColorStateList(R.color.action_bar_title));
          }
        }
        refreshItem.setVisible(true);
      } else {
        MenuItemCompat.setActionView(refreshItem, null);
        if (mHasFeatureIndeterminateProgress) refreshItem.setVisible(false);
      }
    }
    mPendingMenuRefreshState = null;
    // if(mHasFeatureIndeterminateProgress)
    // setSupportProgressBarIndeterminateVisibility(refreshing);
  }
  @SuppressWarnings("NewApi")
  @Override
  protected void initLayout(View v) {
    mRecyclerView = (RecyclerView) v.findViewById(R.id.recyclerview);

    LinearLayoutManager lm =
        new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(lm);

    mAdapter = new MultiListPreferenceAdapter();
    mRecyclerView.setAdapter(mAdapter);

    Button clearButton = (Button) v.findViewById(R.id.clear_button);
    clearButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mAdapter.mDataset == null) {
              return;
            }

            try {
              for (int i = 0; i < mAdapter.mDataset.size(); i++) {
                AppContainer item = mAdapter.mDataset.get(i);
                item.setChecked(false);
                mAdapter.mDataset.set(i, item);
              }
              mAdapter.notifyDataSetChanged();
            } catch (Exception e) {
              Log.e(TAG, "Illegal recyclerview state: " + e.toString());
            }
          }
        });

    Button okButton = (Button) v.findViewById(R.id.ok_button);
    okButton.setTextColor(mAccentColor);
    okButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mListener != null) {
              mListener.onItemsSaved(mAdapter.getSelectedItems());
            }
            close();
          }
        });

    mProgressBar = (ProgressBar) v.findViewById(R.id.progressbar);
    if (Utils.isLollipop()) {
      mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mAccentColor));
    }

    update();
  }
Example #3
0
 static void setIndeterminateTintList(final ProgressBar view, final ColorStateList list) {
   if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
   view.setIndeterminateTintList(list);
 }