android.support.v4.widget.ImageViewCompat Java Examples

The following examples show how to use android.support.v4.widget.ImageViewCompat. 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 File: ApiCompatibilityUtils.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void setImageTintList(
        @NonNull ImageView view, @Nullable ColorStateList tintList) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
        // Work around broken workaround in ImageViewCompat, see https://crbug.com/891609#c3.
        if (tintList != null && view.getImageTintMode() == null) {
            view.setImageTintMode(PorterDuff.Mode.SRC_IN);
        }
    }
    ImageViewCompat.setImageTintList(view, tintList);
}
 
Example #2
Source File: ImageViewUtil.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public static void setMenuButtonColor(Activity activity, int color) {
  ColorStateList stateList = new ColorStateList(new int[][]{new int[]{}}, new int[]{color});
  ImageView view = findOverflowMenuView(activity);
  if (view != null) {
    ImageViewCompat.setImageTintMode(view, MULTIPLY);
    ImageViewCompat.setImageTintList(view, stateList);
  }
}
 
Example #3
Source File: EquinoxView.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public void themeViews( EquinoxViewOptions options, int position )
{
    title.setTextColor(SuntimesUtils.colorStateList((position  < EquinoxViewAdapter.CENTER_POSITION ? options.disabledColor : options.titleColor), options.disabledColor, options.pressedColor));

    ImageViewCompat.setImageTintList(btn_flipperNext, SuntimesUtils.colorStateList(options.titleColor, options.disabledColor, options.pressedColor));
    ImageViewCompat.setImageTintList(btn_flipperPrev, SuntimesUtils.colorStateList(options.titleColor, options.disabledColor, options.pressedColor));

    note_equinox_vernal.themeViews(options.labelColor, options.seasonColors[0], options.textColor);
    note_solstice_summer.themeViews(options.labelColor, options.seasonColors[1], options.textColor);
    note_equinox_autumnal.themeViews(options.labelColor, options.seasonColors[2], options.textColor);
    note_solstice_winter.themeViews(options.labelColor, options.seasonColors[3], options.textColor);
}
 
Example #4
Source File: MoonApsisView.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
private void themeDrawables()
{
    ImageViewCompat.setImageTintList(forwardButton, SuntimesUtils.colorStateList(colorAccent, colorDisabled, colorPressed));
    SuntimesUtils.colorizeImageView(forwardButton, colorBackground);

    ImageViewCompat.setImageTintList(backButton, SuntimesUtils.colorStateList(colorAccent, colorDisabled, colorPressed));
    SuntimesUtils.colorizeImageView(backButton, colorBackground);
}
 
Example #5
Source File: WorldMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ResourceType")
public void themeViews(Context context)
{
    if (themeOverride != null)
    {
        color_pressed = color_warning = themeOverride.getActionColor();
        color_normal = themeOverride.getTitleColor();
        color_accent = themeOverride.getAccentColor();

        dialogTitle.setTextColor(themeOverride.getTitleColor());
        utcTime.setTextColor(themeOverride.getTimeColor());
        worldmap.themeViews(context, themeOverride);
    }

    if (seekbar != null) {
        seekbar.setTrackColor(color_accent);
        seekbar.setTickColor(color_accent, color_accent, color_accent);
        seekbar.getThumb().setColorFilter(color_accent, PorterDuff.Mode.SRC_IN);
    }

    ImageViewCompat.setImageTintList(playButton, SuntimesUtils.colorStateList(color_normal, color_disabled, color_pressed));
    ImageViewCompat.setImageTintList(resetButton, SuntimesUtils.colorStateList(color_warning, color_disabled, color_pressed));
    ImageViewCompat.setImageTintList(recordButton, SuntimesUtils.colorStateList(color_warning, color_disabled, color_pressed));
    ImageViewCompat.setImageTintList(pauseButton, SuntimesUtils.colorStateList(color_accent, color_disabled, color_pressed));
    ImageViewCompat.setImageTintList(nextButton, SuntimesUtils.colorStateList(color_normal, color_disabled, color_pressed));
    ImageViewCompat.setImageTintList(prevButton, SuntimesUtils.colorStateList(color_normal, color_disabled, color_pressed));
    ImageViewCompat.setImageTintList(menuButton, SuntimesUtils.colorStateList(color_normal, color_disabled, color_pressed));

    if (speedButton != null) {
        speedButton.setTextColor(SuntimesUtils.colorStateList(color_normal, color_disabled, color_pressed));
    }
}
 
Example #6
Source File: MoonPhasesView1.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
private void themeDrawables()
{
    ImageViewCompat.setImageTintList(forwardButton, SuntimesUtils.colorStateList(colorAccent, colorDisabled, colorPressed));
    SuntimesUtils.colorizeImageView(forwardButton, colorBackground);

    ImageViewCompat.setImageTintList(backButton, SuntimesUtils.colorStateList(colorAccent, colorDisabled, colorPressed));
    SuntimesUtils.colorizeImageView(backButton, colorBackground);
}
 
Example #7
Source File: CardViewHolder.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
protected void themeCardViews(Context context, CardAdapter.CardAdapterOptions options)
{
    if (options.themeOverride != null) {
        themeCardViews(context, options.themeOverride, options);
    }
    ImageViewCompat.setImageTintList(btn_flipperNext, SuntimesUtils.colorStateList(options.color_accent, options.color_disabled, options.color_pressed));
    ImageViewCompat.setImageTintList(btn_flipperPrev, SuntimesUtils.colorStateList(options.color_accent, options.color_disabled, options.color_pressed));
}
 
Example #8
Source File: TintColorSetter.java    From aircon with MIT License 4 votes vote down vote up
@Override
protected void setAttr(final ImageView view, final int color) {
	ImageViewCompat.setImageTintList(view, ColorStateList.valueOf(color));
}
 
Example #9
Source File: BaseImageWidget.java    From relight with Apache License 2.0 4 votes vote down vote up
public T imageTintList(ColorStateList tint) {
    ImageViewCompat.setImageTintList(view, tint);
    return self();
}
 
Example #10
Source File: RuuviTagAdapter.java    From com.ruuvi.station with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    final RuuviTag tag = getItem(position);


    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_item_main, parent, false);
    }

    TextView txtId = convertView.findViewById(R.id.id);
    TextView lastseen = convertView.findViewById(R.id.lastseen);
    TextView temp = convertView.findViewById(R.id.row_main_temperature);
    TextView humid = convertView.findViewById(R.id.row_main_humidity);
    TextView pres = convertView.findViewById(R.id.row_main_pressure);
    TextView signal = convertView.findViewById(R.id.row_main_signal);

    txtId.setText(tag.getDispayName());

    int ballColorRes = (position % 2 == 0) ? R.color.main : R.color.mainLight;

    ((ImageView)convertView.findViewById(R.id.row_main_letter))
            .setImageBitmap(Utils.createBall((int)getContext().getResources().getDimension(R.dimen.letter_ball_radius),
                    getContext().getResources().getColor(ballColorRes),
                    Color.WHITE,
                    txtId.getText().charAt(0) + ""));

    convertView.findViewById(R.id.row_main_root).setTag(tag);
    //convertView.findViewById(R.id.row_main_letter).setOnClickListener(tagMenuClickListener);

    String updatedAt = getContext().getResources().getString(R.string.updated) + " " + Utils.strDescribingTimeSince(tag.updateAt);

    lastseen.setText(updatedAt);
    AppCompatImageView bell = convertView.findViewById(R.id.bell);
    int status = AlarmChecker.getStatus(tag);
    switch (status) {
        case -1:
            bell.setVisibility(View.VISIBLE);
            bell.setImageResource(R.drawable.ic_notifications_off_24px);
            break;
        case 0:
            bell.setVisibility(View.VISIBLE);
            bell.setImageResource(R.drawable.ic_notifications_on_24px);
            break;
        case 1:
            bell.setImageResource(R.drawable.ic_notifications_active_24px);
            bell.setVisibility(bell.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
            break;
    }
    ImageViewCompat.setImageTintList(bell, ColorStateList.valueOf(getContext().getResources().getColor(R.color.main)));

    temp.setText(tag.getTemperatureString(getContext()));
    humid.setText(String.format(getContext().getString(R.string.humidity_reading), tag.humidity));
    pres.setText(String.format(getContext().getString(R.string.pressure_reading), tag.pressure));
    signal.setText(String.format(getContext().getString(R.string.signal_reading), tag.rssi));

    return convertView;
}