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.davisosa.structura.activities.base.BaseActivity.java

private View createDrawerItem(final int itemId, ViewGroup container) {
    boolean selected = getSelfDrawerItem() == itemId;

    int layout;/* ww  w  .  j  av a 2 s  .c om*/
    if (itemId == DRAWER_ITEM_SEPARATOR) {
        layout = R.layout.drawer_separator;
    } else if (itemId == DRAWER_ITEM_SEPARATOR_SPECIAL) {
        layout = R.layout.drawer_separator;
    } else {
        layout = R.layout.drawer_item;
    }
    View view = getLayoutInflater().inflate(layout, container, false);

    if (isSeparator(itemId)) {
        // We're done.
        UIUtils.setAccessibilityIgnore(view);
        return view;
    }

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

    // Set icon and text.
    if (iconId > 0) {
        iconView.setVisibility(View.VISIBLE);
        iconView.setImageResource(iconId);
    } else {
        iconView.setVisibility(View.INVISIBLE);
    }
    titleView.setText(getString(titleId));

    formatDrawerItem(view, itemId, selected);

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

    return view;
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

public void setIcon(int resId) {
    View dialogView = getView();//  w ww  . ja  va2  s.co  m
    View contentView = (View) dialogView.getTag(R.id.content_fragment);
    ImageView iconView = (ImageView) contentView.findViewById(R.id.icon);
    if (iconView != null) {
        iconView.setImageResource(resId);
    }
}

From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java

/**
 * When the user press a button of a movement, it is added to the grid and to the list with all
 * the commands of the movements to send to the microcontrolller board.
 * @param drawableId the id of the drawable of the button clicked
 * @param movement the movement associated to that button
 *///from www  .  ja v a  2 s.  c  om
private void addButtonPressedToGrid(int drawableId, String movement) {
    ImageView view = (ImageView) ImageView.inflate(getActivity().getBaseContext(),
            R.layout.grid_view_item_layout, null);
    view.setImageResource(drawableId);
    gridView.addView(view);
    scheduledControls.add(movement);

}

From source file:com.arantius.tivocommander.Explore.java

protected void finishRequest() {
    if (--mRequestCount != 0) {
        return;//from  ww  w  . jav  a2s .  co m
    }

    getParent().setProgressBarIndeterminateVisibility(false);

    if (mRecordingId == null) {
        for (JsonNode recording : mContent.path("recordingForContentId")) {
            String state = recording.path("state").asText();
            if ("inProgress".equals(state) || "complete".equals(state) || "scheduled".equals(state)) {
                mRecordingId = recording.path("recordingId").asText();
                mRecordingState = state;
                break;
            }
        }
    }

    // Fill mChoices based on the data we now have.
    if ("scheduled".equals(mRecordingState)) {
        mChoices.add(RecordActions.DONT_RECORD.toString());
    } else if ("inProgress".equals(mRecordingState)) {
        mChoices.add(RecordActions.RECORD_STOP.toString());
    } else if (mOfferId != null) {
        mChoices.add(RecordActions.RECORD.toString());
    }
    if (mSubscriptionId != null) {
        mChoices.add(RecordActions.SP_MODIFY.toString());
        mChoices.add(RecordActions.SP_CANCEL.toString());
    } else if (mCollectionId != null && !"movie".equals(mContent.path("collectionType").asText())
            && !mContent.has("movieYear")) {
        mChoices.add(RecordActions.SP_ADD.toString());
    }

    setContentView(R.layout.explore);

    // Show only appropriate buttons.
    findViewById(R.id.explore_btn_watch).setVisibility(
            "complete".equals(mRecordingState) || "inprogress".equals(mRecordingState) ? View.VISIBLE
                    : View.GONE);
    hideViewIfNull(R.id.explore_btn_upcoming, mCollectionId);
    if (mChoices.size() == 0) {
        findViewById(R.id.explore_btn_record).setVisibility(View.GONE);
    }
    // Delete / undelete buttons visible only if appropriate.
    findViewById(R.id.explore_btn_delete)
            .setVisibility("complete".equals(mRecordingState) ? View.VISIBLE : View.GONE);
    findViewById(R.id.explore_btn_undelete)
            .setVisibility("deleted".equals(mRecordingState) ? View.VISIBLE : View.GONE);

    // Display titles.
    String title = mContent.path("title").asText();
    String subtitle = mContent.path("subtitle").asText();
    ((TextView) findViewById(R.id.content_title)).setText(title);
    TextView subtitleView = ((TextView) findViewById(R.id.content_subtitle));
    if ("".equals(subtitle)) {
        subtitleView.setVisibility(View.GONE);
    } else {
        subtitleView.setText(subtitle);
    }

    // Display (only the proper) badges.
    if (mRecording != null && mRecording.path("episodic").asBoolean()
            && !mRecording.path("repeat").asBoolean()) {
        findViewById(R.id.badge_new).setVisibility(View.VISIBLE);
    }
    if (mRecording != null && mRecording.path("hdtv").asBoolean()) {
        findViewById(R.id.badge_hd).setVisibility(View.VISIBLE);
    }
    ImageView iconSubType = (ImageView) findViewById(R.id.icon_sub_type);
    TextView textSubType = (TextView) findViewById(R.id.text_sub_type);
    // TODO: Downloading state?
    if ("complete".equals(mRecordingState)) {
        iconSubType.setVisibility(View.GONE);
        textSubType.setVisibility(View.GONE);
    } else if ("inProgress".equals(mRecordingState)) {
        iconSubType.setImageResource(R.drawable.recording_recording);
        textSubType.setText(R.string.sub_recording);
    } else if (mSubscriptionType != null) {
        switch (mSubscriptionType) {
        case SEASON_PASS:
            iconSubType.setImageResource(R.drawable.todo_seasonpass);
            textSubType.setText(R.string.sub_season_pass);
            break;
        case SINGLE_OFFER:
            iconSubType.setImageResource(R.drawable.todo_single_offer);
            textSubType.setText(R.string.sub_single_offer);
            break;
        case WISHLIST:
            iconSubType.setImageResource(R.drawable.todo_wishlist);
            textSubType.setText(R.string.sub_wishlist);
            break;
        default:
            iconSubType.setVisibility(View.GONE);
            textSubType.setVisibility(View.GONE);
        }
    } else {
        iconSubType.setVisibility(View.GONE);
        textSubType.setVisibility(View.GONE);
    }

    // Display channel and time.
    if (mRecording != null) {
        String channelStr = "";
        JsonNode channel = mRecording.path("channel");
        if (!channel.isMissingNode()) {
            channelStr = String.format("%s %s, ", channel.path("channelNumber").asText(),
                    channel.path("callSign").asText());
        }

        // Lots of shows seem to be a few seconds short, add padding so that
        // rounding down works as expected. Magic number.
        final int minutes = (30 + mRecording.path("duration").asInt()) / 60;

        String durationStr = minutes >= 60 ? String.format(Locale.US, "%d hr", minutes / 60)
                : String.format(Locale.US, "%d min", minutes);
        if (isRecordingPartial()) {
            durationStr += " (partial)";
        }
        ((TextView) findViewById(R.id.content_chan_len)).setText(channelStr + durationStr);

        String airTime = new SimpleDateFormat("EEE MMM d, hh:mm a", Locale.US)
                .format(Utils.parseDateTimeStr(mRecording.path("actualStartTime").asText()));
        ((TextView) findViewById(R.id.content_air_time)).setText("Air time: " + airTime);
    } else {
        ((TextView) findViewById(R.id.content_chan_len)).setVisibility(View.GONE);
        ((TextView) findViewById(R.id.content_air_time)).setVisibility(View.GONE);
    }

    // Construct and display details.
    ArrayList<String> detailParts = new ArrayList<String>();
    int season = mContent.path("seasonNumber").asInt();
    int epNum = mContent.path("episodeNum").path(0).asInt();
    if (season != 0 && epNum != 0) {
        detailParts.add(String.format("Sea %d Ep %d", season, epNum));
    }
    if (mContent.has("mpaaRating")) {
        detailParts.add(mContent.path("mpaaRating").asText().toUpperCase(Locale.US));
    } else if (mContent.has("tvRating")) {
        detailParts.add("TV-" + mContent.path("tvRating").asText().toUpperCase(Locale.US));
    }
    detailParts.add(mContent.path("category").path(0).path("label").asText());
    int year = mContent.path("originalAirYear").asInt();
    if (year != 0) {
        detailParts.add(Integer.toString(year));
    }

    // Filter empty strings.
    for (int i = detailParts.size() - 1; i >= 0; i--) {
        if ("".equals(detailParts.get(i)) || null == detailParts.get(i)) {
            detailParts.remove(i);
        }
    }
    // Then format the parts into one string.
    String detail1 = "(" + Utils.join(", ", detailParts) + ") ";
    if ("() ".equals(detail1)) {
        detail1 = "";
    }

    String detail2 = mContent.path("description").asText();
    TextView detailView = ((TextView) findViewById(R.id.content_details));
    if (detail2 == null) {
        detailView.setText(detail1);
    } else {
        Spannable details = new SpannableString(detail1 + detail2);
        details.setSpan(new ForegroundColorSpan(Color.WHITE), detail1.length(), details.length(), 0);
        detailView.setText(details);
    }

    // Add credits.
    ArrayList<String> credits = new ArrayList<String>();
    for (JsonNode credit : mContent.path("credit")) {
        String role = credit.path("role").asText();
        if ("actor".equals(role) || "host".equals(role) || "guestStar".equals(role)) {
            credits.add(credit.path("first").asText() + " " + credit.path("last").asText());
        }
    }
    TextView creditsView = (TextView) findViewById(R.id.content_credits);
    creditsView.setText(Utils.join(", ", credits));

    // Find and set the banner image if possible.
    ImageView imageView = (ImageView) findViewById(R.id.content_image);
    View progressView = findViewById(R.id.content_image_progress);
    String imageUrl = Utils.findImageUrl(mContent);
    new DownloadImageTask(this, imageView, progressView).execute(imageUrl);
}

From source file:com.ayuget.redface.ui.activity.ReplyActivity.java

protected View setupUserView(LayoutInflater inflater, User user) {
    View userView = inflater.inflate(R.layout.dialog_reply_spinner_item, actionsToolbar, false);
    ImageView avatarView = (ImageView) userView.findViewById(R.id.user_avatar);
    TextView usernameView = (TextView) userView.findViewById(R.id.user_username);

    avatarView.setImageResource(R.drawable.profile_background_red);
    usernameView.setText(user.getUsername());

    if (!user.isGuest()) {
        loadUserAvatarInto(user, avatarView);
    }/*from   w w w .  j a  va  2s.c  om*/

    return userView;
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java

@Override
public void create() {
    try {/*from  ww  w  .jav a 2 s .  c  o  m*/
        setContentView(R.layout.grouped_contacts_details);

        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");
        if (widget == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }

        person = (Person) store.getSerializable("person");
        if (person == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }
        setTopBarTitle(widget.getTitle());

        Boolean single = currentIntent.getBooleanExtra("single", true);

        setTopBarLeftButtonTextAndColor(
                single ? getResources().getString(R.string.common_home_upper)
                        : getResources().getString(R.string.common_back_upper),
                getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });
        setTopBarTitleColor(getResources().getColor(android.R.color.black));
        setTopBarBackgroundColor(Statics.color1);

        if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) {

            ImageView shareButton = (ImageView) getLayoutInflater()
                    .inflate(R.layout.grouped_contacts_share_button, null);
            shareButton.setLayoutParams(
                    new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density),
                            (int) (39 * getResources().getDisplayMetrics().density)));
            shareButton.setColorFilter(Color.BLACK);
            setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share),
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder();

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                                sharingDialogBuilder
                                        .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();
                                                Intent email = new Intent(Intent.ACTION_SEND);
                                                email.putExtra(Intent.EXTRA_TEXT, message);
                                                email.setType("message/rfc822");
                                                startActivity(Intent.createChooser(email,
                                                        getString(R.string.choose_email_client)));
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                                sharingDialogBuilder
                                        .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();

                                                try {
                                                    Utils.sendSms(ContactDetailsActivity.this, message);
                                                } catch (ActivityNotFoundException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT)))
                                sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook,
                                        R.drawable.gc_add_to_contacts, true,
                                        new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                createNewContact(person.getName(), person.getPhone(),
                                                        person.getEmail());
                                            }
                                        });

                            showDialogSharing(sharingDialogBuilder.build());
                        }
                    });

        }

        boolean hasSchema = store.getBoolean("hasschema");
        cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

        contacts = person.getContacts();

        if (widget.getTitle().length() > 0) {
            setTitle(widget.getTitle());
        }

        root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root);

        if (hasSchema) {
            root.setBackgroundColor(Statics.color1);
        } else if (widget.isBackgroundURL()) {
            cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL());
            File backgroundFile = new File(cacheBackgroundFile);
            if (backgroundFile.exists()) {
                root.setBackgroundDrawable(
                        new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile))));
            } else {
                BackgroundDownloadTask dt = new BackgroundDownloadTask();
                dt.execute(widget.getBackgroundURL());
            }
        } else if (widget.isBackgroundInAssets()) {
            AssetManager am = this.getAssets();
            root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL())));
        }

        if (contacts != null) {
            ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar);

            avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            if (person.hasAvatar() && NetworkUtils.isOnline(this)) {
                avatarImage.setVisibility(View.VISIBLE);
                Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar)
                        .dontAnimate().into(avatarImage);
            } else {
                avatarImage.setVisibility(View.VISIBLE);
                avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            }

            String name = "";
            neededContacts = new ArrayList<>();
            for (Contact con : contacts) {
                if ((con.getType() == 5) || (con.getDescription().length() == 0)) {
                } else {
                    if (con.getType() == 0) {
                        name = con.getDescription();
                    } else
                        neededContacts.add(con);
                }
            }

            if (neededContacts.isEmpty()) {
                handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA);
                return;
            }

            headSeparator = findViewById(R.id.gc_head_separator);
            bottomSeparator = findViewById(R.id.gc_bottom_separator);
            imageBottom = findViewById(R.id.gc_image_bottom_layout);
            personName = (TextView) findViewById(R.id.gc_details_description);

            if ("".equals(name))
                personName.setVisibility(View.GONE);
            else {
                personName.setVisibility(View.VISIBLE);
                personName.setText(name);
                personName.setTextColor(Statics.color3);
            }
            if (Statics.isLight) {
                headSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
            } else {
                headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
            }

            ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1);

            ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view);
            list.setDivider(null);

            ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this,
                    R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1));
            list.setAdapter(adapter);
            list.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
                    listViewItemClick(position);
                }
            });
        }

        if (widget.hasParameter("add_contact")) {
            HashMap<String, String> hm = new HashMap<>();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    hm.put("contactName", contacts.get(i).getDescription());
                }
                    break;
                case 1: {
                    hm.put("contactNumber", contacts.get(i).getDescription());
                }
                    break;
                case 2: {
                    hm.put("contactEmail", contacts.get(i).getDescription());
                }
                    break;
                case 3: {
                    hm.put("contactSite", contacts.get(i).getDescription());
                }
                    break;
                }
            }
            addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm);
        }
        if (widget.hasParameter("send_sms")) {
            HashMap<String, String> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                sb.append(contacts.get(i).getDescription());
                if (i < contacts.size() - 1) {
                    sb.append(", ");
                }
            }
            hm.put("text", sb.toString());
            addNativeFeature(NATIVE_FEATURES.SMS, null, hm);
        }
        if (widget.hasParameter("send_mail")) {
            HashMap<String, CharSequence> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    sb.append("Name: ");
                }
                    break;
                case 1: {
                    sb.append("Phone: ");
                }
                    break;
                case 2: {
                    sb.append("Email: ");
                }
                    break;
                case 3: {
                    sb.append("Site: ");
                }
                    break;
                case 4: {
                    sb.append("Address: ");
                }
                    break;
                }
                sb.append(contacts.get(i).getDescription());
                sb.append("<br/>");
            }

            if (widget.isHaveAdvertisement()) {
                sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)");
            }

            hm.put("text", sb.toString());
            hm.put("subject", "Contacts");
            addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm);
        }

    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.tdispatch.passenger.fragment.SearchAddressFragment.java

@Override
protected void onPostCreateView() {

    ImageView iv = (ImageView) mFragmentView.findViewById(R.id.icon);
    EditText et = (EditText) mFragmentView.findViewById(R.id.address);

    int imgId = R.drawable.ic_launcher;
    int hintId = R.string.address_search_generic_hint;
    switch (mType) {
    case SearchActivity.TYPE_PICKUP:
        imgId = R.drawable.map_marker_pickup;
        hintId = R.string.address_search_pickup_hint;
        break;//w ww  . ja v a  2  s  .c om
    case SearchActivity.TYPE_DROPOFF:
        imgId = R.drawable.map_marker_dropoff;
        hintId = R.string.address_search_dropoff_hint;
        break;
    }
    iv.setImageResource(imgId);

    et.setText((mAddress != null) ? mAddress.getAddress() : "");
    et.setHint(hintId);

    et.setOnEditorActionListener(mOnEditorActionListener);
    et.addTextChangedListener(mTextWatcher);

    WebnetTools.setVisibility(mFragmentView, R.id.button_voice_search,
            mVoiceSearchAvailable ? View.VISIBLE : View.GONE);

    int[] ids = { R.id.button_voice_search, R.id.button_clear };
    for (int id : ids) {
        View v = mFragmentView.findViewById(id);
        if (v != null) {
            v.setOnClickListener(mOnClickListener);
        }
    }

    WebnetTools.setVisibility(mFragmentView, R.id.button_clear, View.GONE);

    ListView lv = (ListView) mFragmentView.findViewById(R.id.list);
    mAdapter = new ListAdapter(mParentActivity, 0, mItems);
    lv.setAdapter(mAdapter);
}

From source file:org.ros.android.app_chooser.ExchangeActivity.java

public void updateAppDetails() {
    final AppManager man = appManager;
    if (man == null) {
        return;/*from w  w w  .j  a v a  2s  .c  o m*/
    }
    man.getAppDetails(appSelected, new ServiceResponseListener<GetAppDetails.Response>() {
        @Override
        public void onSuccess(GetAppDetails.Response message) {
            final ExchangeApp app = message.app;
            if (app == null) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        revertToState();
                        appDetailView.setVisibility(appDetailView.GONE);
                        new AlertDialog.Builder(ExchangeActivity.this).setTitle("Error on Details Update!")
                                .setCancelable(false)
                                .setMessage("Failed: cannot contact robot! Null application returned")
                                .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                }).create().show();
                    }
                });
                return;
            }
            Bitmap bitmap = null;
            if (app.icon.data.length > 0 && app.icon.format != null
                    && (app.icon.format.equals("jpeg") || app.icon.format.equals("png"))) {
                bitmap = BitmapFactory.decodeByteArray(app.icon.data, 0, app.icon.data.length);
            }
            final Bitmap iconBitmap = bitmap;
            Log.i("RosAndroid", "GetInstallationState.Response: " + availableAppsCache.size() + " apps");
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ImageView iv = (ImageView) ExchangeActivity.this.findViewById(R.id.exchange_icon);
                    if (iconBitmap != null) {
                        iv.setImageBitmap(iconBitmap);
                    } else {
                        iv.setImageResource(R.drawable.icon);
                    }
                    exchangeAppDetailTextView.setText(app.description.toString());
                    update(availableAppsCache, installedAppsCache);
                }
            });
        }

        @Override
        public void onFailure(final RemoteException e) {
            e.printStackTrace();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    revertToState();
                    appDetailView.setVisibility(appDetailView.GONE);
                    new AlertDialog.Builder(ExchangeActivity.this).setTitle("Error on Details Update!")
                            .setCancelable(false).setMessage("Failed: cannot contact robot: " + e.toString())
                            .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).create().show();
                }
            });
        }
    });
}

From source file:com.njlabs.amrita.aid.aums.AumsActivity.java

private void loadPhoto() {
    aums.getPhotoFile(new FileResponse() {
        @Override/*from  w w  w. j a v  a 2s. c  o  m*/
        public void onSuccess(File file) {
            findViewById(R.id.student_profile_pic_progress).setVisibility(View.GONE);
            ImageView myImage = (ImageView) findViewById(R.id.student_profile_pic);
            myImage.setVisibility(View.VISIBLE);
            Picasso.with(baseContext).load(file).error(R.drawable.user).into(myImage);
        }

        @Override
        public void onFailure(Throwable throwable) {
            Ln.e(throwable);
            findViewById(R.id.student_profile_pic_progress).setVisibility(View.GONE);
            ImageView myImage = (ImageView) findViewById(R.id.student_profile_pic);
            myImage.setVisibility(View.VISIBLE);
            myImage.setImageResource(R.drawable.user);
        }
    });
}

From source file:com.pandoroid.PandoroidPlayer.java

/**
 * Description: Refreshes the view with the specified song. If song is null
 *    it will reset to the default configuration.
 * @param song -The song to set the view to show.
 *//*from w  w w . j  a va2 s.c o m*/
private void songRefresh(Song song) {
    TextView top = (TextView) findViewById(R.id.player_topText);
    ImageView image = (ImageView) findViewById(R.id.player_image);

    if (song != null) {
        getSupportActionBar().setTitle(String.format("" + song.getTitle()));
        m_service.image_downloader.download(song.getAlbumCoverUrl(), image);
        top.setText(String.format("%s\n%s", song.getArtist(), song.getAlbum()));
    } else {
        image.setImageResource(R.drawable.transparent);
        top.setText(R.string.loading);
        getSupportActionBar().setTitle(R.string.app_name);
    }

}