Example usage for android.widget ImageView getDrawable

List of usage examples for android.widget ImageView getDrawable

Introduction

In this page you can find the example usage for android.widget ImageView getDrawable.

Prototype

public Drawable getDrawable() 

Source Link

Document

Gets the current Drawable, or null if no Drawable has been assigned.

Usage

From source file:com.azcltd.android.test.kolesov.DrawableManager.java

public void fetchDrawableOnThreadWithNoImage(final String urlString, final ImageView imageView,
        final boolean isThumbnail) {
    fetchDrawableOnThread(urlString, imageView, false, false);
    if (imageView.getDrawable() == null) {
        //fetchDrawableOnThread(urlString, imageView, false, true);
        //if(imageView.getDrawable() == null)
        {// ww  w  . j ava2s  .  c om
            if (imageView.getTag(0) != isErrorImageKey) {
                fetchDrawableOnThread("http://www.wildcatpad.com/images/wutu.jpg", imageView, false, false);
                imageView.setTag(0, isErrorImageKey);
            }
            //                else
            //                {
            //                    fetchDrawableOnThread(urlString, imageView, false, true);
            //                    imageView.setTag(0, "");
            //                }
        }
    }
}

From source file:net.simno.klingar.ui.PlayerController.java

@OnClick(R.id.player_next)
void onClickNext(ImageView nextButton) {
    ((Animatable) nextButton.getDrawable()).start();
    musicController.next();
}

From source file:inc.bait.jubilee.model.helper.util.ImgLoader.java

private BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }//from w  ww .  j a v a  2 s . com
    }
    return null;
}

From source file:net.simno.klingar.ui.PlayerController.java

@OnClick(R.id.player_previous)
void onClickPrevious(ImageView previousButton) {
    ((Animatable) previousButton.getDrawable()).start();
    musicController.previous();
}

From source file:com.cnm.cnmrc.fragment.search.SearchVodSub.java

private Bundle makeBundle(View view, int position) {
    String title = adapter.getItem(position).getTitle();
    String hd = adapter.getItem(position).getHd();
    String grade = adapter.getItem(position).getGrade();
    String director = adapter.getItem(position).getDirector();
    String actor = adapter.getItem(position).getActor();
    String price = adapter.getItem(position).getPrice();
    String contents = adapter.getItem(position).getContents();

    ImageView logo = (ImageView) view.findViewById(R.id.logo_img);
    Bitmap logoImage = ((BitmapDrawable) logo.getDrawable()).getBitmap(); // ? no image ? ?? .

    Bundle bundle = new Bundle();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Bitmap bitmap = logoImage;//from   w w  w . j a  v  a 2  s. c  o  m
    boolean result = bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    if (result) { // ??  ... not all Formats support all bitmap configs directly
    } else {
        bitmap = Util.getNoBitmap(getActivity());
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    }
    byte[] logoImg = baos.toByteArray();

    bundle.putByteArray("logoImg", logoImg);
    bundle.putString("title", title);
    bundle.putString("hd", hd);
    bundle.putString("grade", grade);
    bundle.putString("director", director);
    bundle.putString("actor", actor);
    bundle.putString("price", price);
    bundle.putString("contents", contents);

    return bundle;
}

From source file:com.siso.app.adapter.BannerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final View view = viewlist.get(position);
    final ImageView imageView = (ImageView) view.findViewById(R.id.item_banner_img);
    //      final LinearLayout loading = (LinearLayout)view.findViewById(R.id.item_banner_loading);
    Log.i("tag", "imgUrl[position]==" + imgUrl[position]);
    if (imageView.getDrawable() == null) {
        Picasso picasso = Picasso.with(imageView.getContext());
        picasso.load(imgUrl[position]).into(imageView);
        //         Log.i("image", "position=="+position+""+imgUrl[position]);
        //         AsyncHttpClient client=new AsyncHttpClient();
        //         client.get(imgUrl[position], new AsyncHttpResponseHandler() {
        //            
        //            @Override
        //            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
        //               if(statusCode==200){
        //                  BitmapFactory factory=new BitmapFactory();
        //                  Bitmap bitmap=factory.decodeByteArray(responseBody, 0, responseBody.length);
        //                  imageView.setImageBitmap(bitmap);
        //                  loading.setVisibility(View.GONE);
        //               }
        //            }
        //            
        //            @Override
        //            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
        //               loading.setVisibility(View.GONE);
        //               Toast.makeText(context, context.getResources().getString(R.string.timeoutError), Toast.LENGTH_SHORT);
        //            }
        //         });
    }/* w  ww  .  j a  va  2 s.c  o m*/

    ViewParent vp = view.getParent();
    if (vp != null) {
        ViewGroup parent = (ViewGroup) vp;
        parent.removeView(view);
    }
    container.addView(view);
    return view;
}

From source file:com.freshdigitable.udonroad.StatusViewBase.java

protected void setTint(ImageView view, @ColorRes int color) {
    //    Log.d(TAG, "setTint: " + color);
    DrawableCompat.setTint(view.getDrawable(), ContextCompat.getColor(getContext(), color));
}

From source file:com.jlt.patadata.WaitingFragment.java

/**
 * Overrides/* www  . j a  v  a 2s.  c  o m*/
 */

@Override
// begin onCreateView
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // 0. inflate the layout with the waiting layout
    // 1. start animating the loading icon
    // 2. return inflated layout

    // 0. inflate the layout with the waiting layout

    View rootView = inflater.inflate(R.layout.fragment_loading, container, false);

    // 1. start animating the loading icon

    ImageView loadingImageView = (ImageView) rootView.findViewById(R.id.fem_iv_loading);

    Drawable drawable = loadingImageView.getDrawable();

    Log.e("onCreateView: ", String.valueOf(drawable instanceof Animatable));

    if (drawable instanceof Animatable) {
        ((Animatable) drawable).start();
    }

    //        AnimatedVectorDrawableCompat animatedVectorDrawableCompat = AnimatedVectorDrawableCompat.create( getActivity(), R.drawable.animated_sync_arrows );
    //
    //        ImageView loadingImageView = ( ImageView ) rootView.findViewById( R.id.fem_iv_loading );
    //
    //        loadingImageView.setImageDrawable( animatedVectorDrawableCompat );
    //
    //        Log.e( "onCreateView: ", String.valueOf( animatedVectorDrawableCompat == null ) );
    //        animatedVectorDrawableCompat.start();

    // 2. return inflated layout

    return rootView;

}

From source file:com.fastbootmobile.encore.app.fragments.AlbumsFragment.java

/**
 * {@inheritDoc}/*from  www.j a  va2 s.co  m*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View root = inflater.inflate(R.layout.fragment_albums, container, false);
    mGridView = (GridView) root.findViewById(R.id.gvAlbums);
    mGridView.setFastScrollEnabled(true);

    // Get the albums
    new GetAlbumsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    // Setup the click listener
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            AlbumsAdapter.ViewHolder tag = (AlbumsAdapter.ViewHolder) view.getTag();
            ImageView ivCover = tag.ivCover;
            Album item = mAdapter.getItem(position);

            Bitmap hero = ((MaterialTransitionDrawable) ivCover.getDrawable()).getFinalDrawable().getBitmap();
            Intent intent = AlbumActivity.craftIntent(getActivity(), hero, item.getRef(), item.getProvider(),
                    tag.itemColor);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(), tag.ivCover,
                        "itemImage");
                getActivity().startActivity(intent, opt.toBundle());
            } else {
                startActivity(intent);
            }
        }
    });

    return root;
}

From source file:ar.com.lapotoca.resiliencia.gallery.ui.ImageDetailActivity.java

private Uri getLocalBitmapUri(ImageView imageView) {
    // Extract Bitmap from ImageView drawable
    Drawable drawable = imageView.getDrawable();
    Bitmap bmp;/*from  ww  w.  ja  va 2s .  c  o  m*/
    if (drawable instanceof BitmapDrawable) {
        bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
    } else {
        return null;
    }
    if (bmp == null) {
        return null;
    }
    // Store image to default external storage directory
    Uri bmpUri = null;
    try {
        // Use methods on Context to access package-specific directories on external storage.
        // This way, you don't need to request external read/write permission.
        // See https://youtu.be/5xVh-7ywKpE?t=25m25s
        File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES),
                "share_image_" + System.currentTimeMillis() + ".png");
        FileOutputStream out = new FileOutputStream(file);
        bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
        out.close();
        bmpUri = Uri.fromFile(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bmpUri;
}