Example usage for android.widget ImageView setImageDrawable

List of usage examples for android.widget ImageView setImageDrawable

Introduction

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

Prototype

public void setImageDrawable(@Nullable Drawable drawable) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

From source file:com.cms.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 va  2s .co  m*/
private void forceDownload(String url, ImageView imageView) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

    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 = new BitmapDownloaderTask(imageView);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            task.execute(url);
            break;
        }
    }
}

From source file:com.synconset.ImageFetcher.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.
 *///w  w w . ja  v a 2 s  . co m
private void forceDownload(Integer position, ImageView imageView, int rotate) {
    if (position == null) {
        imageView.setImageDrawable(null);
        return;
    }

    if (cancelPotentialDownload(position, imageView)) {
        BitmapFetcherTask task = new BitmapFetcherTask(imageView.getContext(), imageView, rotate);
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(imageView.getContext(), task, origId);
        imageView.setImageDrawable(downloadedDrawable);
        imageView.setMinimumHeight(colWidth);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            task.executeOnExecutor(executor, position);
        } else {
            try {
                task.execute(position);
            } catch (RejectedExecutionException e) {
                // Oh :(
            }
        }

    }
}

From source file:com.afwsamples.testdpc.EnableProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mCheckinState = new CheckInState(this);
    if (savedInstanceState == null) {
        if (getIntent().getBooleanExtra(EXTRA_ENABLE_PROFILE_NOW, false)) {
            mCheckinState.setFirstAccountState(CheckInState.FIRST_ACCOUNT_STATE_READY);
            ProvisioningUtil.enableProfile(this);
        } else {/*from   w ww. j a  v  a 2 s .c  o  m*/
            // Set up an alarm to enable profile in case we do not receive first account ready
            // broadcast for whatever reason.
            FirstAccountReadyBroadcastReceiver.scheduleFirstAccountReadyTimeoutAlarm(this,
                    WAIT_FOR_FIRST_ACCOUNT_READY_TIMEOUT);
        }
    }
    setContentView(R.layout.enable_profile_activity);
    mSetupWizardLayout = (SetupWizardLayout) findViewById(R.id.setup_wizard_layout);
    NavigationBar navigationBar = mSetupWizardLayout.getNavigationBar();
    navigationBar.getBackButton().setEnabled(false);
    navigationBar.setNavigationBarListener(this);
    mFinishButton = navigationBar.getNextButton();
    mFinishButton.setText(R.string.finish_button);

    mCheckInStateReceiver = new CheckInStateReceiver();

    // This is just a user friendly shortcut to the policy management screen of this app.
    ImageView appIcon = (ImageView) findViewById(R.id.app_icon);
    TextView appLabel = (TextView) findViewById(R.id.app_label);
    try {
        PackageManager packageManager = getPackageManager();
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(),
                0 /* Default flags */);
        appIcon.setImageDrawable(packageManager.getApplicationIcon(applicationInfo));
        appLabel.setText(packageManager.getApplicationLabel(applicationInfo));
    } catch (PackageManager.NameNotFoundException e) {
        Log.w("TestDPC", "Couldn't look up our own package?!?!", e);
    }

    // Show the user which account now has management, if specified.
    String addedAccount = getIntent().getStringExtra(LaunchIntentUtil.EXTRA_ACCOUNT_NAME);
    if (addedAccount != null) {
        View accountMigrationStatusLayout;
        if (isAccountMigrated(addedAccount)) {
            accountMigrationStatusLayout = findViewById(R.id.account_migration_success);
        } else {
            accountMigrationStatusLayout = findViewById(R.id.account_migration_fail);
        }
        accountMigrationStatusLayout.setVisibility(View.VISIBLE);
        TextView managedAccountName = (TextView) accountMigrationStatusLayout
                .findViewById(R.id.managed_account_name);
        managedAccountName.setText(addedAccount);
    }
}

From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditExpenseActivity.java

/**
 * Called when dialog appears to show current expense photo.
 * /*from  w  ww .j  av  a 2 s  . co  m*/
 * Loads photo to be displayed.
 * ImageView is the location for the image to be displayed, height and width
 * are of the size the the image will be displayed in.
 * 
 * @param ImageView
 * @param int width
 * @param int height
 */
private void loadPhoto(ImageView imageView, int width, int height) {

    ImageView tempImageView = imageView;

    AlertDialog.Builder imageDialog = new AlertDialog.Builder(this);
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.image_adapter, (ViewGroup) findViewById(R.id.layout_root));
    ImageView image = (ImageView) layout.findViewById(R.id.fullimage);
    image.setImageDrawable(tempImageView.getDrawable());
    imageDialog.setView(layout);
    String showDate = null;
    if (expense.getDate() != null) {
        showDate = sdf.format(expense.getDate());
    } else {
        showDate = "";
    }
    imageDialog.setPositiveButton(
            expense.getName() + " " + showDate + " " + expense.getScale() + " " + "Size: " + size + " Byte",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

    imageDialog.create();
    imageDialog.show();
}

From source file:net.sinoace.library.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  ww .ja  va2  s.  c  o  m*/
private void forceDownload(String url, ImageView imageView) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

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

    }
}

From source file: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.
 *///w  w w .  j  a  v a 2s.  c o m
private void forceDownload(String url, ImageView imageView) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

    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 = new BitmapDownloaderTask(imageView);
        //                    task.execute(url);
        //                    break;
        //
        //                case CORRECT:
        //                    task = new BitmapDownloaderTask(imageView);
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
        imageView.setImageDrawable(downloadedDrawable);
        imageView.setMinimumHeight(156);
        task.execute(url);
        //                    break;
        //            }
    }
}

From source file:org.immopoly.android.helper.ImageListDownloader.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 ww  . j  ava  2  s  .c  o m*/
private void forceDownload(String url, ImageView imageView, String cookie) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(new BitmapDrawable(fallbackBitmap));
        // stop animation
        imageView.setAnimation(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        BitmapDownloaderTask task = new BitmapDownloaderTask(imageView);
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
        // stop animation
        imageView.setAnimation(loadingAnimation);
        imageView.setImageDrawable(downloadedDrawable);
        task.execute(url, cookie);
    }
}

From source file:com.bxduan.apps.secretgallery.ImageDownloader.java

private void forceDownload(String url, ImageView imageView) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;//from  ww w  . j av a  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 = new BitmapDownloaderTask(imageView);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            task.execute(url);
            break;
        }
    }
}

From source file:com.androidtest.HttpParser2.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  ww  .ja  v  a 2s.c  o m*/
private void forceDownload(String url, ImageView imageView) {
    // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        //Log.d(TAG,"Mode : "+mode);
        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);
            task.execute(url);
            break;

        case CORRECT:
            task = new BitmapDownloaderTask(imageView);
            DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
            imageView.setImageDrawable(downloadedDrawable);
            imageView.setMinimumHeight(156);
            task.execute(url);
            break;
        }
    }
}

From source file:FacebookImageLoader.java

private void forceLoad(String filename, ImageView imageView) {
    // State sanity: filename is guaranteed to never be null in LoadedDrawable and cache keys.
    if (filename == null) {
        imageView.setImageDrawable(null);
        return;/* w ww . jav  a 2 s . c  o m*/
    }

    BitmapLoaderTask task = new BitmapLoaderTask(imageView);
    //This is where we tie a reference to the image filename to ImageView.
    LoadedDrawable downloadedDrawable = new LoadedDrawable(filename);
    imageView.setImageDrawable(downloadedDrawable);
    task.execute(filename);
}