Example usage for android.content.res ColorStateList valueOf

List of usage examples for android.content.res ColorStateList valueOf

Introduction

In this page you can find the example usage for android.content.res ColorStateList valueOf.

Prototype

@NonNull
public static ColorStateList valueOf(@ColorInt int color) 

Source Link

Usage

From source file:com.xamoom.android.xamoomcontentblocks.XamoomMapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_xamoom_map, container, false);
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);

    mSpotTitleTextView = (TextView) view.findViewById(R.id.spot_title_text_view);
    mSpotExcerptTextView = (TextView) view.findViewById(R.id.spot_excerpt_text_view);
    mSpotImageView = (ImageView) view.findViewById(R.id.spot_image_view);
    mSpotContentButton = (Button) view.findViewById(R.id.spot_content_button);
    mFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.spot_fab);
    mFloatingActionButton.setBackgroundTintList(
            ColorStateList.valueOf(getResources().getColor(R.color.googlemaps_linkblock_background_color)));
    mMapCloseButton = (Button) view.findViewById(R.id.map_close_button);

    View bottomSheet = view.findViewById(R.id.bottom_sheet);
    mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
    mBottomSheetBehavior.setPeekHeight(300);
    mBottomSheetBehavior.setHideable(true);
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);

    mFloatingActionButton.hide();/*from w  w  w . j a  v  a 2  s. com*/

    mapFragment.getMapAsync(this);

    mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (newState == BottomSheetBehavior.STATE_EXPANDED) {
                setBottomPadding(bottomSheet.getHeight());
                zoomToMarker(mActiveMarker, true);
            }

            if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
                setBottomPadding(300);
            }

            if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                setBottomPadding(0);
                mFloatingActionButton.hide();
            }
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            if (mActiveMarker != null) {
                zoomToMarker(mActiveMarker, true);
            }
        }
    });

    mMapCloseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFragmentManager().popBackStack();
        }
    });

    return view;
}

From source file:com.joaquimley.faboptions.FabOptions.java

public void setFabColor(@ColorRes int fabColor) {
    Context context = getContext();
    if (context != null) {
        @ColorInt//from w  w  w .ja  va 2  s.  c o  m
        int colorId = ContextCompat.getColor(context, fabColor);
        mFab.setBackgroundTintList(ColorStateList.valueOf(colorId));
    }
}

From source file:kr.co.generic.wifianalyzer.wifi.ChannelRatingAdapter.java

@NonNull
@Override//ww w. ja  v a  2 s .  c  om
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        LayoutInflater layoutInflater = MainContext.INSTANCE.getMainActivity().getLayoutInflater();
        view = layoutInflater.inflate(kr.co.generic.wifianalyzer.R.layout.channel_rating_details, parent,
                false);
    }

    WiFiChannel wiFiChannel = getItem(position);
    if (wiFiChannel == null) {
        return view;
    }

    ((TextView) view.findViewById(kr.co.generic.wifianalyzer.R.id.channelNumber))
            .setText(String.format(Locale.ENGLISH, "%d", wiFiChannel.getChannel()));
    ((TextView) view.findViewById(kr.co.generic.wifianalyzer.R.id.accessPointCount))
            .setText(String.format(Locale.ENGLISH, "%d", channelRating.getCount(wiFiChannel)));
    Strength strength = Strength.reverse(channelRating.getStrength(wiFiChannel));
    RatingBar ratingBar = (RatingBar) view.findViewById(kr.co.generic.wifianalyzer.R.id.channelRating);
    int size = Strength.values().length;
    ratingBar.setMax(size);
    ratingBar.setNumStars(size);
    ratingBar.setRating(strength.ordinal() + 1);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ratingBar.getProgressDrawable().setColorFilter(
                ContextCompat.getColor(getContext(), kr.co.generic.wifianalyzer.R.color.success_color),
                PorterDuff.Mode.SRC_ATOP);
    } else {
        ratingBar.setProgressTintList(
                ColorStateList.valueOf(ContextCompat.getColor(getContext(), strength.colorResource())));
    }

    return view;
}

From source file:com.antonioleiva.materializeyourapp.DetailActivity.java

private void updateBackground(FloatingActionButton fab, Palette palette) {
    int lightMutedColor = palette.getLightMutedColor(getResources().getColor(android.R.color.white));
    int mutedColor = palette.getMutedColor(getResources().getColor(R.color.accent));

    fab.setRippleColor(lightMutedColor);
    fab.setBackgroundTintList(ColorStateList.valueOf(mutedColor));
}

From source file:com.elekso.potfix.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    PowerManager pm = (PowerManager) getApplicationContext()
            .getSystemService(getApplicationContext().POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, " POTFIX holding wake lock");
    wl.acquire();/*from www .jav a  2  s.c o m*/
    Globals.getInstance().setFlexiblemap(true);

    //
    //
    //        new Thread(new Runnable(){
    //            @Override
    //            public void run() {
    //                try {
    //                    LALpotfixservicePortBinding service = new LALpotfixservicePortBinding();
    //                    try {
    //                        globaldata_test=service.CheckWS("mandar");
    //
    //                    } catch (Exception e) {
    //                        e.printStackTrace();
    //                    }
    //                } catch (Exception ex) {
    //                    ex.printStackTrace();
    //                }
    //            }
    //        }).start();

    String login = "";

    //  Config.getInstance(getBaseContext(),getCacheDir()).setProfile("df","asd");
    login = Config.getInstance(getBaseContext(), getCacheDir()).getProfileName();
    if (login == null || login.isEmpty()) {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        return;
    }
    //remove
    //  Stetho.initializeWithDefaults(this);

    // Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Drawer
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    tusername = (TextView) drawer.findViewById(R.id.tvusername);
    //        tuseremail =(TextView) findViewById(R.id.tvuseremail);
    //
    //        if(login!=null)
    //            tusername.setText("jhjhjhjh");
    //   if(Config.getInstance().getProfileEmail()!=null)
    //tuseremail.setText(Config.getInstance().getProfileEmail());

    // FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setRippleColor(Color.parseColor("#78D6F3"));
    fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#039FDC")));
    fab.setImageResource(R.drawable.ic_gps_fixed_white_24dp);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (currentFragment) {
            case 1: //profile
                Snackbar.make(view, "Updating Information", Snackbar.LENGTH_LONG).setAction("Action", null)
                        .show();
                Fragment frg = new ProfileFragment();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.frame_containerone, frg);
                transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                transaction.commit();
                break;
            case 2: //map

                if (Globals.getInstance().getFlexiblemap()) {
                    Snackbar.make(view, "Free to Scroll", Snackbar.LENGTH_LONG).setAction("Action", null)
                            .show();
                    Globals.getInstance().setFlexiblemap(false);
                    fab.setRippleColor(Color.parseColor("#FFE082"));
                    fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FFB300")));
                    fab.setImageResource(R.drawable.ic_gps_off_white_24dp);
                } else {
                    Snackbar.make(view, "Follow Potfix", Snackbar.LENGTH_LONG).setAction("Action", null).show();
                    Globals.getInstance().setFlexiblemap(true);
                    fab.setRippleColor(Color.parseColor("#78D6F3"));
                    fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#039FDC")));
                    fab.setImageResource(R.drawable.ic_gps_fixed_white_24dp);
                }
                break;
            case 3: //share
                //Snackbar.make(view, "Some sharing action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
                String[] TO = { "aziz@potfix.com" };
                String[] CC = { "" };
                Intent emailIntent = new Intent(Intent.ACTION_SEND);

                emailIntent.setData(Uri.parse("mailto:"));
                emailIntent.setType("text/plain");
                emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
                emailIntent.putExtra(Intent.EXTRA_CC, CC);
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Potfix Communication");
                emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message...");

                try {
                    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
                    finish();
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT)
                            .show();
                }
                break;
            case 4: //legal
                Snackbar.make(view, "Software License", Snackbar.LENGTH_LONG).setAction("Action", null).show();
                drawer.openDrawer(Gravity.LEFT);
                break;
            }

        }
    });

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    startService(new Intent(getBaseContext(), BackgroundService.class));

    FragmentTransaction mTransaction = getSupportFragmentManager().beginTransaction();
    MapsFragment mFRaFragment = new MapsFragment();
    mTransaction.add(R.id.frame_containerone, mFRaFragment);
    mTransaction.commit();

    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        Toast.makeText(this, "GPS is Enabled in your devide", Toast.LENGTH_SHORT).show();
    } else {
        showGPSDisabledAlertToUser();
    }

    //        if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
    //            Toast.makeText(this, "Network is Enabled in your devide", Toast.LENGTH_SHORT).show();
    //        }else{
    //            showNetDisabledAlertToUser();
    //        }
    createNotification();
}

From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapter.java

@NonNull
@Override/*  w w  w.  j a v a2  s  .  c om*/
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        LayoutInflater layoutInflater = MainContext.INSTANCE.getMainActivity().getLayoutInflater();
        view = layoutInflater.inflate(R.layout.channel_rating_details, parent, false);
    }

    WiFiChannel wiFiChannel = getItem(position);
    if (wiFiChannel == null) {
        return view;
    }

    ((TextView) view.findViewById(R.id.channelNumber))
            .setText(String.format(Locale.ENGLISH, "%d", wiFiChannel.getChannel()));
    ((TextView) view.findViewById(R.id.accessPointCount))
            .setText(String.format(Locale.ENGLISH, "%d", channelRating.getCount(wiFiChannel)));
    Strength strength = Strength.reverse(channelRating.getStrength(wiFiChannel));
    RatingBar ratingBar = (RatingBar) view.findViewById(R.id.channelRating);
    int size = Strength.values().length;
    ratingBar.setMax(size);
    ratingBar.setNumStars(size);
    ratingBar.setRating(strength.ordinal() + 1);
    int color = ContextCompat.getColor(getContext(), strength.colorResource());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        setRatingBarColor(ratingBar.getProgressDrawable(), color);
    } else {
        ratingBar.setProgressTintList(ColorStateList.valueOf(color));
    }

    return view;
}

From source file:com.hataskrau.ui.issue.detailed.DetailedIssueActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_datailed_issue);

    tvTitle = (TextView) findViewById(R.id.activity_detailed_issue_tvTitle);
    tvAddress = (TextView) findViewById(R.id.activity_detailed_issue_tvAddress);
    vHeader = findViewById(R.id.activity_detailed_issue_vHeader);
    btSendEmail = (FloatingActionButton) findViewById(R.id.activity_detailed_issue_btSendEmail);
    tvDescriptionTitle = (TextView) findViewById(R.id.activity_detailed_issue_tvDescriptionTitle);
    tvDescription = (TextView) findViewById(R.id.activity_detailed_issue_tvDescription);
    tvSolutionTitle = (TextView) findViewById(R.id.activity_detailed_issue_tvSolutionTitle);
    tvSolution = (TextView) findViewById(R.id.activity_detailed_issue_tvSolution);

    btSendEmail.setOnClickListener(this);

    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of app memory

    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls);
    mPager = (ViewPager) findViewById(R.id.activity_detailed_issue_vpImages);
    mPager.setAdapter(mAdapter);//  w  ww  .  ja  v a  2 s.  c o  m
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin));
    mPager.setOffscreenPageLimit(2);

    // Set the current item based on the extra passed in to this activity
    String issueId = getIntent().getStringExtra(EXTRA_ISSUE_ID);

    //        Toast.makeText(this, "issueId = " + issueId, Toast.LENGTH_SHORT).show();
    if (issueId != null) {
        IssueDAO issueDAO = DbManager.getHelper().getIssueTable();
        Issue issue = issueDAO.getDetailedIssue(issueId);
        tvTitle.setText(issue.getTitle());
        tvAddress.setText(issue.getAddress());
        int primaryStatusColor;
        if (issue.getStatus() != null)
            primaryStatusColor = getResources().getColor(issue.getStatus().getPrimaryColorId());
        else
            primaryStatusColor = getResources().getColor(R.color.material_grey_700);
        vHeader.setBackgroundColor(primaryStatusColor);
        if (issue.getSynopsys() == null) {
            tvDescriptionTitle.setVisibility(View.GONE);
            tvDescription.setVisibility(View.GONE);
        } else {
            tvDescriptionTitle.setTextColor(ColorStateList.valueOf(primaryStatusColor));
            tvDescription.setText(issue.getSynopsys());
        }
        if (issue.getSolution() == null) {
            tvSolutionTitle.setVisibility(View.GONE);
            tvSolution.setVisibility(View.GONE);
        } else {
            tvSolutionTitle.setTextColor(ColorStateList.valueOf(primaryStatusColor));
            tvSolution.setText(issue.getSolution());
        }
        getFragmentManager().beginTransaction()
                .add(R.id.comments_container, CommentsFragment.newInstance(issueId)).commit();
    }
}

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 {/*from   w w  w . j  a va  2s  . co  m*/
        if (getProgressDrawable() instanceof LayerDrawable) {
            LayerDrawable layer = (LayerDrawable) getProgressDrawable();
            DrawableCompat.setTintList(layer.findDrawableByLayerId(android.R.id.progress).mutate(),
                    ColorStateList.valueOf(value));
        }
    }
}

From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.CalibrateListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calibrate_list);

    textSubtitle = (TextView) findViewById(R.id.textSubtitle);
    textSubtitle1 = (TextView) findViewById(R.id.textSubtitle1);
    textSubtitle2 = (TextView) findViewById(R.id.textSubtitle2);

    ((TextView) findViewById(R.id.textTitle)).setText(CaddisflyApp.getApp().getCurrentTestInfo().getName());

    fabEditCalibration = (FloatingActionButton) findViewById(R.id.fabEditCalibration);

    if (AppPreferences.isDiagnosticMode()) {
        fabEditCalibration//from  w w  w .jav a  2  s .  c om
                .setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.cyan)));
    }

    fabEditCalibration.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showEditCalibrationDetailsDialog(true);
        }
    });

    loadDetails();
}

From source file:com.forum.lottery.view.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);// w ww.ja  v  a  2  s .  co  m
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColorStateList(1);
    if (tabTextColor == null)
        tabTextColor = ColorStateList.valueOf(0xFF666666);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}