List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:com.rp.podemu.MainActivity.java
private void updateSerialStatus() { SerialInterface serialInterface = serialInterfaceBuilder .getSerialInterface((UsbManager) getSystemService(Context.USB_SERVICE)); if (serialInterface != null) { this.serialStatusText.setTextColor(Color.rgb(0x00, 0xff, 0x00)); this.serialStatusText.setText("connected"); this.serialStatusHint.setText(String.format("VID: 0x%04X, ", serialInterface.getVID()) + String.format("PID: 0x%04X\n", serialInterface.getPID()) + "Cable: " + serialInterface.getName()); } else {//from w ww. ja v a2 s .c o m this.serialStatusText.setTextColor(Color.rgb(0xff, 0x00, 0x00)); this.serialStatusText.setText("disconnected"); this.serialStatusHint.setText(R.string.serial_status_hint); } }
From source file:lollipop.iconics.IconicsDrawable.java
/** * Set contour color for the./*from w ww.j ava 2 s. c om*/ * * @param contourColor * @return The current IconExtDrawable for chaining. */ public IconicsDrawable contourColor(@ColorInt int contourColor) { int red = Color.red(contourColor); int green = Color.green(contourColor); int blue = Color.blue(contourColor); mContourPaint.setColor(Color.rgb(red, green, blue)); mContourPaint.setAlpha(Color.alpha(contourColor)); invalidateSelf(); return this; }
From source file:es.upv.riromu.arbre.main.MainActivity.java
@Override protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("cropping")) { state[CROP_IMAGE] = savedInstanceState.getBoolean("cropping"); }//from w w w .j a va 2 s .c o m if (savedInstanceState.containsKey("treated")) { state[TREAT_IMAGE] = savedInstanceState.getBoolean("treated"); } if (savedInstanceState.containsKey("image_uri")) { image_uri = Uri.parse(savedInstanceState.getString("image_uri")); } if (savedInstanceState.getBoolean("image")) { String fileName = "temp_image.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); image = Util.decodeScaledBitmapFromFile(file.getPath(), MAX_SIZE, MAX_SIZE); // image = BitmapFactory.decodeStream(imageStream); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } } if (state[CROP_IMAGE]) { String fileName = "temp_cropped.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); croppedimage = BitmapFactory.decodeStream(imageStream); imageStream.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } if (state[TREAT_IMAGE]) { String fileName = "temp_treated.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); ImageView imv = (ImageView) findViewById(R.id.image_intro); imv.setImageBitmap(BitmapFactory.decodeStream(imageStream)); imageStream.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } ImageView imv = (ImageView) findViewById(R.id.image_intro); colours = savedInstanceState.getIntArray("colours"); if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE]) imv.setImageBitmap(croppedimage); else { imv.setImageBitmap(image); } TextView imc = (TextView) findViewById(R.id.textView); imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B])); }
From source file:com.example.android.supportv7.widget.vlayout.VLayoutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); mFirstText = (TextView) findViewById(R.id.first); mLastText = (TextView) findViewById(R.id.last); mCountText = (TextView) findViewById(R.id.count); mTotalOffsetText = (TextView) findViewById(R.id.total_offset); final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view); findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() { @Override/*from www . ja v a 2 s. c om*/ public void onClick(View v) { EditText position = (EditText) findViewById(R.id.position); if (!TextUtils.isEmpty(position.getText())) { try { int pos = Integer.parseInt(position.getText().toString()); recyclerView.scrollToPosition(pos); } catch (Exception e) { Log.e("VlayoutActivity", e.getMessage(), e); } } else { recyclerView.requestLayout(); } } }); final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) { } @Override public void onScrolled(RecyclerView recyclerView, int i, int i2) { mFirstText.setText("First: " + layoutManager.findFirstVisibleItemPosition()); mLastText.setText( "Existing: " + MainViewHolder.existing + " Created: " + MainViewHolder.createdTimes); mCountText.setText("Count: " + recyclerView.getChildCount()); mTotalOffsetText.setText("Total Offset: " + layoutManager.getOffsetToStart()); } }); //layoutManager.setRecycleOffset(300); recyclerView.setLayoutManager(layoutManager); // layoutManager.setReverseLayout(true); RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() { public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { int position = ((LayoutParams) view.getLayoutParams()).getViewPosition(); outRect.set(4, 4, 4, 4); } }; final RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool(); recyclerView.setRecycledViewPool(viewPool); // recyclerView.addItemDecoration(itemDecoration); viewPool.setMaxRecycledViews(0, 20); final DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, true); recyclerView.setAdapter(delegateAdapter); final List<DelegateAdapter.Adapter> adapters = new LinkedList<>(); if (BANNER_LAYOUT) { adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 1) { @Override public void onViewRecycled(MainViewHolder holder) { if (holder.itemView instanceof ViewPager) { ((ViewPager) holder.itemView).setAdapter(null); } } @Override public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == 1) return new MainViewHolder(LayoutInflater.from(VLayoutActivity.this) .inflate(R.layout.view_pager, parent, false)); return super.onCreateViewHolder(parent, viewType); } @Override public int getItemViewType(int position) { return 1; } @Override protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) { } @Override public void onBindViewHolder(MainViewHolder holder, int position) { if (holder.itemView instanceof ViewPager) { ViewPager viewPager = (ViewPager) holder.itemView; viewPager.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200)); // from position to get adapter viewPager.setAdapter(new PagerAdapter(this, viewPool)); } } }); } //{ // GridLayoutHelper helper = new GridLayoutHelper(10); // helper.setAspectRatio(4f); // helper.setGap(10); // adapters.add(new SubAdapter(this, helper, 80)); //} if (FLOAT_LAYOUT) { FloatLayoutHelper layoutHelper = new FloatLayoutHelper(); layoutHelper.setAlignType(FixLayoutHelper.BOTTOM_RIGHT); layoutHelper.setDefaultLocation(100, 400); LayoutParams layoutParams = new LayoutParams(150, 150); adapters.add(new SubAdapter(this, layoutHelper, 1, layoutParams)); } if (LINEAR_LAYOUT) { LinearLayoutHelper layoutHelper1 = new LinearLayoutHelper(); layoutHelper1.setAspectRatio(2.0f); LinearLayoutHelper layoutHelper2 = new LinearLayoutHelper(); layoutHelper2.setAspectRatio(4.0f); layoutHelper2.setDividerHeight(10); layoutHelper2.setMargin(10, 30, 10, 10); layoutHelper2.setPadding(10, 30, 10, 10); layoutHelper2.setBgColor(0xFFF5A623); adapters.add(new SubAdapter(this, layoutHelper1, 1)); adapters.add(new SubAdapter(this, layoutHelper2, 6) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { if (position % 2 == 0) { LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300); layoutParams.mAspectRatio = 5; holder.itemView.setLayoutParams(layoutParams); } } }); } { SingleLayoutHelper layoutHelper = new SingleLayoutHelper(); layoutHelper.setBgColor(Color.BLUE); layoutHelper.setMargin(0, 30, 0, 200); adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100))); } if (STICKY_LAYOUT) { StickyLayoutHelper layoutHelper = new StickyLayoutHelper(); //layoutHelper.setOffset(100); layoutHelper.setAspectRatio(4); adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100))); } { //final StaggeredGridLayoutHelper helper = new StaggeredGridLayoutHelper(3, 10); //helper.setBgColor(0xFF86345A); //adapters.add(new SubAdapter(this, helper, 4) { // @Override // public void onBindViewHolder(MainViewHolder holder, int position) { // super.onBindViewHolder(holder, position); // LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300); // if (position % 2 == 0) { // layoutParams.mAspectRatio = 1.0f; // } else { // layoutParams.height = 340 + position % 7 * 20; // } // holder.itemView.setLayoutParams(layoutParams); // } //}); final GridLayoutHelper helper = new GridLayoutHelper(3, 4); helper.setBgColor(0xFF86345A); adapters.add(new SubAdapter(this, helper, 4) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300); holder.itemView.setLayoutParams(layoutParams); } }); } { RangeGridLayoutHelper layoutHelper = new RangeGridLayoutHelper(4); layoutHelper.setBgColor(Color.GREEN); layoutHelper.setWeights(new float[] { 20f, 26.665f }); layoutHelper.setPadding(15, 15, 15, 15); layoutHelper.setMargin(15, 15, 15, 15); layoutHelper.setHGap(10); layoutHelper.setVGap(10); GridRangeStyle rangeStyle = new GridRangeStyle(); rangeStyle.setBgColor(Color.RED); rangeStyle.setSpanCount(2); rangeStyle.setWeights(new float[] { 46.665f }); rangeStyle.setPadding(15, 15, 15, 15); rangeStyle.setMargin(15, 15, 15, 15); rangeStyle.setHGap(5); rangeStyle.setVGap(5); layoutHelper.addRangeStyle(4, 7, rangeStyle); GridRangeStyle rangeStyle1 = new GridRangeStyle(); rangeStyle1.setBgColor(Color.YELLOW); rangeStyle1.setSpanCount(2); rangeStyle1.setWeights(new float[] { 46.665f }); rangeStyle1.setPadding(15, 15, 15, 15); rangeStyle1.setMargin(15, 15, 15, 15); rangeStyle1.setHGap(5); rangeStyle1.setVGap(5); layoutHelper.addRangeStyle(8, 11, rangeStyle1); adapters.add(new SubAdapter(this, layoutHelper, 16)); } if (SINGLE_LAYOUT) { SingleLayoutHelper layoutHelper = new SingleLayoutHelper(); layoutHelper.setBgColor(Color.rgb(135, 225, 90)); layoutHelper.setAspectRatio(4); layoutHelper.setMargin(10, 20, 10, 20); layoutHelper.setPadding(10, 10, 10, 10); adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100))); } if (COLUMN_LAYOUT) { ColumnLayoutHelper layoutHelper = new ColumnLayoutHelper(); layoutHelper.setBgColor(0xff00f0f0); layoutHelper.setWeights(new float[] { 40.0f, Float.NaN, 40 }); adapters.add(new SubAdapter(this, layoutHelper, 5) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { if (position == 0) { LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300); layoutParams.mAspectRatio = 4; holder.itemView.setLayoutParams(layoutParams); } else { LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300); layoutParams.mAspectRatio = Float.NaN; holder.itemView.setLayoutParams(layoutParams); } } }); } if (ONEN_LAYOUT) { OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper(); helper.setBgColor(0xff876384); helper.setAspectRatio(4.0f); helper.setColWeights(new float[] { 40f, 45f }); helper.setMargin(10, 20, 10, 20); helper.setPadding(10, 10, 10, 10); adapters.add(new SubAdapter(this, helper, 2)); } if (ONEN_LAYOUT) { OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper(); helper.setBgColor(0xffef8ba3); helper.setAspectRatio(2.0f); helper.setColWeights(new float[] { 40f }); helper.setRowWeight(30f); helper.setMargin(10, 20, 10, 20); helper.setPadding(10, 10, 10, 10); adapters.add(new SubAdapter(this, helper, 4) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams(); if (position == 0) { lp.rightMargin = 1; } else if (position == 1) { } else if (position == 2) { lp.topMargin = 1; lp.rightMargin = 1; } } }); } if (ONEN_LAYOUT) { adapters.add(new SubAdapter(this, new OnePlusNLayoutHelper(), 0)); OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper(); helper.setBgColor(0xff87e543); helper.setAspectRatio(1.8f); helper.setColWeights(new float[] { 33.33f, 50f, 40f }); helper.setMargin(10, 20, 10, 20); helper.setPadding(10, 10, 10, 10); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); adapters.add(new SubAdapter(this, helper, 3, lp) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams(); if (position == 0) { lp.rightMargin = 1; } } }); } if (COLUMN_LAYOUT) { adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 0)); adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 4)); } if (FIX_LAYOUT) { FixLayoutHelper layoutHelper = new FixLayoutHelper(10, 10); adapters.add(new SubAdapter(this, layoutHelper, 0)); layoutHelper = new FixLayoutHelper(FixLayoutHelper.TOP_RIGHT, 20, 20); adapters.add(new SubAdapter(this, layoutHelper, 1) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200); holder.itemView.setLayoutParams(layoutParams); } }); } //if (STICKY_LAYOUT) { // StickyLayoutHelper layoutHelper = new StickyLayoutHelper(false); // adapters.add(new SubAdapter(this, layoutHelper, 0)); // layoutHelper = new StickyLayoutHelper(false); // layoutHelper.setOffset(100); // adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100))); //} if (GRID_LAYOUT) { GridLayoutHelper layoutHelper = new GridLayoutHelper(2); layoutHelper.setMargin(7, 0, 7, 0); layoutHelper.setWeights(new float[] { 46.665f }); layoutHelper.setHGap(3); adapters.add(new SubAdapter(this, layoutHelper, 2)); layoutHelper = new GridLayoutHelper(4); layoutHelper.setWeights(new float[] { 20f, 26.665f }); layoutHelper.setMargin(7, 0, 7, 0); layoutHelper.setHGap(3); adapters.add(new SubAdapter(this, layoutHelper, 8)); } if (GRID_LAYOUT) { adapters.add(new SubAdapter(this, new GridLayoutHelper(4), 0)); GridLayoutHelper helper = new GridLayoutHelper(4); helper.setAspectRatio(4f); //helper.setColWeights(new float[]{40, 20, 30, 30}); // helper.setMargin(0, 10, 0, 10); helper.setGap(10); adapters.add(new SubAdapter(this, helper, 80) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams(); // lp.bottomMargin = 1; // lp.rightMargin = 1; } }); } if (FIX_LAYOUT) { adapters.add(new SubAdapter(this, new ScrollFixLayoutHelper(20, 20), 1) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams layoutParams = new LayoutParams(200, 200); holder.itemView.setLayoutParams(layoutParams); } }); } if (LINEAR_LAYOUT) adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 10)); if (GRID_LAYOUT) { GridLayoutHelper helper = new GridLayoutHelper(3); helper.setMargin(0, 10, 0, 10); adapters.add(new SubAdapter(this, helper, 3)); } if (STAGGER_LAYOUT) { // adapters.add(new SubAdapter(this, new StaggeredGridLayoutHelper(2, 0), 0)); final StaggeredGridLayoutHelper helper = new StaggeredGridLayoutHelper(2, 10); helper.setMargin(20, 10, 10, 10); helper.setPadding(10, 10, 20, 10); helper.setBgColor(0xFF86345A); adapters.add(new SubAdapter(this, helper, 27) { @Override public void onBindViewHolder(MainViewHolder holder, int position) { super.onBindViewHolder(holder, position); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200); if (position % 2 == 0) { layoutParams.mAspectRatio = 1.0f; } else { layoutParams.height = 340 + position % 7 * 20; } holder.itemView.setLayoutParams(layoutParams); } }); } if (COLUMN_LAYOUT) { // adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 3)); } if (GRID_LAYOUT) { // adapters.add(new SubAdapter(this, new GridLayoutHelper(4), 24)); } delegateAdapter.setAdapters(adapters); final Handler mainHandler = new Handler(Looper.getMainLooper()); trigger = new Runnable() { @Override public void run() { //recyclerView.scrollToPosition(22); //recyclerView.getAdapter().notifyDataSetChanged(); //mainHandler.postDelayed(trigger, 1000); //List<DelegateAdapter.Adapter> newAdapters = new ArrayList<>(); //newAdapters.add((new SubAdapter(VLayoutActivity.this, new ColumnLayoutHelper(), 3))); //newAdapters.add((new SubAdapter(VLayoutActivity.this, new GridLayoutHelper(4), 24))); //delegateAdapter.addAdapter(0, new SubAdapter(VLayoutActivity.this, new ColumnLayoutHelper(), 3)); //delegateAdapter.addAdapter(1, new SubAdapter(VLayoutActivity.this, new GridLayoutHelper(4), 24)); //delegateAdapter.notifyDataSetChanged(); } }; mainHandler.postDelayed(trigger, 1000); mSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mainHandler.postDelayed(new Runnable() { @Override public void run() { mSwipeRefreshLayout.setRefreshing(false); } }, 2000L); } }); setListenerToRootView(); }
From source file:com.rp.podemu.MainActivity.java
private void updateIPodStatus() { try {//w ww .j a v a 2 s . c o m if (iPodConnected == OAPMessenger.IPOD_MODE_AIR) { this.dockStatusText.setTextColor(Color.rgb(0x00, 0xff, 0x00)); this.dockStatusText.setText("AiR mode"); if (podEmuService.isDockIconLoaded) { dockingLogoView.setBitmap(podEmuService.dockIconBitmap); } } else if (iPodConnected == OAPMessenger.IPOD_MODE_SIMPLE) { this.dockStatusText.setTextColor(Color.rgb(0x00, 0xff, 0x00)); this.dockStatusText.setText("simple mode"); } else // docking station disconnected { this.dockStatusText.setTextColor(Color.rgb(0xff, 0x00, 0x00)); this.dockStatusText.setText("disconnected"); if (dockingLogoView != null) { dockingLogoView.resetBitmap(); if (podEmuService != null) { podEmuService.dockIconBitmap = dockingLogoView.getResizedBitmap(); } } } } catch (Exception e) { PodEmuLog.printStackTrace(e); throw e; } }
From source file:org.tpmkranz.notifyme.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_checkaccessibility: prefs.setPrevVersion(0);//from www. j a v a 2s .c om ((TemporaryStorage) getApplicationContext()).accessGranted(false); finish(); startActivity(getIntent()); return true; case R.id.main_menu_popup: final View view = ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.main_menu_popup, null); if (android.os.Build.VERSION.SDK_INT >= 11) view.findViewById(R.id.main_menu_popup_background).setVisibility(View.GONE); ((CheckBox) view.findViewById(R.id.main_menu_popup_background_checkbox)) .setChecked(prefs.isBackgroundColorInverted()); view.findViewById(R.id.main_menu_popup_background_caption) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((CheckBox) view.findViewById(R.id.main_menu_popup_background_checkbox)).toggle(); } }); ((CheckBox) view.findViewById(R.id.main_menu_popup_orientation_checkbox)) .setChecked(prefs.isOrientationFixed()); view.findViewById(R.id.main_menu_popup_orientation_caption) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((CheckBox) view.findViewById(R.id.main_menu_popup_orientation_checkbox)).toggle(); } }); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)).setMax(255); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_r)) .setText((progress == 0 ? "" : String.valueOf(progress))); } ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb(progress, ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .getProgress()))); } }); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_r)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { try { if (Integer.parseInt(s.toString()) > 255) { s.replace(0, s.length(), "255"); return; } else if (Integer.parseInt(s.toString()) < 0) { s.replace(0, s.length(), "0"); return; } ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .setProgress(Integer.parseInt(s.toString())); } catch (Exception e) { ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)).setProgress(0); s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)).setMax(255); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_g)) .setText((progress == 0 ? "" : String.valueOf(progress))); } ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb( ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .getProgress(), progress, ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .getProgress()))); } }); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_g)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { try { if (Integer.parseInt(s.toString()) > 255) { s.replace(0, s.length(), "255"); return; } else if (Integer.parseInt(s.toString()) < 0) { s.replace(0, s.length(), "0"); return; } ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .setProgress(Integer.parseInt(s.toString())); } catch (Exception e) { ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)).setProgress(0); s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)).setMax(255); ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_b)) .setText((progress == 0 ? "" : String.valueOf(progress))); } ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb( ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .getProgress(), progress))); } }); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_b)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { try { if (Integer.parseInt(s.toString()) > 255) { s.replace(0, s.length(), "255"); return; } else if (Integer.parseInt(s.toString()) < 0) { s.replace(0, s.length(), "0"); return; } ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .setProgress(Integer.parseInt(s.toString())); } catch (Exception e) { ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)).setProgress(0); s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((ImageView) view.findViewById(R.id.main_menu_popup_color_preview)) .setImageDrawable(new ColorDrawable(Color.rgb(prefs.getSliderBackgroundR(), prefs.getSliderBackgroundG(), prefs.getSliderBackgroundB()))); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_r)) .setText(String.valueOf(prefs.getSliderBackgroundR())); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_g)) .setText(String.valueOf(prefs.getSliderBackgroundG())); ((EditText) view.findViewById(R.id.main_menu_popup_color_edit_b)) .setText(String.valueOf(prefs.getSliderBackgroundB())); ((EditText) view.findViewById(R.id.main_menu_popup_timeout_editor)).setText( (prefs.getScreenTimeout() == 0L ? "" : String.valueOf(prefs.getScreenTimeout() / 1000L))); ((EditText) view.findViewById(R.id.main_menu_popup_timeout_editor)) .addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().equals("")) return; try { if (Long.parseLong(s.toString()) > 9999L) s.replace(0, s.length(), "9999"); else if (Long.parseLong(s.toString()) < 0L) s.replace(0, s.length(), "0"); } catch (Exception e) { s.clear(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .setChecked(prefs.isInterfaceSlider()); ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(0) .setEnabled(((CheckBox) v).isChecked()); for (int i = 0; i < 3; i++) { ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(0).setEnabled(((CheckBox) v).isChecked()); ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(1).setEnabled(((CheckBox) v).isChecked()); } ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(2) .setVisibility((((CheckBox) v).isChecked() ? View.VISIBLE : View.INVISIBLE)); } }); ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(0).setEnabled( ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)).isChecked()); for (int i = 0; i < 3; i++) { ((ViewGroup) ((ViewGroup) ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(1)) .getChildAt(i)).getChildAt(0) .setEnabled(((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); ((ViewGroup) ((ViewGroup) ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(1)) .getChildAt(i)).getChildAt(1) .setEnabled(((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); } ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(2).setVisibility( (((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)).isChecked() ? View.VISIBLE : View.INVISIBLE)); view.findViewById(R.id.main_menu_popup_interface_caption) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)).toggle(); ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(0).setEnabled( ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); for (int i = 0; i < 3; i++) { ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(0) .setEnabled(((CheckBox) view .findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); ((ViewGroup) ((ViewGroup) ((ViewGroup) view .findViewById(R.id.main_menu_popup_color)).getChildAt(1)).getChildAt(i)) .getChildAt(1) .setEnabled(((CheckBox) view .findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); } ((ViewGroup) view.findViewById(R.id.main_menu_popup_color)).getChildAt(2).setVisibility( (((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked() ? View.VISIBLE : View.INVISIBLE)); } }); new AlertDialog.Builder(this).setView(view) .setPositiveButton(R.string.main_menu_popup_save_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { prefs.setBackgroundColorInverted( ((CheckBox) view.findViewById(R.id.main_menu_popup_background_checkbox)) .isChecked()); prefs.setInterfaceSlider( ((CheckBox) view.findViewById(R.id.main_menu_popup_interface_checkbox)) .isChecked()); prefs.setSliderBackground( ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_r)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_g)) .getProgress(), ((SeekBar) view.findViewById(R.id.main_menu_popup_color_slider_b)) .getProgress()); prefs.setScreenTimeout( (((EditText) view.findViewById(R.id.main_menu_popup_timeout_editor)).getText() .toString().equals("") ? 0L : Long.parseLong(((EditText) view .findViewById(R.id.main_menu_popup_timeout_editor)) .getText().toString()) * 1000L)); prefs.setOrientationFixed( ((CheckBox) view.findViewById(R.id.main_menu_popup_orientation_checkbox)) .isChecked()); } }).setNegativeButton(R.string.main_menu_popup_cancel_button, null).show(); return true; case R.id.main_menu_help: new AlertDialog.Builder(this).setMessage(R.string.main_menu_help_message) .setTitle(R.string.main_menu_help_title) .setPositiveButton(R.string.main_menu_help_ok_button, null).setNegativeButton( R.string.main_menu_help_question_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://forum.xda-developers.com/showthread.php?t=2173226")) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }) .show(); return true; case R.id.main_menu_about: ViewGroup about = (ViewGroup) ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.main_menu_about, null); ((TextView) about.getChildAt(0)).setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(this).setView(about).setTitle(R.string.main_menu_about_title) .setPositiveButton(R.string.main_menu_about_ok_button, null).show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.ksharkapps.musicnow.ui.activities.AudioPlayerActivity.java
private void processImage() { Bitmap image = ((BitmapDrawable) mAlbumArt.getDrawable()).getBitmap(); ColorArt colorArt = new ColorArt(image); // get the colors colorArt.getBackgroundColor();/* w ww .j a v a 2 s. com*/ colorArt.getPrimaryColor(); colorArt.getSecondaryColor(); colorArt.getDetailColor(); Bitmap imagen = ((BitmapDrawable) mAlbumArt.getDrawable()).getBitmap(); long reds = 0L; long greens = 0L; long blues = 0L; int[] pixeles = new int[imagen.getWidth() * imagen.getHeight()]; imagen.getPixels(pixeles, 0, imagen.getWidth(), 0, 0, imagen.getWidth(), imagen.getHeight()); for (int cursor = 0; cursor < pixeles.length; cursor++) { reds += Color.red(pixeles[cursor]); greens += Color.green(pixeles[cursor]); blues += Color.blue(pixeles[cursor]); } long numPixels = imagen.getWidth() * imagen.getHeight(); reds /= numPixels; greens /= numPixels; blues /= numPixels; Punto3D[] pixelesRef = { new Punto3D(255, 0, 0), new Punto3D(0, 255, 0), new Punto3D(0, 0, 255), new Punto3D(255, 255, 0), new Punto3D(0, 255, 255), new Punto3D(255, 0, 255), new Punto3D(0, 0, 0), new Punto3D(255, 255, 255) }; Punto3D pixelActual = new Punto3D(reds, greens, blues); double[] distancias = { pixelActual.distancia(pixelesRef[0]), pixelActual.distancia(pixelesRef[1]), pixelActual.distancia(pixelesRef[2]), pixelActual.distancia(pixelesRef[3]), pixelActual.distancia(pixelesRef[4]), pixelActual.distancia(pixelesRef[5]), pixelActual.distancia(pixelesRef[6]), pixelActual.distancia(pixelesRef[7]) }; String[] colors = { "Red", "Green", "Blue", "Yellow", "Cyan ", "Magenta", " Black ", "White" }; double dist_minima = 255; int indice_minima = 0; for (int index = 0; index < distancias.length; index++) { if (distancias[index] <= dist_minima) { indice_minima = index; dist_minima = distancias[index]; } Log.i("Distancias", "Distancias en pos " + index + ": " + distancias[index]); } GradientDrawable gd2 = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.rgb((int) pixelesRef[indice_minima].getX(), (int) pixelesRef[indice_minima].getY(), (int) pixelesRef[indice_minima].getZ()), colorArt.getBackgroundColor(), colorArt.getDetailColor() }); gd2.setCornerRadius(0f); player_bg.setBackgroundDrawable(gd2); }
From source file:org.noise_planet.noisecapture.Results.java
private void setDataS() { ArrayList<String> xVals = new ArrayList<String>(); Collections.addAll(xVals, ltob); ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>(); for (int i = 0; i < splHistogram.size(); i++) { yVals1.add(new BarEntry(splHistogram.get(i), i)); }//from w w w . j av a2 s .c o m BarDataSet set1 = new BarDataSet(yVals1, "DataSet"); set1.setValueTextColor(Color.WHITE); set1.setColors(new int[] { Color.rgb(0, 128, 255), Color.rgb(0, 128, 255), Color.rgb(0, 128, 255), Color.rgb(102, 178, 255), Color.rgb(102, 178, 255), Color.rgb(102, 178, 255) }); ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); dataSets.add(set1); BarData data = new BarData(xVals, dataSets); data.setValueTextSize(10f); data.setValueFormatter(new FreqValueFormater(sChart)); sChart.setData(data); sChart.invalidate(); }
From source file:net.willwebberley.gowertides.ui.DayFragment.java
/****** * //from w w w .j a v a 2s. c om * INITIALIZATION METHODS */ /* * Get the layout components initialized and make their variable names global. */ private void initComponents() { try { tideGraph = new TideGraph((XYPlot) layoutView.findViewById(R.id.tideGraphComponent), dayView.getApplicationContext()); sunriseText = (TextView) layoutView.findViewById(R.id.sunriseText); sunriseText.setTextColor(Color.rgb(0, 100, 0)); sunsetText = (TextView) layoutView.findViewById(R.id.sunsetText); sunsetText.setTextColor(Color.rgb(100, 0, 0)); sunsetCountField = (TextView) layoutView.findViewById(R.id.sunsetCountField); sunsetCountField.setTextColor(Color.rgb(100, 25, 25)); weatherDescriptionView = (TextView) layoutView.findViewById(R.id.weather_description); weatherDescriptionView.setTextColor(Color.rgb(0, 150, 220)); ((TextView) layoutView.findViewById(R.id.surf_head)).setTextColor(Color.rgb(0, 150, 220)); } catch (Exception e) { System.err.println(e); } }
From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.CandlestickChartsFragment.java
public void updateKines(List<KLine> list) { if (list == null) { return;/*w w w . j av a 2 s . c om*/ } mChart.resetTracking(); ArrayList<CandleEntry> yVals1 = new ArrayList<CandleEntry>(); ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < list.size(); i++) { // float mult = 400; KLine kLine = list.get(i); float val = (float) kLine.getVal(); float high = (float) kLine.getHigh(); float low = (float) kLine.getLow(); float open = (float) kLine.getOpen(); float close = (float) kLine.getClose(); yVals1.add(new CandleEntry(i, high, low, open, close)); xVals.add(kLine.getTime()); } CandleDataSet set1 = new CandleDataSet(yVals1, "Data Set"); set1.setAxisDependency(YAxis.AxisDependency.LEFT); // set1.setColor(Color.rgb(80, 80, 80)); set1.setShadowColor(Color.DKGRAY); set1.setShadowWidth(0.7f); set1.setDecreasingColor(Color.RED); set1.setDecreasingPaintStyle(Paint.Style.FILL); set1.setIncreasingColor(Color.rgb(122, 242, 84)); set1.setIncreasingPaintStyle(Paint.Style.STROKE); set1.setNeutralColor(Color.BLUE); //set1.setHighlightLineWidth(1f); CandleData data = new CandleData(xVals, set1); mChart.setData(data); mChart.invalidate(); }