Skip to content

Commit

Permalink
fixed media preload
Browse files Browse the repository at this point in the history
fixed #692
  • Loading branch information
mariotaku committed Feb 2, 2017
1 parent c953a5f commit eb74345
Show file tree
Hide file tree
Showing 20 changed files with 435 additions and 557 deletions.
Expand Up @@ -210,8 +210,7 @@ public interface SharedPreferenceConstants {
String KEY_PHISHING_LINK_WARNING = "phishing_link_warning";
@Preference(type = STRING, hasDefault = true, defaultString = VALUE_LINK_HIGHLIGHT_OPTION_NONE)
String KEY_LINK_HIGHLIGHT_OPTION = "link_highlight_option";
String KEY_PRELOAD_PROFILE_IMAGES = "preload_profile_images";
String KEY_PRELOAD_PREVIEW_IMAGES = "preload_preview_images";
String KEY_MEDIA_PRELOAD = "media_preload";
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
String KEY_PRELOAD_WIFI_ONLY = "preload_wifi_only";
@Preference(type = BOOLEAN)
Expand Down
Expand Up @@ -46,7 +46,8 @@
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.ParcelableUserList;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.provider.TwidereDataStore;
import org.mariotaku.twidere.provider.TwidereDataStore.CacheFiles;
import org.mariotaku.twidere.provider.TwidereDataStore.CachedImages;
import org.mariotaku.twidere.provider.TwidereDataStore.DNS;
import org.mariotaku.twidere.provider.TwidereDataStore.Permissions;
import org.mariotaku.twidere.util.model.AccountDetailsUtils;
Expand Down Expand Up @@ -78,7 +79,7 @@ public static void appendComposeActivityText(final Activity activity, final Stri
public static ParcelFileDescriptor getCachedImageFd(final Context context, final String url) {
if (context == null || url == null) return null;
final ContentResolver resolver = context.getContentResolver();
final Uri.Builder builder = TwidereDataStore.CachedImages.CONTENT_URI.buildUpon();
final Uri.Builder builder = CachedImages.CONTENT_URI.buildUpon();
builder.appendQueryParameter(QUERY_PARAM_URL, url);
try {
return resolver.openFileDescriptor(builder.build(), "r");
Expand All @@ -87,27 +88,10 @@ public static ParcelFileDescriptor getCachedImageFd(final Context context, final
}
}

public static String getCachedImagePath(final Context context, final String url) {
if (context == null || url == null) return null;
final ContentResolver resolver = context.getContentResolver();
final Uri.Builder builder = TwidereDataStore.CachedImages.CONTENT_URI.buildUpon();
builder.appendQueryParameter(QUERY_PARAM_URL, url);
final Cursor cur = resolver.query(builder.build(), TwidereDataStore.CachedImages.MATRIX_COLUMNS, null, null, null);
if (cur == null) return null;
try {
if (cur.getCount() == 0) return null;
final int path_idx = cur.getColumnIndex(TwidereDataStore.CachedImages.PATH);
cur.moveToFirst();
return cur.getString(path_idx);
} finally {
cur.close();
}
}

public static ParcelFileDescriptor getCacheFileFd(final Context context, final String name) {
if (context == null || name == null) return null;
final ContentResolver resolver = context.getContentResolver();
final Uri.Builder builder = TwidereDataStore.CacheFiles.CONTENT_URI.buildUpon();
final Uri.Builder builder = CacheFiles.CONTENT_URI.buildUpon();
builder.appendQueryParameter(QUERY_PARAM_NAME, name);
try {
return resolver.openFileDescriptor(builder.build(), "r");
Expand Down

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

0 comments on commit eb74345

Please sign in to comment.