Skip to content

Commit 3fe7de8

Browse files
use fresco to load notes images.
this caches the images, thus removes all the stutter and lag. 'special portion of memory' == #somuchwin lots of of love to @facebook
1 parent efe1567 commit 3fe7de8

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies {
4747
compile 'com.parse.bolts:bolts-android:1.1.4'
4848
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
4949
compile 'com.koushikdutta.ion:ion:2.0.5'
50+
compile 'com.facebook.fresco:fresco:0.4.0+'
5051
compile 'com.google.android.gms:play-services:6.5.87'
5152
compile 'com.android.support:palette-v7:21.0.0'
5253
}

app/libs/nineoldandroids-2.4.0.jar

-108 KB
Binary file not shown.

app/proguard-rules.pro

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
19+
## - - - Facebook - - - ##
1820
-keep class com.facebook.** {
1921
*;
20-
}
22+
}
23+
24+
## - - - Fresco - - - ##
25+
# Keep our interfaces so they can be used by other ProGuard rules.
26+
# See http://sourceforge.net/p/proguard/bugs/466/
27+
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
28+
# Do not strip any method/class that is annotated with @DoNotStrip
29+
-keep @com.facebook.common.internal.DoNotStrip class *
30+
-keepclassmembers class * {
31+
@com.facebook.common.internal.DoNotStrip *;
32+
}
33+
-dontwarn okio.**
34+
-dontwarn javax.annotation.**

app/src/main/java/in/tosc/studddin/ApplicationWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.support.v7.app.ActionBarActivity;
88
import android.util.Log;
99

10+
import com.facebook.drawee.backends.pipeline.Fresco;
1011
import com.parse.Parse;
1112
import com.parse.ParseACL;
1213
import com.parse.ParseFacebookUtils;
@@ -29,6 +30,7 @@ public void onCreate() {
2930
ParseACL defaultACL = new ParseACL();
3031
ParseFacebookUtils.initialize(getResources().getString(R.string.facebook_app_id));
3132
ParseTwitterUtils.initialize("FfUOeQ5OBuv0qOkdHbfXCrwdk", "xQmFnUSii54eS3iUrl0uIrxfeL4EfIdFc6iyoHUDgSIVGDbauD");
33+
Fresco.initialize(this);
3234
}
3335

3436
public static void setCustomTheme(ActionBarActivity actionBarActivity, int primary, int secondary){

app/src/main/java/in/tosc/studddin/fragments/notes/NotesCustomGridViewAdapter.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package in.tosc.studddin.fragments.notes;
22

33
import android.content.Context;
4+
import android.net.Uri;
45
import android.support.v7.widget.RecyclerView;
56
import android.view.LayoutInflater;
67
import android.view.View;
78
import android.view.ViewGroup;
89
import android.widget.TextView;
910

11+
import com.facebook.drawee.view.SimpleDraweeView;
1012
import com.parse.GetDataCallback;
1113
import com.parse.ParseException;
1214
import com.parse.ParseFile;
@@ -56,12 +58,9 @@ public void onBindViewHolder(ViewHolder holder, final int position) {
5658

5759
holder.topicNameTxtView.setText(notesTopicName.get(position));
5860

59-
holder.notesImage.setParseFile(notesFirstImage.get(position).get(0));
60-
holder.notesImage.loadInBackground(new GetDataCallback() {
61-
@Override
62-
public void done(byte[] bytes, ParseException e) {
63-
}
64-
});
61+
Uri notesThumbUri = Uri.parse(notesFirstImage.get(position).get(0).getUrl());
62+
63+
holder.notesImage.setImageURI(notesThumbUri);
6564

6665
holder.itemView.setOnClickListener(new View.OnClickListener() {
6766
@Override
@@ -85,14 +84,14 @@ public int getItemCount() {
8584

8685
public static class ViewHolder extends RecyclerView.ViewHolder {
8786
public TextView topicNameTxtView;
88-
public ParseImageView notesImage;
87+
public SimpleDraweeView notesImage;
8988

9089

9190
public ViewHolder(View itemView) {
9291
super(itemView);
9392

9493
topicNameTxtView = (TextView) itemView.findViewById(R.id.notes_gridview_topicname);
95-
notesImage = (ParseImageView) itemView.findViewById(R.id.notes_gridview_image_view);
94+
notesImage = (SimpleDraweeView) itemView.findViewById(R.id.notes_gridview_image_view);
9695

9796
}
9897

app/src/main/res/layout/notes_search_gridview_item.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:fresco="http://schemas.android.com/apk/res-auto"
45
android:orientation="horizontal"
56
android:layout_width="match_parent"
67
xmlns:card_view="http://schemas.android.com/apk/res-auto"
@@ -15,12 +16,10 @@
1516
android:layout_height="match_parent"
1617
>
1718

18-
<com.parse.ParseImageView
19+
<com.facebook.drawee.view.SimpleDraweeView
1920
android:id="@+id/notes_gridview_image_view"
2021
android:layout_width="match_parent"
2122
android:layout_height="200dp"
22-
android:layout_centerHorizontal="true"
23-
android:layout_alignParentTop="true"
2423
android:scaleType="fitXY"/>
2524

2625

0 commit comments

Comments
 (0)