List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:com.jigarmjoshi.ReportFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_report, container, false); reportImageView = (ImageView) rootView.findViewById(R.id.reportImageView); this.cameraIconBitMap = BitmapFactory.decodeResource(getResources(), R.drawable.cam); p1ReportButton = (Button) rootView.findViewById(R.id.buttonReportP1); p1ReportButton.setBackgroundColor(Color.RED); p1ReportButton.setTextColor(Color.BLACK); p2ReportButton = (Button) rootView.findViewById(R.id.buttonReportP2); p2ReportButton.setBackgroundColor(Color.rgb(255, 100, 0)); // orange p2ReportButton.setTextColor(Color.BLACK); p3ReportButton = (Button) rootView.findViewById(R.id.buttonReportP3); p3ReportButton.setBackgroundColor(Color.rgb(255, 150, 0)); p3ReportButton.setTextColor(Color.BLACK); reportImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { File newFile = getImageFile(); try { newFile.createNewFile(); } catch (IOException e) { e.printStackTrace();/*from w w w. ja v a2s.com*/ } Uri outputFileUri = Uri.fromFile(newFile); Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(cameraIntent, TAKE_PHOTO_CODE); } }); p1ReportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { performAction(Utility.P1); } }); p2ReportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { performAction(Utility.P2); } }); p3ReportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { performAction(Utility.P3); } }); // Gets the MapView from the XML layout and creates it mapView = (MapView) rootView.findViewById(R.id.mapviewReport); mapView.onCreate(savedInstanceState); // Gets to GoogleMap from the MapView and does initialization stuff map = mapView.getMap(); map.getUiSettings().setMyLocationButtonEnabled(true); // map.setMyLocationEnabled(true); mapView.refreshDrawableState(); // Needs to call MapsInitializer before doing any CameraUpdateFactory // calls try { MapsInitializer.initialize(this.getActivity()); } catch (Exception e) { e.printStackTrace(); } Utility.focusAtCurrentLocation(map); return rootView; }
From source file:com.networksaremadeofstring.anonionooid.RelayGraphDetailsFragment.java
@Override public void onResume() { super.onResume(); try {//from ww w .j a v a2 s . c om graphContainer.removeAllViews(); } catch (Exception e) { e.printStackTrace(); } new AsyncTask<Void, Void, JSONObject>() { @Override protected JSONObject doInBackground(Void... params) { try { return API.getRelayGraphs(getArguments().getString(Ooo.ARG_ITEM_ID)); } catch (Exception e) { e.printStackTrace(); return null; } } @Override protected void onPostExecute(JSONObject graphDetails) { //3 Day View try { int writeValueCount = graphDetails.getJSONObject("write_history").getJSONObject("3_days") .getJSONArray("values").length(); GraphView.GraphViewData[] writeValues = new GraphView.GraphViewData[writeValueCount]; for (int i = 0; i < writeValueCount; i++) { writeValues[i] = new GraphView.GraphViewData(i, graphDetails.getJSONObject("write_history") .getJSONObject("3_days").getJSONArray("values").getInt(i)); } GraphViewSeries writeSeries = new GraphViewSeries("Write Rate", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(31, 119, 180), 1), writeValues); int readValueCount = graphDetails.getJSONObject("read_history").getJSONObject("3_days") .getJSONArray("values").length(); GraphView.GraphViewData[] readValues = new GraphView.GraphViewData[readValueCount]; for (int i = 0; i < readValueCount; i++) { readValues[i] = new GraphView.GraphViewData(i, graphDetails.getJSONObject("read_history") .getJSONObject("3_days").getJSONArray("values").getInt(i)); } GraphViewSeries readSeries = new GraphViewSeries("Read Rate", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(255, 127, 14), 1), readValues); GraphView graphView = new LineGraphView(getActivity(), "3 Day Bandwidth Activity"); graphView.addSeries(writeSeries); graphView.addSeries(readSeries); graphView.setMinimumHeight(400); graphView.setMinimumWidth(200); graphView.setShowLegend(true); graphView.setScalable(true); graphView.setHorizontalLabels(new String[] { graphDetails.getJSONObject("read_history").getJSONObject("3_days").getString("first"), graphDetails.getJSONObject("read_history").getJSONObject("3_days").getString("last") }); graphContainer.addView(graphView); } catch (Exception e) { e.printStackTrace(); } //1 week View try { int writeValueCount = graphDetails.getJSONObject("write_history").getJSONObject("1_week") .getJSONArray("values").length(); GraphView.GraphViewData[] writeValues = new GraphView.GraphViewData[writeValueCount]; for (int i = 0; i < writeValueCount; i++) { writeValues[i] = new GraphView.GraphViewData(i, graphDetails.getJSONObject("write_history") .getJSONObject("1_week").getJSONArray("values").getInt(i)); } GraphViewSeries writeSeries = new GraphViewSeries("Write Rate", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(31, 119, 180), 1), writeValues); int readValueCount = graphDetails.getJSONObject("read_history").getJSONObject("1_week") .getJSONArray("values").length(); GraphView.GraphViewData[] readValues = new GraphView.GraphViewData[readValueCount]; for (int i = 0; i < readValueCount; i++) { readValues[i] = new GraphView.GraphViewData(i, graphDetails.getJSONObject("read_history") .getJSONObject("1_week").getJSONArray("values").getInt(i)); } GraphViewSeries readSeries = new GraphViewSeries("Read Rate", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(255, 127, 14), 1), readValues); GraphView graphView = new LineGraphView(getActivity(), "1 Week Bandwidth Activity"); graphView.addSeries(writeSeries); graphView.addSeries(readSeries); graphView.setMinimumHeight(400); graphView.setMinimumWidth(200); graphView.setShowLegend(true); graphView.setHorizontalLabels(new String[] { graphDetails.getJSONObject("read_history").getJSONObject("1_week").getString("first"), graphDetails.getJSONObject("read_history").getJSONObject("1_week").getString("last") }); graphView.setScalable(true); graphContainer.addView(graphView); } catch (Exception e) { e.printStackTrace(); } //1 Month View try { int writeValueCount = graphDetails.getJSONObject("write_history").getJSONObject("1_month") .getJSONArray("values").length(); GraphView.GraphViewData[] writeValues = new GraphView.GraphViewData[writeValueCount]; for (int i = 0; i < writeValueCount; i++) { writeValues[i] = new GraphView.GraphViewData(i, graphDetails.getJSONObject("write_history") .getJSONObject("1_month").getJSONArray("values").getInt(i)); } GraphViewSeries writeSeries = new GraphViewSeries("Write Rate", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(31, 119, 180), 1), writeValues); int readValueCount = graphDetails.getJSONObject("read_history").getJSONObject("1_month") .getJSONArray("values").length(); GraphView.GraphViewData[] readValues = new GraphView.GraphViewData[readValueCount]; for (int i = 0; i < readValueCount; i++) { readValues[i] = new GraphView.GraphViewData(i, graphDetails.getJSONObject("read_history") .getJSONObject("1_month").getJSONArray("values").getInt(i)); } GraphViewSeries readSeries = new GraphViewSeries("Read Rate", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(255, 127, 14), 1), readValues); GraphView graphView = new LineGraphView(getActivity(), "1 Month Bandwidth Activity"); graphView.addSeries(writeSeries); graphView.addSeries(readSeries); graphView.setMinimumHeight(400); graphView.setMinimumWidth(200); graphView.setShowLegend(true); graphView.setScalable(true); graphView.setHorizontalLabels(new String[] { graphDetails.getJSONObject("read_history").getJSONObject("1_month").getString("first"), graphDetails.getJSONObject("read_history").getJSONObject("1_month") .getString("last") }); graphContainer.addView(graphView); } catch (Exception e) { e.printStackTrace(); } } }.execute(null, null, null); }
From source file:at.wada811.gammacorrection.MainActivity.java
protected Bitmap gamma(double gamma) { int[] lut = new int[256]; for (int i = 0; i < lut.length; i++) { lut[i] = Math.min((int) Math.round(255 * Math.pow(i / 255.0, 1.0 / gamma)), 255); }// www .j ava 2 s.c o m Bitmap bitmap = BitmapUtils.copy(mBitmap); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); for (int w = 0; w < width; w++) { for (int h = 0; h < height; h++) { int r = 0; int g = 0; int b = 0; int color = pixels[w + h * width]; r = Color.red(color); g = Color.green(color); b = Color.blue(color); // r = lut[r]; g = lut[g]; b = lut[b]; // color = Color.rgb(r, g, b); pixels[w + h * width] = color; } } bitmap.setPixels(pixels, 0, width, 0, 0, width, height); return bitmap; }
From source file:com.dcs.fakecurrencydetector.MainActivity.java
@Override public void onClick(View view) { String serialPrefix = readText(input); int id = radioGroup.getCheckedRadioButtonId(); RadioButton selectedRadio = (RadioButton) radioGroup.findViewById(id); String noteValue = selectedRadio.getText().toString(); boolean found = foundInFakeNotesStore(serialPrefix, noteValue); if (found) {/*from www . j a va2 s . c om*/ resultView.setTextColor(Color.RED); resultView.setText(R.string.search_result_found); } else { resultView.setTextColor(Color.rgb(0x33, 0x66, 0x00)); resultView.setText(R.string.search_result_notfound); } }
From source file:com.emotiona.study.listviewpage.SwipeMenuListViewFragment.java
private void initData() { mAppList = getActivity().getPackageManager().getInstalledApplications(0); mAdapter = new AppAdapter(); mListView.setAdapter(mAdapter);//from w ww . ja va 2 s .c om // step 1. create a MenuCreator SwipeMenuCreator creator = new SwipeMenuCreator() { @Override public void create(SwipeMenu menu) { // create "open" item SwipeMenuItem openItem = new SwipeMenuItem(getActivity()); // set item background openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9, 0xCE))); // set item width openItem.setWidth(dp2px(90)); // set item title openItem.setTitle("Open"); // set item title fontsize openItem.setTitleSize(18); // set item title font color openItem.setTitleColor(Color.WHITE); openItem.setIcon(android.R.drawable.ic_menu_add); // add to menu menu.addMenuItem(openItem); // create "delete" item SwipeMenuItem deleteItem = new SwipeMenuItem(getActivity()); // set item background deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25))); // set item width deleteItem.setWidth(dp2px(90)); // set a icon deleteItem.setIcon(android.R.drawable.ic_delete); // add to menu menu.addMenuItem(deleteItem); } }; // set creator mListView.setMenuCreator(creator); // step 2. listener item click event mListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(int position, SwipeMenu menu, int index) { ApplicationInfo item = mAppList.get(position); switch (index) { case 0: // open open(item); break; case 1: // delete // delete(item); mAppList.remove(position); mAdapter.notifyDataSetChanged(); break; } return false; } }); // set SwipeListener mListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() { @Override public void onSwipeStart(int position) { // swipe start } @Override public void onSwipeEnd(int position) { // swipe end } }); // set MenuStateChangeListener mListView.setOnMenuStateChangeListener(new SwipeMenuListView.OnMenuStateChangeListener() { @Override public void onMenuOpen(int position) { } @Override public void onMenuClose(int position) { } }); // other setting // listView.setCloseInterpolator(new BounceInterpolator()); // test item long click mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getActivity(), position + " long click", Toast.LENGTH_SHORT).show(); return false; } }); }
From source file:com.zhejunzhu.ucviewpager.weight.StreamTabIndicator.java
public StreamTabIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); mSelectColor = Color.rgb(11, 188, 188); mUnSelectColor = Color.rgb(188, 188, 188); mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT)); }
From source file:bg.phpgcm2.MainActivity.java
private void newButton(String str, int num) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.height = 30;//from ww w. j a va2 s . c om final LinearLayout lm = (LinearLayout) findViewById(R.id.mainLayout); Button btn = new Button(this); btn.setId(num); get_map_data_btn_id = btn.getId(); btn.setText("get_map_data"); btn.setBackgroundColor(Color.rgb(170, 180, 190)); lm.addView(btn, params); Button btn1 = ((Button) findViewById(get_map_data_btn_id)); btn1.setPadding(0, 0, 0, 0); btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { SharedPreferences settings = getSharedPreferences("Motolife", MODE_PRIVATE); String fb = settings.getString("fb", "0"); Toast.makeText(view.getContext(), "Button clicked index = " + get_map_data_btn_id, Toast.LENGTH_SHORT).show(); } }); }
From source file:com.mycodehurts.rapidmath.app.TestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_test); if (savedInstanceState == null) { //getSupportFragmentManager().beginTransaction() //.add(R.id.container, new PlaceholderFragment()) //.commit(); }//from ww w . j a v a2 s. c o m Bundle extras = getIntent().getExtras(); if (extras != null) { iLevel = extras.getInt("iLevel"); if (iLevel == 0) { strTestType = "Easy"; ((TextView) findViewById(R.id.txtTestType)).setTextColor(Color.rgb(0, 128, 0)); } else if (iLevel == 1) { strTestType = "Medium"; ((TextView) findViewById(R.id.txtTestType)).setTextColor(Color.rgb(255, 140, 0)); } else { strTestType = "Hard"; ((TextView) findViewById(R.id.txtTestType)).setTextColor(Color.rgb(255, 0, 0)); } ((TextView) findViewById(R.id.txtTestType)).setText(strTestType); bEnableTimer = extras.getInt("enableTimer"); } Button btn = (Button) findViewById(R.id.btnNextQuestion); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onBtnClicked(view); } }); PrepareQuestions(); NextQuestion(); ((RMApplication) getApplication()).getTracker(RMApplication.TrackerName.APP_TRACKER); }
From source file:com.cwx.daytodayaccount.view.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);// w w w.ja v a 2 s. c om setBackgroundColor(Color.rgb(164, 211, 238)); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
From source file:org.akvo.caddisfly.app.MainApp.java
public void setSwatches(String testCode) { testCode = testCode.toUpperCase();/*www. java 2s . c om*/ colorList.clear(); rangeIntervals.clear(); try { currentTestInfo = JsonUtils.loadJson(FileUtils.readRawTextFile(this, R.raw.tests_json), testCode); } catch (JSONException e) { e.printStackTrace(); } if (currentTestInfo == null) { return; } rangeStart = currentTestInfo.getRanges().get(0).getStart(); double rangeEnd = currentTestInfo.getRanges().get(0).getEnd(); rangeIncrementStep = currentTestInfo.getIncrement(); double increment; increment = rangeIncrementStep * rangeIncrementValue; for (double i = 0.0; i <= rangeEnd - rangeStart; i += increment) { rangeIntervals.add(i); } for (double i = 0; i <= (rangeEnd - rangeStart) * 10; i++) { colorList.add(new ColorInfo(Color.rgb(0, 0, 0), 100)); } loadCalibratedSwatches(currentTestInfo.getCode()); }