Java Code Examples for android.graphics.drawable.Drawable

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  36 
vote

public void setContentWidth(int width){
  Drawable popupBackground=mPopup.getBackground();
  if (popupBackground != null) {
    popupBackground.getPadding(mTempRect);
    mDropDownWidth=mTempRect.left + mTempRect.right + width;
  }
 else {
    mDropDownWidth=width;
  }
}
 

Example 2

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  36 
vote

public void setContentWidth(int width){
  Drawable popupBackground=mPopup.getBackground();
  if (popupBackground != null) {
    popupBackground.getPadding(mTempRect);
    mDropDownWidth=mTempRect.left + mTempRect.right + width;
  }
 else {
    mDropDownWidth=width;
  }
}
 

Example 3

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  36 
vote

public void setContentWidth(int width){
  Drawable popupBackground=mPopup.getBackground();
  if (popupBackground != null) {
    popupBackground.getPadding(mTempRect);
    mDropDownWidth=mTempRect.left + mTempRect.right + width;
  }
 else {
    mDropDownWidth=width;
  }
}
 

Example 4

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: CommitViewHolder.java

  36 
vote

public void updateViewFor(RevCommit commit){
  this.commit=commit;
  commit_date.setText(Time.timeSinceSeconds(commit.getCommitTime()) + ITALIC_CLIPPING_BUFFER);
  Drawable avatarBitmap=avatarSession.get(gravatarIdFor(commit.getAuthorIdent().getEmailAddress()));
  gravatar.setImageDrawable(avatarBitmap);
  commit_shortdesc.setText(commit.getShortMessage());
}
 

Example 5

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/adapter/.

Source file: SessionAdapter.java

  36 
vote

@Override public View getView(int position,View convertView,ViewGroup parent){
  View view=super.getView(position,convertView,parent);
  Session session=sessions.get(position);
  Drawable background=evenOddBackground(position);
  view.setBackgroundDrawable(background);
  fillTitle(view,context,session);
  fillStats(view,session);
  fillTypes(view,session);
  return view;
}
 

Example 6

From project Airports, under directory /src/com/nadmm/airports/wx/.

Source file: MetarFragment.java

  36 
vote

protected void addWindRow(LinearLayout layout,Metar metar){
  View row=addRow(layout,getWindsDescription(metar));
  TextView tv=(TextView)row.findViewById(R.id.item_label);
  if (metar.windDirDegrees > 0) {
    float declination=GeoUtils.getMagneticDeclination(mLocation);
    Drawable wind=WxUtils.getWindBarbDrawable(tv.getContext(),metar,declination);
    tv.setCompoundDrawablesWithIntrinsicBounds(wind,null,null,null);
    tv.setCompoundDrawablePadding(UiUtils.convertDpToPx(getActivity(),6));
  }
}
 

Example 7

From project AlarmApp-Android, under directory /src/org/alarmapp/activities/map/.

Source file: AlarmMapActivity.java

  36 
vote

private void initFirefighterOverlay(){
  Drawable drawable=this.getResources().getDrawable(R.drawable.map_marker_blue);
  fireFighterOverlay=new MarkerOverlay(drawable,this);
  List<Overlay> mapOverlays=this.map.getOverlays();
  mapOverlays.add(fireFighterOverlay);
}
 

Example 8

From project Alerte-voirie-android, under directory /src/com/c4mprod/utils/.

Source file: ImageDownloader.java

  36 
vote

/** 
 * @param imageView Any imageView
 * @return Retrieve the currently active download task (if any) associated with this imageView.null if there is no such task.
 */
private static BitmapDownloaderTask getBitmapDownloaderTask(ImageView imageView){
  if (imageView != null) {
    Drawable drawable=imageView.getDrawable();
    if (drawable instanceof DownloadedDrawable) {
      DownloadedDrawable downloadedDrawable=(DownloadedDrawable)drawable;
      return downloadedDrawable.getBitmapDownloaderTask();
    }
  }
  return null;
}
 

Example 9

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  36 
vote

public void setContentWidth(int width){
  Drawable popupBackground=mPopup.getBackground();
  if (popupBackground != null) {
    popupBackground.getPadding(mTempRect);
    mDropDownWidth=mTempRect.left + mTempRect.right + width;
  }
 else {
    mDropDownWidth=width;
  }
}
 

Example 10

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/statement/.

Source file: MakeStatementActivity.java

  36 
vote

private Drawable createBackgroundDrawable(int kind){
  Drawable result;
  if (kind == AmenService.OBJEKT_KIND_PERSON) {
    result=getResources().getDrawable(R.drawable.rounded_edges_green);
  }
 else   if (kind == AmenService.OBJEKT_KIND_PLACE) {
    result=getResources().getDrawable(R.drawable.rounded_edges_blue);
  }
 else {
    result=getResources().getDrawable(R.drawable.rounded_edges_orange);
  }
  return result;
}
 

Example 11

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  36 
vote

public void setContentWidth(int width){
  Drawable popupBackground=mPopup.getBackground();
  if (popupBackground != null) {
    popupBackground.getPadding(mTempRect);
    mDropDownWidth=mTempRect.left + mTempRect.right + width;
  }
 else {
    mDropDownWidth=width;
  }
}
 

Example 12

From project android-cropimage, under directory /src/com/android/camera/.

Source file: ImageViewTouchBase.java

  36 
vote

private void setImageBitmap(Bitmap bitmap,int rotation){
  super.setImageBitmap(bitmap);
  Drawable d=getDrawable();
  if (d != null) {
    d.setDither(true);
  }
  Bitmap old=mBitmapDisplayed.getBitmap();
  mBitmapDisplayed.setBitmap(bitmap);
  mBitmapDisplayed.setRotation(rotation);
  if (old != null && old != bitmap && mRecycler != null) {
    mRecycler.recycle(old);
  }
}
 

Example 13

From project android-joedayz, under directory /Proyectos/AndroidFoursquare/src/com/mycompany/fsq/.

Source file: FoursquareDialog.java

  36 
vote

private void setUpTitle(){
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  Drawable icon=getContext().getResources().getDrawable(R.drawable.foursquare_icon);
  mTitle=new TextView(getContext());
  mTitle.setText("Foursquare");
  mTitle.setTextColor(Color.WHITE);
  mTitle.setTypeface(Typeface.DEFAULT_BOLD);
  mTitle.setBackgroundColor(0xFF0cbadf);
  mTitle.setPadding(MARGIN + PADDING,MARGIN,MARGIN,MARGIN);
  mTitle.setCompoundDrawablePadding(MARGIN + PADDING);
  mTitle.setCompoundDrawablesWithIntrinsicBounds(icon,null,null,null);
  mContent.addView(mTitle);
}
 

Example 14

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/list/activity/task/.

Source file: InboxActivity.java

  36 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  mOtherButton.setText(R.string.clean_inbox_button_title);
  Drawable cleanIcon=getResources().getDrawable(R.drawable.edit_clear);
  cleanIcon.setBounds(0,0,24,24);
  mOtherButton.setCompoundDrawables(cleanIcon,null,null,null);
  mOtherButton.setVisibility(View.VISIBLE);
}
 

Example 15

From project android-tether, under directory /facebook/src/com/facebook/android/.

Source file: FbDialog.java

  36 
vote

private void createCrossImage(){
  mCrossImage=new ImageView(getContext());
  mCrossImage.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      mListener.onCancel();
      FbDialog.this.dismiss();
    }
  }
);
  Drawable crossDrawable=getContext().getResources().getDrawable(R.drawable.close);
  mCrossImage.setImageDrawable(crossDrawable);
  mCrossImage.setVisibility(View.INVISIBLE);
}
 

Example 16

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: PairApplicationsActivity.java

  35 
vote

/** 
 * {@inheritDoc} 
 */
@Override protected void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.pair_applications_layout);
  setHomeButtonEnabled(false);
  Bundle bundle=getIntent().getExtras();
  if (bundle.containsKey(PAIR_APP_NAME)) {
    String appName=bundle.getString(PAIR_APP_NAME);
    ImageView img=(ImageView)findViewById(R.id.imageView1);
    String logoUri="drawable/applogo_" + appName.toLowerCase();
    int imageResource=getResources().getIdentifier(logoUri,null,getPackageName());
    try {
      Drawable d=getResources().getDrawable(imageResource);
      img.setImageDrawable(d);
      img.requestLayout();
    }
 catch (    NotFoundException e) {
      Log.e(TAG,"Could not find the requested image using uri " + logoUri);
      e.printStackTrace();
    }
    TextView appNameView=(TextView)findViewById(R.id.app_name);
    appNameView.setText(appName);
  }
 else {
    Log.w(TAG,"Unknown application");
  }
}
 

Example 17

From project android-mapviewballoons, under directory /android-mapviewballoons/src/com/readystatesoftware/mapviewballoons/.

Source file: BalloonItemizedOverlay.java

  35 
vote

/** 
 * Sets the onTouchListener for the balloon being displayed, calling the overridden  {@link #onBalloonTap} method.
 */
private OnTouchListener createBalloonTouchListener(){
  return new OnTouchListener(){
    float startX;
    float startY;
    public boolean onTouch(    View v,    MotionEvent event){
      View l=((View)v.getParent()).findViewById(R.id.balloon_main_layout);
      Drawable d=l.getBackground();
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (d != null) {
          int[] states={android.R.attr.state_pressed};
          if (d.setState(states)) {
            d.invalidateSelf();
          }
        }
        startX=event.getX();
        startY=event.getY();
        return true;
      }
 else       if (event.getAction() == MotionEvent.ACTION_UP) {
        if (d != null) {
          int newStates[]={};
          if (d.setState(newStates)) {
            d.invalidateSelf();
          }
        }
        if (Math.abs(startX - event.getX()) < 40 && Math.abs(startY - event.getY()) < 40) {
          onBalloonTap(currentFocusedIndex,currentFocusedItem);
        }
        return true;
      }
 else {
        return false;
      }
    }
  }
;
}
 

Example 18

From project android-pulltorefresh, under directory /library/src/com/handmark/pulltorefresh/library/.

Source file: PullToRefreshBase.java

  35 
vote

@SuppressWarnings("deprecation") private void init(Context context,AttributeSet attrs){
  setOrientation(LinearLayout.VERTICAL);
  ViewConfiguration config=ViewConfiguration.get(context);
  mTouchSlop=config.getScaledTouchSlop();
  TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.PullToRefresh);
  if (a.hasValue(R.styleable.PullToRefresh_ptrMode)) {
    mMode=Mode.mapIntToMode(a.getInteger(R.styleable.PullToRefresh_ptrMode,0));
  }
  mRefreshableView=createRefreshableView(context,attrs);
  addRefreshableView(context,mRefreshableView);
  mHeaderLayout=createLoadingLayout(context,Mode.PULL_DOWN_TO_REFRESH,a);
  mFooterLayout=createLoadingLayout(context,Mode.PULL_UP_TO_REFRESH,a);
  if (a.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
    Drawable background=a.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
    if (null != background) {
      setBackgroundDrawable(background);
    }
  }
  if (a.hasValue(R.styleable.PullToRefresh_ptrAdapterViewBackground)) {
    Drawable background=a.getDrawable(R.styleable.PullToRefresh_ptrAdapterViewBackground);
    if (null != background) {
      mRefreshableView.setBackgroundDrawable(background);
    }
  }
  if (a.hasValue(R.styleable.PullToRefresh_ptrOverScroll)) {
    mOverScrollEnabled=a.getBoolean(R.styleable.PullToRefresh_ptrOverScroll,true);
  }
  handleStyledAttributes(a);
  a.recycle();
  updateUIForMode();
}
 

Example 19

From project AndroidCommon, under directory /src/com/asksven/android/common/privateapiproxies/.

Source file: Alarm.java

  34 
vote

public Drawable getIcon(Context ctx){
  if (m_icon == null) {
    String myPackage=m_strPackageName;
    if (!myPackage.equals("")) {
      PackageManager manager=ctx.getPackageManager();
      try {
        m_icon=manager.getApplicationIcon(myPackage);
      }
 catch (      Exception e) {
        m_icon=null;
      }
    }
  }
  return m_icon;
}
 

Example 20

From project actionbar, under directory /actionbar-library/src/main/java/com/github/erd/actionbar/widget/.

Source file: Actionbar.java

  33 
vote

/** 
 * Set the logo image.
 * @param draw Image drawable.
 */
public void setLogo(Drawable draw){
  if (draw != null) {
    logo.setImageDrawable(draw);
    logo.setVisibility(View.VISIBLE);
  }
}
 

Example 21

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarCompatHoneycomb.java

  33 
vote

public static void setIcon(Activity activity,Drawable icon){
  View v=activity.findViewById(android.R.id.home);
  if (v != null && v instanceof ImageView) {
    ((ImageView)v).setImageDrawable(icon);
  }
}
 

Example 22

From project Android, under directory /app/src/main/java/com/github/mobile/util/.

Source file: AvatarLoader.java

  33 
vote

private AvatarLoader setImage(final Drawable image,final ImageView view,Object tag){
  view.setImageDrawable(image);
  view.setTag(id.iv_avatar,tag);
  view.setVisibility(VISIBLE);
  return this;
}
 

Example 23

From project android-client, under directory /xwiki-android-components/src/hu/scythe/droidwriter/.

Source file: DroidWriterEditText.java

  33 
vote

private void initialize(){
  imageGetter=new Html.ImageGetter(){
    @Override public Drawable getDrawable(    String source){
      return null;
    }
  }
;
  this.addTextChangedListener(new DWTextWatcher());
}
 

Example 24

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: ItemizedOverlay.java

  33 
vote

/** 
 * Constructs a new ItemizedOverlay.
 * @param defaultMarker the default marker (may be null).
 */
public ItemizedOverlay(Drawable defaultMarker){
  super();
  this.defaultMarker=defaultMarker;
  this.itemPosition=new Point();
  this.visibleItems=new ArrayList<Integer>(ARRAY_LIST_INITIAL_CAPACITY);
  this.visibleItemsRedraw=new ArrayList<Integer>(ARRAY_LIST_INITIAL_CAPACITY);
}
 

Example 25

From project android-thaiime, under directory /common/src/com/android/ex/editstyledtext/.

Source file: EditStyledText.java

  33 
vote

private void rescaleBigImage(Drawable image){
  if (DBG) {
    Log.d(LOG_TAG,"--- rescaleBigImage:");
  }
  if (MAXWIDTH < 0) {
    return;
  }
  int image_width=image.getIntrinsicWidth();
  int image_height=image.getIntrinsicHeight();
  if (DBG) {
    Log.d(LOG_TAG,"--- rescaleBigImage:" + image_width + ","+ image_height+ ","+ MAXWIDTH);
  }
  if (image_width > MAXWIDTH) {
    image_width=MAXWIDTH;
    image_height=image_height * MAXWIDTH / image_width;
  }
  image.setBounds(0,0,image_width,image_height);
}
 

Example 26

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/widget/.

Source file: AbstractItemView.java

  33 
vote

public AbstractItemView(Context context,IManager manager,int width,Bitmap defaultCover,Drawable selection,int thumbSize,boolean fixedSize){
  super(context);
  if (manager != null) {
    mResponse=new CoverResponse(context,manager,defaultCover,thumbSize,mHandler);
  }
 else {
    mResponse=null;
  }
  mWidth=width;
  mDefaultCover=defaultCover;
  mSelection=selection;
  final float screenScale=fixedSize ? 1 : ThumbSize.SCREEN_SCALE;
  padding=(int)(5 * ThumbSize.PIXEL_SCALE * screenScale);
  size12=(int)(12 * ThumbSize.PIXEL_SCALE * screenScale);
  size18=(int)(18 * ThumbSize.PIXEL_SCALE * screenScale);
  size20=(int)(20 * ThumbSize.PIXEL_SCALE * screenScale);
  size25=(int)(25 * ThumbSize.PIXEL_SCALE * screenScale);
  size35=(int)(35 * ThumbSize.PIXEL_SCALE * screenScale);
  size42=(int)(42 * ThumbSize.PIXEL_SCALE * screenScale);
  size50=(int)(50 * ThumbSize.PIXEL_SCALE * screenScale);
  size55=(int)(55 * ThumbSize.PIXEL_SCALE * screenScale);
  size59=(int)(59 * ThumbSize.PIXEL_SCALE * screenScale);
  size65=(int)(65 * ThumbSize.PIXEL_SCALE * screenScale);
  size103=(int)(103 * ThumbSize.PIXEL_SCALE * screenScale);
}
 

Example 27

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/util/google/.

Source file: SimpleMenuItem.java

  33 
vote

public Drawable getIcon(){
  if (mIconDrawable != null) {
    return mIconDrawable;
  }
  if (mIconResId != 0) {
    return mMenu.getResources().getDrawable(mIconResId);
  }
  return null;
}