Search in sources :

Example 46 with BitmapDrawable

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
        }
    }
}
Also used : TextView(android.widget.TextView) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TextView(android.widget.TextView) View(android.view.View)

Example 47 with BitmapDrawable

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);
}
Also used : ViewGroup(android.view.ViewGroup) ZLFile(org.geometerplus.zlibrary.core.filesystem.ZLFile) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View)

Example 48 with BitmapDrawable

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);
}
Also used : InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) TextView(android.widget.TextView) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 49 with BitmapDrawable

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();
}
Also used : Bitmap(android.graphics.Bitmap) SharePhoto(com.facebook.share.model.SharePhoto) ShareOpenGraphAction(com.facebook.share.model.ShareOpenGraphAction) ArrayList(java.util.ArrayList) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 50 with BitmapDrawable

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());
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)640 Bitmap (android.graphics.Bitmap)426 Drawable (android.graphics.drawable.Drawable)187 Canvas (android.graphics.Canvas)182 Paint (android.graphics.Paint)110 Rect (android.graphics.Rect)77 View (android.view.View)77 ImageView (android.widget.ImageView)63 ColorDrawable (android.graphics.drawable.ColorDrawable)59 TextView (android.widget.TextView)51 IOException (java.io.IOException)40 Resources (android.content.res.Resources)35 LayerDrawable (android.graphics.drawable.LayerDrawable)33 AnimationDrawable (android.graphics.drawable.AnimationDrawable)30 File (java.io.File)27 Test (org.junit.Test)24 Matrix (android.graphics.Matrix)23 Intent (android.content.Intent)22 StateListDrawable (android.graphics.drawable.StateListDrawable)22 InputStream (java.io.InputStream)22