Example usage for android.graphics.drawable LayerDrawable findDrawableByLayerId

List of usage examples for android.graphics.drawable LayerDrawable findDrawableByLayerId

Introduction

In this page you can find the example usage for android.graphics.drawable LayerDrawable findDrawableByLayerId.

Prototype

public Drawable findDrawableByLayerId(int id) 

Source Link

Document

Looks for a layer with the given ID and returns its Drawable .

Usage

From source file:com.github.dfa.diaspora_android.ui.BadgeDrawable.java

public static void setBadgeCount(Context context, LayerDrawable icon, String count) {

    BadgeDrawable badge;/*from  w w  w .j a v a2  s  . c o m*/

    // Reuse drawable if possible
    Drawable reuse = icon.findDrawableByLayerId(R.id.ic_badge);
    if (reuse != null && reuse instanceof BadgeDrawable) {
        badge = (BadgeDrawable) reuse;
    } else {
        badge = new BadgeDrawable(context);
    }

    badge.setCount(count);
    icon.mutate();
    icon.setDrawableByLayerId(R.id.ic_badge, badge);
}

From source file:com.bartoszlipinski.flippablestackview.sample.fragment.ColorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_dummy, container, false);
    Bundle bdl = getArguments();/*from  w  w w .j a  va 2 s  .c om*/

    mMainLayout = (FrameLayout) v.findViewById(R.id.main_layout);

    LayerDrawable bgDrawable = (LayerDrawable) mMainLayout.getBackground();
    GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape);
    shape.setColor(bdl.getInt(EXTRA_COLOR));

    return v;
}

From source file:com.stepstone.stepper.internal.ColorableProgressBar.java

private void updateProgressDrawable() {
    LayerDrawable progressBarDrawable = (LayerDrawable) getProgressDrawable();
    Drawable backgroundDrawable = progressBarDrawable.findDrawableByLayerId(android.R.id.background);
    Drawable progressDrawable = progressBarDrawable.findDrawableByLayerId(android.R.id.progress);
    TintUtil.tintDrawable(backgroundDrawable, mProgressBackgroundColor);
    TintUtil.tintDrawable(progressDrawable, mProgressColor);
}

From source file:com.bartoszlipinski.recyclerviewheader2.sample.adapter.ColorItemsAdapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    SampleViewHolder viewHolder = (SampleViewHolder) holder;

    LayerDrawable bgDrawable = (LayerDrawable) viewHolder.mainLayout.getBackground();
    GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape);
    shape.setColor(colors[position]);//from   www.ja va 2s .co  m
}

From source file:app.com.timbuktu.fragment.ColorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_collectionview, container, false);
    Bundle bdl = getArguments();//www.j a v  a 2s . c  o  m

    mFragmentLayout = (FrameLayout) v.findViewById(R.id.fragment_layout);

    LayerDrawable bgDrawable = (LayerDrawable) mFragmentLayout.getBackground();
    GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape);
    shape.setColor(bdl.getInt(EXTRA_COLOR));

    TextView tv = (TextView) v.findViewById(R.id.header);
    Collection collection = bdl.getParcelable(EXTRA_COLLECTION);
    tv.setText("Position - " + bdl.getInt(EXTRA_POS));

    if (collection != null) {
        tv.setText("Position - " + bdl.getInt(EXTRA_POS) + " # of Pics :" + collection.size());

        ImageView imgView = (ImageView) v.findViewById(R.id.collage);
        mTask = new CollageWorkerTask(imgView, collection);
        mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }

    return v;
}

From source file:me.trashout.ui.SelectableImageButton.java

/**
 * Change background selected color/*from  w w  w . j a  va2s. c o  m*/
 * @param color
 */
public void setBackgroundSelectedColor(int color) {

    LayerDrawable layerDrawable = (LayerDrawable) ContextCompat.getDrawable(getContext(),
            R.drawable.background_trash_circle_button_selected);
    GradientDrawable shape = (GradientDrawable) layerDrawable
            .findDrawableByLayerId(R.id.selected_background_shape).mutate();
    shape.setColor(color);

    StateListDrawable states = new StateListDrawable();
    states.addState(new int[] { android.R.attr.state_pressed }, shape);
    states.addState(new int[] { android.R.attr.state_selected }, shape);
    states.addState(new int[] {},
            ContextCompat.getDrawable(getContext(), R.drawable.background_trash_circle_button));

    setBackground(states);
    invalidate();
}

From source file:com.applivery.applvsdklib.ui.views.update.MustUpdateViewImpl.java

private void initViewElements(View view) {
    this.updateMessage = (TextView) view.findViewById(R.id.must_update_message);
    this.permissionsDenied = (TextView) view.findViewById(R.id.permissions_denied_message);
    this.update = (Button) view.findViewById(R.id.must_update_button);
    this.progressBar = (ProgressBar) view.findViewById(R.id.must_update_progress_bar);

    LayerDrawable layerDrawable = (LayerDrawable) progressBar.getProgressDrawable();
    Drawable progressDrawable = layerDrawable.findDrawableByLayerId(android.R.id.progress);
    progressDrawable.setColorFilter(//w ww.  j ava  2 s  .  co m
            ContextCompat.getColor(AppliverySdk.getApplicationContext(), R.color.appliveryMainColor),
            PorterDuff.Mode.SRC_IN);
}

From source file:com.facebook.react.views.slider.ReactSlider.java

@TargetApi(21)
public void setProgressColor(Integer value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setProgressTintList(ColorStateList.valueOf(value));
    } else {/*w w w .j a  v  a2 s  .  c  o  m*/
        if (getProgressDrawable() instanceof LayerDrawable) {
            LayerDrawable layer = (LayerDrawable) getProgressDrawable();
            DrawableCompat.setTintList(layer.findDrawableByLayerId(android.R.id.progress).mutate(),
                    ColorStateList.valueOf(value));
        }
    }
}

From source file:com.facebook.react.views.slider.ReactSlider.java

@TargetApi(21)
public void setProgressBackgroundColor(Integer value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setProgressBackgroundTintList(ColorStateList.valueOf(value));
    } else {/*from w  w  w.  j  ava  2 s . c  o m*/
        if (getProgressDrawable() instanceof LayerDrawable) {
            LayerDrawable layer = (LayerDrawable) getProgressDrawable();
            DrawableCompat.setTintList(layer.findDrawableByLayerId(android.R.id.background).mutate(),
                    ColorStateList.valueOf(value));
        }
    }
}

From source file:cn.edu.nuc.seeworld.fg.ColorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_dummy, container, false);
    Bundle bdl = getArguments();//from w  w w .j a v  a2  s .  c o m
    mContext = this.getActivity();
    mMainLayout = (FrameLayout) v.findViewById(R.id.main_layout);

    LayerDrawable bgDrawable = (LayerDrawable) mMainLayout.getBackground();
    GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape);
    shape.setColor(bdl.getInt(EXTRA_COLOR));
    imageView = (ImageView) v.findViewById(R.id.iv_camera);
    pic_imageView = (ImageView) v.findViewById(R.id.iv_pic);
    et_site = (EditText) v.findViewById(R.id.et_site);
    et_text = (EditText) v.findViewById(R.id.et_writeword);
    btn_publish = (Button) v.findViewById(R.id.btn_publish);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
            LayoutInflater layoutInflater = LayoutInflater.from(v.getContext());
            View v1 = layoutInflater.inflate(R.layout.camera_dialog, null);
            builder.setView(v1);
            camera_log_buttons[0] = (Button) v1.findViewById(R.id.bt_camera_dialog_1);
            camera_log_buttons[1] = (Button) v1.findViewById(R.id.bt_camera_dialog_2);
            camera_log_buttons[2] = (Button) v1.findViewById(R.id.bt_camera_dialog_3);
            for (int i = 0; i < 3; i++) {
                camera_log_buttons[i].setOnClickListener(new cameraonclicklistener());

            }
            dialog = builder.create();
            dialog.show();
        }
    });
    btn_publish.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            publish();
        }
    });
    return v;
}