use of android.graphics.drawable.BitmapDrawable in project FBReaderJ by geometer.
the class BackgroundPreference method onBindView.
@Override
protected void onBindView(View view) {
super.onBindView(view);
final TextView titleView = (TextView) view.findViewById(R.id.background_preference_title);
titleView.setText(myResource.getValue());
final TextView summaryView = (TextView) view.findViewById(R.id.background_preference_summary);
final View previewWidget = view.findViewById(R.id.background_preference_widget);
final String value = myProfile.WallpaperOption.getValue();
if (value.length() == 0) {
summaryView.setText(myResource.getResource("solidColor").getValue());
previewWidget.setBackgroundColor(ZLAndroidColorUtil.rgb(myProfile.BackgroundOption.getValue()));
} else {
if (value.startsWith("/")) {
summaryView.setText(value.substring(value.lastIndexOf("/") + 1));
} else {
final String key = value.substring(value.lastIndexOf("/") + 1, value.lastIndexOf("."));
summaryView.setText(myResource.getResource(key).getValue());
}
try {
previewWidget.setBackgroundDrawable(new BitmapDrawable(getContext().getResources(), ZLFile.createFileByPath(value).getInputStream()));
} catch (Throwable t) {
// ignore
}
}
}
use of android.graphics.drawable.BitmapDrawable in project FBReaderJ by geometer.
the class PredefinedImages method onStart.
@Override
protected void onStart() {
super.onStart();
setTitle(myResource.getValue());
final ArrayAdapter<ZLFile> adapter = new ArrayAdapter<ZLFile>(this, R.layout.background_predefined_item, R.id.background_predefined_item_title) {
public View getView(int position, View convertView, final ViewGroup parent) {
final View view = super.getView(position, convertView, parent);
final TextView titleView = (TextView) view.findViewById(R.id.background_predefined_item_title);
final String name = getItem(position).getShortName();
final String key = name.substring(0, name.indexOf("."));
titleView.setText(myResource.getResource(key).getValue());
final View previewWidget = view.findViewById(R.id.background_predefined_item_preview);
try {
previewWidget.setBackgroundDrawable(new BitmapDrawable(getResources(), getItem(position).getInputStream()));
} catch (Throwable t) {
}
return view;
}
};
for (ZLFile file : WallpapersUtil.predefinedWallpaperFiles()) {
adapter.add(file);
}
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
use of android.graphics.drawable.BitmapDrawable in project coursera-android by aporter.
the class ContactInfoListAdapter method bindView.
// Update and return a contact data view
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView textView = (TextView) view.findViewById(R.id.name);
textView.setText(cursor.getString(cursor.getColumnIndex(Contacts.DISPLAY_NAME)));
// Default photo
BitmapDrawable photoBitmap = mNoPictureBitmap;
// Get actual thumbnail photo if it exists
String photoContentUri = cursor.getString(cursor.getColumnIndex(Contacts.PHOTO_THUMBNAIL_URI));
if (null != photoContentUri) {
InputStream input = null;
try {
// Read thumbnail data from input stream
input = context.getContentResolver().openInputStream(Uri.parse(photoContentUri));
if (input != null) {
photoBitmap = new BitmapDrawable(mApplicationContext.getResources(), input);
photoBitmap.setBounds(0, 0, mBitmapSize, mBitmapSize);
}
} catch (FileNotFoundException e) {
Log.i(TAG, "FileNotFoundException");
}
}
// Set thumbnail image
textView.setCompoundDrawables(photoBitmap, null, null, null);
}
use of android.graphics.drawable.BitmapDrawable in project facebook-android-sdk by facebook.
the class RpsFragment method getThrowAction.
private ShareOpenGraphAction getThrowAction() {
// The OG objects have their own bitmaps we could rely on, but in order to demonstrate
// attaching an in-memory bitmap (e.g., a game screencap) we'll send the bitmap explicitly
// ourselves.
ImageButton view = gestureImages[playerChoice];
BitmapDrawable drawable = (BitmapDrawable) view.getBackground();
final Bitmap bitmap = drawable.getBitmap();
return new ShareOpenGraphAction.Builder().setActionType(OpenGraphConsts.THROW_ACTION_TYPE).putString("fb_sample_rps:gesture", getBuiltInGesture(playerChoice)).putString("fb_sample_rps:opposing_gesture", getBuiltInGesture(computerChoice)).putPhotoArrayList("og:image", new ArrayList<SharePhoto>() {
{
add(new SharePhoto.Builder().setBitmap(bitmap).build());
}
}).build();
}
use of android.graphics.drawable.BitmapDrawable in project facebook-android-sdk by facebook.
the class UserSettingsFragment method processImageResponse.
private void processImageResponse(String id, ImageResponse response) {
if (response != null) {
Bitmap bitmap = response.getBitmap();
if (bitmap != null) {
BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap);
drawable.setBounds(0, 0, getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_height));
userProfilePic = drawable;
userProfilePicID = id;
connectedStateLabel.setCompoundDrawables(null, drawable, null, null);
connectedStateLabel.setTag(response.getRequest().getImageUri());
}
}
}
Aggregations