List of usage examples for android.widget ImageView getDrawable
public Drawable getDrawable()
From source file:ch.carteggio.ui.ConversationIconLoader.java
private ConversationPictureRetrievalTask getConversationPictureRetrievalTask(ImageView image) { if (image != null) { Drawable drawable = image.getDrawable(); if (drawable instanceof AsyncDrawable) { AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; return asyncDrawable.getContactPictureRetrievalTask(); }/*from w w w . j a v a2 s . c o m*/ } return null; }
From source file:com.ks.coordinatorlayoutdemo.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override// w ww .j ava 2 s.co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); setContentView(R.layout.activity_detail); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE); supportPostponeEnterTransition(); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); String itemDesc = getIntent().getStringExtra(EXTRA_DESC); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); final ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getIntExtra(EXTRA_IMAGE, 0)).into(image, new Callback() { @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap(); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); TextView title = (TextView) findViewById(R.id.title); title.setText(itemTitle); TextView desc = (TextView) findViewById(R.id.description); desc.setText(itemDesc); }
From source file:com.delaroystudios.materializeapp.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override/*from w w w. j a v a2 s . c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); setContentView(R.layout.activity_detail); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE); supportPostponeEnterTransition(); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); final ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(image, new Callback() { @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap(); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); TextView title = (TextView) findViewById(R.id.title); title.setText(itemTitle); }
From source file:com.appsummary.luoxf.myappsummary.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override/* w ww .j a v a 2s .c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE); supportPostponeEnterTransition(); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); final ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(image, new Callback() { @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap(); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); TextView title = (TextView) findViewById(R.id.title); title.setText(itemTitle); }
From source file:com.acceleratedio.pac_n_zoom.DrawSVG.java
public ArrayList<ImageView> DrawSVG(Context context, ImageView orgnlImageView, RelativeLayout rel_anm_lo) { paint.setColor(Color.WHITE);/* w ww .j a v a 2s . c o m*/ paint.setStyle(Paint.Style.FILL); LoadSVG.SVGData data = AnimActivity.svg_data; ArrayList<ImageView> imgViews = new ArrayList<ImageView>(); imgViews.add(orgnlImageView); if (data.symbl != null) { ArrayList<String> sprt_ordr = data.svg.ordr; int sym_mbr = 0; Bitmap bitmap; Canvas canvas; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); data.svg.initScl = new float[sprt_nmbr]; float[] initScl = data.svg.initScl; for (int sprt_mbr = 1; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); // e.g., id="g2_0" if (Integer.parseInt(sprt_id.substring(sprt_id.indexOf('_') + 1)) > 0) { // The symbol is already drawn; replicate the view String init_sprt = sprt_id.substring(0, sprt_id.indexOf('_') + 1) + '0'; String svg_ordr = data.svg.svg_ordr; String cnt_str = svg_ordr.substring(0, svg_ordr.indexOf(init_sprt)); ImageView init_vw = imgViews.get(StringUtils.countMatches(cnt_str, ",")); Bitmap initBmp = ((BitmapDrawable) init_vw.getDrawable()).getBitmap(); bitmap = Bitmap.createBitmap(initBmp.getWidth(), initBmp.getHeight(), initBmp.getConfig()); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); } else { // The symbol needs to be drawn; a new view is used bitmap = getCreatBmp(rel_anm_lo); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); // - Set the init values xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); // - Draw the bitmap LoadSVG.symbol crt_sym = data.symbl.get(sym_mbr); ArrayList<LoadSVG.path> pths = crt_sym.pths; int pth_nmbr = pths.size(); // Loop through the paths for (int pth_mbr = 0; pth_mbr < pth_nmbr; pth_mbr += 1) { LoadSVG.path crt_pth = pths.get(pth_mbr); final Path path = new Path(); final Paint paint = new Paint(); /* Debug if (pth_mbr + 1 == pth_nmbr) { String log_str = "Paths: pth_mbr = " + String.valueOf(pth_mbr) + "; color = " + crt_pth.clr; Log.d("DrawSVG", log_str); } */ paint.setColor(Color.parseColor(crt_pth.clr)); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); ld_pth_pnts(crt_pth.pth, path); path.close(); path.setFillType(Path.FillType.EVEN_ODD); canvas.drawPath(path, paint); } canvas.restore(); sym_mbr += 1; } ImageView iv = new ImageView(context); iv.setImageBitmap(bitmap); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); iv.draw(canvas); iv.setLayoutParams(rlp); iv.setBackgroundColor(Color.TRANSPARENT); imgViews.add(iv); } // sprites } // if symbol return imgViews; }
From source file:com.hfs.materialhome.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override// www . j a v a2 s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); setContentView(R.layout.activity_detail); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE); supportPostponeEnterTransition(); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); mExpandableTextView = (ExpandableTextView) findViewById(R.id.description); mExpandableTextView.setText(getResources().getString(R.string.lorem_ipsum)); final ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(image, new Callback() { @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap(); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); TextView title = (TextView) findViewById(R.id.title); title.setText(itemTitle); }
From source file:at.florian_lentsch.expirysync.AddProductActivity.java
/** * Adds the image from the form to {@link Article#images} (if there is one) * // w w w .j a v a2 s . co m * @param article * the article to add the image to * @return list of images (currently only contains 1 or 0 * {@link ArticleImage}s) */ private ArrayList<ArticleImage> addFormImageToArticle(Article article) { final DatabaseManager dbManager = DatabaseManager.getInstance(); final ArrayList<ArticleImage> imagesList = new ArrayList<ArticleImage>(); final ImageView productImageView = (ImageView) findViewById(R.id.product_img); final BitmapDrawable drawable = ((BitmapDrawable) productImageView.getDrawable()); final Bitmap productBitmap = drawable != null ? drawable.getBitmap() : null; article = dbManager.updateOrAddArticle(article); if (this.photoPath != null || productBitmap != null) { final Resources res = getResources(); ArticleImage image = new ArticleImage(); // TODO: Make hardcoded dimensions configurable: image.imageData = (this.photoPath != null) ? getPhotoData(300, 200) : getBitmapData(productBitmap, res.getDimensionPixelSize(R.dimen.product_img_width), res.getDimensionPixelSize(R.dimen.product_img_height)); image.article = article; article.images = dbManager.initializeArticleImagesCollection(); article.images.add(image); imagesList.add(image); } return imagesList; }
From source file:com.barswipe.materials.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override/* w ww . ja v a2 s .c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); setContentView(R.layout.activity_detail); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE); supportPostponeEnterTransition(); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((Toolbar) (findViewById(R.id.toolbar))).setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); final ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(image, new Callback() { @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap(); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); TextView title = (TextView) findViewById(R.id.title); title.setText(itemTitle); }
From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingCursorAdapter.java
/** * Stop the animation drawable on this imageView and hide the imageView. *//*from w ww. ja v a 2 s . co m*/ private void stopAnimation(final ImageView imageView) { if (imageView.getVisibility() == View.VISIBLE) { Log.v(TAG, "stopAnimation"); imageView.setVisibility(View.INVISIBLE); final AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable(); animationDrawable.setVisible(false, false); } }
From source file:com.tjcj.carrental.fragment.DriverFragment.java
private boolean isEqual(ImageView v) { return v.getDrawable().getCurrent().getConstantState() == getResources() .getDrawable(R.drawable.icon_bacgroud).getConstantState(); }