Updated Glide

This commit is contained in:
Karim Abou Zeid 2016-02-06 01:11:40 +01:00
commit d60e4b8c8a
8 changed files with 9 additions and 202 deletions

View file

@ -131,7 +131,6 @@ dependencies {
compile 'com.android.support:percent:23.1.1' compile 'com.android.support:percent:23.1.1'
compile 'com.android.support:preference-v7:23.1.1' compile 'com.android.support:preference-v7:23.1.1'
compile 'com.github.ksoichiro:android-observablescrollview:1.6.0' compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
compile 'asia.ivity.android:drag-sort-listview:1.0'
compile 'com.github.semoncat.seekarc:library:0.1' compile 'com.github.semoncat.seekarc:library:0.1'
compile 'com.github.kabouzeid:AndroidSlidingUpPanel:3.2.1' compile 'com.github.kabouzeid:AndroidSlidingUpPanel:3.2.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
@ -142,6 +141,7 @@ dependencies {
compile 'com.anjlab.android.iab.v3:library:1.0.+' compile 'com.anjlab.android.iab.v3:library:1.0.+'
compile 'de.psdev.licensesdialog:licensesdialog:1.8.0' compile 'de.psdev.licensesdialog:licensesdialog:1.8.0'
compile 'com.github.kabouzeid:AppIntro:3.3.0k' compile 'com.github.kabouzeid:AppIntro:3.3.0k'
compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
compile 'com.github.kabouzeid:RecyclerView-FastScroll:v1.4-kmod' compile 'com.github.kabouzeid:RecyclerView-FastScroll:v1.4-kmod'
} }

View file

@ -22,8 +22,12 @@
-keepattributes Signature -keepattributes Signature
-keepattributes Exceptions -keepattributes Exceptions
# Glide Modules # Glide
-keep public class * implements com.bumptech.glide.module.GlideModule -keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
# ButterKnife # ButterKnife
-keep class butterknife.** { *; } -keep class butterknife.** { *; }

View file

@ -113,7 +113,7 @@
android:value="GlideModule" /> android:value="GlideModule" />
<meta-data <meta-data
android:name="com.kabouzeid.gramophone.glide.okhttp.OkHttpGlideModule" android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
android:value="GlideModule" /> android:value="GlideModule" />
<activity <activity

View file

@ -2,13 +2,13 @@ package com.kabouzeid.gramophone.glide.artistimage;
import android.content.Context; import android.content.Context;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.data.DataFetcher; import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GenericLoaderFactory; import com.bumptech.glide.load.model.GenericLoaderFactory;
import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.ModelLoader; import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.model.ModelLoaderFactory; import com.bumptech.glide.load.model.ModelLoaderFactory;
import com.bumptech.glide.load.model.stream.StreamModelLoader; import com.bumptech.glide.load.model.stream.StreamModelLoader;
import com.kabouzeid.gramophone.glide.okhttp.OkHttpUrlLoader;
import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient; import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient;
import java.io.InputStream; import java.io.InputStream;

View file

@ -1,31 +0,0 @@
package com.kabouzeid.gramophone.glide.okhttp;
import android.content.Context;
import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.GlideModule;
import java.io.InputStream;
/**
* A {@link GlideModule} implementation to replace Glide's default
* {@link java.net.HttpURLConnection} based {@link com.bumptech.glide.load.model.ModelLoader}
* with an OkHttp based {@link com.bumptech.glide.load.model.ModelLoader}.
* <p/>
* <p> If you're using gradle, you can include this module simply by depending on the aar, the
* module will be merged in by manifest merger. For other build systems or for more more
* information, see {@link GlideModule}. </p>
*/
public class OkHttpGlideModule implements GlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Do nothing.
}
@Override
public void registerComponents(Context context, Glide glide) {
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
}

View file

@ -1,78 +0,0 @@
package com.kabouzeid.gramophone.glide.okhttp;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.util.ContentLengthInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/**
* Fetches an {@link InputStream} using the okhttp library.
*/
public class OkHttpStreamFetcher implements DataFetcher<InputStream> {
private static final String TAG = "OkHttpFetcher";
private final Call.Factory client;
private final GlideUrl url;
private InputStream stream;
private ResponseBody responseBody;
public OkHttpStreamFetcher(Call.Factory client, GlideUrl url) {
this.client = client;
this.url = url;
}
@Override
public InputStream loadData(Priority priority) throws Exception {
Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl());
for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
String key = headerEntry.getKey();
requestBuilder.addHeader(key, headerEntry.getValue());
}
Request request = requestBuilder.build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
long contentLength = response.body().contentLength();
responseBody = response.body();
stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
} else {
Log.d(TAG, "OkHttp got error response: " + response.code() + ", " + response.message());
}
return stream;
}
@Override
public void cleanup() {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
// Ignored
}
if (responseBody != null) {
responseBody.close();
}
}
@Override
public String getId() {
return url.getCacheKey();
}
@Override
public void cancel() {
// TODO: call cancel on the client when this method is called on a background thread. See #257
}
}

View file

@ -1,76 +0,0 @@
package com.kabouzeid.gramophone.glide.okhttp;
import android.content.Context;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GenericLoaderFactory;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.model.ModelLoaderFactory;
import java.io.InputStream;
import okhttp3.Call;
import okhttp3.OkHttpClient;
/**
* A simple model loader for fetching media over http/https using OkHttp.
*/
public class OkHttpUrlLoader implements ModelLoader<GlideUrl, InputStream> {
private final Call.Factory client;
public OkHttpUrlLoader(Call.Factory client) {
this.client = client;
}
@Override
public DataFetcher<InputStream> getResourceFetcher(GlideUrl model, int width, int height) {
return new OkHttpStreamFetcher(client, model);
}
/**
* The default factory for {@link OkHttpUrlLoader}s.
*/
public static class Factory implements ModelLoaderFactory<GlideUrl, InputStream> {
private static volatile Call.Factory internalClient;
private Call.Factory client;
private static Call.Factory getInternalClient() {
if (internalClient == null) {
synchronized (Factory.class) {
if (internalClient == null) {
internalClient = new OkHttpClient();
}
}
}
return internalClient;
}
/**
* Constructor for a new Factory that runs requests using a static singleton client.
*/
public Factory() {
this(getInternalClient());
}
/**
* Constructor for a new Factory that runs requests using given client.
*
* @param client this is typically an instance of {@code OkHttpClient}.
*/
public Factory(Call.Factory client) {
this.client = client;
}
@Override
public ModelLoader<GlideUrl, InputStream> build(Context context, GenericLoaderFactory factories) {
return new OkHttpUrlLoader(client);
}
@Override
public void teardown() {
// Do nothing, this instance doesn't own the client.
}
}
}

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
android:listSelector="?rect_selector"
android:id="@+id/dragSortListView"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:drag_start_mode="onLongPress"
app:float_alpha="0.5"
app:max_drag_scroll_speed="2"
app:use_default_controller="true" />