Java Code Examples for com.afollestad.materialdialogs.util.DialogUtils

The following examples show how to use com.afollestad.materialdialogs.util.DialogUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OpenHub   Source File: ColorChooserDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@ColorInt
private int getSelectedColor() {
  if (colorChooserCustomFrame != null
      && colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
    return selectedCustomColor;
  }

  int color = 0;
  if (subIndex() > -1) {
    color = colorsSub[topIndex()][subIndex()];
  } else if (topIndex() > -1) {
    color = colorsTop[topIndex()];
  }
  if (color == 0) {
    int fallback = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
    }
    color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
  }
  return color;
}
 
Example 2
Source Project: APlayer   Source File: ColorChooserDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@ColorInt
private int getSelectedColor() {
  if (mColorChooserCustomFrame != null
      && mColorChooserCustomFrame.getVisibility() == View.VISIBLE) {
    return mSelectedCustomColor;
  }

  int color = 0;
  if (subIndex() > -1) {
    color = mColorsSub[topIndex()][subIndex()];
  } else if (topIndex() > -1) {
    color = mColorsTop[topIndex()];
  }
  if (color == 0) {
    int fallback = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
    }
    color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
  }
  return color;
}
 
Example 3
protected void invalidateInputMinMaxIndicator(EditText inputMinMax, int currentLength) {
    if (inputMinMax != null) {
        int materialBlue = ContextCompat.getColor(getActivity(), com.afollestad.materialdialogs.R.color.md_material_blue_600);
        int widgetColor = DialogUtils.resolveColor(getActivity(), com.afollestad.materialdialogs.R.attr.colorAccent, materialBlue);

        if (Build.VERSION.SDK_INT >= 21) {
            widgetColor = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent, widgetColor);
        }
        final boolean isDisabled = currentLength > 20;
        final int colorText = isDisabled ? ContextCompat.getColor(getActivity(), R.color.red)
                : -1;
        final int colorWidget = isDisabled ? ContextCompat.getColor(getActivity(), R.color.red)
                : widgetColor;
        inputMinMax.setTextColor(colorText);
        MDTintHelper.setTint(inputMinMax, colorWidget);
    }
}
 
Example 4
Source Project: bleYan   Source File: BleDeviceActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void invalidateInputMinMaxIndicator(EditText input, int currentLength) {
    if (input != null) {
        int materialBlue = ContextCompat.getColor(this, com.afollestad.materialdialogs.R.color.md_material_blue_600);
        int widgetColor = DialogUtils.resolveColor(this, com.afollestad.materialdialogs.R.attr.colorAccent, materialBlue);

        if (Build.VERSION.SDK_INT >= 21) {
            widgetColor = DialogUtils.resolveColor(this, android.R.attr.colorAccent, widgetColor);
        }
        final boolean isDisabled = currentLength > 20;
        final int colorText = isDisabled ? ContextCompat.getColor(this, R.color.red)
                : -1;
        final int colorWidget = isDisabled ? ContextCompat.getColor(this, R.color.red)
                : widgetColor;
        input.setTextColor(colorText);
        MDTintHelper.setTint(input, colorWidget);
    }
}
 
Example 5
private void setUpViews() {
    setUpRecyclerView();
    setUpSongsAdapter();
    artistTextView.setOnClickListener(v -> {
        if (album != null) {
            NavigationUtil.goToArtist(AlbumDetailActivity.this, album.getArtistId());
        }
    });
    setColors(DialogUtils.resolveColor(this, R.attr.defaultFooterColor));
}
 
Example 6
Source Project: Orin   Source File: ArtistDetailActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void setUpObservableListViewParams() {
    artistImageViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height_artist_profile);
    toolbarColor = DialogUtils.resolveColor(this, R.attr.defaultFooterColor);
    int toolbarHeight = Util.getActionBarSize(this);
    titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
    headerOffset = toolbarHeight;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
    }
}
 
Example 7
Source Project: Orin   Source File: AlbumDetailActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void setUpObservableListViewParams() {
    albumArtViewHeight = getResources().getDimensionPixelSize(R.dimen.header_image_height);
    toolbarColor = DialogUtils.resolveColor(this, R.attr.defaultFooterColor);
    int toolbarHeight = Util.getActionBarSize(this);
    titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height_album_detail);
    headerOffset = toolbarHeight;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        headerOffset += getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
    }
}
 
Example 8
private void setUpViews() {
    setUpRecyclerView();
    setUpSongsAdapter();
    artistTextView.setOnClickListener(v -> {
        if (album != null) {
            NavigationUtil.goToArtist(AlbumDetailActivity.this, album.getArtistId());
        }
    });
    setColors(DialogUtils.resolveColor(this, R.attr.defaultFooterColor));
}
 
Example 9
Source Project: memoir   Source File: RTApi.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param context      Can be an Application or an Activity context
 * @param rtProxy      The RTProxy provided by the app.
 * @param mediaFactory the RTMediaFactory provided by the app.
 */
public RTApi(Context context, RTProxy rtProxy, RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory) {
    synchronized (sTheLock) {
        sAppContext = context.getApplicationContext();
    }
    sDarkTheme = DialogUtils.resolveBoolean(context, R.attr.md_dark_theme, false);

    mRTProxy = rtProxy;
    mMediaFactory = mediaFactory;
}
 
Example 10
Source Project: memoir   Source File: RTApi.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param context      Can be an Application or an Activity context
 * @param rtProxy      The RTProxy provided by the app.
 * @param mediaFactory the RTMediaFactory provided by the app.
 */
public RTApi(Context context, RTProxy rtProxy, RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory) {
    synchronized (sTheLock) {
        sAppContext = context.getApplicationContext();
    }
    sDarkTheme = DialogUtils.resolveBoolean(context, R.attr.md_dark_theme, false);

    mRTProxy = rtProxy;
    mMediaFactory = mediaFactory;
}
 
Example 11
private void init(Context context, AttributeSet attrs) {
    setLayoutResource(context, this, attrs);
    int fallback;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        fallback = DialogUtils.resolveColor(context, android.R.attr.colorAccent);
    else fallback = 0;
    fallback = DialogUtils.resolveColor(context, com.afollestad.materialdialogs.commons.R.attr.colorAccent, fallback);
    mColor = DialogUtils.resolveColor(context, com.afollestad.materialdialogs.commons.R.attr.md_widget_color, fallback);

    mEditText = new AppCompatEditText(context, attrs);
    // Give it an ID so it can be saved/restored
    mEditText.setId(android.R.id.edit);
    mEditText.setEnabled(true);
}
 
Example 12
private void setUpViews() {
    setUpRecyclerView();
    setUpSongsAdapter();
    artistTextView.setOnClickListener(v -> {
        if (album != null) {
            NavigationUtil.goToArtist(AlbumDetailActivity.this, album.getArtistId());
        }
    });
    setColors(DialogUtils.resolveColor(this, R.attr.defaultFooterColor));
}
 
Example 13
private void setUpViews() {
    setUpSongListView();
    setUpAlbumRecyclerView();
    setColors(DialogUtils.resolveColor(this, R.attr.defaultFooterColor));
}
 
Example 14
Source Project: OpenHub   Source File: ColorChooserDialog.java    License: GNU General Public License v3.0 4 votes vote down vote up
@NonNull
public Builder customColors(@ArrayRes int topLevel, @Nullable int[][] subLevel) {
  colorsTop = DialogUtils.getColorArray(context, topLevel);
  colorsSub = subLevel;
  return this;
}
 
Example 15
private void setUpViews() {
    setUpSongListView();
    setUpAlbumRecyclerView();
    setColors(DialogUtils.resolveColor(this, R.attr.defaultFooterColor));
}
 
Example 16
Source Project: APlayer   Source File: CircleView.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setBackgroundResource(@ColorRes int color) {
  setBackgroundColor(DialogUtils.getColor(getContext(), color));
}
 
Example 17
Source Project: APlayer   Source File: ColorChooserDialog.java    License: GNU General Public License v3.0 4 votes vote down vote up
@NonNull
public Builder customColors(@ArrayRes int topLevel, @Nullable int[][] subLevel) {
  mColorsTop = DialogUtils.getColorArray(mContext, topLevel);
  mColorsSub = subLevel;
  return this;
}
 
Example 18
private void setUpViews() {
    setUpSongListView();
    setUpAlbumRecyclerView();
    setColors(DialogUtils.resolveColor(this, R.attr.defaultFooterColor));
}