Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.cs.widget.tab.PagerSlidingTabStrip1.java

private void addIconTab(final int position, TextImageRes res) {

    RadioButton tab = new RadioButton(getContext());
    tab.setCompoundDrawablesWithIntrinsicBounds(0, res.getResId(), 0, 0);
    tab.setButtonDrawable(new ColorDrawable(Color.TRANSPARENT));
    tab.setGravity(Gravity.CENTER);/*from  w ww  .j  a  v a2 s  .  c om*/
    tab.setText(res.getText());
    tab.setTextColor(getContext().getResources().getColorStateList(res.getTextColorId()));
    addTab(position, tab);

}

From source file:com.example.app_2.activities.ImageGridActivity.java

private void setActionBar() {
    mActionBar = getActionBar();//from   ww  w.  j a va  2s . c  o  m
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    if (mEditMode) {
        mActionBar.setBackgroundDrawable(new ColorDrawable(0xff0084b3));
        mActionBar.setDisplayShowTitleEnabled(false);
        mActionBar.setDisplayShowTitleEnabled(true);
    } else {
        mActionBar.setBackgroundDrawable(new ColorDrawable(0xff4d055e));
        mActionBar.setDisplayShowTitleEnabled(false);
        mActionBar.setDisplayShowTitleEnabled(true);
        Uri uri = Uri.parse(UserContract.CONTENT_URI + "/" + logged_user_id);
        Cursor c = getContentResolver().query(uri, new String[] { UserContract.Columns.IMG_FILENAME }, null,
                null, null);
        c.moveToFirst();
        if (!c.isAfterLast()) {
            String path = Storage.getPathToScaledBitmap(c.getString(0), 50);
            Bitmap user_icon = ScalingUtilities.decodeFile(path, 50, 50, ScalingLogic.FIT);
            mActionBar.setIcon(new BitmapDrawable(getResources(), user_icon));
        }
        c.close();
    }

    navSpinner = new ArrayList<SpinnerNavItem>();
    navSpinner.add(new SpinnerNavItem("Alfabetycznie", R.drawable.sort_ascend));
    navSpinner.add(new SpinnerNavItem("Ostatnio zmodyfikowane", R.drawable.clock));
    navSpinner.add(new SpinnerNavItem("Najczciej uywane", R.drawable.favourites));

    title_nav_adapter = new TitleNavigationAdapter(getApplicationContext(), navSpinner);
    mActionBar.setListNavigationCallbacks(title_nav_adapter, this);
}

From source file:com.androidinspain.deskclock.alarms.AlarmActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setVolumeControlStream(AudioManager.STREAM_ALARM);
    final long instanceId = AlarmInstance.getId(getIntent().getData());
    mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId);
    if (mAlarmInstance == null) {
        // The alarm was deleted before the activity got created, so just finish()
        LOGGER.e("Error displaying alarm for intent: %s", getIntent());
        finish();//www.j  a  v a 2 s. co m
        return;
    } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) {
        LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance);
        finish();
        return;
    }

    LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance);

    // Get the volume/camera button behavior setting
    mVolumeBehavior = DataModel.getDataModel().getAlarmVolumeButtonBehavior();

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);

    // Hide navigation bar to minimize accidental tap on Home key
    hideNavigationBar();

    // Close dialogs and window shade, so this is fully visible
    sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

    // Honor rotation on tablets; fix the orientation on phones.
    if (!getResources().getBoolean(com.androidinspain.deskclock.R.bool.rotateAlarmAlert)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    }

    mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);

    setContentView(com.androidinspain.deskclock.R.layout.alarm_activity);

    mAlertView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.alert);
    mAlertTitleView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_title);
    mAlertInfoView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_info);

    mContentView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.content);
    mAlarmButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.alarm);
    mSnoozeButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.snooze);
    mDismissButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.dismiss);
    mHintView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.hint);

    final TextView titleView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.title);
    final TextClock digitalClock = (TextClock) mContentView
            .findViewById(com.androidinspain.deskclock.R.id.digital_clock);
    final CircleView pulseView = (CircleView) mContentView
            .findViewById(com.androidinspain.deskclock.R.id.pulse);

    titleView.setText(mAlarmInstance.getLabelOrDefault(this));
    Utils.setTimeFormat(digitalClock, false);

    mCurrentHourColor = ThemeUtils.resolveColor(this, android.R.attr.windowBackground);
    getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor));

    mAlarmButton.setOnTouchListener(this);
    mSnoozeButton.setOnClickListener(this);
    mDismissButton.setOnClickListener(this);

    mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f);
    mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE);
    mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor);
    mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView,
            PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()),
            PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR,
                    ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0)));
    mPulseAnimator.setDuration(PULSE_DURATION_MILLIS);
    mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR);
    mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mPulseAnimator.start();
}

From source file:com.edgar.banner.BannerPagerView.java

private void init(AttributeSet attrs, int defStyle) {
    Context context = getContext();
    Resources resource = context.getResources();
    LayoutInflater.from(getContext()).inflate(R.layout.banner_layout, this, true);
    mViewPage = (LoopViewPager) findViewById(R.id.carouse_viewpager);
    setBannerScroller(new BannerScroller(getContext()));
    mViewPage.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPage.setOnPageChangeListener(mCarousePageListener);
    mBannerPageAdapter = new DefaultBannerPageViewAdapter();
    mIndicatorParams.gravity = Gravity.BOTTOM;
    mPointPadding = resource.getDimensionPixelOffset(R.dimen.point_margin);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BannerPagerView, defStyle, 0);
    int N = a.getIndexCount();
    for (int i = 0; i < N; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.BannerPagerView_bannerAnimation) {
            int transformerType = a.getInt(attr, 0);
            setBannerPageTransformer(true, TransformerType.convert(transformerType));
        } else if (attr == R.styleable.BannerPagerView_enableAutoPlayer) {
            setEnableAutoPlay(a.getBoolean(attr, false));
        } else if (attr == R.styleable.BannerPagerView_indicatorStyle) {
            mIndicatorStyle = a.getInt(attr, IndicatorStyle.CIRCLE_INDICATOR);
        } else if (attr == R.styleable.BannerPagerView_indicatorLayout) {
            int resId = a.getResourceId(attr, 0);
            if (resId != 0) {
                View indicatorView = LayoutInflater.from(context).inflate(resId, this, false);
                if (!(indicatorView instanceof BannerIndicator)) {
                    throw new IllegalArgumentException("Your indicator must implements BannerIndicator.");
                }/*from w  w w . java  2 s . c  om*/
                mIndicatorView = indicatorView;
                mBannerIndicator = (BannerIndicator) indicatorView;
                addView(mIndicatorView);
            }
        } else if (attr == R.styleable.BannerPagerView_unSelectDrawable) {
            mUnSelectedDrawable = a.getDrawable(attr);
        } else if (attr == R.styleable.BannerPagerView_selectedDrawable) {
            mSelectedDrawable = a.getDrawable(attr);
        } else if (attr == R.styleable.BannerPagerView_indicatorGravity) {
            mIndicatorGravity = a.getInt(attr, Gravity.CENTER);
        } else if (attr == R.styleable.BannerPagerView_pointPadding) {
            mPointPadding = a.getDimensionPixelOffset(attr, mPointPadding);
        } else if (attr == R.styleable.BannerPagerView_indicatorBackground) {
            mIndicatorBackground = a.getDrawable(attr);
        }
    }

    if (mUnSelectedDrawable == null) {
        mUnSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_normal_background);
    }
    if (mSelectedDrawable == null) {
        mSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_selected_background);
    }
    if (mIndicatorBackground == null) {
        mIndicatorBackground = new ColorDrawable(resource.getColor(R.color.indicator_background));
    }
    if (mBannerIndicator == null) {
        setIndicatorStyle(mIndicatorStyle);
    }

    a.recycle();
}

From source file:com.grepsound.fragments.MyProfileFragment.java

@Override
public void onResume() {
    super.onResume();
    Log.i("PROFILE", "onResume");
    ((ActionBarActivity) getActivity()).getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.holo_orange_light)));
    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("Lisional");
    deltaY = mCallbacks.getToolbar().getHeight();
    if (mProfile == null)
        mCallbacks.getProfile(this);
    else/*from   w  w w  .  j a v  a2  s  . co m*/
        onRequestSuccess(mProfile);
}

From source file:com.androidpi.bricks.gallery.lru.cache.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 *
 * @param imageView//from   w w  w  .j  av a2s .  co m
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final
        // drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(imageView.getResources().getColor(android.R.color.transparent)), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.ibm.mil.readyapps.physio.activities.LandingActivity.java

private void setupToolbarWithDrawer() {
    landingMenuDrawer = (DrawerLayout) findViewById(R.id.landing_drawer_layout);
    menuItems = (ListView) findViewById(R.id.menu_list);
    menuItems.setOnItemClickListener(this);

    View header = getLayoutInflater().inflate(R.layout.menu_header, null);

    MenuAdapter menuAdapter = new MenuAdapter(this);
    menuAdapter.setUpHeader(header);/*from  www  .j  a  v a  2s  . co  m*/
    menuItems.addHeaderView(header);
    menuItems.setAdapter(menuAdapter);
    Toolbar toolbar = new Toolbar(this);

    menuListener = new ActionBarDrawerToggle(this, landingMenuDrawer, toolbar, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            //switch menu icon to x icon
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.x_button);
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.menu_button);
        }
    };

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    LayoutInflater Inflator = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View toolbarView = Inflator.inflate(R.layout.toolbar, null);
    TextView titleText = (TextView) toolbarView.findViewById(R.id.title_text);

    Typeface robotoBold = AndroidUtils.robotoBold(this);
    titleText.setTypeface(robotoBold);

    ouchButton = (ImageButton) toolbarView.findViewById(R.id.ouch_button);
    ouchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PainLocationFragment fragment = new PainLocationFragment();
            if (!isCurrentFragment(fragment)) {
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment)
                        .addToBackStack(PainLocationFragment.class.getSimpleName()).commit();
                landingMenuDrawer.closeDrawer(menuItems);
            }
        }
    });

    actionBar = getSupportActionBar();
    actionBar.setCustomView(toolbarView, new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
            ActionBar.LayoutParams.WRAP_CONTENT));
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.black)));

    landingMenuDrawer.setDrawerListener(menuListener);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.menu_button);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

From source file:com.kccomy.orgar.ui.note.NoteFragment.java

private void initPopupWindow() {
    View popupWindowView = getActivity().getLayoutInflater().inflate(R.layout.popup_window_share, null);

    //??/*from  ww  w .j  a  va 2s . co  m*/
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addCategory(Intent.CATEGORY_DEFAULT);
    shareIntent.setType("text/plain");

    PackageManager packageManager = getContext().getPackageManager();
    List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(shareIntent,
            PackageManager.GET_RESOLVED_FILTER);

    // RecyclerAdapter
    RecyclerView recyclerView = (RecyclerView) popupWindowView.findViewById(R.id.popup_widow_share_recycler);
    ShareAdapter shareAdapter = new ShareAdapter(packageManager);
    shareAdapter.setData(resolveInfos);
    shareAdapter.setAppIconClickListener(shareListener);

    recyclerView.setAdapter(shareAdapter);
    recyclerView
            .setLayoutManager(new GridLayoutManager(getContext(), 2, LinearLayoutManager.HORIZONTAL, false));

    // ?PopupWindow
    popupWindowView.setFocusable(true);
    popupWindowView.setFocusableInTouchMode(true);

    PopupWindow popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);

    popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));

    popupWindow.setAnimationStyle(R.style.anim_menu_bottombar);

    setWindowAlpha(0.5f);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            setWindowAlpha(1f);
        }
    });

    popupWindow.showAtLocation(getActivity().getLayoutInflater().inflate(R.layout.fragment_note, null),
            Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
}

From source file:com.cw.litenote.note_add.Note_addCameraVideo.java

protected void onActivityResult(int requestCode, int resultCode, Intent videoReturnedIntent) {
    System.out.println("Note_addCameraVideo / onActivityResult");
    if (requestCode == TAKE_VIDEO_ACT) {
        if (resultCode == Activity.RESULT_OK) {
            // disable Rotate to avoid leak window
            //            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

            // Note: 
            // for Google Camera App, imageReturnedIntent is null
            // default path of Google camera is /sdcard/DCIM/Camera 

            // check returned intent
            Uri intentVideoUri = null;/*w ww .j a v a 2  s . c  o m*/
            if (videoReturnedIntent == null) {
                System.out.println("returned intent is null");
            } else {
                intentVideoUri = videoReturnedIntent.getData();

                if (intentVideoUri == null)
                    System.out.println("-- videoUri = " + null);
                else
                    System.out.println("-- videoUri = " + intentVideoUri.toString());
            }

            // set for Rotate any times
            if (noteId != null) {
                cameraVideoUri = dB_page.getNotePictureUri_byId(noteId);
            }

            // Add for Sony, the file size is 0 for given file name by putExtra 
            if (videoReturnedIntent != null) {
                Uri uri = Uri.parse(cameraVideoUri);
                File file = new File(uri.getPath());

                // update file name by returned intent
                if (file.length() == 0) {
                    System.out.println("--- file size = 0");
                    String path = Util.getLocalRealPathByUri(Note_addCameraVideo.this, intentVideoUri);
                    videoUriInDB = "file://" + path;
                    enSaveDb = true;
                    noteId = savePictureStateInDB(noteId, videoUriInDB);
                    enSaveDb = false;
                }
            }

            if (getIntent().getExtras().getString("extra_ADD_NEW_TO_TOP", "false").equalsIgnoreCase("true")
                    && (dB_page.getNotesCount(true) > 0))
                Page_recycler.swap(Page_recycler.mDb_page);

            Toast.makeText(this, R.string.toast_saved, Toast.LENGTH_SHORT).show();

            // check and delete duplicated image file in 100ANDRO (Sony) / 100MEDIA (hTC)
            int lastContentId = getLastCapturedVideoId(this);
            handleDuplicatedVideo(this, lastContentId);

            noteId = null; // set null for Insert
            takeVideoWithName();
        } else if (resultCode == RESULT_CANCELED) {
            // hide action bar
            if (getActionBar() != null)
                getActionBar().hide();

            // set background to transparent
            getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

            Toast.makeText(this, R.string.note_cancel_add_new, Toast.LENGTH_LONG).show();

            // delete the temporary note in DB
            if (noteId != null)
                dB_page.deleteNote(noteId, true);

            // When auto time out of taking picture App happens, 
            // Note_addCameraVideo activity will start from onCreate,
            // at this case, mImageUri is null
            if (videoUri != null) {
                File tempFile = new File(videoUri.getPath());
                if (tempFile.isFile()) {
                    // delete 0 bit temporary file
                    tempFile.delete();
                    System.out.println("temp 0 bit file is deleted");
                }
            }
            finish();
            return; // must add this
        }

    }
}

From source file:com.google.android.finsky.detailspage.WarningMessageModule.java

public final void bindView(View paramView) {
      WarningMessageModuleLayout localWarningMessageModuleLayout = (WarningMessageModuleLayout) paramView;
      int j;//from www.  j  ava  2 s .  c  o m
      if ((!localWarningMessageModuleLayout.mBinded) || (this.mNeedsRefresh)) {
          String str = ((WarningMessageModuleData) this.mModuleData).messageText;
          boolean bool = ((WarningMessageModuleData) this.mModuleData).isMessageLink;
          int i = ((WarningMessageModuleData) this.mModuleData).messageIconResId;
          j = ((WarningMessageModuleData) this.mModuleData).detailsDoc.mDocument.backendId;
          localWarningMessageModuleLayout.mBinded = true;
          localWarningMessageModuleLayout.mWarningMessageText.setText(str);
          localWarningMessageModuleLayout.mWarningMessageIcon.setImageResource(i);
          if (!bool) {
              break label231;
          }
          localWarningMessageModuleLayout.mWarningMessageText.setMovementMethod(LinkMovementMethod.getInstance());
      }
      for (;;) {
          Context localContext = localWarningMessageModuleLayout.getContext();
          ColorStateList localColorStateList = CorpusResourceUtils.getSecondaryTextColor(localContext, j);
          localWarningMessageModuleLayout.mWarningMessageText.setTextColor(localColorStateList);
          int k = UiUtils.interpolateColor$4868c7be(CorpusResourceUtils.getPrimaryColor(localContext, j));
          int m = localWarningMessageModuleLayout.getPaddingTop();
          int n = localWarningMessageModuleLayout.getPaddingBottom();
          int i1 = ViewCompat.getPaddingEnd(localWarningMessageModuleLayout);
          int i2 = ViewCompat.getPaddingStart(localWarningMessageModuleLayout);
          Drawable[] arrayOfDrawable = new Drawable[2];
          arrayOfDrawable[0] = new ColorDrawable(k);
          arrayOfDrawable[1] = ContextCompat.getDrawable(localContext, 2130837958);
          localWarningMessageModuleLayout.setBackgroundDrawable(new LayerDrawable(arrayOfDrawable));
          ViewCompat.setPaddingRelative(localWarningMessageModuleLayout, i2, m, i1, n);
          this.mNeedsRefresh = false;
          return;
          label231: localWarningMessageModuleLayout.mWarningMessageText.setMovementMethod(null);
      }
  }