Example usage for android.widget ImageView setImageResource

List of usage examples for android.widget ImageView setImageResource

Introduction

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

Prototype

@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync")
public void setImageResource(@DrawableRes int resId) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

From source file:com.hybris.mobile.app.commerce.adapter.ProductListAdapterBase.java

/**
 * Show image Product from URL// w  w w. j a v  a 2s.co  m
 *
 * @param imageUrl    image url
 * @param imageView
 * @param progressBar
 * @param productCode product code to find
 */
protected void loadProductImage(String imageUrl, final ImageView imageView, final ProgressBar progressBar,
        String productCode) {

    // Loading the product image
    if (CommerceApplication.isOnline()) {
        if (StringUtils.isNotBlank(imageUrl)) {
            CommerceApplication.getContentServiceHelper().loadImage(imageUrl,
                    "product_list_image_" + productCode, imageView, 0, 0, true, new OnRequestListener() {

                        @Override
                        public void beforeRequest() {
                            imageView.setImageResource(android.R.color.transparent);
                            imageView.setVisibility(View.GONE);
                            progressBar.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void afterRequestBeforeResponse() {

                        }

                        @Override
                        public void afterRequest(boolean isDataSynced) {
                            imageView.setVisibility(View.VISIBLE);
                        }
                    }, true);
        }
    } else {
        Log.i(TAG, "Application offline, displaying no image for product " + productCode);
        imageView.setImageDrawable(getContext().getResources().getDrawable(R.drawable.no_image_product));
        imageView.setVisibility(View.VISIBLE);
    }
}

From source file:be.matteotaroli.pomodoro.IntroFragment.java

@Nullable
@Override/*from   ww  w  .  j a v a 2s  .  c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_intro_page, container, false);

    mPager = ((IntroActivity) getActivity()).getPager();
    TextView titleTv = (TextView) view.findViewById(R.id.intro_title_textView);
    TextView textTv = (TextView) view.findViewById(R.id.intro_text_textView);
    ImageView pictureIV = (ImageView) view.findViewById(R.id.intro_picture_imageView);
    TextView skipTv = (TextView) view.findViewById(R.id.intro_skip);
    TextView nextTv = (TextView) view.findViewById(R.id.intro_next);

    View.OnClickListener skipIntro = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), TimerActivity.class);
            startActivity(intent);
            getActivity().finish();
        }
    };
    View.OnClickListener next = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(mPage + 1);
        }
    };

    if (mPage == IntroAdapter.PAGE_COUNT - 1) {
        /* Last page */
        skipTv.setVisibility(View.INVISIBLE);
        nextTv.setText(R.string.lets_start);
        nextTv.setOnClickListener(skipIntro);

        titleTv.setText(R.string.intro_end_title);
        textTv.setText(R.string.intro_end_text);
        pictureIV.setImageResource(R.drawable.pomodoro);
        pictureIV.setContentDescription(getResources().getString(R.string.logo_description));
    } else {
        /* Any other page */
        skipTv.setOnClickListener(skipIntro);
        nextTv.setText(R.string.intro_next);
        nextTv.setOnClickListener(next);

        titleTv.setText(pages[mPage][0]);
        textTv.setText(pages[mPage][1]);

        /*  TODO  - v 0.1.0 - add pictures and uncomment those lines
            pictureIV.setImageResource(pages[mPage][2]);
            pictureIV.setContentDescription(getResources().getString(pages[mPage][3]));
        */
    }

    view.setTag(mPage);
    return view;
}

From source file:com.forum.fiend.osp.SettingsFragment.java

private void setupUserCard() {

    if (getActivity() == null) {
        return;//w w w .  jav a 2 s  . c o m
    }

    LinearLayout userLayout = (LinearLayout) getActivity().findViewById(R.id.settings_user_box);

    if (application.getSession().getServer().serverUserId.contentEquals("0")) {
        userLayout.setVisibility(View.GONE);
    } else {
        ImageView ivAvatar = (ImageView) getActivity().findViewById(R.id.settings_user_avatar);
        TextView tvUsername = (TextView) getActivity().findViewById(R.id.settings_user_name);
        ImageView ivLogout = (ImageView) getActivity().findViewById(R.id.settings_user_logout);

        tvUsername.setText(application.getSession().getServer().serverUserName);

        if (application.getSession().getServer().serverAvatar.contains("http")) {
            ImageLoader.getInstance().displayImage(application.getSession().getServer().serverAvatar, ivAvatar);
        } else {
            ivAvatar.setImageResource(R.drawable.no_avatar);
        }

        ivLogout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                logOut();
            }
        });

        userLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                loadMyWall();
            }
        });
    }
}

From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFilteredFragment.java

@Override
public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex,
        Object tag) {/*from  w w w . j a v a2  s .c  om*/
    final VideoLibraryModel.Video video = (VideoLibraryModel.Video) tag;
    if (video == null) {
        return;
    }
    ImageView thumbnailView = (ImageView) view.findViewById(R.id.thumbnail);
    TextView titleView = (TextView) view.findViewById(R.id.title);
    TextView speakersView = (TextView) view.findViewById(R.id.speakers);
    TextView descriptionView = (TextView) view.findViewById(R.id.description);
    titleView.setText(video.getTitle());
    speakersView.setText(video.getSpeakers());
    speakersView.setVisibility(TextUtils.isEmpty(video.getSpeakers()) ? View.GONE : View.VISIBLE);
    descriptionView.setText(video.getDesc());
    descriptionView.setVisibility(
            TextUtils.isEmpty(video.getDesc()) || video.getTitle().equals(video.getDesc()) ? View.GONE
                    : View.VISIBLE);

    String thumbUrl = video.getThumbnailUrl();
    if (TextUtils.isEmpty(thumbUrl)) {
        thumbnailView.setImageResource(android.R.color.transparent);
    } else {
        mImageLoader.loadImage(thumbUrl, thumbnailView);
    }

    // Display the overlay if the video has already been played.
    if (video.getAlreadyPlayed()) {
        styleVideoAsViewed(view);
    }

    final String videoId = video.getId();
    final String youtubeLink = TextUtils.isEmpty(videoId) ? ""
            : videoId.contains("://") ? videoId
                    : String.format(Locale.US, Config.VIDEO_LIBRARY_URL_FMT, videoId);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!TextUtils.isEmpty(youtubeLink)) {
                LOGD(TAG, "Launching Youtube video: " + youtubeLink);

                // ANALYTICS EVENT: Click on a video on the Filtered Video Library screen
                // Contains: video's YouTube URL, http://www.youtube.com/...
                AnalyticsHelper.sendEvent(FILTERED_VIDEO_LIBRARY_ANALYTICS_CATEGORY, "selectvideo",
                        youtubeLink);
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(youtubeLink));
                UIUtils.preferPackageForIntent(getActivity(), i, UIUtils.YOUTUBE_PACKAGE_NAME);
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                startActivity(i);
                // Mark the video as played.
                fireVideoPlayedEvent(video);
                // Display the overlay for videos that has already been played.
                styleVideoAsViewed(view);
            }
        }
    });
}

From source file:com.nbplus.vbroadlauncher.fragment.LauncherFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_launcher, container, false);

    mMainViewLayout = (LinearLayout) v.findViewById(R.id.main_view_layout);

    // push agent ??.
    mPushServiceStatus = (ImageView) v.findViewById(R.id.ic_nav_wifi);
    if (((BaseActivity) getActivity()).isPushServiceConnected()) {
        mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_on);
    } else {// ww  w .  ja  va 2s . com
        mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_off);
    }

    mVillageName = (TextView) v.findViewById(R.id.launcher_village_name);
    mVillageName.setText(LauncherSettings.getInstance(getActivity()).getVillageName());

    mApplicationsView = (LinearLayout) v.findViewById(R.id.ic_nav_apps);
    mApplicationsView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), ShowApplicationActivity.class);
            startActivity(intent);
            getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        }
    });
    mServiceTreeMap = (LinearLayout) v.findViewById(R.id.ic_nav_show_map);
    mServiceTreeMap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!NetworkUtils.isConnected(getActivity())) {
                ((BaseActivity) getActivity()).showNetworkConnectionAlertDialog();
                return;
            }
            Intent intent = new Intent(getActivity(), BroadcastWebViewActivity.class);

            ShortcutData data = new ShortcutData(Constants.SHORTCUT_TYPE_WEB_DOCUMENT_SERVER,
                    R.string.btn_show_map, getActivity().getResources().getString(R.string.addr_show_map),
                    R.drawable.ic_menu_04, R.drawable.ic_menu_shortcut_02_selector, 0, null);

            VBroadcastServer serverInfo = LauncherSettings.getInstance(getActivity()).getServerInformation();
            data.setDomain(serverInfo.getDocServer());

            intent.putExtra(Constants.EXTRA_NAME_SHORTCUT_DATA, data);
            startActivity(intent);
        }
    });
    mOutdoorMode = (LinearLayout) v.findViewById(R.id.ic_nav_outdoor);
    mOutdoorText = (TextView) v.findViewById(R.id.tv_outdoor);
    if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) {
        mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on));
        mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0);
    } else {
        mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off));
        mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0);
    }
    mOutdoorMode.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast toast;

            boolean mode = false;
            if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) {
                LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(false);
                mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0);
                mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off));

                toast = Toast.makeText(getActivity(), R.string.outdoor_mode_off, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                toast.show();
            } else {
                mode = true;
                LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(true);
                mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on));
                mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0);

                toast = Toast.makeText(getActivity(), R.string.outdoor_mode_on, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                toast.show();
            }

            HomeLauncherApplication application = (HomeLauncherApplication) getActivity()
                    .getApplicationContext();
            if (application != null) {
                application.outdoorModeChanged(mode);
            }
        }
    });
    // ?? ?
    mIoTDataSync = (LinearLayout) v.findViewById(R.id.ic_iot_data_sync);
    mIoTDataSyncText = (TextView) v.findViewById(R.id.tv_iot_data_sync);
    mIoTDataSync.setOnClickListener(mIoTSyncClickListener);
    mIoTDataSync.setClickable(true);
    mIoTDataSync.setEnabled(true);

    mTextClock = (TextClock) v.findViewById(R.id.text_clock);
    if (mTextClock != null) {
        mTextClock.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent intent = new Intent(Intent.ACTION_MAIN);
                    intent.addCategory(Intent.CATEGORY_APP_CALENDAR);
                    startActivity(intent);
                    getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                } catch (ActivityNotFoundException e) {
                    e.printStackTrace();
                    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
                    alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent i = new Intent(
                                    android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
                            i.addCategory(Intent.CATEGORY_DEFAULT);
                            startActivity(i);
                        }
                    });
                    alert.setMessage(R.string.alert_calendar_not_found);
                    alert.show();
                }
            }
        });
    }
    mWeatherView = (WeatherView) v.findViewById(R.id.weather_view);
    mMainViewLeftPanel = (LinearLayout) v.findViewById(R.id.main_view_left_panel);
    mMainViewRightPanel = (LinearLayout) v.findViewById(R.id.main_view_right_panel);

    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // add main shortcut.
    ArrayList<ShortcutData> mainShortcutDatas = LauncherSettings.getInstance(getActivity())
            .getLauncherMainShortcuts();
    mMainShortcutGridLayout = (GridLayout) v.findViewById(R.id.main_shortcut_grid);
    float dp;// = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_width);
    //        float widthPx = DisplayUtils.pxFromDp(getActivity(), dp);
    //
    //        dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_height);
    //        float heightPx = DisplayUtils.pxFromDp(getActivity(), dp);

    dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_font_size);
    float mainShortcutFontPx = DisplayUtils.pxFromDp(getActivity(), dp);
    for (int i = 0; i < mMainShortcutGridLayout.getColumnCount(); i++) {
        /**
         * right shortcut panel
         */
        ShortcutData data = mainShortcutDatas.get(i);
        FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_top_item,
                mMainShortcutGridLayout, false);//new Button(getActivity());
        mMainShortcutGridLayout.addView(btnLayout);
        if (data.getPushType() != null && data.getPushType().length > 0) {
            data.setLauncherButton(btnLayout);
            mPushNotifiableShorcuts.add(data);
        }

        btnLayout.setBackgroundResource(data.getIconBackResId());

        //            GridLayout.LayoutParams lp = (GridLayout.LayoutParams)btnLayout.getLayoutParams();
        //            lp.width = (int)widthPx;
        //            lp.height = (int)heightPx;
        //            btnLayout.setLayoutParams(lp);

        TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label);
        label.setText(data.getName());
        label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mainShortcutFontPx);
        label.setTextColor(getResources().getColor(R.color.white));
        label.setTypeface(null, Typeface.BOLD);
        label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

        ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image);
        icon.setImageResource(data.getIconResId());

        btnLayout.setTag(data);
        btnLayout.setOnClickListener(this);
    }

    // add other shortcuts.
    mShorcutGridLayout = (GridLayout) v.findViewById(R.id.shortcut_grid);
    ArrayList<ShortcutData> shortcutDatas = LauncherSettings.getInstance(getActivity()).getLauncherShortcuts();
    int columnNum = mShorcutGridLayout.getColumnCount();
    final int MAX_ROW_NUM = 3;

    int shortcutNum = shortcutDatas.size() > (columnNum * MAX_ROW_NUM) ? (columnNum * MAX_ROW_NUM)
            : shortcutDatas.size();
    dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_font_size);
    float btnFontPx = DisplayUtils.pxFromDp(getActivity(), dp);

    for (int i = 0; i < shortcutNum; i++) {
        /**
         * right shortcut panel
         */
        ShortcutData data = shortcutDatas.get(i);
        FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_item,
                mShorcutGridLayout, false);//new Button(getActivity());
        mShorcutGridLayout.addView(btnLayout);
        if (data.getPushType() != null && data.getPushType().length > 0) {
            data.setLauncherButton(btnLayout);
            mPushNotifiableShorcuts.add(data);
        }

        btnLayout.setBackgroundResource(data.getIconBackResId());

        TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label);
        label.setText(data.getName());
        label.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnFontPx);
        label.setTextColor(getResources().getColor(R.color.white));
        label.setTypeface(null, Typeface.BOLD);
        label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

        ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image);
        icon.setImageResource(data.getIconResId());

        btnLayout.setTag(data);
        btnLayout.setOnClickListener(this);
    }

    setContentViewByOrientation();

    return v;
}

From source file:com.android.systemui.statusbar.phone.NavigationBarView.java

public void setMenuVisibility(final boolean show, final boolean force) {

    if (!force && mShowMenu == show)
        return;//from  ww w . j  a va  2 s  . co m

    if ((currentSetting == SHOW_DONT) || mHasBigMenuButton) {
        return;
    }

    mShowMenu = show;
    boolean localShow = show;

    ImageView leftButton = (ImageView) getLeftMenuButton();
    ImageView rightButton = (ImageView) getRightMenuButton();

    switch (currentVisibility) {
    case VISIBILITY_ALWAYS:
        localShow = true;
    case VISIBILITY_SYSTEM:
        if (mTablet_UI == 1) {
            rightButton.setImageResource(R.drawable.ic_sysbar_menu_big);
            leftButton.setImageResource(R.drawable.ic_sysbar_menu_big);
        } else {
            rightButton
                    .setImageResource(mVertical ? R.drawable.ic_sysbar_menu_land : R.drawable.ic_sysbar_menu);
            leftButton.setImageResource(mVertical ? R.drawable.ic_sysbar_menu_land : R.drawable.ic_sysbar_menu);
        }
        break;
    case VISIBILITY_NEVER:
        leftButton.setImageResource(R.drawable.ic_sysbar_menu_inviz);
        rightButton.setImageResource(R.drawable.ic_sysbar_menu_inviz);
        localShow = true;
        break;
    case VISIBILITY_SYSTEM_AND_INVIZ:
        if (localShow) {
            if (mTablet_UI == 1) {
                rightButton.setImageResource(R.drawable.ic_sysbar_menu_big);
                leftButton.setImageResource(R.drawable.ic_sysbar_menu_big);
            } else {
                rightButton.setImageResource(
                        mVertical ? R.drawable.ic_sysbar_menu_land : R.drawable.ic_sysbar_menu);
                leftButton.setImageResource(
                        mVertical ? R.drawable.ic_sysbar_menu_land : R.drawable.ic_sysbar_menu);
            }
        } else {
            localShow = true;
            leftButton.setImageResource(R.drawable.ic_sysbar_menu_inviz);
            rightButton.setImageResource(R.drawable.ic_sysbar_menu_inviz);
        }
        break;
    }

    // do this after just in case show was changed
    // Tablet menu buttons should not take up space when hidden.
    switch (currentSetting) {
    case SHOW_BOTH_MENU:
        if (mTablet_UI == 1) {
            leftButton.setVisibility(localShow ? View.VISIBLE : View.GONE);
            rightButton.setVisibility(localShow ? View.VISIBLE : View.GONE);
        } else {
            leftButton.setVisibility(localShow ? View.VISIBLE : View.INVISIBLE);
            rightButton.setVisibility(localShow ? View.VISIBLE : View.INVISIBLE);
        }
        break;
    case SHOW_LEFT_MENU:
        if (mTablet_UI == 1) {
            leftButton.setVisibility(localShow ? View.VISIBLE : View.GONE);
        } else {
            leftButton.setVisibility(localShow ? View.VISIBLE : View.INVISIBLE);
        }
        rightButton.setVisibility((mTablet_UI == 1) ? View.GONE : View.INVISIBLE);
        break;
    default:
    case SHOW_RIGHT_MENU:
        leftButton.setVisibility((mTablet_UI == 1) ? View.GONE : View.INVISIBLE);
        if (mTablet_UI == 1) {
            rightButton.setVisibility(localShow ? View.VISIBLE : View.GONE);
        } else {
            rightButton.setVisibility(localShow ? View.VISIBLE : View.INVISIBLE);
        }
        break;
    }
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

private View makeNavDrawerItem(final int itemId, ViewGroup container) {
    int layout;/*w w w.java 2  s . c  o m*/
    if (itemId == SEPARATOR) {
        layout = R.layout.navdrawer_separator;
    } else if (itemId == HEADER) {
        layout = R.layout.navdrawer_header;
    } else {
        layout = R.layout.navdrawer_item;
    }

    View view = getLayoutInflater().inflate(layout, container, false);

    if (itemId == SEPARATOR || itemId == HEADER) {
        // TODO: Header click
        // TODO: Accessibility?
        return view;
    }

    ImageView iconView = (ImageView) view.findViewById(R.id.icon);
    TextView titleView = (TextView) view.findViewById(R.id.title);
    int iconId = itemId >= 0 && itemId < NAV_DRAWER_DRAWABLE_IDS.length ? NAV_DRAWER_DRAWABLE_IDS[itemId] : 0;
    int titleId = itemId >= 0 && itemId < NAV_DRAWER_STRING_IDS.length ? NAV_DRAWER_STRING_IDS[itemId] : 0;

    iconView.setVisibility(iconId == 0 ? View.GONE : View.VISIBLE);
    if (iconId > 0) {
        iconView.setImageResource(iconId);
    }
    titleView.setText(titleId);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onNavDrawerItemClick(itemId);
        }
    });

    return view;
}

From source file:com.nd.pad.GreenBrowser.util.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 .c om*/
 */
private void forceDownload(String url, ImageView imageView, int width, int height, String parentFullFileName,
        int loadingDrawable_ID, int failDrawable_ID, boolean isSaveLocal, ImageDownLoaderAction action) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageResource(failDrawable_ID);
        return;
    }
    if (cancelPotentialDownload(url, imageView)) {
        /*modeCORRECT*/
        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 = new BitmapDownloaderTask(imageView, failDrawable_ID, isSaveLocal,
                    action);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView, width, height, parentFullFileName, failDrawable_ID,
                    isSaveLocal, action);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task, loadingDrawable_ID);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            try {
                task.execute(url);
            } catch (RejectedExecutionException localRejectedExecutionException) {
            }
            break;
        }
    }
}

From source file:com.crearo.gpslogger.GpsMainActivity.java

private void setBulbStatus(boolean started) {
    ImageView bulb = (ImageView) findViewById(R.id.notification_bulb);
    bulb.setImageResource(started ? R.drawable.circle_green : R.drawable.circle_none);
}

From source file:com.nd.teacherplatform.util.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.ja v a 2  s. c  o  m
private void forceDownload(String url, ImageView imageView, int width, int height, String parentFullFileName,
        int loadingDrawable_ID, int failDrawable_ID, boolean isSaveLocal, ImageDownLoaderAction action) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageResource(failDrawable_ID);
        return;
    }
    if (cancelPotentialDownload(url, imageView)) {
        /* modeCORRECT */
        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 = new BitmapDownloaderTask(imageView, failDrawable_ID, isSaveLocal,
                    action);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView, width, height, parentFullFileName, failDrawable_ID,
                    isSaveLocal, action);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task, loadingDrawable_ID);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            try {
                task.execute(url);
            } catch (RejectedExecutionException localRejectedExecutionException) {
            }
            break;
        }
    }
}