mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Code style fixes
This commit is contained in:
parent
34b5d56ab1
commit
c5ba202a56
@ -1,5 +1,6 @@
|
|||||||
package com.fsck.k9.provider;
|
package com.fsck.k9.provider;
|
||||||
|
|
||||||
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -10,6 +11,7 @@ import android.graphics.BitmapFactory;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
@ -22,9 +24,9 @@ import com.fsck.k9.mailstore.StorageManager;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple ContentProvider that allows file access to attachments.
|
* A simple ContentProvider that allows file access to attachments.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* Warning! We make heavy assumptions about the Uris used by the {@link LocalStore} for an
|
* Warning! We make heavy assumptions about the Uris used by the {@link LocalStore} for an
|
||||||
* {@link Account} here.
|
* {@link Account} here.
|
||||||
@ -38,8 +40,8 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
private static final String FORMAT_THUMBNAIL = "THUMBNAIL";
|
private static final String FORMAT_THUMBNAIL = "THUMBNAIL";
|
||||||
|
|
||||||
private static final String[] DEFAULT_PROJECTION = new String[] {
|
private static final String[] DEFAULT_PROJECTION = new String[] {
|
||||||
AttachmentProviderColumns._ID,
|
AttachmentProviderColumns._ID,
|
||||||
AttachmentProviderColumns.DATA,
|
AttachmentProviderColumns.DATA,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static class AttachmentProviderColumns {
|
public static class AttachmentProviderColumns {
|
||||||
@ -70,12 +72,12 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
|
|
||||||
public static Uri getAttachmentThumbnailUri(Account account, long id, int width, int height) {
|
public static Uri getAttachmentThumbnailUri(Account account, long id, int width, int height) {
|
||||||
return CONTENT_URI.buildUpon()
|
return CONTENT_URI.buildUpon()
|
||||||
.appendPath(account.getUuid())
|
.appendPath(account.getUuid())
|
||||||
.appendPath(Long.toString(id))
|
.appendPath(Long.toString(id))
|
||||||
.appendPath(FORMAT_THUMBNAIL)
|
.appendPath(FORMAT_THUMBNAIL)
|
||||||
.appendPath(Integer.toString(width))
|
.appendPath(Integer.toString(width))
|
||||||
.appendPath(Integer.toString(height))
|
.appendPath(Integer.toString(height))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear(Context context) {
|
public static void clear(Context context) {
|
||||||
@ -111,8 +113,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getThumbnailFile(Context context, String accountUuid,
|
private static File getThumbnailFile(Context context, String accountUuid, String attachmentId) {
|
||||||
String attachmentId) {
|
|
||||||
String filename = "thmb_" + accountUuid + "_" + attachmentId + ".tmp";
|
String filename = "thmb_" + accountUuid + "_" + attachmentId + ".tmp";
|
||||||
File dir = context.getCacheDir();
|
File dir = context.getCacheDir();
|
||||||
return new File(dir, filename);
|
return new File(dir, filename);
|
||||||
@ -183,7 +184,9 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try { in.close(); } catch (Throwable ignore) { /* ignore */ }
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (Throwable ignore) { /* ignore */ }
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
return null;
|
return null;
|
||||||
@ -197,8 +200,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||||
String sortOrder) {
|
|
||||||
|
|
||||||
String[] columnNames = (projection == null) ? DEFAULT_PROJECTION : projection;
|
String[] columnNames = (projection == null) ? DEFAULT_PROJECTION : projection;
|
||||||
|
|
||||||
@ -309,8 +311,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
|
|
||||||
private Bitmap createImageThumbnail(InputStream data) {
|
private Bitmap createImageThumbnail(InputStream data) {
|
||||||
try {
|
try {
|
||||||
Bitmap bitmap = BitmapFactory.decodeStream(data);
|
return BitmapFactory.decodeStream(data);
|
||||||
return bitmap;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
} catch (OutOfMemoryError oome) {
|
||||||
/*
|
/*
|
||||||
* Improperly downloaded images, corrupt bitmaps and the like can commonly
|
* Improperly downloaded images, corrupt bitmaps and the like can commonly
|
||||||
|
Loading…
Reference in New Issue
Block a user