Example usage for android.widget ImageView getResources

List of usage examples for android.widget ImageView getResources

Introduction

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

Prototype

public Resources getResources() 

Source Link

Document

Returns the resources associated with this view.

Usage

From source file:com.github.programmerr47.vkgroups.imageloading.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./* ww  w  . j a  va 2s .c  o m*/
 */
private void setImageDrawable(ImageView imageView, BitmapDrawable drawable, LoadBitmapParams loadingParams) {
    Drawable finalDrawable = postProcessDrawable(drawable, loadingParams);

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(imageView.getResources().getColor(android.R.color.transparent)),
                finalDrawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(finalDrawable);
    }
}

From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java

@Override
public void onUpdateFab(@NonNull ImageView fab) {
    if (getStopwatch().isRunning()) {
        fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_pause_white_24dp);
        fab.setContentDescription(// w w w. j  a  v a 2s  .  c om
                fab.getResources().getString(com.wizardsofm.deskclock.R.string.sw_pause_button));
    } else {
        fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp);
        fab.setContentDescription(
                fab.getResources().getString(com.wizardsofm.deskclock.R.string.sw_start_button));
    }
    fab.setVisibility(VISIBLE);
}

From source file:com.slava.android.utils.ImageDownloader.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.
 *//*from  w  w w.  j  a v  a2s . co m*/
private void forceDownload(String url, ImageView imageView, int cornersRadius) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null || url.equals("")) {
        imageView.setImageDrawable(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, cornersRadius);
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(imageView.getResources(),
                mLoadingIndicator, task);
        imageView.setImageDrawable(downloadedDrawable);
        imageView.setMinimumHeight(156);
        task.execute(url);
    }
}

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

private void forceDownload(String url, ImageView imageView) {
    if (url == null) {
        imageView.setImageDrawable(null);
        return;//ww  w  .  j  a  va 2 s.  c o m
    }

    if (cancelPotentialDownload(url, imageView)) {
        BitmapDownloaderTask task = null;
        task = new BitmapDownloaderTask(imageView, url);
        Object obj = imageView.getTag();
        int resId = -1;
        Bitmap bitmapDefault = null;
        if (obj != null) {
            resId = (Integer) obj;
            bitmapDefault = BitmapFactory.decodeResource(imageView.getResources(), resId);
        }
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(bitmapDefault, task);
        imageView.setImageDrawable(downloadedDrawable);
        // imageView.setBackgroundColor(Color.WHITE);
        //         imageView.setBackgroundResource(R.drawable.wallpaper_bg);
        imageView.setMinimumHeight(156);
        task.execute();
    }
}

From source file:com.androidinspain.deskclock.stopwatch.StopwatchFragment.java

private void updateFab(@NonNull ImageView fab, boolean animate) {
    if (getStopwatch().isRunning()) {
        if (animate) {
            fab.setImageResource(R.drawable.ic_play_pause_animation);
        } else {/*  w ww . j  a  v a  2  s  .  c o m*/
            fab.setImageResource(R.drawable.ic_play_pause);
        }
        fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button));
    } else {
        if (animate) {
            fab.setImageResource(R.drawable.ic_pause_play_animation);
        } else {
            fab.setImageResource(R.drawable.ic_pause_play);
        }
        fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button));
    }
    fab.setVisibility(VISIBLE);
}

From source file:orbin.deskclock.timer.TimerFragment.java

@Override
public void onUpdateFab(@NonNull ImageView fab) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();
        if (timer == null) {
            fab.setVisibility(INVISIBLE);
            return;
        }//from www .ja v a2s  .c  om

        fab.setVisibility(VISIBLE);
        switch (timer.getState()) {
        case RUNNING:
            fab.setImageResource(R.drawable.ic_pause_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_stop));
            break;
        case RESET:
        case PAUSED:
            fab.setImageResource(R.drawable.ic_start_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_start));
            break;
        case EXPIRED:
            fab.setImageResource(R.drawable.ic_stop_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_stop));
            break;
        }

    } else if (mCurrentView == mCreateTimerView) {
        if (mCreateTimerView.hasValidInput()) {
            fab.setImageResource(R.drawable.ic_start_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_start));
            fab.setVisibility(VISIBLE);
        } else {
            fab.setVisibility(INVISIBLE);
        }
    }
}

From source file:com.stasbar.knowyourself.timer.TimerFragment.java

public void onUpdateFab(@NonNull ImageView fab) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();
        if (timer == null) {
            fab.setVisibility(INVISIBLE);
            return;
        }//w  w w .  ja  v a  2s. c  o  m

        fab.setVisibility(VISIBLE);
        switch (timer.getState()) {
        case RUNNING:
            fab.setImageResource(R.drawable.ic_pause_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_stop));
            break;
        case RESET:
        case PAUSED:
            fab.setImageResource(R.drawable.ic_start_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_start));
            break;
        case MISSED:
        case EXPIRED:
            fab.setImageResource(R.drawable.ic_stop_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_stop));
            break;
        }

    } else if (mCurrentView == mCreateTimerView) {
        if (mCreateTimerView.hasValidInput()) {
            fab.setImageResource(R.drawable.ic_start_white_24dp);
            fab.setContentDescription(fab.getResources().getString(R.string.timer_start));
            fab.setVisibility(VISIBLE);
        } else {
            fab.setVisibility(INVISIBLE);
        }
    }
}

From source file:com.wizardsofm.deskclock.timer.TimerFragment.java

@Override
public void onUpdateFab(@NonNull ImageView fab) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();
        if (timer == null) {
            fab.setVisibility(INVISIBLE);
            return;
        }//  w  w w  . jav a  2s  .  com

        fab.setVisibility(VISIBLE);
        switch (timer.getState()) {
        case RUNNING:
            fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_pause_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_stop));
            break;
        case RESET:
        case PAUSED:
            fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_start));
            break;
        case EXPIRED:
            fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_stop_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_stop));
            break;
        }

    } else if (mCurrentView == mCreateTimerView) {
        if (mCreateTimerView.hasValidInput()) {
            fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_start));
            fab.setVisibility(VISIBLE);
        } else {
            fab.setVisibility(INVISIBLE);
        }
    }
}

From source file:com.life.wuhan.util.ImageDownloader.java

private void forceDownload(String url, ImageView imageView) {
    if (url == null) {
        imageView.setImageDrawable(null);
        return;//from   w  ww  .j ava  2  s .  co m
    }

    if (cancelPotentialDownload(url, imageView)) {
        switch (mode) {
        case NO_ASYNC_TASK:
            Bitmap bitmap = downloadBitmap(url);
            addBitmapToCache(url, bitmap);
            imageView.setImageBitmap(bitmap);
            break;

        case NO_DOWNLOADED_DRAWABLE:
            imageView.setMinimumHeight(156);
            BitmapDownloaderTask task = null;

            task = new BitmapDownloaderTask(imageView);

            task.execute(url);
            break;

        case CORRECT:

            task = new BitmapDownloaderTask(imageView);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(imageView.getResources(), task);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            task.execute(url);
            break;
        }
    }
}

From source file:com.androidinspain.deskclock.timer.TimerFragment.java

private void updateFab(@NonNull ImageView fab, boolean animate) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();
        if (timer == null) {
            fab.setVisibility(INVISIBLE);
            return;
        }/*w  w  w . jav  a2  s.co m*/

        fab.setVisibility(VISIBLE);
        switch (timer.getState()) {
        case RUNNING:
            if (animate) {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_play_pause_animation);
            } else {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_play_pause);
            }
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_stop));
            break;
        case RESET:
            if (animate) {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_stop_play_animation);
            } else {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_pause_play);
            }
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_start));
            break;
        case PAUSED:
            if (animate) {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_pause_play_animation);
            } else {
                fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_pause_play);
            }
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_start));
            break;
        case MISSED:
        case EXPIRED:
            fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_stop_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_stop));
            break;
        }
    } else if (mCurrentView == mCreateTimerView) {
        if (mCreateTimerView.hasValidInput()) {
            fab.setImageResource(com.androidinspain.deskclock.R.drawable.ic_start_white_24dp);
            fab.setContentDescription(
                    fab.getResources().getString(com.androidinspain.deskclock.R.string.timer_start));
            fab.setVisibility(VISIBLE);
        } else {
            fab.setContentDescription(null);
            fab.setVisibility(INVISIBLE);
        }
    }
}