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:ca.rmen.android.scrumchatter.meeting.detail.MeetingCursorAdapter.java

/**
 * Show the imageView and start its animation drawable.
 *//*from  w w  w  .j  a  va2  s.  c  o  m*/
private void startAnimation(final ImageView imageView) {
    if (imageView.getVisibility() != View.VISIBLE) {
        Log.v(TAG, "startAnimation");
        imageView.setVisibility(View.VISIBLE);
        final AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
        // On some devices, directly calling start() on the animation does not work.
        // We have to wait until the ImageView is visible before starting the animation.
        imageView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @SuppressWarnings("deprecation")
            @Override
            public void onGlobalLayout() {
                if (!animationDrawable.isRunning()) {
                    imageView.post(() -> {
                        animationDrawable.setVisible(true, false);
                        animationDrawable.start();
                    });
                }
                imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
        });
    }
}

From source file:com.glabs.homegenie.adapters.MediaRendererWidgetAdapter.java

@Override
public void updateViewModel() {

    if (_module.View == null)
        return;/*from w w  w. j av  a  2s  . c  om*/

    _updateRendererDisplayData();

    TextView title = (TextView) _module.View.findViewById(R.id.titleText);
    TextView subtitle = (TextView) _module.View.findViewById(R.id.subtitleText);
    TextView infotext = (TextView) _module.View.findViewById(R.id.infoText);

    title.setText(_module.getDisplayName());
    infotext.setVisibility(View.GONE);

    subtitle.setText(Control.getUpnpDisplayName(_module));
    //
    if (_module.getParameter("UPnP.StandardDeviceType") != null
            && !_module.getParameter("UPnP.StandardDeviceType").Value.trim().equals("")) {
        infotext.setText(_module.getParameter("UPnP.StandardDeviceType").Value);
        infotext.setVisibility(View.VISIBLE);
    }
    //
    final ImageView image = (ImageView) _module.View.findViewById(R.id.iconImage);
    if (image.getTag() == null && !(image.getDrawable() instanceof AsyncImageDownloadTask.DownloadedDrawable)) {
        AsyncImageDownloadTask asyncDownloadTask = new AsyncImageDownloadTask(image, true,
                new AsyncImageDownloadTask.ImageDownloadListener() {
                    @Override
                    public void imageDownloadFailed(String imageUrl) {
                    }

                    @Override
                    public void imageDownloaded(String imageUrl, Bitmap downloadedImage) {
                        image.setTag("CACHED");
                    }
                });
        asyncDownloadTask.download(Control.getHgBaseHttpAddress() + getModuleIcon(_module), image);
    }
}

From source file:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java

public void updateAutoUpdateView(boolean value) {
    ImageView icon = (ImageView) getView().findViewById(R.id.status_icon);
    icon.getDrawable().setAlpha((value ? 255 : 70));
    icon.invalidate();//w ww .j  av  a 2 s.c  om
}

From source file:com.hackvg.android.views.activities.MoviesActivity.java

@Override
public void onClick(View touchedView, int moviePosition, float touchedX, float touchedY) {

    Intent movieDetailActivityIntent = new Intent(MoviesActivity.this, MovieDetailActivity.class);

    String movieID = mMoviesAdapter.getMovieList().get(moviePosition).getId();
    movieDetailActivityIntent.putExtra(EXTRA_MOVIE_ID, movieID);
    movieDetailActivityIntent.putExtra(EXTRA_MOVIE_POSITION, moviePosition);

    ImageView mCoverImage = (ImageView) touchedView.findViewById(R.id.item_movie_cover);
    BitmapDrawable bitmapDrawable = (BitmapDrawable) mCoverImage.getDrawable();

    if (mMoviesAdapter.isMovieReady(moviePosition) || bitmapDrawable != null) {

        sPhotoCache.put(0, bitmapDrawable.getBitmap());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            startDetailActivityBySharedElements(touchedView, moviePosition, movieDetailActivityIntent);
        else/*ww  w  . jav  a2 s  .  c o  m*/
            startDetailActivityByAnimation(touchedView, (int) touchedX, (int) touchedY,
                    movieDetailActivityIntent);

    } else {

        Toast.makeText(this, getString(R.string.activity_movies_message_loading_film), Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:org.odk.collect.android.widgets.QuestionWidget.java

public void recycleDrawables() {
    List<ImageView> images = new ArrayList<>();
    // collect all the image views
    recycleDrawablesRecursive(this, images);
    for (ImageView imageView : images) {
        imageView.destroyDrawingCache();
        Drawable d = imageView.getDrawable();
        if (d != null && d instanceof BitmapDrawable) {
            imageView.setImageDrawable(null);
            BitmapDrawable bd = (BitmapDrawable) d;
            Bitmap bmp = bd.getBitmap();
            if (bmp != null) {
                bmp.recycle();/*from  ww w  .  j  av  a 2  s.  c  o  m*/
            }
        }
    }
}

From source file:com.p2c.thelife.SettingsFragment.java

private void rotateImage(float angle) {
    ImageView imageView = (ImageView) getActivity().findViewById(R.id.settings_image);

    if (m_updatedBitmap == null) {
        m_updatedBitmap = Utilities.getBitmapFromDrawable(imageView.getDrawable());
    }//from  w  w w . jav a 2s . c  o  m

    // rotate image in memory
    Matrix matrix = new Matrix();
    matrix.setRotate(angle);
    m_updatedBitmap = Bitmap.createBitmap(m_updatedBitmap, 0, 0, m_updatedBitmap.getWidth(),
            m_updatedBitmap.getHeight(), matrix, true);

    // save new image bitmap
    imageView.setImageBitmap(m_updatedBitmap);
}

From source file:br.com.anteros.android.synchronism.view.AbstractSynchronismFragment.java

@Nullable
@Override/* ww  w. j  av  a  2  s .  com*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.synchronism_view, null);

    onlyExportData = getActivity().getIntent().getBooleanExtra(SynchronismConstants.ONLY_EXPORT_DATA, false);

    if (onlyExportData)
        executeImport = false;

    finishAfterSynchronismOrError = getActivity().getIntent()
            .getBooleanExtra(SynchronismConstants.FINISH_AFTER_SYNCHRONISM_OR_ERROR, false);
    showMessageOnFinishSynchronism = getActivity().getIntent()
            .getBooleanExtra(SynchronismConstants.SHOW_MESSAGE_ON_FINISH_SYNCHRONISM, true);
    autoExecute = getActivity().getIntent().getBooleanExtra(SynchronismConstants.AUTO_EXECUTE_SYNCHRONISM,
            false);

    ImageView imgSyncronism = (ImageView) view.findViewById(R.id.syncronism_view_anSyncronism);
    anSyncronism = (AnimationDrawable) imgSyncronism.getDrawable();

    listenerUpdateView = new SynchronismListenerViewUpdate(this, this);

    synchronismManager().setExportListener(this);
    synchronismManager().setImportListener(this);

    lbTables = (TextView) view.findViewById(R.id.syncronism_view_lbTables);
    pbTables = (ProgressBar) view.findViewById(R.id.syncronism_view_pb_tables);

    lbActions = (TextView) view.findViewById(R.id.syncronism_view_lbActions);
    pbActions = (ProgressBar) view.findViewById(R.id.syncronism_view_pb_actions);

    lbStatus = (TextView) view.findViewById(R.id.syncronism_view_lb_status);

    return view;
}

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

private void onArtistClick(int i, View v) {
    if (mAdapter.getChildrenCount(SearchAdapter.ARTIST) > 1) {
        SearchAdapter.SearchEntry entry = mAdapter.getChild(SearchAdapter.ARTIST, i);

        if (entry.ref.equals(KEY_SPECIAL_MORE)) {
            mAdapter.setGroupMaxCount(SearchAdapter.ARTIST,
                    mAdapter.getGroupMaxCount(SearchAdapter.ARTIST) + 5);
        } else {/*from  w ww  . j  a  v  a2  s .  c  om*/
            SearchAdapter.ViewHolder holder = (SearchAdapter.ViewHolder) v.getTag();
            ImageView ivCover = holder.albumArtImageView;
            Bitmap hero = ((MaterialTransitionDrawable) ivCover.getDrawable()).getFinalDrawable().getBitmap();
            int color = 0xffffff;
            if (hero != null) {
                Palette palette = Palette.generate(hero);
                Palette.Swatch darkVibrantColor = palette.getDarkVibrantSwatch();
                Palette.Swatch darkMutedColor = palette.getDarkMutedSwatch();

                if (darkVibrantColor != null) {
                    color = darkVibrantColor.getRgb();
                } else if (darkMutedColor != null) {
                    color = darkMutedColor.getRgb();
                } else {
                    color = getResources().getColor(R.color.default_album_art_background);
                }
            }
            Intent intent = new Intent(getActivity(), ArtistActivity.class);
            intent.putExtra(ArtistActivity.EXTRA_ARTIST, entry.ref);
            intent.putExtra(ArtistActivity.EXTRA_BACKGROUND_COLOR, color);
            Utils.queueBitmap(ArtistActivity.BITMAP_ARTIST_HERO, hero);

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

From source file:com.owncloud.android.ui.activity.UserInfoActivity.java

private void populateUserInfoElement(View container, TextView textView, String text, ImageView icon,
        @ColorInt int tint) {
    if (!TextUtils.isEmpty(text)) {
        textView.setText(text);/*from  www .  j  a v  a2s.  co m*/
        DrawableCompat.setTint(icon.getDrawable(), tint);
    } else {
        container.setVisibility(View.GONE);
    }
}

From source file:com.saulmm.cui.OrderDialogFragment.java

private View createSelectedColorView(ImageView selectedView) {
    final ImageView fakeImageView = new CircleImageView(getContext(), null, R.attr.colorStyle);

    fakeImageView.setImageDrawable(selectedView.getDrawable());
    fakeImageView.setLayoutParams(SelectedParamsFactory.startColorParams(selectedView));
    return fakeImageView;
}