Example usage for android.view View getBackground

List of usage examples for android.view View getBackground

Introduction

In this page you can find the example usage for android.view View getBackground.

Prototype

public Drawable getBackground() 

Source Link

Document

Gets the background drawable

Usage

From source file:online.privacy.SetupActivity.java

@SuppressWarnings("deprecation")
private void setErrorState(View view) {
    ColorStateList stateList = ContextCompat.getColorStateList(activitySetup, R.color.input_text_error);
    Drawable wrappedDrawable = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTintList(wrappedDrawable, stateList);
    view.setBackgroundDrawable(wrappedDrawable);
}

From source file:online.privacy.SetupActivity.java

@SuppressWarnings("deprecation")
private void clearErrorState(View view) {
    ColorStateList stateList = ContextCompat.getColorStateList(activitySetup, R.color.input_text_normal);
    Drawable wrappedDrawable = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTintList(wrappedDrawable, stateList);
    view.setBackgroundDrawable(wrappedDrawable);
}

From source file:de.toshsoft.tsremote.configuration.ConfigurationMainFragment.java

@Override
public void KeyLearned(final int status, final String remoteName, final String keyName,
        final View changedView) {
    if (getActivity() == null) {
        learingAlertDialog.hide();//from w  w  w .  j  a v  a2  s  .  c om
        return;
    }

    getActivity().runOnUiThread(new Runnable() {
        public void run() {
            View currentButton = (View) changedView
                    .findViewById(((Number) DatabaseHelper.UI_TO_DB_MAP.get(keyName)).intValue());
            currentButton.getBackground().setColorFilter(status < 20 ? Color.RED : Color.GREEN,
                    PorterDuff.Mode.MULTIPLY);

            DatabaseHelper dbHelper = new DatabaseHelper(changedView.getContext());
            dbHelper.updateKeyFromRemote(remoteName, keyName, status < 20 ? "none" : "set");

            learingAlertDialog.hide();
        }
    });
}

From source file:com.varejodigital.activities.DetailActivity.java

private void updateBackground(View view, Palette palette) {
    int lightMutedColor = palette.getLightMutedColor(getResources().getColor(R.color.accent));
    int mutedColor = palette.getMutedColor(getResources().getColor(R.color.accent));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        RippleDrawable ripple = (RippleDrawable) view.getBackground();
        GradientDrawable rippleBackground = (GradientDrawable) ripple.getDrawable(0);
        rippleBackground.setColor(lightMutedColor);
        ripple.setColor(ColorStateList.valueOf(mutedColor));
    } else {/*from   www .  j a va  2  s .  com*/
        StateListDrawable drawable = (StateListDrawable) view.getBackground();
        drawable.setColorFilter(mutedColor, PorterDuff.Mode.SRC_ATOP);
    }
}

From source file:info.guardianproject.otr.app.im.app.AccountWizardActivity.java

private void unbindDrawables(View view) {
    if (view != null) {
        if (view.getBackground() != null) {
            view.getBackground().setCallback(null);
        }//from w  ww  .j av  a 2s .c  om
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                unbindDrawables(((ViewGroup) view).getChildAt(i));
            }
            ((ViewGroup) view).removeAllViews();
        }
    }
}

From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java

private void unbindDrawables(View view) {
    if (view.getBackground() != null) {
        view.getBackground().setCallback(null);
    }/*from w  ww. java 2s  .  c  o m*/
    if (view instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
            unbindDrawables(((ViewGroup) view).getChildAt(i));
        }
        ((ViewGroup) view).removeAllViews();
    }
}

From source file:com.androzic.route.RouteDetails.java

@Override
public void onListItemClick(ListView lv, View v, int position, long id) {
    v.setTag("selected");
    selectedKey = position;// w  w  w .  ja va 2s.co  m
    selectedBackground = v.getBackground();
    v.setBackgroundColor(accentColor);
    // https://gist.github.com/mediavrog/9345938#file-iconizedmenu-java-L55
    MenuBuilder menu = new MenuBuilder(getActivity());
    menu.setCallback(this);
    MenuPopupHelper popup = new MenuPopupHelper(getActivity(), menu, v.findViewById(R.id.name));
    popup.setForceShowIcon(true);
    popup.setCallback(this);
    new SupportMenuInflater(getActivity())
            .inflate(navigation ? R.menu.routewaypointnavigation_menu : R.menu.routewaypoint_menu, menu);
    popup.show();
}

From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomNavigationTextView.java

private ColorDrawable getColorDrawable(View view) {
    return view.getBackground() != null && view.getBackground() instanceof ColorDrawable
            ? ((ColorDrawable) view.getBackground())
            : new ColorDrawable(Color.WHITE);
}

From source file:com.aigo.kt03airdemo.ui.view.ResideLayout.java

private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v))
        return true;

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18)
        return false;

    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}

From source file:name.teze.layout.lib.SlidingPaneLayout.java

public static boolean isOpaque(View view) {
    final Drawable bg = view.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }/*from   w  w  w.  j a  v  a 2 s  . c  o m*/
    return false;
}