List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:org.openbitcoinwidget.WidgetProvider.java
private static int getColor(ColorMode colorMode, WidgetColor widgetColor) { if (colorMode.equals(ColorMode.Default)) { switch (widgetColor) { case Warning: return Color.parseColor("#ff3030"); case StartValue: return Color.YELLOW; case Normal: return Color.LTGRAY; case Increase: return Color.GREEN; case Decrease: return Color.parseColor("#ff3030"); default:/* ww w . j a va 2 s.c o m*/ throw new IllegalArgumentException("No color defined for " + widgetColor); } } else if (colorMode.equals(ColorMode.Grayscale)) { switch (widgetColor) { case Warning: return Color.WHITE; case StartValue: return Color.LTGRAY; case Normal: return Color.LTGRAY; case Increase: return Color.WHITE; case Decrease: return Color.GRAY; default: throw new IllegalArgumentException("No color defined for " + widgetColor); } } else { throw new IllegalArgumentException("No color mode defined for " + colorMode); } }
From source file:com.facebook.litho.ComponentsStethoManagerImpl.java
private static int parseColor(String color) { if (color == null || color.length() == 0) { return Color.TRANSPARENT; }/*w ww. jav a 2 s . co m*/ // Color.parse does not handle hax code with 3 ints e.g. #123 if (color.length() == 4) { final char r = color.charAt(1); final char g = color.charAt(2); final char b = color.charAt(3); color = "#" + r + r + g + g + b + b; } return Color.parseColor(color); }
From source file:com.njlabs.amrita.aid.aums.AumsActivity.java
private void getSessionIdAndLogin(final String rollNo, final String password, AumsServer.Server server) { aums.logout();/*from ww w. j a va 2 s . c o m*/ aums.switchServer(server); dialog.setMessage("Starting a new session ..."); aums.getSessionId(new SessionResponse() { @Override public void onSuccess(String formAction, String lt) { dialog.setMessage("Logging into AUMS ..."); aums.login(rollNo, password, formAction, lt, new LoginResponse() { @Override public void onSuccess(String name, String rollNo) { isLoggedIn = true; setupLayout(R.layout.activity_aums_profile, Color.parseColor("#e91e63")); dialog.dismiss(); TextView nameView = (TextView) findViewById(R.id.student_name); TextView rollNoView = (TextView) findViewById(R.id.student_roll_no); if (getCurrentFocus() != null) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } nameView.setText(WordUtils.capitalizeFully(name)); rollNoView.setText(rollNo); getSupportActionBar().setSubtitle("Logged in as " + WordUtils.capitalizeFully(name)); loadCgpa(); loadPhoto(); Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "AUMS"); bundle.putString(FirebaseAnalytics.Param.CHARACTER, name + " - " + rollNo); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "screen"); tracker.logEvent(FirebaseAnalytics.Event.LOGIN, bundle); } @Override public void onFailedAuthentication() { dialog.dismiss(); createSnackbar("Credentials were incorrect."); } @Override public void onServerChanged(AumsServer.Server server) { dialog.setMessage("Switching server ..."); getSessionIdAndLogin(rollNo, password, server); } @Override public void onFailure(Throwable throwable) { dialog.dismiss(); createSnackbar("An error occurred while connecting to the server."); Ln.e(throwable); } @Override public void onSiteStructureChange() { dialog.dismiss(); createSnackbar("Site's structure has changed. Reported to the developer."); } }); } @Override public void onFailure(Throwable throwable) { dialog.dismiss(); createSnackbar("An error occurred while connecting to the server."); Ln.e(throwable); } @Override public void onSiteStructureChange() { dialog.dismiss(); createSnackbar("Site's structure has changed. Reported to the developer."); } }); }
From source file:au.com.wallaceit.reddinator.MainActivity.java
private void setThemeColors() { int themenum = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context) .getString(context.getString(R.string.widget_theme_pref), "1")); switch (themenum) { case 1:/*from w ww . j a va 2 s.c om*/ actionBar.getCustomView().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#CEE3F8"))); appView.setBackgroundColor(Color.WHITE); configbutton.setBackgroundColor(Color.parseColor("#CEE3F8")); refreshbutton.setBackgroundColor(Color.parseColor("#CEE3F8")); errorIcon.setBackgroundColor(Color.parseColor("#CEE3F8")); srtext.setTextColor(Color.parseColor("#000000")); break; case 3: case 5: Drawable header = getResources().getDrawable(android.R.drawable.dark_header); actionBar.getCustomView().setBackgroundDrawable(header); appView.setBackgroundColor(Color.BLACK); configbutton.setBackgroundDrawable(null); refreshbutton.setBackgroundDrawable(null); errorIcon.setBackgroundDrawable(header); srtext.setTextColor(Color.parseColor("#FFFFFF")); break; case 4: case 2: actionBar.getCustomView().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#5F99CF"))); appView.setBackgroundColor(Color.BLACK); configbutton.setBackgroundColor(Color.parseColor("#5F99CF")); refreshbutton.setBackgroundColor(Color.parseColor("#5F99CF")); errorIcon.setBackgroundColor(Color.parseColor("#5F99CF")); srtext.setTextColor(Color.parseColor("#000000")); break; } }
From source file:adventure_fragments.Hiking.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); ((MainActivityTrekkly) activity).onSectionAttached(4); MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity()); mA.restoreActionBar(Color.parseColor("#DE4F5F")); }
From source file:com.flowzr.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.flowzr_sync); //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212"))); renderLastTime();//from w w w. j a v a2 s . c o m CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero); chkForce.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { resetLastTime(); renderLastTime(); } }); Button syncButton = (Button) findViewById(R.id.sync); syncButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startSync(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String accountName = MyPreferences.getFlowzrAccount(getApplicationContext()); if (accountName == null) { Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT) .show(); return; } if (isOnline(FlowzrSyncActivity.this)) { //checkPlayServices(); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); return; } // Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT) .show(); FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this); ft.execute(); //visitFlowzr(accountName); } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:com.android.nsboc.ComposeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mItem != null) { switch (mItem.id + "") { case "1": mRootView = inflater.inflate(R.layout.form_unlicensed, container, false); break; case "2": mRootView = inflater.inflate(R.layout.form_salon, container, false); break; }/* w w w . j a va 2 s .c o m*/ } showCurrentDateInEditText(); ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle); if (complianceToggle != null) { final LinearLayout complianceContainer = (LinearLayout) mRootView .findViewById(R.id.compliance_container); complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { complianceContainer.setVisibility(View.VISIBLE); final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(), R.layout.compliance_layout, null); Spinner violationTypeSpinner = (Spinner) complianceLayout .findViewById(R.id.violation_type_spinner); violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.VISIBLE); break; case 1: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.GONE); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ToggleButton anotherToggle = (ToggleButton) complianceLayout .findViewById(R.id.compliance_toggle); anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout)); complianceContainer.addView(complianceLayout); } else { complianceContainer.setVisibility(View.GONE); } } }); } ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle); if (emailToggle != null) { final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout); emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { emailLayout.setVisibility(View.VISIBLE); } else { emailLayout.setVisibility(View.GONE); } } }); } final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview); if (noticeTextView != null) { noticeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (noticeTextView.getCurrentTextColor() == Color.BLACK) { noticeTextView.setText(R.string.civil_citation_header); noticeTextView.setTextColor(Color.parseColor("#17405e")); noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>")); mRootView.findViewById(R.id.civil_citation).requestFocus(); } else { noticeTextView.setText(R.string.civil_citation_notice); noticeTextView.setMaxLines(Integer.MAX_VALUE); noticeTextView.setTextColor(Color.BLACK); noticeTextView.setText( noticeTextView.getText().toString().replace("<u>", "").replace("</u>", "")); } } }); } Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state); if (stateSpinner != null) { stateSpinner.setSelection(27); } return mRootView; }
From source file:adventure_fragments.Running.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); ((MainActivityTrekkly) activity).onSectionAttached(6); MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity()); mA.restoreActionBar(Color.parseColor("#FF8000")); }
From source file:adventure_fragments.Skiing.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); ((MainActivityTrekkly) activity).onSectionAttached(7); MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity()); mA.restoreActionBar(Color.parseColor("#79CDCD")); }
From source file:adventure_fragments.Kayaking.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); ((MainActivityTrekkly) activity).onSectionAttached(5); MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity()); mA.restoreActionBar(Color.parseColor("#028482")); }