Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

In this page you can find the example usage for android.graphics Color parseColor.

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:com.amaze.filemanager.fragments.Main.java

void switchToGrid() {
    IS_LIST = false;/*from   ww  w.  j  ava  2s .c om*/
    ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST);
    folder = res.getDrawable(R.drawable.ic_grid_folder_new);
    fixIcons();

    if (theme1 == 1) {

        listView.setBackgroundDrawable(
                new ColorDrawable(getResources().getColor(R.color.holo_dark_background)));
    } else {

        if (IS_LIST)
            listView.setBackgroundDrawable(
                    new ColorDrawable(getResources().getColor(android.R.color.background_light)));
        else
            listView.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#f2f2f2")));
    }
    if (mLayoutManagerGrid == null)
        if (columns == -1 || columns == 0)
            mLayoutManagerGrid = new GridLayoutManager(getActivity(), 3);
        else
            mLayoutManagerGrid = new GridLayoutManager(getActivity(), columns);
    listView.setLayoutManager(mLayoutManagerGrid);
    adapter = null;
}

From source file:com.android.kalite27.ScriptActivity.java

/**
 * When the file pick is finished// w  ww . j  a va2  s.co m
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == DirectoryPicker.PICK_DIRECTORY) {
        if (resultCode == RESULT_OK) {
            Bundle extras = data.getExtras();
            String path = (String) extras.get(DirectoryPicker.CHOSEN_DIRECTORY);
            // do stuff with path
            if (check_directory(path)) {
                // if the path is changed
                if (contentPath != path) {
                    // set the local settings
                    mUtilities.setContentPath(path, this);
                    FileTextView.setText("Content location: " + path);
                    FileTextView.setBackgroundColor(Color.parseColor("#A3CC7A"));
                    ServerStatusTextView.setText("Starting server ... ");
                    ServerStatusTextView.setTextColor(Color.parseColor("#005987"));
                    spinner.setVisibility(View.VISIBLE);
                    runScriptService("restart");
                    isFileBrowserClosed = true;
                } else {
                    // TODO: the path is not changed
                    isFileBrowserClosed = true;
                    openWebViewIfAllConditionsMeet();
                }
            }
        } else {
            //exit file browser by pressing back buttom
            isFileBrowserClosed = true;
            openWebViewIfAllConditionsMeet();
        }
    }
}

From source file:com.mainpanel.LifeApp_Map.java

@SuppressLint("NewApi")
@Override/*from   w w w.j a v  a2  s  .co m*/
public boolean onMyLocationButtonClick() {
    Log.d("mymap", "button click event");
    //Toast.makeText(this, "Refresh", Toast.LENGTH_SHORT).show();
    // Return false so that we don't consume the event and the default behavior still occurs
    // (the camera animates to the user's current position).
    //mMap.clear();
    double lat = mLocationClient.getLastLocation().getLatitude();
    double longi = mLocationClient.getLastLocation().getLongitude();

    //        lat = 40.6944;
    //        longi = -73.9865;

    CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(lat, longi)).zoom(15)
            .build();

    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

    // create marker
    MarkerOptions marker = new MarkerOptions().position(new LatLng(lat, longi)).title("You're here")
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.home));

    // adding marker
    mMap.addMarker(marker).showInfoWindow();

    CircleOptions circleOptions = new CircleOptions().center(new LatLng(lat, longi)) //set center
            .radius(500) //set radius in meters
            .fillColor(Color.parseColor("#500084d3")).strokeColor(Color.TRANSPARENT).strokeWidth(2);

    mMap.addCircle(circleOptions);

    mMap.setOnInfoWindowClickListener(this);

    return false;
}

From source file:com.dm.wallpaper.board.activities.WallpaperBoardActivity.java

private void initNavigationViewHeader() {
    String imageUrl = getResources().getString(R.string.navigation_view_header);
    String titleText = getResources().getString(R.string.navigation_view_header_title);
    View header = mNavigationView.getHeaderView(0);
    HeaderView image = ButterKnife.findById(header, R.id.header_image);
    LinearLayout container = ButterKnife.findById(header, R.id.header_title_container);
    TextView title = ButterKnife.findById(header, R.id.header_title);
    TextView version = ButterKnife.findById(header, R.id.header_version);

    Point point = getNavigationViewHeaderStyle(getResources().getString(R.string.navigation_view_header_style));
    image.setRatio(point.x, point.y);/*from  w  w w  . j  ava 2s  . co m*/

    if (titleText.length() == 0) {
        container.setVisibility(View.GONE);
    } else {
        title.setText(titleText);
        try {
            String versionText = "v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
            version.setText(versionText);
        } catch (Exception ignored) {
        }
    }

    if (ColorHelper.isValidColor(imageUrl)) {
        image.setBackgroundColor(Color.parseColor(imageUrl));
        return;
    }

    if (!URLUtil.isValidUrl(imageUrl)) {
        imageUrl = "drawable://" + DrawableHelper.getResourceId(this, imageUrl);
    }

    ImageLoader.getInstance().displayImage(imageUrl, new ImageViewAware(image),
            ImageConfig.getDefaultImageOptions(), new ImageSize(720, 720), null, null);
}

From source file:com.chenl.widgets.flippablestackview.indicator.OrientedPagerSlidingTabLayout.java

private static final StateListDrawable createStateDrawable() {
    StateListDrawable stateListDrawable = new StateListDrawable();
    ColorDrawable normal = new ColorDrawable(Color.TRANSPARENT);
    ColorDrawable pressed = new ColorDrawable(Color.parseColor("#66000000"));
    stateListDrawable.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled },
            pressed);/*ww w.j a v  a  2s .co m*/
    stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, pressed);
    stateListDrawable.addState(new int[] { android.R.attr.state_enabled }, normal);
    stateListDrawable.addState(new int[] {}, normal);
    return stateListDrawable;
}

From source file:com.amaze.filemanager.fragments.Main.java

void switchToList() {
    IS_LIST = true;//from   www  . j  av  a 2 s  .  c  om
    if (theme1 == 1) {
        setBackground(new ColorDrawable(getResources().getColor(R.color.holo_dark_background)));
    } else {

        if (IS_LIST)
            setBackground(new ColorDrawable(getResources().getColor(android.R.color.background_light)));
        else
            setBackground(new ColorDrawable(Color.parseColor("#f2f2f2")));
    }
    ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST);
    folder = res.getDrawable(R.drawable.ic_grid_folder_new);
    fixIcons();
    if (mLayoutManager == null)
        mLayoutManager = new LinearLayoutManager(getActivity());
    listView.setLayoutManager(mLayoutManager);
    adapter = null;
}

From source file:com.filemanager.free.fragments.Main.java

void switchToList() {
    IS_LIST = true;//from   w  ww . j a  v a 2 s  . co  m
    if (theme1 == 1) {
        setBackground(new ColorDrawable(ContextCompat.getColor(getContext(), R.color.holo_dark_background)));
    } else {

        if (IS_LIST)
            setBackground(
                    new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.background_light)));
        else
            setBackground(new ColorDrawable(Color.parseColor("#f2f2f2")));
    }
    ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST);
    folder = ContextCompat.getDrawable(getContext(), R.drawable.ic_grid_folder_new);
    fixIcons();
    if (mLayoutManager == null)
        mLayoutManager = new LinearLayoutManager(getActivity());
    listView.setLayoutManager(mLayoutManager);
    adapter = null;
}

From source file:org.csp.everyaware.offline.Map.java

@Override
public void onResume() {
    Utils.paused = false;//from   w w w.j  av  a 2 s. co m
    super.onResume();
    mMapView.onResume();

    //acquire partial wake lock
    if (!mWakeLock.isHeld())
        mWakeLock.acquire();

    mLocationSource.registerLocUpdates();

    if (Utils.uploadOn == Constants.INTERNET_ON_INT)
        mInterUplStatus.setBackgroundResource(R.drawable.internet_on);
    else if (Utils.uploadOn == Constants.INTERNET_OFF_INT)
        mInterUplStatus.setBackgroundResource(R.drawable.internet_off);
    else if (Utils.uploadOn == Constants.UPLOAD_ON_INT)
        mInterUplStatus.setBackgroundResource(R.drawable.upload);

    if (mCameraTrackOn)
        mFollowCamBtn.setBackgroundResource(R.drawable.follow_camera_pressed);
    else
        mFollowCamBtn.setBackgroundResource(R.drawable.follow_camera_not_pressed);

    //register receiver for messages from store'n'forward service
    IntentFilter internetOnFilter = new IntentFilter(Constants.INTERNET_ON);
    registerReceiver(mServiceReceiver, internetOnFilter);
    IntentFilter internetOffFilter = new IntentFilter(Constants.INTERNET_OFF);
    registerReceiver(mServiceReceiver, internetOffFilter);
    IntentFilter uploadOnFilter = new IntentFilter(Constants.UPLOAD_ON);
    registerReceiver(mServiceReceiver, uploadOnFilter);
    IntentFilter uploadOffFilter = new IntentFilter(Constants.UPLOAD_OFF);
    registerReceiver(mServiceReceiver, uploadOffFilter);

    //register receiver for messages from gps tracking service
    IntentFilter phoneGpsOnFilter = new IntentFilter(Constants.PHONE_GPS_ON);
    registerReceiver(mGpsServiceReceiver, phoneGpsOnFilter);
    IntentFilter networkGpsOnFilter = new IntentFilter(Constants.NETWORK_GPS_ON);
    registerReceiver(mGpsServiceReceiver, networkGpsOnFilter);
    IntentFilter phoneGpsOffFilter = new IntentFilter(Constants.PHONE_GPS_OFF);
    registerReceiver(mGpsServiceReceiver, phoneGpsOffFilter);

    //get selected track and draw it on map
    mTrack = Utils.track;

    if (mTrack != null) {
        Log.d("Map", "onCreate()--> shown session id: " + mTrack.mSessionId);

        if (mGoogleMap != null)
            mGoogleMap.clear();

        int divider = 1;

        long trackLength = mTrack.mNumOfRecords;

        Log.d("Map", "onResume()--> track length: " + trackLength);

        if (trackLength > 1800)
            divider = 2;
        if (trackLength > 3600)
            divider = 4;
        if (trackLength > 7200)
            divider = 8;
        if (trackLength > 14400)
            divider = 16;

        mLatLngPoints = mDbManager.loadLatLngPointsBySessionId(mTrack.mSessionId, divider);
        if (mLatLngPoints != null) {
            int size = mLatLngPoints.size();

            if (size > 0) {
                calcMinAvgPollValue();
                drawPath();
                mCameraTrackOn = false;
                if (mGoogleMap != null)
                    try {
                        mGoogleMap.animateCamera(
                                CameraUpdateFactory.newLatLng(mLatLngPoints.get(size - 1).mLatLng));
                    } catch (NullPointerException e) {
                        e.printStackTrace();
                    }
            }
        }
    }

    if (mMapPolygons == null)
        mMapPolygons = new ArrayList<Polygon>();

    int color;

    //draw map cluster on the map
    if ((mMapClusters != null) && (mMapClusters.size() > 0)) {
        for (int i = 0; i < mMapClusters.size(); i++) {
            MapCluster mapCluster = mMapClusters.get(i);

            if (mapCluster.mBcLevel != 0) {
                if ((mapCluster.mBcLevel > 0) && (mapCluster.mBcLevel <= 10))
                    color = ColorHelper.numberToColor(mapCluster.mBcLevel * BC_MULTIPLIER);
                else
                    color = ColorHelper.numberToColor(100);

                mMapPolygons.add(mGoogleMap.addPolygon(new PolygonOptions()
                        .add(new LatLng(mapCluster.mMinLat, mapCluster.mMinLon),
                                new LatLng(mapCluster.mMinLat, mapCluster.mMaxLon),
                                new LatLng(mapCluster.mMaxLat, mapCluster.mMaxLon),
                                new LatLng(mapCluster.mMaxLat, mapCluster.mMinLon))
                        .strokeColor(Color.TRANSPARENT)
                        .fillColor(Color.parseColor("#66" + String.format("%06X", 0xFFFFFF & color)))));
            }
        }
    }
}

From source file:com.chalmers.feedlr.activity.FeedActivity.java

public void authorizeTwitter(View v) {
    if (!isOnline()) {
        return;//from  www .  ja v  a 2  s .co m
    }

    clientHandler.authorize(Clients.TWITTER, new AuthListener() {
        @Override
        public void onAuthorizationComplete() {
            twitterAuthButton.setText(res.getString(R.string.twitter_authorized));
            twitterAuthButton.setEnabled(false);
            twitterAuthButton.setTextColor(Color.parseColor("#919191"));
            twitterAuthButton.setBackgroundResource(R.drawable.twitter_logo_disabled);
        }

        @Override
        public void onAuthorizationFail() {
            Toast.makeText(FeedActivity.this, "Twitter authorization failed", Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.subreddit_select_menu, menu);
    // set options menu view
    int iconColor = Color.parseColor("#DBDBDB");
    (menu.findItem(R.id.menu_submit))//from w w  w .j a v  a  2s .c om
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_pencil).color(iconColor).actionBarSize());
    (menu.findItem(R.id.menu_feedprefs))
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_list_alt).color(iconColor).actionBarSize());
    if (mAppWidgetId == 0) {
        (menu.findItem(R.id.menu_widgettheme)).setEnabled(false);
    }
    (menu.findItem(R.id.menu_widgettheme))
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_paint_brush).color(iconColor).actionBarSize());
    (menu.findItem(R.id.menu_thememanager))
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_cogs).color(iconColor).actionBarSize());
    (menu.findItem(R.id.menu_account)).setIcon(
            new IconDrawable(this, Iconify.IconValue.fa_reddit_square).color(iconColor).actionBarSize());
    (menu.findItem(R.id.menu_prefs))
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_wrench).color(iconColor).actionBarSize());
    (menu.findItem(R.id.menu_about))
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_info_circle).color(iconColor).actionBarSize());

    return super.onCreateOptionsMenu(menu);
}