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:org.messic.android.smartphone.activities.main.fragments.playlist.PlaylistFragment.java

/**
 * Show the AlbumInfo Activity//  w w w . j a  va2  s .  c  o  m
 *
 * @param cover
 * @param album
 */

private void showAlbumInfo(ImageView cover, MDMAlbum album) {
    //lets show the albuminfoactivity
    Intent ssa = new Intent(getActivity(), AlbumInfoActivity.class);
    ssa.putExtra(AlbumInfoActivity.EXTRA_ALBUM_SID, album);
    Bitmap bitmap = ((BitmapDrawable) cover.getDrawable()).getBitmap();
    AlbumInfoActivity.defaultArt = bitmap;
    //ssa.putExtra(AlbumInfoActivity.EXTRA_ALBUM_ART, bitmap);

    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this.getActivity(),
            cover, "cover");
    getActivity().startActivity(ssa, options.toBundle());
}

From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java

@Override
public synchronized void showProgressIndicatorInTool() {
    MBToolDefinition refreshToolDef = getRefreshToolDef();
    Menu menu = _menu;/*w ww  .  j a va2  s. com*/

    if (refreshToolDef != null && menu != null) {
        final MenuItem item = menu.findItem(refreshToolDef.getName().hashCode());

        ImageView rotationImage = getRotationImage();

        float imageWidth = rotationImage.getDrawable().getIntrinsicWidth();
        int framePadding = (int) ((ScreenUtil.convertDimensionPixelsToPixels(_context, 80) - imageWidth) / 2);

        final FrameLayout frameLayout = new FrameLayout(_context);
        frameLayout.setLayoutParams(
                new FrameLayout.LayoutParams(ScreenUtil.convertDimensionPixelsToPixels(_context, 80),
                        LayoutParams.WRAP_CONTENT, Gravity.CENTER));
        frameLayout.setPadding(framePadding, 0, framePadding, 0);

        frameLayout.addView(rotationImage);

        MBViewManager.getInstance().runOnUiThread(new MBThread() {
            @Override
            public void runMethod() {
                //item.setIcon(null);
                MenuItemCompat.setActionView(item, frameLayout);
                getRotationImage().getAnimation().startNow();
            }
        });
    }
}

From source file:com.antonioleiva.materializeyourapp.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initActivityTransitions();/* w w w. j a v  a 2  s.c  o m*/

    setContentView(R.layout.activity_detail);
    ActivityCompat.postponeEnterTransition(this);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    String itemTitle = getIntent().getStringExtra(EXTRA_TITLE);
    setTitle(itemTitle);

    final ImageView image = (ImageView) findViewById(R.id.image);
    ViewCompat.setTransitionName(image, EXTRA_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, image);
                }
            });
        }

        @Override
        public void onError() {

        }
    });

    TextView title = (TextView) findViewById(R.id.title);
    title.setText(itemTitle);
}

From source file:nl.hnogames.domoticz.Fragments.Cameras.java

private void createListView(ArrayList<CameraInfo> Cameras) {
    if (getView() == null)
        return;//from www  . j av a2  s  . c o  m

    if (mRecyclerView == null) {
        mRecyclerView = (RecyclerView) getView().findViewById(R.id.my_recycler_view);
        mSwipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipe_refresh_layout);
        mRecyclerView.setHasFixedSize(true);
        GridLayoutManager mLayoutManager = new GridLayoutManager(context, 2);
        mRecyclerView.setLayoutManager(mLayoutManager);
    }

    if (mAdapter == null) {
        mAdapter = new CamerasAdapter(Cameras, context, mDomoticz, refreshTimer);
        mAdapter.setOnItemClickListener(new CamerasAdapter.onClickListener() {
            @Override
            public void onItemClick(int position, View v) {
                if (mPhoneConnectionUtil.isNetworkAvailable()) {
                    try {
                        ImageView cameraImage = (ImageView) v.findViewById(R.id.image);
                        TextView cameraTitle = (TextView) v.findViewById(R.id.name);
                        Bitmap savePic = ((BitmapDrawable) cameraImage.getDrawable()).getBitmap();

                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                            if (!PermissionsUtil.canAccessStorage(context)) {
                                permissionFragmentHelper.request(PermissionsUtil.INITIAL_STORAGE_PERMS);
                            } else
                                processImage(savePic, cameraTitle.getText().toString());
                        } else {
                            processImage(savePic, cameraTitle.getText().toString());
                        }
                    } catch (Exception ex) {
                        errorHandling(ex, coordinatorLayout);
                    }
                } else {
                    if (coordinatorLayout != null) {
                        UsefulBits.showSnackbar(getContext(), coordinatorLayout, R.string.error_notConnected,
                                Snackbar.LENGTH_SHORT);
                        if (getActivity() instanceof MainActivity)
                            ((MainActivity) getActivity()).Talk(R.string.error_notConnected);
                    }
                }
            }
        });
        alphaSlideIn = new SlideInBottomAnimationAdapter(mAdapter);
        mRecyclerView.setAdapter(alphaSlideIn);
    } else {
        mAdapter.setData(Cameras);
        mAdapter.notifyDataSetChanged();
        alphaSlideIn.notifyDataSetChanged();
    }

    mSwipeRefreshLayout.setRefreshing(false);
}

From source file:com.varejodigital.activities.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initActivityTransitions();/*  w w  w  . j a v a  2  s.  c  o  m*/

    setContentView(R.layout.activity_detail);
    ActivityCompat.postponeEnterTransition(this);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String itemTitle = getIntent().getStringExtra(EXTRA_TITLE);
    setTitle(itemTitle);

    final ImageView image = (ImageView) findViewById(R.id.image);
    ViewCompat.setTransitionName(image, EXTRA_IMAGE);
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(image, new Callback() {
        @Override
        public void onSuccess() {
            Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
            Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
                public void onGenerated(Palette palette) {
                    applyPalette(palette, image);
                }
            });
        }

        @Override
        public void onError() {

        }
    });

    TextView title = (TextView) findViewById(R.id.title);
    title.setText(itemTitle);
}

From source file:com.jwetherell.quick_response_code.EncoderActivity.java

public Uri getLocalBitmapUri(ImageView imageView) {
    // Extract Bitmap from ImageView drawable
    Drawable drawable = imageView.getDrawable();
    Bitmap bmp = null;//from   w w w  .  java  2 s.  c  o m
    if (drawable instanceof BitmapDrawable) {
        bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
    } else {
        return null;
    }
    // Store image to default external storage directory
    Uri bmpUri = null;
    try {
        File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
                "miwifiQR_" + System.currentTimeMillis() + ".png");
        file.getParentFile().mkdirs();
        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;
}

From source file:org.messic.android.smartphone.activities.main.fragments.explore.ExploreFragment.java

/**
 * Show the AlbumInfo Activity/*from w  ww . j  av  a2s  . c  o m*/
 *
 * @param cover
 * @param album
 */
private void showAlbumInfo(ImageView cover, MDMAlbum album) {
    //lets show the albuminfoactivity
    Intent ssa = new Intent(getActivity(), AlbumInfoActivity.class);
    ssa.putExtra(AlbumInfoActivity.EXTRA_ALBUM_SID, album);
    BitmapDrawable d = ((BitmapDrawable) cover.getDrawable());
    if (d != null) {
        Bitmap bitmap = d.getBitmap();
        AlbumInfoActivity.defaultArt = bitmap;
        //ssa.putExtra(AlbumInfoActivity.EXTRA_ALBUM_ART, bitmap);

        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this.getActivity(),
                cover, "cover");
        getActivity().startActivity(ssa, options.toBundle());
    }
}

From source file:com.secretlisa.lib.utils.BaseImageLoader.java

private BitmapDownloaderTask getBitmapDownloaderTask(ImageView imageView) {
    if (imageView != null) {
        Drawable drawable = imageView.getDrawable();
        if (drawable instanceof DownloadedDrawable) {
            DownloadedDrawable downloadedDrawable = (DownloadedDrawable) drawable;
            return downloadedDrawable.getBitmapDownloaderTask();
        }//from   w w w . j a v  a2 s.co  m
    }
    return null;
}

From source file:org.android.framework.engine.image.ImageWorker.java

/**
 * @param imageView Any imageView/*from  w  w  w .  j  a  va 2s  .c o m*/
 * @return Retrieve the currently active work task (if any) associated with this imageView.
 * null if there is no such task.
 */
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();
        }
    }
    return null;
}

From source file:com.mobileman.moments.android.frontend.activity.IncomingCallActivity.java

private void sendNotificationAndFinish() {
    if (streamingUser != null) {
        Intent intent = new Intent(getApplicationContext(), MediaPlayerActivity.class);
        Bundle extras = new Bundle();
        extras.putString(MediaPlayerActivity.MEDIA_URL, streamingUser.getStream().getFullVideoUrl());
        extras.putString(MediaPlayerActivity.THUMBNAIL_URL, streamingUser.getStream().getFullThumbnailUrl());
        extras.putString(MediaPlayerActivity.USER_ID, streamingUser.getUuid());
        intent.putExtras(extras);//from w  w w.j  av  a 2s . c om
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_SINGLE_TOP);

        PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder b = new NotificationCompat.Builder(getApplicationContext());
        String notificationTitle = userName + " " + getResources().getString(R.string.isLiveSuffix);
        String notificationText = "";// getResources().getString(R.string.missedCallNotification) + " " + streamingUser.getName();
        String mediaUrl = streamingUser.getStream().getFullVideoUrl();

        if ((streamingUser.getStream() != null) && (streamingUser.getStream().getTitle() != null)) {
            notificationText = streamingUser.getStream().getTitle(); //notificationText + "(" + streamingUser.getStream().getTitle() + ")";
        }
        ImageView incomingCallUserImageView = (ImageView) findViewById(R.id.incomingCallUserImageView);
        Bitmap bitmap = ((BitmapDrawable) incomingCallUserImageView.getDrawable()).getBitmap();
        NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
        b.setAutoCancel(true).setSmallIcon(R.drawable.ic_launcher).setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis()).setTicker("X").setContentTitle(notificationTitle)
                .setContentText(notificationText)
                .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
                .setContentIntent(contentIntent);
        //            if (bitmap != null) {
        //                b.setLargeIcon(bitmap);
        //            }

        NotificationManager notificationManager = (NotificationManager) getApplicationContext()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(++NOTIFICATION_COUNTER, b.build());

    }
    finish();
}