List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:com.jjoe64.graphview_demos.fragments.TapOnSeries.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); GraphView graph = (GraphView) rootView.findViewById(R.id.graph); BarGraphSeries<DataPoint> series = new BarGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 3), new DataPoint(2, 1), new DataPoint(3, 0), new DataPoint(4, 3) }); series.setColor(Color.rgb(255, 120, 120)); series.setSpacing(50);//from w w w .j a v a2 s .c om graph.addSeries(series); LineGraphSeries<DataPoint> series2 = new LineGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, -1), new DataPoint(1, 1), new DataPoint(2, 2), new DataPoint(3, 1), new DataPoint(4, 4) }); graph.addSeries(series2); PointsGraphSeries<DataPoint> series3 = new PointsGraphSeries<DataPoint>( new DataPoint[] { new DataPoint(0, 3), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 5) }); graph.addSeries(series3); series3.setColor(Color.RED); // legend series.setTitle("foo"); series2.setTitle("bar"); graph.getLegendRenderer().setVisible(true); graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.MIDDLE); // register tap on series callback series.setOnDataPointTapListener(new OnDataPointTapListener() { @Override public void onTap(Series series, DataPointInterface dataPoint) { Toast.makeText(getActivity(), "Series1: On Data Point clicked: " + dataPoint, Toast.LENGTH_SHORT) .show(); } }); series2.setOnDataPointTapListener(new OnDataPointTapListener() { @Override public void onTap(Series series, DataPointInterface dataPoint) { Toast.makeText(getActivity(), "Series2: On Data Point clicked: " + dataPoint, Toast.LENGTH_SHORT) .show(); } }); series3.setOnDataPointTapListener(new OnDataPointTapListener() { @Override public void onTap(Series series, DataPointInterface dataPoint) { Toast.makeText(getActivity(), "Series3: On Data Point clicked: " + dataPoint, Toast.LENGTH_SHORT) .show(); } }); return rootView; }
From source file:com.jjoe64.graphview_demos.fragments.LineBarCombination.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); GraphView graph = (GraphView) rootView.findViewById(R.id.graph); BarGraphSeries<DataPoint> series = new BarGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, -2), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) }); graph.addSeries(series);//from w ww .j a va 2 s .c o m LineGraphSeries<DataPoint> series2 = new LineGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, 3), new DataPoint(1, 3), new DataPoint(2, 6), new DataPoint(3, 2), new DataPoint(4, 5) }); graph.addSeries(series2); // style series.setColor(Color.rgb(255, 120, 120)); series.setSpacing(50); // legend series.setTitle("foo"); series2.setTitle("bar"); graph.getLegendRenderer().setVisible(true); graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.MIDDLE); return rootView; }
From source file:com.example.h156252.connected_cars.CarGrid.java
/** Called when the activity is first created. */ @Override/*from w w w . ja v a 2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_car_grid); try { Window window = getWindow(); // clear FLAG_TRANSLUCENT_STATUS flag: window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // finally change the color window.setStatusBarColor(Color.rgb(0, 0, 0)); android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.rgb(0, 0, 0))); } catch (Exception e) { // Toast.makeText(getApplicationContext(),"Exception in actionbar "+e.getLocalizedMessage(),Toast.LENGTH_SHORT).show(); } session = new SessionManagement(this); tts = new TextToSpeech(this, this); //Toast.makeText(getApplicationContext(),"Entering activity",Toast.LENGTH_SHORT).show(); Intent intent = getIntent(); String result = intent.getStringExtra(HomeScreen.EXTRA_MESSAGE); //Toast.makeText(getApplicationContext(),"obtaining result: " +result,Toast.LENGTH_SHORT).show(); ArrayList<String> listdata = new ArrayList<String>(); try { JSONArray jArray = new JSONArray(result); if (jArray != null) { for (int i = 0; i < jArray.length(); i++) { String jstr = jArray.get(i).toString(); JSONObject jObj = new JSONObject(jstr); String id = jObj.getString("id"); //String phone = jObj.getString("phone"); String brand = jObj.getString("text"); String text = jObj.getString("cartext"); String carno = jObj.getString("carnum"); String color = jObj.getString("color"); //String isDone = jObj.getString("isDone"); String result_combine = "CAR " + i + ":\nCar id : #" + id + "*\n" + "License No. : " + carno + "\n" + "Color : " + color + "\n" + "Brand : " + brand + "\n" + "Text behind car : " + text; String rr = "Success " + result_combine; //Toast.makeText(getApplicationContext(),rr,Toast.LENGTH_SHORT).show(); String own_id = session.getID(); if (!(id.equals(own_id))) listdata.add(result_combine); } } } catch (Exception e) { //Toast.makeText(getApplicationContext(),e.getLocalizedMessage(),Toast.LENGTH_SHORT).show(); } //Toast.makeText(getApplicationContext(),"out of json",Toast.LENGTH_SHORT).show(); final GridView gridview = (GridView) findViewById(R.id.gridview); // final String[] items = new String[] { "Item1", "Item2", "Item3","Item4", "Item5", "Item6", "Item7", "Item8" }; ArrayAdapter<String> ad = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, listdata); //Toast.makeText(getApplicationContext(),"setting array adapter",Toast.LENGTH_SHORT).show(); //gridview.setBackgroundColor(Color.GRAY); gridview.setNumColumns(2); gridview.setGravity(Gravity.CENTER); gridview.setAdapter(ad); gridview.setBackgroundColor(Color.GRAY); //Toast.makeText(getApplicationContext(),"setting grid view",Toast.LENGTH_SHORT).show(); gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) { // TODO Auto-generated method stub // Toast.makeText(getApplicationContext(), "" + arg2,Toast.LENGTH_SHORT).show(); //Toast.makeText(getApplicationContext(),"Prompting speech",Toast.LENGTH_SHORT).show(); try { String s = ((TextView) v).getText().toString(); int start = 0; // '(' position in string int end = 0; // ')' position in string for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '#') // Looking for '(' position in string start = i; else if (s.charAt(i) == '*') // Looking for ')' position in string end = i; } receiver_id = s.substring(start + 1, end); //Toast.makeText(getApplicationContext(), "ID: " + receiver_id, Toast.LENGTH_SHORT).show(); //promptSpeechInput(); } catch (Exception e) { // Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } //receiver_id = grid_text.substring(grid_text.indexOf("#") + 1, grid_text.indexOf("#")); //Toast.makeText(getApplicationContext(),receiver_id,Toast.LENGTH_SHORT).show(); try { promptSpeechInput(); } catch (Exception e) { //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } try { Intent intent_rate = new Intent(getApplicationContext(), RateDriving.class); intent_rate.putExtra(EXTRA_MESSAGE, receiver_id); startActivity(intent_rate); } catch (Exception e) { //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } //new VoiceTask().execute("http://myfirst.au-syd.mybluemix.net/api/Items"); } }); }
From source file:com.cs180.ucrtinder.youwho.Messenger.MessengerPushReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (debug)//from w w w . j ava 2s . co m Log.w(TAG, "onReceive() action: " + intent.getAction() + ", extras: " + YouWhoApplication.toString(intent.getExtras(), "\n", "\n")); if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { if (debug) Log.w(TAG, "onReceive() Waking Up! due to action: " + intent.getAction()); return; } NotificationManager notificationService = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); String text = intent.getStringExtra("layer-push-message"); Uri conversationId = (Uri) intent.getExtras().get("layer-conversation-id"); String title = getTitle(context, conversationId); if (title == null) title = context.getResources().getString(R.string.app_name); Notification.Builder bld = new Notification.Builder(context); bld.setContentTitle(title).setContentText(text).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true) .setLights(Color.rgb(0, 255, 0), 100, 1900) .setDefaults(NotificationCompat.DEFAULT_SOUND | NotificationCompat.DEFAULT_VIBRATE); Intent chatIntent = new Intent(context, AtlasMessagesScreen.class); chatIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); chatIntent.putExtra(keys.CONVERSATION_URI, conversationId.toString()); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, chatIntent, PendingIntent.FLAG_ONE_SHOT); bld.setContentIntent(resultPendingIntent); final Notification notification = bld.getNotification(); try { // Group notifications by Conversation notificationService.notify(conversationId.hashCode(), notification); } catch (SecurityException ignored) { // 4.1.2 device required VIBRATE permission when in Vibrate mode. // Fixed in 4.2.1 https://android.googlesource.com/platform/frameworks/base/+/cc2e849 } }
From source file:com.licubeclub.zionhs.Notices_Parents.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notices_parents); getSupportActionBar().setDisplayHomeAsUpEnabled(true); listview = (ListView) findViewById(R.id.listView); cManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mobile = cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); wifi = cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); SRL = (SwipeRefreshLayout) findViewById(R.id.swipe_container); SRL.setColorSchemeColors(Color.rgb(231, 76, 60), Color.rgb(46, 204, 113), Color.rgb(41, 128, 185), Color.rgb(241, 196, 15)); SRL.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override// ww w .j a v a 2 s . c om public void onRefresh() { networkTask(); } }); if (mobile.isConnected() || wifi.isConnected()) { } else { Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_connection_warning), Toast.LENGTH_LONG); finish(); } networkTask(); }
From source file:it.scoppelletti.mobilepower.preference.ColorPreference.java
/** * Imposta il colore.//from ww w.j a v a 2 s .c om * * @param value Valore. * @param component Codice del componente. */ private void setColor(int value, int component) { int red, green, blue; switch (component) { case Color.RED: red = value; green = Color.green(myEditingValue); blue = Color.blue(myEditingValue); myEditingValue = Color.rgb(red, green, blue); break; case Color.GREEN: red = Color.red(myEditingValue); green = value; blue = Color.blue(myEditingValue); myEditingValue = Color.rgb(red, green, blue); break; case Color.BLUE: red = Color.red(myEditingValue); green = Color.green(myEditingValue); blue = value; myEditingValue = Color.rgb(red, green, blue); break; default: myEditingValue = value; break; } myEditingPreview.setImageDrawable(new ColorDrawable(myEditingValue)); }
From source file:com.adwhirl.adapters.QuattroAdapter.java
@Override public void handle() { AdWhirlLayout adWhirlLayout = adWhirlLayoutReference.get(); if (adWhirlLayout == null) { return;//from www. j a va2s.c o m } Activity activity = adWhirlLayout.activityReference.get(); if (activity == null) { return; } QWAdView quattro = new QWAdView(activity, siteId, publisherId, MediaType.banner, Placement.top, DisplayMode.normal, 0, AnimationType.slide, this, true); // Make sure to store the view, as Quattro callbacks don't have references // to it quattroView = quattro; Extra extra = adWhirlLayout.extra; int bgColor = Color.rgb(extra.bgRed, extra.bgGreen, extra.bgBlue); int fgColor = Color.rgb(extra.fgRed, extra.fgGreen, extra.fgBlue); quattroView.setBackgroundColor(bgColor); quattroView.setTextColor(fgColor); // Quattro callbacks will queue rotate }
From source file:foam.jellyfish.StarwispCanvas.java
public void DrawText(Canvas canvas, JSONArray prim, float sx, float sy) { try {// w ww. j av a 2s. c o m canvas.save(); if (prim.getString(6).equals("vertical")) canvas.rotate(-90, prim.getInt(2) * sx, prim.getInt(3) * sy); Paint myPaint = new Paint(); JSONArray c = prim.getJSONArray(4); myPaint.setColor(Color.rgb(c.getInt(0), c.getInt(1), c.getInt(2))); myPaint.setTextSize(prim.getInt(5)); myPaint.setTypeface(m_Typeface); canvas.drawText(prim.getString(1), prim.getInt(2) * sx, prim.getInt(3) * sy, myPaint); canvas.restore(); } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } }
From source file:com.roy.test.testPullToFresh.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new AsyncAction<JSONArray>(this) { @Override//from w w w .j a v a 2 s . c om public void afterExecution(JSONArray result) { jadapter.setArray(result); jadapter.notifyDataSetChanged(); } @Override public boolean execute(Context context) { JSONObject obj = null; try { obj = new Mon("http://www.json-generator.com/api/json/get/bUpnyUCUSW?indent=2").sendAndWrap(); setResult(obj.getJSONArray("users")); } catch (Exception exception) { } return true; } }.cancelable().execute(); jadapter = new JSONAdapter(this, new JSONArray()) { @Override public View createRowView(int index, JSONObject item) { LinearLayout layout = new LinearLayout(context); final LayoutMaker m = new LayoutMaker(context, layout, false); m.addRowLayout(false, m.layFW()); { m.getLastLayout().setBackgroundColor(Color.GREEN); m.add(m.createStyledText("").tag("id").center().size(14).color(Color.rgb(102, 139, 139)).get(), m.layFW(5)); m.add(m.createStyledText("").tag("name").center().size(11).get(), m.layFW(4)); m.add(m.createStyledText("").tag("age").center().size(13).get(), m.layFW(5)); m.add(m.createStyledText("").tag("gender").center().size(13).get(), m.layFW(5)); m.add(m.createStyledText("").tag("team").center().size(12).get(), m.layFW(4)); // Log.i("test","index is : "+String.valueOf(index) ); m.escape(); } return layout; } @Override public void fillRowView(int index, View cellRenderer, JSONObject item) throws JSONException { findView(cellRenderer, "id", TextView.class).setText(item.getString("userId")); findView(cellRenderer, "name", TextView.class).setText(item.getString("name")); findView(cellRenderer, "age", TextView.class).setText(item.getString("age")); findView(cellRenderer, "gender", TextView.class).setText(item.getString("gender")); // findView(cellRenderer, "team", TextView.class).setText(item.getString("team")); findView(cellRenderer, "team", TextView.class).setText(String.valueOf(index)); } }; list.add("Hello"); list.add("This is stormzhang"); list.add("An Android Developer"); list.add("Love Open Source"); list.add("My GitHub: stormzhang"); list.add("weibo: googdev"); // aa=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); //mListView = (ListView) findViewById(R.id.listview); // mListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getDataa())); //mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); mSwipeLayout = new SwipeRefreshLayout(this); mSwipeLayout.setOnRefreshListener(this); mListView = new ListView(this); // mListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getDataa())); mListView.setAdapter(jadapter); mSwipeLayout.addView(mListView); mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); maker.addColLayout(false, maker.layFW()); { // maker.getLastLayout().setBackgroundColor(Color.YELLOW); Config.logi("test"); maker.add(mSwipeLayout, maker.layFF()); //maker.add(mListView,maker.layWW(0)); } adapter = new ObjectAdapter<String>(this, list) { @Override public View createRowView(int index, String item) { LinearLayout layout_main = new LinearLayout(context); LayoutMaker m = new LayoutMaker(context, layout_main, false); m.addColLayout(false, m.layFF(1)); { m.add(m.createButton("test"), m.layFW(0)); m.add(m.createStyledText("123").color(Color.WHITE).get(), m.layFW(0)); } Config.logi("create row"); return layout_main; } @Override public void fillRowView(int index, View cellRenderer, String item) { //findView(cellRenderer, "fruit", TextView.class).setText(item); Config.logi("fill row"); } }; }
From source file:com.ab.activity.AbActivity.java
/** * ??./*from www .j a va 2 s. c o m*/ * * @param savedInstanceState the saved instance state * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle) */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); mInflater = LayoutInflater.from(this); //? mAbTitleBar = new AbTitleBar(this); // ab_base = new RelativeLayout(this); ab_base.setBackgroundColor(Color.rgb(255, 255, 255)); // contentLayout = new RelativeLayout(this); contentLayout.setPadding(0, 0, 0, 0); //? mAbBottomBar = new AbBottomBar(this); //View ab_base.addView(mAbTitleBar, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mAbTitleBar.setVisibility(View.GONE); RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); ab_base.addView(mAbBottomBar, layoutParamsBottomBar); RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId()); layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId()); ab_base.addView(contentLayout, layoutParamsContent); //Application? abApplication = getApplication(); //ContentView setContentView(ab_base, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); }