Java Code Examples for android.graphics.drawable.BitmapDrawable
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 android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/voice/.
Source file: SoundIndicator.java

public SoundIndicator(Context context,AttributeSet attrs){ super(context,attrs); mFrontDrawable=getDrawable(); BitmapDrawable edgeDrawable=(BitmapDrawable)context.getResources().getDrawable(R.drawable.vs_popup_mic_edge); mEdgeBitmap=edgeDrawable.getBitmap(); mEdgeBitmapOffset=mEdgeBitmap.getHeight() / 2; mDrawingBuffer=Bitmap.createBitmap(mFrontDrawable.getIntrinsicWidth(),mFrontDrawable.getIntrinsicHeight(),Config.ARGB_8888); mBufferCanvas=new Canvas(mDrawingBuffer); mClearPaint=new Paint(); mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mMultPaint=new Paint(); mMultPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); mHandler=new Handler(); }
Example 2
From project ActionBarSherlock, under directory /samples/demos/src/com/actionbarsherlock/sample/demos/.
Source file: Styled.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.text); ((TextView)findViewById(R.id.text)).setText(R.string.styled_content); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { BitmapDrawable bg=(BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped); bg.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); getSupportActionBar().setBackgroundDrawable(bg); BitmapDrawable bgSplit=(BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped_split_img); bgSplit.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); getSupportActionBar().setSplitBackgroundDrawable(bgSplit); } }
Example 3
From project agit, under directory /agit/src/main/java/com/madgag/android/.
Source file: ActionBarUtil.java

public static void fixImageTilingOn(ActionBar actionBar){ if (Build.VERSION.SDK_INT < ICE_CREAM_SANDWICH) { Resources resources=actionBar.getThemedContext().getResources(); BitmapDrawable bg=(BitmapDrawable)resources.getDrawable(R.drawable.actionbar_background); bg.setTileModeXY(REPEAT,REPEAT); actionBar.setBackgroundDrawable(bg); } }
Example 4
From project andlytics, under directory /src/com/github/andlyticsproject/.
Source file: BaseDetailsActivity.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); getSupportActionBar().setDisplayHomeAsUpEnabled(true); String appName=getDbAdapter().getAppName(packageName); if (appName != null) { getSupportActionBar().setSubtitle(appName); } if (iconFilePath != null) { Bitmap bm=BitmapFactory.decodeFile(iconFilePath); BitmapDrawable icon=new BitmapDrawable(getResources(),bm); getSupportActionBar().setIcon(icon); } }
Example 5
From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/voice/.
Source file: SoundIndicator.java

public SoundIndicator(Context context,AttributeSet attrs){ super(context,attrs); mFrontDrawable=getDrawable(); BitmapDrawable edgeDrawable=(BitmapDrawable)context.getResources().getDrawable(R.drawable.vs_popup_mic_edge); mEdgeBitmap=edgeDrawable.getBitmap(); mEdgeBitmapOffset=mEdgeBitmap.getHeight() / 2; mDrawingBuffer=Bitmap.createBitmap(mFrontDrawable.getIntrinsicWidth(),mFrontDrawable.getIntrinsicHeight(),Config.ARGB_8888); mBufferCanvas=new Canvas(mDrawingBuffer); mClearPaint=new Paint(); mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mMultPaint=new Paint(); mMultPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); mHandler=new Handler(); }
Example 6
From project androidquery, under directory /src/com/androidquery/callback/.
Source file: BitmapAjaxCallback.java

private static Drawable makeDrawable(ImageView iv,Bitmap bm,float ratio,float anchor){ BitmapDrawable bd=null; if (ratio > 0) { bd=new RatioDrawable(iv.getResources(),bm,iv,ratio,anchor); } else { bd=new BitmapDrawable(iv.getResources(),bm); } return bd; }
Example 7
From project androidZenWriter, under directory /src/com/javaposse/android/zenwriter/.
Source file: AndroidZenWriterActivity.java

public static Drawable getDrawable(Context context,String filename){ BitmapFactory.Options opts=new BitmapFactory.Options(); opts.inSampleSize=2; Bitmap backgroundBitmap=BitmapFactory.decodeFile(filename,opts); if (backgroundBitmap != null) { BitmapDrawable drawable=new BitmapDrawable(context.getResources(),backgroundBitmap); return drawable; } return null; }
Example 8
From project apps-for-android, under directory /AnyCut/src/com/example/anycut/.
Source file: CreateShortcutActivity.java

/** * Returns the icon for the phone call action. * @param r The resources to load the icon from * @param resId The resource ID to load * @return the icon for the phone call action */ private Bitmap getPhoneActionIcon(Resources r,int resId){ Drawable phoneIcon=r.getDrawable(resId); if (phoneIcon instanceof BitmapDrawable) { BitmapDrawable bd=(BitmapDrawable)phoneIcon; return bd.getBitmap(); } else { return null; } }
Example 9
From project BazaarUtils, under directory /src/com/congenialmobile/widget/.
Source file: LazyImageView.java

public void unloadDrawable(){ loadRequested=false; Drawable d=imageView.getDrawable(); if (super.getCurrentView() == imageView) super.showNext(); if (d == null) return; if (d == loadedDrawable && (d instanceof BitmapDrawable)) { if (DEBUG_LIV) Log.i(TAG,"LazyImageView :: unloadDrawable"); BitmapDrawable bd=(BitmapDrawable)d; bd.getBitmap().recycle(); loadedDrawable=null; imageView.setImageDrawable(null); } }
Example 10
From project BibleQuote-for-Android, under directory /src/com/BibleQuote/utils/.
Source file: ViewUtils.java

public static void setActionBarBackground(SherlockActivity context){ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { BitmapDrawable bg=(BitmapDrawable)context.getResources().getDrawable(R.drawable.action_bar_bg); bg.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); context.getSupportActionBar().setBackgroundDrawable(bg); } }
Example 11
From project callmeter, under directory /src/de/ub0r/android/callmeter/.
Source file: CallMeter.java

/** * Fix ActionBar background. See http://b.android.com/15340. * @param ab {@link ActionBar} * @param r {@link Resources} * @param bg res id of background {@link BitmapDrawable} * @param bgSplit res id of background {@link BitmapDrawable} in split mode */ public static void fixActionBarBackground(final ActionBar ab,final Resources r,final int bg,final int bgSplit){ BitmapDrawable d=(BitmapDrawable)r.getDrawable(bg); d.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); ab.setBackgroundDrawable(d); if (bgSplit >= 0) { d=(BitmapDrawable)r.getDrawable(bgSplit); d.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); ab.setSplitBackgroundDrawable(d); } }
Example 12
From project Common-Sense-Net-2, under directory /RealFarm/src/com/commonsensenet/realfarm/.
Source file: HelpEnabledActivity.java

/** * Initializes all the shared components. */ protected void initActivity(){ mDataProvider=RealFarmProvider.getInstance(this); mSoundQueue=SoundQueue.getInstance(); ApplicationTracker.getInstance().logEvent(EventType.ACTIVITY_VIEW,Global.userId,getLogTag()); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); BitmapDrawable bg=(BitmapDrawable)getResources().getDrawable(R.drawable.bg_curved_extended); getSupportActionBar().setBackgroundDrawable(bg); }
Example 13
From project danbooru-gallery-android, under directory /src/tw/idv/palatis/danboorugallery/.
Source file: ViewImageActivity.java

@Override public void onDestroy(){ BitmapDrawable drawable=(BitmapDrawable)image.getDrawable(); if (drawable != null) { Bitmap bitmap=drawable.getBitmap(); if (bitmap != null) if (BitmapMemCache.getInstance().get(post.preview_url) != bitmap) bitmap.recycle(); } image.setImageDrawable(null); super.onDestroy(); }
Example 14
From project droid-comic-viewer, under directory /src/net/robotmedia/acv/ui/widget/.
Source file: SuperImageView.java

public int getOriginalWidth(){ Drawable image=getDrawable(); BitmapDrawable bitmapDrawable; if (image instanceof BitmapDrawable && (bitmapDrawable=(BitmapDrawable)image).getBitmap() != null) { return bitmapDrawable.getBitmap().getWidth(); } else if (image != null) { return image.getIntrinsicWidth(); } else { return 0; } }
Example 15
From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/demos/src/com/actionbarsherlock/sample/demos/.
Source file: Styled.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.text); ((TextView)findViewById(R.id.text)).setText(R.string.styled_content); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { BitmapDrawable bg=(BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped); bg.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); getSupportActionBar().setBackgroundDrawable(bg); BitmapDrawable bgSplit=(BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped_split_img); bgSplit.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); getSupportActionBar().setSplitBackgroundDrawable(bgSplit); } }
Example 16
From project greenInject, under directory /greenInjectTest/src/de/greenrobot/inject/test/.
Source file: ActivityInjectTest.java

public void testInject(){ TestActivity activity=getActivity(); assertNotNull(activity.textViewReference); assertNull(activity.textView); assertNull(activity.app_name); assertNull(activity.icon); Injector.injectInto(activity); assertSame(activity.textViewReference,activity.textView); assertEquals(activity.getString(R.string.app_name),activity.app_name); BitmapDrawable drawable=(BitmapDrawable)activity.getResources().getDrawable(R.drawable.icon); assertEquals(drawable.getBitmap().getHeight(),activity.icon.getBitmap().getHeight()); assertEquals(drawable.getBitmap().getHeight(),activity.iconBitmap.getHeight()); }
Example 17
From project ICS_LatinIME_QHD, under directory /java/src/com/android/inputmethod/deprecated/voice/.
Source file: SoundIndicator.java

public SoundIndicator(Context context,AttributeSet attrs){ super(context,attrs); mFrontDrawable=getDrawable(); BitmapDrawable edgeDrawable=(BitmapDrawable)context.getResources().getDrawable(R.drawable.vs_popup_mic_edge); mEdgeBitmap=edgeDrawable.getBitmap(); mEdgeBitmapOffset=mEdgeBitmap.getHeight() / 2; mDrawingBuffer=Bitmap.createBitmap(mFrontDrawable.getIntrinsicWidth(),mFrontDrawable.getIntrinsicHeight(),Config.ARGB_8888); mBufferCanvas=new Canvas(mDrawingBuffer); mClearPaint=new Paint(); mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mMultPaint=new Paint(); mMultPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); mHandler=new Handler(); }
Example 18
From project iPhoroidUI, under directory /src/org/klab/iphoroid/widget/support/.
Source file: HasImage.java

/** * @see #imageViewsOfActivity */ private static boolean isUsed(Bitmap target){ for ( ImageView imageView : getImageViewsOfActivities()) { BitmapDrawable bitmapDrawable=(BitmapDrawable)imageView.getDrawable(); if (bitmapDrawable != null) { Bitmap bitmap=bitmapDrawable.getBitmap(); if (bitmap == target) { return true; } } } return false; }
Example 19
From project kevoree-library, under directory /android/org.kevoree.library.android.osmdroid/src/main/java/org/osmdroid/views/overlay/.
Source file: TilesOverlay.java

private void clearLoadingTile(){ final BitmapDrawable bitmapDrawable=mLoadingTile; mLoadingTile=null; if (bitmapDrawable != null) { bitmapDrawable.getBitmap().recycle(); } }
Example 20
From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/graphics/.
Source file: DensityActivity.java

private void addBitmapDrawable(LinearLayout layout,int resource,boolean scale){ Bitmap bitmap; bitmap=loadAndPrintDpi(resource,scale); View view=new View(this); final BitmapDrawable d=new BitmapDrawable(getResources(),bitmap); if (!scale) d.setTargetDensity(getResources().getDisplayMetrics()); view.setBackgroundDrawable(d); view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(),d.getIntrinsicHeight())); layout.addView(view); }
Example 21
void UpdateBackground(int backgroundType,int backgroundTileSize,int backgroundColour){ Bitmap bitmap=generateBackgroundTile(backgroundType,backgroundTileSize,backgroundColour); BitmapDrawable bd=new BitmapDrawable(bitmap); bd.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); mCanvasView.setBackgroundDrawable(bd); }
Example 22
From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/mit150/.
Source file: MIT150RemoteView.java

/** */ public void updateImage(Bitmap image){ LayoutParams params=new LayoutParams(width,LayoutParams.WRAP_CONTENT); setLayoutParams(params); Bitmap bm; bm=BitmapUtils.getRoundedCornerBitmap(ctx,image,0); mContentView.setImageBitmap(bm); mTextView=(TextView)findViewById(R.id.mit150CorridorTV); bm=BitmapUtils.createRoundedBottomBitmap(ctx,width,50,color); BitmapDrawable bd=new BitmapDrawable(bm); mTextView.setBackgroundDrawable(bd); }
Example 23
public static Drawable getRotatedDrawable(Context context,int resid,float rotation){ Resources res=context.getResources(); Bitmap bmp=BitmapFactory.decodeResource(res,resid); Bitmap rotated=Bitmap.createBitmap(bmp.getWidth(),bmp.getHeight(),Bitmap.Config.ARGB_8888); Canvas canvas=new Canvas(rotated); canvas.setDensity(Bitmap.DENSITY_NONE); canvas.rotate(rotation,bmp.getWidth() / 2,bmp.getHeight() / 2); canvas.drawBitmap(bmp,0,0,sPaint); return new BitmapDrawable(res,rotated); }
Example 24
From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/cwac/cache/.
Source file: SimpleWebImageCache.java

@Override protected Void doInBackground(Object... params){ String url=params[1].toString(); File cache=(File)params[2]; try { put(url,new BitmapDrawable(cache.getAbsolutePath())); if (params[0] != null) { bus.send(params[0]); } } catch ( Throwable t) { Log.e(TAG,"Exception loading image from disk",t); } return (null); }
Example 25
From project Android, under directory /app/src/main/java/com/github/mobile/util/.
Source file: AvatarLoader.java

/** * Get image for user * @param userId * @return image */ protected BitmapDrawable getImage(final String userId){ File avatarFile=new File(avatarDir,userId); if (!avatarFile.exists() || avatarFile.length() == 0) return null; Bitmap bitmap=decode(avatarFile); if (bitmap != null) return new BitmapDrawable(context.getResources(),bitmap); else { avatarFile.delete(); return null; } }
Example 26
From project AndroidSensorLogger, under directory /src/com/sstp/androidsensorlogger/.
Source file: CameraActivity.java

public void onPictureTaken(byte[] data,Camera camera){ Log.d(TAG,"onPictureTaken()"); int counter=1; try { Log.d(TAG,"prepare to open fileOutputStream"); OutputStream fileOutputStream=getContentResolver().openOutputStream(pictureUri); Log.d(TAG,"prepare to write data"); fileOutputStream.write(data); Log.d(TAG,"prepare to flush stream"); fileOutputStream.flush(); Log.d(TAG,"prepare to close stream"); fileOutputStream.close(); saveResult(RESULT_OK); Bitmap bm=null; ByteArrayInputStream bytes=new ByteArrayInputStream(data); BitmapDrawable bmd=new BitmapDrawable(bytes); bm=bmd.getBitmap(); Save_to_SD(bm,"ImageFile" + counter); } catch ( Exception e) { Log.e(TAG,"mPictureCallbackJpeg exception caught: " + e); } counter++; }
Example 27
From project android_7, under directory /src/org/immopoly/android/helper/.
Source file: ImageListDownloader.java

/** * Same as download but the image is always downloaded and the cache is not used. Kept private at the moment as its interest is not clear. */ private void forceDownload(String url,ImageView imageView,String cookie){ if (url == null) { imageView.setImageDrawable(new BitmapDrawable(fallbackBitmap)); imageView.setAnimation(null); return; } if (cancelPotentialDownload(url,imageView)) { BitmapDownloaderTask task=new BitmapDownloaderTask(imageView); DownloadedDrawable downloadedDrawable=new DownloadedDrawable(task); imageView.setAnimation(loadingAnimation); imageView.setImageDrawable(downloadedDrawable); task.execute(url,cookie); } }
Example 28
From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/compatibility/.
Source file: BitmapDrawable_Compatible.java

/** * Replaces "new BitmapDrawable(context.getResources(), bitmap)" available only in SDK 1.6 and higher. * @param resources * @param bitmap * @return */ public static BitmapDrawable getNewBitmapDrawable(Resources resources,Bitmap bitmap){ BitmapDrawable b=null; if (use_SDK_1_6) { try { b=BitmapDrawable_SDK_1_6.getNewBitmapDrawable(resources,bitmap); } catch ( VerifyError e) { use_SDK_1_6=false; b=new BitmapDrawable(bitmap); } } else { b=new BitmapDrawable(bitmap); } return b; }
Example 29
From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/photoeditor/actions/.
Source file: AbstractSeekBar.java

@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){ Resources res=getResources(); Drawable thumb=res.getDrawable(R.drawable.photoeditor_seekbar_thumb); int height=h - getPaddingTop() - getPaddingBottom(); int scaledWidth=thumb.getIntrinsicWidth() * height / thumb.getIntrinsicHeight(); Bitmap bitmap=Bitmap.createBitmap(scaledWidth,height,Bitmap.Config.ARGB_8888); Canvas canvas=new Canvas(bitmap); thumb.setBounds(0,0,bitmap.getWidth(),bitmap.getHeight()); thumb.draw(canvas); setThumb(new BitmapDrawable(res,bitmap)); setThumbOffset(0); super.onSizeChanged(w,h,oldw,oldh); }
Example 30
From project anidroid, under directory /anidroid/src/com/github/anidroid/.
Source file: FrameAnimator.java

/** * Create and return animation drawable * @param assetsFramesPath Path to folder with animation framesrelative to "assets" folder of android application * @param defaultDuration How long in milliseconds a single frameshould appear * @param oneShot Play once (true) or repeat (false) * @return AnimationDrawable instance */ public AnimationDrawable create(final String assetsFramesPath,final int defaultDuration,final boolean oneShot){ final List<String> files=assetUtil.getFileList(assetsFramesPath); final SortedMap<Integer,String> frames=frameUtil.extractFrames(files); final AnimationDrawable animationDrawable=new AnimationDrawable(); animationDrawable.setOneShot(oneShot); for ( final Integer key : frames.keySet()) { final Bitmap frame=BitmapFactory.decodeStream(assetUtil.open(frames.get(key))); animationDrawable.addFrame(new BitmapDrawable(frame),defaultDuration); } return animationDrawable; }
Example 31
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: Utils.java

/** * Reuse of bitmaps in tiled backgrounds is a known cause of problems: http://stackoverflow.com/questions/4077487/background-image-not-repeating-in-android-layout So we avoid reusing them * @param d Drawable background that may be a BitmapDrawable or a layered drawablewhose first layer is a tiled bitmap * @return Modified Drawable */ public static Drawable cleanupTiledBackground(Drawable d){ if (d instanceof LayerDrawable) { System.out.println("BG is layered"); LayerDrawable ld=(LayerDrawable)d; Drawable l=ld.getDrawable(0); if (l instanceof BitmapDrawable) { d.mutate(); l.mutate(); System.out.println("Layer0 is BMP"); BitmapDrawable bmp=(BitmapDrawable)l; bmp.mutate(); bmp.setTileModeXY(TileMode.CLAMP,TileMode.CLAMP); bmp.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); } } else if (d instanceof BitmapDrawable) { BitmapDrawable bmp=(BitmapDrawable)d; bmp.mutate(); bmp.setTileModeXY(TileMode.CLAMP,TileMode.CLAMP); bmp.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); } return d; }
Example 32
private BitmapDrawable resizeBitmapDrawable(final BitmapDrawable image,final int width,final int height){ Log.d(TAG,"resizeBitmapDrawable()"); BitmapDrawable background=(BitmapDrawable)getResources().getDrawable(R.drawable.background); Bitmap background_bm=background.getBitmap(); Bitmap image_bm=Bitmap.createScaledBitmap(image.getBitmap(),width,height,true); Bitmap comboImage_bm=Bitmap.createBitmap(background_bm.getWidth(),background_bm.getHeight(),Bitmap.Config.ARGB_8888); Canvas comboImage=new Canvas(comboImage_bm); comboImage.drawBitmap(background_bm,0f,0f,null); comboImage.drawBitmap(image_bm,(background_bm.getWidth() - image_bm.getWidth()) / 2,0f,null); final BitmapDrawable comboImage_bmd=new BitmapDrawable(comboImage_bm); background=null; background_bm=null; image_bm=null; comboImage_bm=null; comboImage=null; return comboImage_bmd; }
Example 33
From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/fragments/.
Source file: NowPlayingFragment.java

public void onCoverDownloaded(Bitmap cover){ coverArtProgress.setVisibility(ProgressBar.INVISIBLE); DisplayMetrics metrics=new DisplayMetrics(); try { getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); if (cover != null) { cover.setDensity((int)metrics.density); BitmapDrawable myCover=new BitmapDrawable(getResources(),cover); coverArt.setImageDrawable(myCover); } else { onCoverNotFound(); } } catch ( Exception e) { e.printStackTrace(); } }
Example 34
From project E12Planner, under directory /src/com/neoware/europlanner/.
Source file: GamesActivity.java

@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.games_layout); BitmapDrawable bg=(BitmapDrawable)getResources().getDrawable(R.drawable.toolbar_bg); bg.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT); ActionBar bar=getSupportActionBar(); bar.setBackgroundDrawable(bg); bar.setTitle(R.string.games_title); bar.setHomeButtonEnabled(true); bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayUseLogoEnabled(true); mTournamentDefn=TournamentDefinition.getTournamentDefnInstance(this); mPager=(ViewPager)findViewById(R.id.groupPager); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mTabAdapter=new TabsAdapter(this,mPager); mPager.setAdapter(mTabAdapter); addGroupsAndKnockout(); Bundle extras=getIntent().getExtras(); int groupIndx=0; if (extras != null) { groupIndx=extras.getInt(GROUP_KNOCKOUT); } mPager.setCurrentItem(groupIndx); }
Example 35
From project Ebento, under directory /src/mobisocial/bento/ebento/ui/quickaction/.
Source file: PopupWindows.java

/** * On pre show */ protected void preShow(){ if (mRootView == null) throw new IllegalStateException("setContentView was not called with a view to display."); onShow(); if (mBackground == null) mWindow.setBackgroundDrawable(new BitmapDrawable()); else mWindow.setBackgroundDrawable(mBackground); mWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); mWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); mWindow.setTouchable(true); mWindow.setFocusable(true); mWindow.setOutsideTouchable(true); mWindow.setContentView(mRootView); }
Example 36
From project evodroid, under directory /src/com/commonsware/cwac/cache/.
Source file: SimpleWebImageCache.java

@SuppressWarnings("unchecked") @Override protected Void doInBackground(Object... params){ String url=params[1].toString(); File cache=(File)params[2]; try { put(url,new BitmapDrawable(cache.getAbsolutePath())); if (params[0] != null) { bus.send(params[0]); } } catch ( Throwable t) { } return (null); }
Example 37
From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/ui/base/.
Source file: WithHeaderActivity.java

protected void setHeaderTitle(String title){ titleButton.setBackgroundDrawable(new BitmapDrawable()); titleButton.setText(title); LayoutParams lp=new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT); lp.setMargins(3,12,0,0); titleButton.setLayoutParams(lp); TextPaint tp=titleButton.getPaint(); tp.setFakeBoldText(true); }
Example 38
From project filemanager, under directory /FileManager/src/org/openintents/filemanager/compatibility/.
Source file: BitmapDrawable_Compatible.java

/** * Replaces "new BitmapDrawable(context.getResources(), bitmap)" available only in SDK 1.6 and higher. * @param resources * @param bitmap * @return */ public static BitmapDrawable getNewBitmapDrawable(Resources resources,Bitmap bitmap){ BitmapDrawable b=null; if (use_SDK_1_6) { try { b=BitmapDrawable_SDK_1_6.getNewBitmapDrawable(resources,bitmap); } catch ( VerifyError e) { use_SDK_1_6=false; b=new BitmapDrawable(bitmap); } } else { b=new BitmapDrawable(bitmap); } return b; }
Example 39
From project framework_base_policy, under directory /src/com/android/internal/policy/impl/.
Source file: IconUtilities.java

public Drawable createIconDrawable(Drawable src){ Bitmap scaled=createIconBitmap(src); StateListDrawable result=new StateListDrawable(); result.addState(new int[]{android.R.attr.state_focused},new BitmapDrawable(createSelectedBitmap(scaled,false))); result.addState(new int[]{android.R.attr.state_pressed},new BitmapDrawable(createSelectedBitmap(scaled,true))); result.addState(new int[0],new BitmapDrawable(scaled)); result.setBounds(0,0,mIconTextureWidth,mIconTextureHeight); return result; }
Example 40
From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.
Source file: PostListAdapter.java

private void downloadPics(final ViewHolder H,Spannable htmlSpannable){ int pos=0; for (int i=0; i <= 2; i++) H.picture[i].setVisibility(View.GONE); for ( ImageSpan img : htmlSpannable.getSpans(0,htmlSpannable.length(),ImageSpan.class)) { htmlSpannable.removeSpan(img); if (pos > 2) break; final TwAjax pidl=new TwAjax(getContext(),true,false); pidl.ignoreSSLCerts=true; final String piurl=img.getSource(); Log.i(TAG,"TRY Downloading post Img: " + piurl); final int targetImg=pos; final File pifile=new File(Max.IMG_CACHE_DIR + "/pi_" + Max.cleanFilename(piurl)); H.picture[targetImg].setTag(pifile.getAbsolutePath()); if (pifile.isFile()) { Log.i(TAG,"OK Load cached post Img: " + piurl); BitmapDrawable bmp=new BitmapDrawable(pifile.getAbsolutePath()); if (bmp.getBitmap() != null && bmp.getBitmap().getWidth() > 30) { H.picture[targetImg].setImageDrawable(bmp); H.picture[targetImg].setVisibility(View.VISIBLE); } } else { pidl.urlDownloadToFile(piurl,pifile.getAbsolutePath(),new Runnable(){ @Override public void run(){ Log.i(TAG,"OK Download post Img: " + piurl); BitmapDrawable bmp=new BitmapDrawable(pifile.getAbsolutePath()); if (bmp.getBitmap() != null && bmp.getBitmap().getWidth() > 30) { H.picture[targetImg].setImageDrawable(bmp); H.picture[targetImg].setVisibility(View.VISIBLE); } } } ); } pos++; } }
Example 41
From project gh4a, under directory /src/com/github/mobile/util/.
Source file: HttpImageGetter.java

public Drawable getDrawable(String source){ File output=null; try { output=File.createTempFile("image",".jpg",dir); InputStream is=fetch(source); if (is != null) { boolean success=FileUtils.save(output,is); if (success) { Bitmap bitmap=ImageUtils.getBitmap(output,width,Integer.MAX_VALUE); if (bitmap == null) { return loading.getDrawable(source); } BitmapDrawable drawable=new BitmapDrawable(context.getResources(),bitmap); drawable.setBounds(0,0,bitmap.getWidth(),bitmap.getHeight()); return drawable; } else { return loading.getDrawable(source); } } else { return loading.getDrawable(source); } } catch ( IOException e) { return loading.getDrawable(source); } finally { if (output != null) output.delete(); } }
Example 42
From project Gingerbread-Keyboard, under directory /src/com/android/inputmethod/latin/.
Source file: LatinKeyboard.java

private void setMicF1Key(Key key){ final Drawable micWithSettingsHintDrawable=new BitmapDrawable(mRes,drawSynthesizedSettingsHintImage(key.width,key.height,mMicIcon,mHintIcon)); key.label=null; key.codes=new int[]{LatinKeyboardView.KEYCODE_VOICE}; key.popupResId=R.xml.popup_mic; key.icon=micWithSettingsHintDrawable; key.iconPreview=mMicPreviewIcon; }
Example 43
From project Gmote, under directory /gmoteclient/src/org/gmote/client/android/.
Source file: ButtonControl.java

private void displayMediaArt(){ if (mBitmap == null) { mMediaImageView.setImageResource(R.drawable.audio); } else { mMediaImageView.setImageBitmap(mBitmap); mContentView.setBackgroundDrawable(new BitmapDrawable(mBitmap)); } }
Example 44
From project Hax-Launcher, under directory /src/com/t3hh4xx0r/haxlauncher/.
Source file: Utilities.java

/** * Returns a Bitmap representing the thumbnail of the specified Bitmap. The size of the thumbnail is defined by the dimension android.R.dimen.launcher_application_icon_size. * @param bitmap The bitmap to get a thumbnail of. * @param context The application's context. * @return A thumbnail for the specified bitmap or the bitmap itself if thethumbnail could not be created. */ static Bitmap resampleIconBitmap(Bitmap bitmap,Context context){ synchronized (sCanvas) { if (sIconWidth == -1) { initStatics(context); } if (bitmap.getWidth() == sIconWidth && bitmap.getHeight() == sIconHeight) { return bitmap; } else { return createIconBitmap(new BitmapDrawable(bitmap),context); } } }
Example 45
From project HtmlSpanner, under directory /src/main/java/net/nightwhistler/htmlspanner/handlers/.
Source file: ImageHandler.java

@Override public void handleTagNode(TagNode node,SpannableStringBuilder builder,int start,int end){ String src=node.getAttributeByName("src"); builder.append("\uFFFC"); Bitmap bitmap=loadBitmap(src); if (bitmap != null) { Drawable drawable=new BitmapDrawable(bitmap); drawable.setBounds(0,0,bitmap.getWidth() - 1,bitmap.getHeight() - 1); builder.setSpan(new ImageSpan(drawable),start,end,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }
Example 46
From project iosched_3, under directory /android/src/com/google/android/apps/iosched/ui/.
Source file: BaseActivity.java

/** * Sets the icon color using some fancy blending mode trickery. */ protected void setActionBarColor(int color){ if (color == 0) { color=0xffffffff; } final Resources res=getResources(); Drawable maskDrawable=res.getDrawable(R.drawable.actionbar_icon_mask); if (!(maskDrawable instanceof BitmapDrawable)) { return; } Bitmap maskBitmap=((BitmapDrawable)maskDrawable).getBitmap(); final int width=maskBitmap.getWidth(); final int height=maskBitmap.getHeight(); Bitmap outBitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888); Canvas canvas=new Canvas(outBitmap); canvas.drawBitmap(maskBitmap,0,0,null); Paint maskedPaint=new Paint(); maskedPaint.setColor(color); maskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); canvas.drawRect(0,0,width,height,maskedPaint); BitmapDrawable outDrawable=new BitmapDrawable(res,outBitmap); getSupportActionBar().setIcon(outDrawable); }
Example 47
From project jamendo-android, under directory /src/com/teleca/jamendo/activity/.
Source file: AlbumActivity.java

private void setupTabs(){ mTabHost=getTabHost(); Bitmap coverBmp=JamendoApplication.getInstance().getImageCache().get(mAlbum.getImage()); if (coverBmp == null) { coverBmp=JamendoApplication.getInstance().getImageCache().get(mAlbum.getImage().replaceAll("1.100.jpg",mBetterRes)); } if (coverBmp != null) { int tabSize=(int)getResources().getDimension(R.dimen.tab_size); int newWidth=tabSize; int newHeight=tabSize; float scaleWidth=((float)newWidth) / coverBmp.getWidth(); float scaleHeight=((float)newHeight) / coverBmp.getHeight(); Matrix matrix=new Matrix(); matrix.postScale(scaleWidth,scaleHeight); Bitmap resizedCoverBmp=Bitmap.createBitmap(coverBmp,0,0,coverBmp.getWidth(),coverBmp.getHeight(),matrix,false); BitmapDrawable coverDrawable=DrawableAccessor.construct(getResources(),resizedCoverBmp); mAlbumTabSpec=mTabHost.newTabSpec("tab1").setIndicator(mAlbum.getName(),coverDrawable).setContent(R.id.TabTracks); } else { mAlbumTabSpec=mTabHost.newTabSpec("tab1").setIndicator(mAlbum.getName(),getResources().getDrawable(R.drawable.tab_no_cd)).setContent(R.id.TabTracks); } mReviewsTabSpec=mTabHost.newTabSpec("tab1").setIndicator(getString(R.string.review),getResources().getDrawable(R.drawable.tab_review)).setContent(R.id.TabReviews); mTabHost.addTab(mAlbumTabSpec); mTabHost.addTab(mReviewsTabSpec); }
Example 48
From project keepassdroid, under directory /src/com/keepassdroid/compat/.
Source file: BitmapDrawableCompat.java

public static BitmapDrawable getBitmapDrawable(Resources res,Bitmap bitmap){ if (constResBitmap != null) { try { return constResBitmap.newInstance(res,bitmap); } catch ( Exception e) { } } return new BitmapDrawable(bitmap); }
Example 49
From project lightbox-android-webservices, under directory /LightboxAndroidWebServices/src/com/lightbox/android/views/.
Source file: RemoteThumbImageView.java

public void loadOnlyIfInMemCache(BitmapSource bitmapSource,int position){ mCurrentImageSource=bitmapSource; Bitmap bitmap=BitmapCache.getInstance().getFromMemory(bitmapSource.getAbsoluteFileName(Type.THM)); if (bitmap != null && (mBitmapDrawable == null || mBitmapDrawable.getBitmap() != bitmap)) { mBitmapDrawable=new BitmapDrawable(bitmap); setImageDrawable(mBitmapDrawable); invalidate(); } }
Example 50
From project madvertise-android-sdk, under directory /madvertiseSDK/src/de/madvertise/android/sdk/.
Source file: MadvertiseView.java

/** * Convenience method for a shiny background for text ads * @param rect * @param backgroundColor * @param mTextColor * @return */ private BitmapDrawable generateBackgroundDrawable(final Rect rect,final int backgroundColor,final int shineColor){ try { Bitmap bitmap=Bitmap.createBitmap(rect.width(),rect.height(),Bitmap.Config.ARGB_8888); Canvas canvas=new Canvas(bitmap); drawTextBannerBackground(canvas,rect,backgroundColor,shineColor); return new BitmapDrawable(bitmap); } catch ( Throwable t) { return null; } }
Example 51
From project mp3tunes-android, under directory /src/com/mp3tunes/android/activity/.
Source file: ArtistBrowser.java

ArtistListAdapter(Context context,ArtistBrowser currentactivity,int layout,Cursor cursor,String[] from,int[] to){ super(context,layout,cursor,from,to); mActivity=currentactivity; mUnknownArtist=context.getString(R.string.unknown_artist_name); Resources r=context.getResources(); mNowPlayingOverlay=r.getDrawable(R.drawable.indicator_ic_mp_playing_list); Bitmap b=BitmapFactory.decodeResource(r,R.drawable.artist_icon); mDefaultArtistIcon=new BitmapDrawable(b); mDefaultArtistIcon.setFilterBitmap(false); mDefaultArtistIcon.setDither(false); getColumnIndices(cursor); mResources=context.getResources(); }
Example 52
From project NFC-Contact-Exchanger, under directory /src/com/tonchidot/nfc_contact_exchanger/lib/.
Source file: VCardUtils.java

public static Drawable getDrawable(String vcard){ byte[] data=getPictureData(vcard); if (data != null) { Bitmap bitmap=BitmapFactory.decodeByteArray(data,0,data.length); if (bitmap != null) { return new BitmapDrawable(bitmap); } } return null; }
Example 53
From project OpenBike, under directory /src/fr/openbike/android/ui/.
Source file: OpenBikeMapActivity.java

@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.map_layout); mReceiver=DetachableResultReceiver.getInstance(new Handler()); mActivityHelper=new ActivityHelper(this); mActivityHelper.setupActionBar(getString(R.string.station_map)); mMapView=(MapView)findViewById(R.id.map_view); mPdialog=new ProgressDialog(OpenBikeMapActivity.this); mMapController=mMapView.getController(); mMapView.setSatellite(false); mMapView.setStreetView(false); mSharedPreferences=PreferenceManager.getDefaultSharedPreferences(this); BitmapDrawable marker=(BitmapDrawable)getResources().getDrawable(R.drawable.pin); marker.setBounds(0,0,marker.getIntrinsicWidth(),marker.getIntrinsicHeight()); mStationsOverlay=new StationsOverlay(getResources(),marker,mMapView,this); mMapOverlays=mMapView.getOverlays(); mMapOverlays.add(mStationsOverlay); if (mMyLocationOverlay == null) { mMyLocationOverlay=new MyLocationOverlay(this,mMapView); } mMapOverlays.add(mMyLocationOverlay); if (savedInstanceState != null && savedInstanceState.containsKey(SHOWING_BALLOON)) { mShowingBalloon=savedInstanceState.getInt(SHOWING_BALLOON); } if (savedInstanceState != null) mNeedZoom=false; startService(new Intent(this,LocationService.class)); }
Example 54
From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/.
Source file: ReportDetailsActivity.java

private void setPictureToImageView(String pictureName,ImageView imageView){ Bitmap picture=null; try { InputStream in=openFileInput(pictureName); picture=BitmapFactory.decodeStream(in); in.close(); LayerDrawable d=(LayerDrawable)getResources().getDrawable(R.drawable.editable_picture_frame); if (picture.getHeight() > picture.getWidth()) { Matrix m=new Matrix(); m.postRotate(-90); picture=Bitmap.createBitmap(picture,0,0,picture.getWidth(),picture.getHeight(),m,true); } picture=Bitmap.createScaledBitmap(picture,d.getIntrinsicWidth(),d.getIntrinsicHeight(),true); d.setDrawableByLayerId(R.id.picture,new BitmapDrawable(picture)); imageView.setImageDrawable(d); if (!hasPic) hasPic=(imageView.getId() == R.id.ImageView_far); } catch ( FileNotFoundException e) { e.printStackTrace(); } catch ( IOException e) { e.printStackTrace(); } }
Example 55
From project android-bankdroid, under directory /src/com/liato/bankdroid/.
Source file: BetterPopupWindow.java

private void preShow(){ if (this.root == null) { throw new IllegalStateException("setContentView was not called with a view to display."); } onShow(); if (this.background == null) { this.window.setBackgroundDrawable(new BitmapDrawable()); } else { this.window.setBackgroundDrawable(this.background); } this.window.setWidth(WindowManager.LayoutParams.FILL_PARENT); this.window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setTouchable(true); this.window.setFocusable(true); this.window.setOutsideTouchable(true); this.window.setContentView(this.root); }
Example 56
From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.
Source file: ImageAdapter.java

public void addFromAssets(String rootPath){ synchronized (images) { try { String[] files=ctx.getAssets().list(rootPath); String random="random_" + files.length; images.add(random); for ( String name : files) { String fullpath="assets:" + rootPath + "/"+ name; images.add(fullpath); htImages.put(fullpath,new BitmapDrawable(ctx.getResources(),ctx.getAssets().open(rootPath + "/" + name))); } notifyDataSetChanged(); } catch ( IOException ioex) { ioex.printStackTrace(); } } }
Example 57
From project android_packages_apps_Gallery, under directory /src/com/android/camera/.
Source file: ThumbnailController.java

private void updateThumb(Bitmap original){ if (original == null) { mThumb=null; mThumbs=null; return; } final int PADDING_WIDTH=2; final int PADDING_HEIGHT=2; LayoutParams param=mButton.getLayoutParams(); final int miniThumbWidth=param.width - 2 * PADDING_WIDTH; final int miniThumbHeight=param.height - 2 * PADDING_HEIGHT; mThumb=ThumbnailUtil.extractMiniThumb(original,miniThumbWidth,miniThumbHeight,Util.NO_RECYCLE_INPUT); Drawable drawable; if (mThumbs == null) { mThumbs=new Drawable[2]; mThumbs[1]=new BitmapDrawable(mResources,mThumb); drawable=mThumbs[1]; mShouldAnimateThumb=false; } else { mThumbs[0]=mThumbs[1]; mThumbs[1]=new BitmapDrawable(mResources,mThumb); mThumbTransition=new TransitionDrawable(mThumbs); drawable=mThumbTransition; mShouldAnimateThumb=true; } mButton.setImageDrawable(drawable); }
Example 58
From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.
Source file: BetterPopupWindow.java

private void preShow(){ if (this.root == null) { throw new IllegalStateException("setContentView was not called with a view to display."); } onShow(); if (this.background == null) { this.window.setBackgroundDrawable(new BitmapDrawable()); } else { this.window.setBackgroundDrawable(this.background); } this.window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setTouchable(true); this.window.setFocusable(true); this.window.setOutsideTouchable(true); this.window.setContentView(this.root); }
Example 59
From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.
Source file: MenuManager.java

public void updateDrawingCacheForApplicationBadgeCountChange(List list){ BadgeCache badgecache=((LauncherApplication)mLauncher.getApplicationContext()).getBadgeCache(); if (mMode != 1) { int i=0; int j=getChildCount(); while (i < j) { ViewGroup viewgroup=(ViewGroup)getChildAt(i); int k=0; for (int l=viewgroup.getChildCount(); k < l; k++) { View view=viewgroup.getChildAt(k); ApplicationInfo applicationinfo=(ApplicationInfo)view.getTag(); applicationinfo.badgeCount=badgecache.getBadgeCount(applicationinfo.intent); Bitmap bitmap=badgecache.getBadgeIcon(applicationinfo.intent.getComponent()); if (bitmap != null) view.setBackgroundDrawable(new BitmapDrawable(getContext().getResources(),bitmap)); view.destroyDrawingCache(); view.buildDrawingCache(); view.invalidate(); } i++; } } }
Example 60
From project BombusLime, under directory /src/org/bombusim/lime/fragments/.
Source file: RosterFragment.java

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){ super.onCreateContextMenu(menu,v,menuInfo); int pos=((AdapterContextMenuInfo)menuInfo).position; contextItem=getListAdapter().getItem(pos); if (contextItem instanceof RosterGroup) { return; } if (contextItem instanceof XmppAccount) { return; } if (contextItem instanceof Contact) { Contact c=(Contact)contextItem; menu.setHeaderTitle(c.getScreenName()); Drawable icon=new BitmapDrawable(c.getAvatar()); menu.setHeaderIcon(icon); MenuInflater inflater=getActivity().getMenuInflater(); if (contextItem instanceof SelfContact) { inflater.inflate(R.menu.contact_self_menu,menu); } else { inflater.inflate(R.menu.contact_menu,menu); } menu.setGroupEnabled(R.id.groupLoggedIn,sb.isLoggedIn(c.getRosterJid())); return; } }
Example 61
From project CHMI, under directory /src/org/kaldax/app/chmi/.
Source file: GMapsLayoutProvider.java

public void ShowImage(int i){ if ((i < 0) || (imgHandler.getImagesCount() <= i)) { Logger.global.log(Level.SEVERE,new Date().toLocaleString() + " Image index out of bounds!"); return; } sbProgress.setMax((imgHandler.getImagesCount() - 1) * 10); sbProgress.setProgress((imgHandler.getImagesCount() - i - 1) * 10); Date imageDate=imgHandler.getImageDate(i); Date date=new Date(); int iImageAge=(int)((date.getTime() - imgHandler.getImageDate(i).getTime()) / 60000); tvDateTextView.setText(activity.getResources().getString(R.string.msg_imagedate) + new Date(imageDate.getTime()).toLocaleString()); tvDateTextView.append(activity.getResources().getString(R.string.msg_imgageA) + Integer.toString(iImageAge) + activity.getResources().getString(R.string.msg_imgageB)); File storageRoot=Environment.getExternalStorageDirectory(); File appStorageRoot=new File(storageRoot,imgHandler.getImagesSubdir()); Bitmap bmp=null; try { String strFileName=imgHandler.getImageName(i); Logger.global.log(Level.INFO,new Date().toLocaleString() + "FileName=" + strFileName); FileInputStream fin=new FileInputStream(new File(appStorageRoot,strFileName)); try { bmp=BitmapFactory.decodeStream(fin); mMapDrawable=new BitmapDrawable(bmp); Logger.global.log(Level.SEVERE,new Date().toLocaleString() + " Image aplpha=" + Integer.toString((int)(activity.chmiConfigBundle._gmaps_transparency_level * 2.55f))); mMapDrawable.setAlpha((int)(activity.chmiConfigBundle._gmaps_transparency_level * 2.55f)); } catch ( OutOfMemoryError me) { Logger.global.log(Level.SEVERE,new Date().toLocaleString() + "OutOfMemory exception"); System.gc(); } fin.close(); } catch ( Exception ex) { Logger.getLogger(CHMI.class.getName()).log(Level.SEVERE,null,ex); } activity.chmiConfigBundle._gmaps_zoom_level=mapView.getZoomLevel(); mapView.invalidate(); iCurentImageIdx=i; }
Example 62
From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/.
Source file: CustomPopupWindow.java

protected void preShow(){ if (root == null) { throw new IllegalStateException("setContentView was not called with a view to display."); } onShow(); if (background == null) { window.setBackgroundDrawable(new BitmapDrawable()); } else { window.setBackgroundDrawable(background); } window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); window.setTouchable(true); window.setFocusable(true); window.setOutsideTouchable(true); window.setContentView(root); }
Example 63
public static BitmapDrawable getRoundedCornerDrawable(Bitmap bitmap,Context context){ Bitmap output; if (bitmap != null) { output=Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888); Canvas canvas=new Canvas(output); final int color=0xff424242; final Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG); final Rect rect=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight()); final RectF rectF=new RectF(rect); canvas.drawARGB(0,0,0,0); paint.setColor(color); canvas.drawRoundRect(rectF,ROUND_Px,ROUND_Px,paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap,rect,rect,paint); } else { output=Bitmap.createBitmap(64,64,Config.ARGB_8888); } return new BitmapDrawable(context.getResources(),output); }
Example 64
From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/.
Source file: BetterPopupWindow.java

private void preShow(){ if (this.root == null) { throw new IllegalStateException("setContentView was not called with a view to display."); } onShow(); if (this.background == null) { this.window.setBackgroundDrawable(new BitmapDrawable()); } else { this.window.setBackgroundDrawable(this.background); } this.window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setTouchable(true); this.window.setFocusable(true); this.window.setOutsideTouchable(true); this.window.setContentView(this.root); }
Example 65
From project mediaphone, under directory /src/ac/robinson/mediaphone/activity/.
Source file: CameraActivity.java

@Override public void onOrientationChanged(int newScreenOrientationDegrees){ if (newScreenOrientationDegrees == OrientationEventListener.ORIENTATION_UNKNOWN) { return; } mScreenOrientation=newScreenOrientationDegrees; Display display=((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); int displayRotation=OrientationManager.getDisplayRotationDegrees(display.getRotation()); int correctedRotation=((newScreenOrientationDegrees - displayRotation + 360) % 360); if (correctedRotation == 180) { newScreenOrientationDegrees=displayRotation; correctedRotation=0; } mDisplayOrientation=CameraUtilities.getPreviewOrientationDegrees(newScreenOrientationDegrees,mCameraConfiguration.cameraOrientationDegrees,mCameraConfiguration.usingFrontCamera); if (mCameraView != null) { mCameraView.setRotation(mDisplayOrientation,mDisplayOrientation); } Resources res=getResources(); Bitmap currentBitmap=BitmapFactory.decodeResource(res,android.R.drawable.ic_menu_revert); ((CenteredImageTextButton)findViewById(R.id.button_cancel_camera)).setCompoundDrawablesWithIntrinsicBounds(null,new BitmapDrawable(res,BitmapUtilities.rotate(currentBitmap,correctedRotation,currentBitmap.getWidth() / 2,currentBitmap.getHeight() / 2)),null,null); currentBitmap=BitmapFactory.decodeResource(res,android.R.drawable.ic_menu_camera); ((CenteredImageTextButton)findViewById(R.id.button_take_picture)).setCompoundDrawablesWithIntrinsicBounds(null,new BitmapDrawable(res,BitmapUtilities.rotate(currentBitmap,correctedRotation,currentBitmap.getWidth() / 2,currentBitmap.getHeight() / 2)),null,null); if (mCameraConfiguration.hasFrontCamera) { currentBitmap=BitmapFactory.decodeResource(res,android.R.drawable.ic_menu_rotate); ((CenteredImageTextButton)findViewById(R.id.button_switch_camera)).setCompoundDrawablesWithIntrinsicBounds(null,new BitmapDrawable(res,BitmapUtilities.rotate(currentBitmap,correctedRotation,currentBitmap.getWidth() / 2,currentBitmap.getHeight() / 2)),null,null); } }
Example 66
From project MyExpenses, under directory /src/org/example/qberticus/quickactions/.
Source file: BetterPopupWindow.java

private void preShow(){ if (this.root == null) { throw new IllegalStateException("setContentView was not called with a view to display."); } onShow(); if (this.background == null) { this.window.setBackgroundDrawable(new BitmapDrawable()); } else { this.window.setBackgroundDrawable(this.background); } this.window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); this.window.setTouchable(true); this.window.setFocusable(true); this.window.setOutsideTouchable(true); this.window.setContentView(this.root); }
Example 67
From project Orweb, under directory /src/info/guardianproject/browser/.
Source file: Browser.java

private void setFavicon(Bitmap icon){ Drawable[] array=new Drawable[2]; PaintDrawable p=new PaintDrawable(Color.WHITE); p.setCornerRadius(3f); array[0]=p; if (icon == null) { array[1]=mGenericFavicon; } else { array[1]=new BitmapDrawable(icon); } LayerDrawable d=new LayerDrawable(array); d.setLayerInset(1,2,2,2,2); this.getSherlock().getActionBar().setIcon(d); }
Example 68
From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 69
From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 70
From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 71
From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.
Source file: PhotoSyncActivity.java

/** * {@inheritDoc} */ @Override public void onItemClick(final AdapterView<?> parent,final View view,final int position,final long id){ final MobeelizerFile photo=((FileSyncEntity)parent.getItemAtPosition(position)).getPhoto(); Dialog dialog=new Dialog(this,R.style.MobeelizerDialogTheme); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.photo_dialog); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); ImageView photoView=(ImageView)dialog.findViewById(R.id.dialogPhoto); photoView.setImageDrawable(BitmapDrawable.createFromStream(photo.getInputStream(),photo.getName())); dialog.show(); }
Example 72
From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.
Source file: ThumbnailCreator.java

public ThumbnailCreator(Context context,int width,int height){ mHeight=height; mWidth=width; mContext=context; if (mCacheMap == null) mCacheMap=new HashMap<String,BitmapDrawable>(); }
Example 73
From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharingExample/src/com/nostra13/example/socialsharing/.
Source file: FacebookActivity.java

private void publishImage(){ Bitmap bmp=((BitmapDrawable)getResources().getDrawable(R.drawable.ic_app)).getBitmap(); ByteArrayOutputStream stream=new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG,100,stream); byte[] bitmapdata=stream.toByteArray(); facebook.publishImage(bitmapdata,Constants.FACEBOOK_SHARE_IMAGE_CAPTION); }
Example 74
From project android_packages_apps_Tag, under directory /canon/src/com/android/apps/tagcanon/.
Source file: TagCanon.java

final NdefMessage[] buildImageMessages(){ Resources res=getResources(); Drawable drawable=res.getDrawable(R.drawable.ic_launcher_nfc); Bitmap photo=((BitmapDrawable)drawable).getBitmap(); final int size=photo.getWidth() * photo.getHeight() * 4; final ByteArrayOutputStream out=new ByteArrayOutputStream(size); try { photo.compress(Bitmap.CompressFormat.PNG,100,out); out.flush(); byte[] payload=out.toByteArray(); out.close(); NdefRecord text=newTextRecord("There's an image below this text!",Locale.US,true); NdefRecord image=newMimeRecord("image/png",payload); NdefMessage[] msgs=new NdefMessage[]{new NdefMessage(new NdefRecord[]{text,image})}; return msgs; } catch ( IOException e) { throw new RuntimeException("Failed to compress image",e); } }
Example 75
From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/beintoosdkutility/.
Source file: LoaderImageView.java

public void setImageDrawable(final String imageUrl,final int width,final int height,final boolean scale){ mDrawable=null; mSpinner.setVisibility(View.VISIBLE); mImage.setVisibility(View.GONE); if (scale) { mImage.setAdjustViewBounds(true); mImage.setMaxHeight(height); mImage.setMaxWidth(width); mImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mSpinner.setLayoutParams(new LayoutParams(width / 2,height / 2)); } new Thread(){ public void run(){ try { mDrawable=getDrawableFromUrl(imageUrl); if (scale) { try { Bitmap bmImg=((BitmapDrawable)mDrawable).getBitmap(); Bitmap resizedbitmap=resize(bmImg,width,height); mDrawable=new BitmapDrawable(resizedbitmap); } catch ( Exception e) { e.printStackTrace(); } } imageLoadedHandler.sendEmptyMessage(COMPLETE); } catch ( MalformedURLException e) { imageLoadedHandler.sendEmptyMessage(FAILED); e.printStackTrace(); } catch ( IOException e) { imageLoadedHandler.sendEmptyMessage(FAILED); e.printStackTrace(); } } } .start(); }
Example 76
From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/pl/polidea/coverflow/.
Source file: ResourceImageAdapter.java

@Override protected Bitmap createBitmap(final int position){ Log.v(TAG,"creating item " + position); final Bitmap bitmap=((BitmapDrawable)context.getResources().getDrawable(IMAGE_RESOURCE_IDS.get(position))).getBitmap(); bitmapMap.put(position,new WeakReference<Bitmap>(bitmap)); return bitmap; }
Example 77
From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 78
From project cw-omnibus, under directory /external/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 79
From project daisy-android-common, under directory /src/com/daisyworks/android/widget/.
Source file: ImageDownloader.java

/** * Once the image is downloaded, associates it to the imageView */ @Override protected void onPostExecute(Bitmap bitmap){ if (isCancelled()) { bitmap=null; } addBitmapToCache(url,bitmap); if (imageViewReference != null) { ImageView imageView=imageViewReference.get(); BitmapDownloaderTask bitmapDownloaderTask=getBitmapDownloaderTask(imageView); if ((this == bitmapDownloaderTask) || (mode != Mode.CORRECT)) { TransitionDrawable d=new TransitionDrawable(new Drawable[]{imageView.getDrawable(),new BitmapDrawable(imageView.getResources(),bitmap)}); imageView.setImageDrawable(d); d.startTransition(400); } } }
Example 80
From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 81
From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 82
From project droid-fu, under directory /src/main/java/com/github/droidfu/imageloader/.
Source file: ImageLoaderHandler.java

/** * Override this method if you need custom handler logic. Note that this method can actually be called directly for performance reasons, in which case the message will be null * @param bitmap the bitmap returned from the image loader * @param msg the handler message; can be null * @return true if the view was updated with the new image, false if it was discarded */ protected boolean handleImageLoaded(Bitmap bitmap,Message msg){ String forUrl=(String)imageView.getTag(); if (imageUrl.equals(forUrl)) { Bitmap image=bitmap != null || errorDrawable == null ? bitmap : ((BitmapDrawable)errorDrawable).getBitmap(); if (image != null) { imageView.setImageBitmap(image); } return true; } return false; }
Example 83
From project examples_2, under directory /SearchView/actionbarsherlock-lib/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 84
From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 85
From project FlipDroid, under directory /web-image-view/src/main/java/com/goal98/android/.
Source file: ImageLoaderHandler.java

/** * Override this method if you need custom handler logic. Note that this method can actually be called directly for performance reasons, in which case the message will be null * @param bitmap the bitmap returned from the it.tika.mongodb.image loader * @param msg the handler message; can be null * @return true if the view was updated with the new it.tika.mongodb.image, false if it was discarded */ protected boolean handleImageLoaded(Bitmap bitmap,Message msg){ String forUrl=(String)imageView.getTag(); if (imageUrl.equals(forUrl)) { Bitmap image=bitmap != null || errorDrawable == null ? bitmap : ((BitmapDrawable)errorDrawable).getBitmap(); if (image != null) { imageView.setImageBitmap(image); } return true; } return false; }
Example 86
From project gauges-android, under directory /app/src/main/java/com/github/mobile/gauges/ui/airtraffic/.
Source file: AirTrafficActivity.java

private void subscribeToGaugeChannels(final Collection<String> subscribeIds){ if (subscribeIds.isEmpty()) return; backgroundThread.execute(new Runnable(){ public void run(){ final AirTrafficPusherCallback callback=new AirTrafficPusherCallback(){ @Override protected void onHit( final Hit hit){ airTrafficView.addHit(hit); gaugeText.post(new Runnable(){ public void run(){ String gaugeTitle=gaugeTitles.get(hit.siteId); if (gaugeTitle == null) return; Bitmap bitmap=resourceProvider.getPin(hit.siteId); if (bitmap != null) pinImage.setBackgroundDrawable(new BitmapDrawable(getResources(),bitmap)); else pinImage.setBackgroundDrawable(null); gaugeLocation.setText(getLocation(hit)); String title=getTitle(hit); if (title.length() > 0) gaugeText.setText(gaugeTitle + ": " + title); else gaugeText.setText(gaugeTitle); } } ); } } ; for ( String gaugeId : subscribeIds) pusher.subscribe(CHANNEL_PREFIX + gaugeId).bind("hit",callback); } } ); }
Example 87
From project gesture-imageview, under directory /main/src/com/polites/android/.
Source file: GestureImageView.java

protected boolean isRecycled(){ if (drawable != null && drawable instanceof BitmapDrawable) { Bitmap bitmap=((BitmapDrawable)drawable).getBitmap(); if (bitmap != null) { return bitmap.isRecycled(); } } return false; }
Example 88
From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 89
From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 90
From project HSR-Timetable, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 91
From project ignition, under directory /ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/images/remote/.
Source file: RemoteImageLoaderTextViewAdapter.java

private void setCompoundDrawable(Drawable drawable){ DisplayMetrics metrics=new DisplayMetrics(); metrics=view.getContext().getResources().getDisplayMetrics(); if (drawable instanceof BitmapDrawable) { ((BitmapDrawable)drawable).setTargetDensity(metrics.densityDpi); } Drawable leftDrawable=left ? drawable : null; Drawable topDrawable=top ? drawable : null; Drawable rightDrawable=right ? drawable : null; Drawable bottomDrawable=bottom ? drawable : null; ((TextView)view).setCompoundDrawablesWithIntrinsicBounds(leftDrawable,topDrawable,rightDrawable,bottomDrawable); }
Example 92
From project IRC-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 93
public AlbumsAdapter(Context context,Cursor cursor){ super(context,R.layout.track_list_item_child,cursor,new String[]{},new int[]{}); mCursor=cursor; mRessource=context.getResources(); if (mArtworkWidth < 0) { Bitmap icon=((BitmapDrawable)mRessource.getDrawable(R.drawable.albumart_mp_unknown_list)).getBitmap(); mArtworkWidth=icon.getWidth(); mArtWorkHeight=icon.getHeight(); } setFilterQueryProvider(this); mIndexer=new AlphabetIndexer(mCursor,mCursor.getColumnIndex(ViewUtils.ALBUM_NAME),mRessource.getString(R.string.fast_scroll_numeric_alphabet)); }
Example 94
From project mediautilities, under directory /src/com/polites/android/.
Source file: GestureImageView.java

protected boolean isRecycled(){ if (drawable != null && drawable instanceof BitmapDrawable) { Bitmap bitmap=((BitmapDrawable)drawable).getBitmap(); if (bitmap != null) { return bitmap.isRecycled(); } } return false; }
Example 95
From project MensaUPB, under directory /libs/ActionbarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 96
From project mobilis, under directory /MobilisXHunt/MobilisXHunt_Android/src/de/tudresden/inf/rn/mobilis/android/xhunt/ui/overlay/.
Source file: PlayerIconOverlay.java

@Override public void draw(Canvas canvas,MapView mapView,boolean shadow){ super.draw(canvas,mapView,shadow); int fontSize=12; int titleMargin=3; XHuntPlayer player=mXhuntService.getCurrentGame().getPlayerByJID(mMapActivity.getMxaProxy().getXmppJid()); Drawable sourceIcon=mMapActivity.getResources().getDrawable(player.getPlayerIconID()); int iconHeight=((BitmapDrawable)sourceIcon).getBitmap().getHeight(); for ( OverlayItem item : overlayIcons) { if (!item.getTitle().contains("ghost")) { GeoPoint point=item.getPoint(); Point markerBottomCenterCoords=new Point(); mapView.getProjection().toPixels(point,markerBottomCenterCoords); TextPaint textPaint=new TextPaint(); Paint paintRect=new Paint(); Rect rect=new Rect(); textPaint.setTextSize(fontSize); textPaint.getTextBounds(item.getSnippet(),0,item.getSnippet().length(),rect); rect.inset(-titleMargin,-titleMargin); rect.offsetTo(markerBottomCenterCoords.x - rect.width() / 2,markerBottomCenterCoords.y - iconHeight - rect.height()); textPaint.setTextAlign(Paint.Align.CENTER); textPaint.setTextSize(fontSize); textPaint.setARGB(255,255,255,255); paintRect.setARGB(130,0,0,0); canvas.drawRoundRect(new RectF(rect),2,2,paintRect); canvas.drawText(item.getSnippet(),rect.left + rect.width() / 2,rect.bottom - titleMargin,textPaint); } } }
Example 97
From project mWater-Android-App, under directory /android/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 98
From project MyHeath-Android, under directory /actionbarlib/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 99
From project OAK, under directory /oak-library/src/main/java/oak/external/com/github/droidfu/imageloader/.
Source file: ImageLoaderHandler.java

/** * Override this method if you need custom handler logic. Note that this method can actually be called directly for performance reasons, in which case the message will be null * @param bitmap the bitmap returned from the image loader * @param msg the handler message; can be null * @return true if the view was updated with the new image, false if it was discarded */ public boolean handleImageLoaded(Bitmap bitmap,Message msg){ String forUrl=(String)imageView.getTag(); if (imageUrl.equals(forUrl)) { Bitmap image=bitmap != null || errorDrawable == null ? bitmap : ((BitmapDrawable)errorDrawable).getBitmap(); if (image != null) { imageView.setImageBitmap(image); } return true; } return false; }
Example 100
From project ohmagePhone, under directory /src/org/ohmage/prompt/photo/.
Source file: PhotoPrompt.java

/** * Recycles the image if it was set * @param view */ public static void clearView(ViewGroup view){ ImageView imageView=(ImageView)view.findViewById(R.id.image_view); if (imageView != null && imageView.getDrawable() instanceof BitmapDrawable) { Bitmap b=((BitmapDrawable)imageView.getDrawable()).getBitmap(); if (b != null) { b.recycle(); b=null; } } }
Example 101
From project onebusaway-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 102
From project open311-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.
Source file: IcsProgressBar.java

/** * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables. */ private Drawable tileify(Drawable drawable,boolean clip){ if (drawable instanceof LayerDrawable) { LayerDrawable background=(LayerDrawable)drawable; final int N=background.getNumberOfLayers(); Drawable[] outDrawables=new Drawable[N]; for (int i=0; i < N; i++) { int id=background.getId(i); outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg=new LayerDrawable(outDrawables); for (int i=0; i < N; i++) { newBg.setId(i,background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap(); if (mSampleTile == null) { mSampleTile=tileBitmap; } final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example 103
From project otto, under directory /sample/src/main/java/com/squareup/otto/sample/.
Source file: LocationMapFragment.java

@Override protected Drawable doInBackground(String... params){ try { return BitmapDrawable.createFromStream(new URL(params[0]).openStream(),"bitmap.jpg"); } catch ( Exception e) { Log.e("LocationMapFragment","Unable to download image.",e); return null; } }