List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
@Override public boolean backPressed() { if (zoomed) { final PhysioAlertDialog alertDialog = new PhysioAlertDialog(getActivity()); alertDialog.setPrimaryText(getResources().getText(R.string.exit)); alertDialog.setSecondaryText(getResources().getString(R.string.information)); if (!blue) { ColorDrawable color = new ColorDrawable(getResources().getColor(R.color.ready_red)); alertDialog.setButtonDrawable(color); }//from www . j a va 2s .co m alertDialog.setPositiveClickListener(new View.OnClickListener() { @Override public void onClick(View v) { resetView(front); alertDialog.dismiss(); } }); alertDialog.setNegativeClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); } }); alertDialog.show(); return true; } return false; }
From source file:com.cw.litenote.DrawerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { ////*from w ww . ja v a 2 s. c o m*/ // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() // // .detectDiskReads() // .detectDiskWrites() // .detectNetwork() // .penaltyLog() // .build()); // // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() //// .detectLeakedSqlLiteObjects() //??? unmark this line will cause strict mode error // .penaltyLog() // .penaltyDeath() // .build()); /// super.onCreate(savedInstanceState); mDrawerActivity = this; setContentView(R.layout.drawer_activity); // Release mode: no debug message if (Define.CODE_MODE == Define.RELEASE_MODE) { OutputStream nullDev = new OutputStream() { public void close() { } public void flush() { } public void write(byte[] b) { } public void write(byte[] b, int off, int len) { } public void write(int b) { } }; System.setOut(new PrintStream(nullDev)); } //Log.d below can be disabled by applying proguard //1. enable proguard-android-optimize.txt in project.properties //2. be sure to use newest version to avoid build error //3. add the following in proguard-project.txt /*-assumenosideeffects class android.util.Log { public static boolean isLoggable(java.lang.String, int); public static int v(...); public static int i(...); public static int w(...); public static int d(...); public static int e(...); } */ Log.d("test log tag", "start app"); System.out.println("================start application =================="); System.out.println("DrawerActivity / onCreate"); UtilImage.getDefaultSacleInPercent(DrawerActivity.this); mAppTitle = getTitle(); mDrawerChildTitles = new ArrayList<String>(); Context context = getApplicationContext(); if (mDb != null) mDb.close(); mDb = new DB(context); mDb.initDrawerDb(mDb); if (mDb_tabs != null) mDb_tabs.close(); mDb_tabs = new DB(context, Util.getPref_lastTimeView_tabs_tableId(this)); mDb_tabs.initTabsDb(mDb_tabs); if (mDb_notes != null) mDb_tabs.close(); mDb_notes = new DB(context, Util.getPref_lastTimeView_notes_tableId(this)); mDb_notes.initNotesDb(mDb_notes); //Add note with the link String intentLink = addIntentLink(getIntent()); if (!Util.isEmptyString(intentLink)) { finish(); // for no active DrawerActivity case } else { // check DB final boolean ENABLE_DB_CHECK = false;//true;// if (ENABLE_DB_CHECK) { // list all drawer tables int drawerCount = mDb.getDrawerChildCount(); for (int drawerPos = 0; drawerPos < drawerCount; drawerPos++) { String drawerTitle = mDb.getDrawerChild_Title(drawerPos); DrawerActivity.mFocus_drawerChildPos = drawerPos; // list all tab tables int tabsTableId = mDb.getTabsTableId(drawerPos); System.out.println("--- tabs table Id = " + tabsTableId + ", drawer title = " + drawerTitle); mDb_tabs = new DB(context, tabsTableId); mDb_tabs.initTabsDb(mDb_tabs); int tabsCount = mDb_tabs.getTabsCount(true); for (int tabPos = 0; tabPos < tabsCount; tabPos++) { TabsHostFragment.mCurrent_tabIndex = tabPos; int tabId = mDb_tabs.getTabId(tabPos, true); int notesTableId = mDb_tabs.getNotesTableId(tabPos, true); String tabTitle = mDb_tabs.getTabTitle(tabPos, true); System.out.println(" --- tab Id = " + tabId); System.out.println(" --- notes table Id = " + notesTableId); System.out.println(" --- tab title = " + tabTitle); mLastOkTabId = tabId; try { mDb_notes = new DB(context, String.valueOf(notesTableId)); mDb_notes.initNotesDb(mDb_notes); mDb_notes.doOpenNotes(); mDb_notes.doCloseNotes(); } catch (Exception e) { } } } // recover focus int tabsTableId = Util.getPref_lastTimeView_tabs_tableId(this); DB.setFocus_tabsTableId(tabsTableId); String notesTableId = Util.getPref_lastTimeView_notes_tableId(this); DB.setFocus_notes_tableId(notesTableId); } //if(ENABLE_DB_CHECK) // get last time drawer number, default drawer number: 1 if (savedInstanceState == null) { for (int i = 0; i < mDb.getDrawerChildCount(); i++) { if (mDb.getTabsTableId(i) == Util.getPref_lastTimeView_tabs_tableId(this)) { mFocus_drawerChildPos = i; System.out .println("DrawerActivity / onCreate / mFocusDrawerId = " + mFocus_drawerChildPos); } } AudioPlayer.mPlayerState = AudioPlayer.PLAYER_AT_STOP; UtilAudio.mIsCalledWhilePlayingAudio = false; } // set drawer title if (mDb.getDrawerChildCount() == 0) { for (int i = 0; i < Define.ORIGIN_TABS_TABLE_COUNT; i++) { String drawerTitle = Define.getDrawerTitle(mDrawerActivity, i); mDrawerChildTitles.add(drawerTitle); mDb.insertDrawerChild(i + 1, drawerTitle); } } else { for (int i = 0; i < mDb.getDrawerChildCount(); i++) { mDrawerChildTitles.add(""); // init only mDrawerChildTitles.set(i, mDb.getDrawerChild_Title(i)); } } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerListView = (DragSortListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set adapter mDb.doOpenDrawer(); Cursor cursor = DB.mCursor_drawerChild; String[] from = new String[] { DB.KEY_DRAWER_TITLE }; int[] to = new int[] { R.id.drawerText }; drawerAdapter = new DrawerAdapter(this, R.layout.drawer_list_item, cursor, from, to, 0); mDb.doCloseDrawer(); mDrawerListView.setAdapter(drawerAdapter); // set up click listener MainUi.addDrawerItemListeners();//??? move to resume? mDrawerListView.setOnItemClickListener(MainUi.itemClick); // set up long click listener mDrawerListView.setOnItemLongClickListener(MainUi.itemLongClick); mController = DrawerListview.buildController(mDrawerListView); mDrawerListView.setFloatViewManager(mController); mDrawerListView.setOnTouchListener(mController); // init drawer dragger mPref_show_note_attribute = getSharedPreferences("show_note_attribute", 0); if (mPref_show_note_attribute.getString("KEY_ENABLE_DRAWER_DRAGGABLE", "no").equalsIgnoreCase("yes")) mDrawerListView.setDragEnabled(true); else mDrawerListView.setDragEnabled(false); mDrawerListView.setDragListener(DrawerListview.onDrag); mDrawerListView.setDropListener(DrawerListview.onDrop); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // getActionBar().setBackgroundDrawable(new ColorDrawable(ColorSet.bar_color)); getActionBar().setBackgroundDrawable(new ColorDrawable(ColorSet.getBarColor(mDrawerActivity))); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* navigation drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { System.out.println("mDrawerToggle onDrawerClosed "); int pos = mDrawerListView.getCheckedItemPosition(); int tblId = mDb.getTabsTableId(pos); DB.setSelected_tabsTableId(tblId); mDrawerChildTitle = mDb.getDrawerChild_Title(pos); setTitle(mDrawerChildTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() // add for deleting drawer if (TabsHostFragment.mTabHost == null) { MainUi.selectDrawerChild(mFocus_drawerChildPos); setTitle(mDrawerChildTitle); } } public void onDrawerOpened(View drawerView) { System.out.println("mDrawerToggle onDrawerOpened "); setTitle(mAppTitle); drawerAdapter.notifyDataSetChanged(); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mContext = getBaseContext(); bEnableConfig = false; // add on back stack changed listener fragmentManager = getSupportFragmentManager(); mOnBackStackChangedListener = DrawerActivity.this; fragmentManager.addOnBackStackChangedListener(mOnBackStackChangedListener); // register an audio stream receiver if (noisyAudioStreamReceiver == null) { noisyAudioStreamReceiver = new NoisyAudioStreamReceiver(); intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY); registerReceiver(noisyAudioStreamReceiver, intentFilter); } } // Show license dialog new EULA_dlg(this).show(); }
From source file:com.lovely3x.eavlibrary.EasyAdapterView.java
public EasyAdapterView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mDebugPaint = new Paint(Paint.ANTI_ALIAS_FLAG); this.mDebugPaint.setColor(Color.RED); this.mDebugPaint.setStrokeWidth(5); this.mDebugPaint.setTextSize( TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics())); ViewConfiguration config = ViewConfiguration.get(context); mTouchSlop = config.getScaledTouchSlop() / 2; this.mVelocity = VelocityTracker.obtain(); mMinimumVelocity = config.getScaledMinimumFlingVelocity(); mMaximumVelocity = config.getScaledMaximumFlingVelocity(); this.mTopEdgeEffect = new EdgeEffect(getContext()); this.mBottomEdgeEffect = new EdgeEffect(getContext()); this.mLeftEdgeEffect = new EdgeEffect(getContext()); this.mRightEdgeEffect = new EdgeEffect(getContext()); mDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1f, getResources().getDisplayMetrics()); mDivider = new ColorDrawable(Color.LTGRAY); if (attrs != null) initAttrs(attrs);//from w w w .j a v a 2 s . c o m setWillNotDraw(false); previewInEditMode(); }
From source file:com.androguide.honamicontrol.MainActivity.java
private StateListDrawable getColouredTouchFeedback() { StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(Color.parseColor(mAppColor))); states.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(Color.parseColor(mAppColor))); states.addState(new int[] {}, getResources().getDrawable(android.R.color.transparent)); return states; }
From source file:com.folioreader.ui.folio.activity.FolioActivity.java
@Override public void setDayMode() { Log.v(LOG_TAG, "-> setDayMode"); actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.white))); toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.black)); }
From source file:com.apptentive.android.sdk.util.Util.java
/** * helper method to generate the ImageButton background with specified highlight color. * * @param selected_color the color shown as highlight * @return//w ww . j a v a2 s . c o m */ public static StateListDrawable getSelectableImageButtonBackground(int selected_color) { ColorDrawable selectedColor = new ColorDrawable(selected_color); StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_pressed }, selectedColor); states.addState(new int[] { android.R.attr.state_activated }, selectedColor); return states; }
From source file:com.android.gallery3d.v5.filtershow.FilterShowActivity.java
public void updateUIAfterServiceStarted() { MasterImage.setMaster(mMasterImage); ImageFilter.setActivityForMemoryToasts(this); mUserPresetsManager = new UserPresetsManager(this); mUserPresetsAdapter = new UserPresetsAdapter(this); setupMasterImage();//from ww w .j ava2 s . c om setupMenu(); setDefaultValues(); fillEditors(); getWindow().setBackgroundDrawable(new ColorDrawable(0)); loadXML(); fillCategories(); loadMainPanel(); extractXMPData(); processIntent(); }
From source file:com.appsimobile.appsii.module.weather.WeatherActivity.java
void showDrawable(Drawable drawable, boolean isImmediate) { mBackgroundImage.setLayerType(View.LAYER_TYPE_SOFTWARE, null); if (isImmediate) { int w = drawable.getIntrinsicWidth(); int viewWidth = mBackgroundImage.getWidth(); float factor = viewWidth / (float) w; int h = (int) (drawable.getIntrinsicHeight() * factor); drawable.setBounds(0, 0, w, h);/*from w w w . java 2 s.co m*/ mBackgroundImage.setImageDrawable(drawable); } else { Drawable current = mBackgroundImage.getDrawable(); if (current == null) current = new ColorDrawable(Color.TRANSPARENT); TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] { current, drawable }); transitionDrawable.setCrossFadeEnabled(true); mBackgroundImage.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(500); } }
From source file:com.armtimes.drawer.NavigationDrawerFragment.java
/** * Per the navigation drawer design guidelines, updates the action bar to show the global app * 'context', rather than just what's in the current screen. *//*from www . j ava 2s .c om*/ private void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setBackgroundDrawable(new ColorDrawable(0xFFFA294C)); actionBar.setTitle(Html.fromHtml("<small>" + getActivity().getString(R.string.app_name) + "</small>")); }
From source file:com.folioreader.ui.folio.activity.FolioActivity.java
@Override public void setNightMode() { Log.v(LOG_TAG, "-> setNightMode"); actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.black))); toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.night_title_text_color)); }