Android MtpObjectInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MtpObjectInfo class.

This code example shows how to use the following methods:getFormat, getObjectHandle
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        MtpObjectInfo info = mObjectList.get(position);
        Intent intent;
        if (info.getFormat() == MtpConstants.FORMAT_ASSOCIATION) {
            intent = new Intent(this, ObjectBrowser.class);
        } else { 
            intent = new Intent(this, ObjectViewer.class);
        } 
        intent.putExtra("device", mDeviceName);
        intent.putExtra("storage", mStorageID);
        intent.putExtra("object", info.getObjectHandle());
        startActivity(intent);
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getFormat, getObjectHandle
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        MtpObjectInfo info = mObjectList.get(position);
        Intent intent;
        if (info.getFormat() == MtpConstants.FORMAT_ASSOCIATION) {
            intent = new Intent(this, ObjectBrowser.class);
        } else { 
            intent = new Intent(this, ObjectViewer.class);
        } 
        intent.putExtra("device", mDeviceName);
        intent.putExtra("storage", mStorageID);
        intent.putExtra("object", info.getObjectHandle());
        startActivity(intent);
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getCompressedSize, getName, getObjectHandle
    public MtpClient getMtpClient() { 
        return mClient;
    } 
 
    public boolean copyFile(String deviceName, MtpObjectInfo objInfo) {
        if (GalleryUtils.hasSpaceForSize(objInfo.getCompressedSize())) {
            File dest = Environment.getExternalStorageDirectory();
            dest = new File(dest, NAME_IMPORTED_FOLDER);
            dest.mkdirs();
            String destPath = new File(dest, objInfo.getName()).getAbsolutePath();
            int objectId = objInfo.getObjectHandle();
            if (mClient.importFile(deviceName, objectId, destPath)) {
                mScannerClient.scanPath(destPath);
                return true; 
            } 
        } else { 
            Log.w(TAG, "No space to import " + objInfo.getName() +
                    " whose size = " + objInfo.getCompressedSize());
        } 
        return false; 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getCompressedSize, getFormat
		int object = _objectHandles[position];
		MtpObjectInfo info = _mtpDevice.getObjectInfo(object);
		 
		/* This format code is what my Sony alpha 200 reports.  
		 * todo: obviously make this a bit more robust! */ 
        if (info.getFormat() != 45313) {
        	byte[] image = _mtpDevice.getObject(object, info.getCompressedSize());
        	Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length);
        	bmp = bmp.createScaledBitmap(bmp, bmp.getWidth() / 5, bmp.getHeight() / 5, false);
        	ByteArrayOutputStream out = new ByteArrayOutputStream();
        	bmp.compress(CompressFormat.JPEG, 60, out);
        	image = out.toByteArray();
        	intent.putExtra("ImageData", image);
        } else { 
        	byte[] image = _mtpDevice.getObject(object, info.getCompressedSize());
        	byte[] thumb = LibRaw.getThumbFromBuffer(image);
        	Bitmap bmp = BitmapFactory.decodeByteArray(thumb, 0, thumb.length);
        	bmp = bmp.createScaledBitmap(bmp, bmp.getWidth(), bmp.getHeight(), false);
        	ByteArrayOutputStream out = new ByteArrayOutputStream();
        	bmp.compress(CompressFormat.JPEG, 80, out);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getImagePixHeight, getImagePixWidth
public class MtpThumbnailDrawable extends AutoThumbnailDrawable<MtpObjectInfo> {
    public void setImage(MtpObjectInfo data) {
        if (data == null) {
            setImage(null, 0, 0); 
        } else { 
            setImage(data, data.getImagePixWidth(), data.getImagePixHeight());
        } 
    } 
 
    @Override 
    protected byte[] getPreferredImageBytes(MtpObjectInfo data) {
        if (data == null) {
            return null; 
        } 
        MtpDevice device = MtpDeviceIndex.getInstance().getDevice();
        if (device != null) {
            return device.getThumbnail(data.getObjectHandle());
        } else { 
            return null; 
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getObjectHandle
            GalleryBitmapPool.getInstance().put(b);
        } 
    } 
 
    public static Bitmap getThumbnail(MtpDevice device, MtpObjectInfo info) {
        byte[] imageBytes = device.getThumbnail(info.getObjectHandle());
        if (imageBytes == null) {
            return null; 
        } 
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length, o);
        if (o.outWidth == 0 || o.outHeight == 0) {
            return null; 
        } 
        o.inBitmap = GalleryBitmapPool.getInstance().get(o.outWidth, o.outHeight);
        o.inMutable = true;
        o.inJustDecodeBounds = false;
        o.inSampleSize = 1;
        try { 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getImagePixHeight, getImagePixWidth
public class MtpThumbnailDrawable extends AutoThumbnailDrawable<MtpObjectInfo> {
    public void setImage(MtpObjectInfo data) {
        if (data == null) {
            setImage(null, 0, 0); 
        } else { 
            setImage(data, data.getImagePixWidth(), data.getImagePixHeight());
        } 
    } 
 
    @Override 
    protected byte[] getPreferredImageBytes(MtpObjectInfo data) {
        if (data == null) {
            return null; 
        } 
        MtpDevice device = MtpDeviceIndex.getInstance().getDevice();
        if (device != null) {
            return device.getThumbnail(data.getObjectHandle());
        } else { 
            return null; 
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDateCreated
            this.bucket = bucket;
        } 
 
        public DateBucket(SimpleDate bucket, MtpObjectInfo firstElement) {
            this(bucket);
            tempElementsList.add(firstElement);
        } 
 
        void sortElements(Comparator<MtpObjectInfo> comparator) {
            Collections.sort(tempElementsList, comparator);
        } 
 
        @Override 
        public String toString() {
            return bucket.toString();
        } 
 
        @Override 
        public int hashCode() { 
            return bucket.hashCode();

4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getDateCreated
     * Comparator to sort MtpObjectInfo objects by date created. 
     */ 
    private static class MtpObjectTimestampComparator implements Comparator<MtpObjectInfo> {
        @Override 
        public int compare(MtpObjectInfo o1, MtpObjectInfo o2) {
            long diff = o1.getDateCreated() - o2.getDateCreated();
            if (diff < 0) {
                return -1; 
            } else if (diff == 0) {
                return 0; 
            } else { 
                return 1; 
            } 
        } 
    } 
 
    private void resetState() { 
        mGeneration++;
        mUnifiedLookupIndex = null;
        mMtpObjects = null;
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Android MtpObjectInfo Methods: