diff options
author | Trumeet <liangyuteng12345@gmail.com> | 2017-03-15 17:56:34 +0800 |
---|---|---|
committer | Trumeet <liangyuteng12345@gmail.com> | 2017-03-15 17:56:34 +0800 |
commit | ee50216174532ca08d7c2a0ea64843986eda9a5e (patch) | |
tree | d12f0513977c0261f3a2b37272e926c79478085e | |
parent | a0e35d0f45c988a1073027e78d5a14c1eefbee37 (diff) | |
download | MAT-BBS_Discuz_Android-ee50216174532ca08d7c2a0ea64843986eda9a5e.tar MAT-BBS_Discuz_Android-ee50216174532ca08d7c2a0ea64843986eda9a5e.tar.gz MAT-BBS_Discuz_Android-ee50216174532ca08d7c2a0ea64843986eda9a5e.tar.bz2 MAT-BBS_Discuz_Android-ee50216174532ca08d7c2a0ea64843986eda9a5e.zip |
Basic avatar load.
-rw-r--r-- | app/build.gradle | 2 | ||||
-rw-r--r-- | app/proguard-rules.pro | 22 | ||||
-rw-r--r-- | app/src/main/java/me/letitfly/mat/model/ForumDisplay.java | 11 | ||||
-rw-r--r-- | app/src/main/java/me/letitfly/mat/utils/adapters/ThreadListAdapter.java | 21 |
4 files changed, 37 insertions, 19 deletions
diff --git a/app/build.gradle b/app/build.gradle index 139ee25..3d2e341 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,6 +46,8 @@ dependencies { // butter knife compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' + // glide + compile 'com.github.bumptech.glide:glide:3.7.0' // bottom sheet compile 'com.flipboard:bottomsheet-core:1.5.3' compile 'com.flipboard:bottomsheet-commons:1.5.3' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index ddec642..86e2c62 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,17 +1,5 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in C:\Users\Trumeet\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { + **[] $VALUES; + public *; +}
\ No newline at end of file diff --git a/app/src/main/java/me/letitfly/mat/model/ForumDisplay.java b/app/src/main/java/me/letitfly/mat/model/ForumDisplay.java index 48cdedf..48fcc29 100644 --- a/app/src/main/java/me/letitfly/mat/model/ForumDisplay.java +++ b/app/src/main/java/me/letitfly/mat/model/ForumDisplay.java @@ -184,10 +184,19 @@ public class ForumDisplay implements Parcelable{ private Reply[] reply; public static class Reply implements Parcelable { + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + private String pid; private String author; private String authorid; private String message; + private String avatar = ""; public String getPid() { return pid; @@ -226,6 +235,7 @@ public class ForumDisplay implements Parcelable{ author = in.readString(); authorid = in.readString(); message = in.readString(); + avatar = in.readString(); } public static final Creator<Reply> CREATOR = new Creator<Reply>() { @@ -251,6 +261,7 @@ public class ForumDisplay implements Parcelable{ parcel.writeString(author); parcel.writeString(authorid); parcel.writeString(message); + parcel.writeString(avatar); } } diff --git a/app/src/main/java/me/letitfly/mat/utils/adapters/ThreadListAdapter.java b/app/src/main/java/me/letitfly/mat/utils/adapters/ThreadListAdapter.java index c3c9e69..dba91ff 100644 --- a/app/src/main/java/me/letitfly/mat/utils/adapters/ThreadListAdapter.java +++ b/app/src/main/java/me/letitfly/mat/utils/adapters/ThreadListAdapter.java @@ -8,8 +8,11 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; +import com.bumptech.glide.Glide; + import java.util.List; +import de.hdodenhof.circleimageview.CircleImageView; import me.letitfly.mat.R; import me.letitfly.mat.model.ForumDisplay; @@ -43,8 +46,22 @@ public class ThreadListAdapter extends ArrayAdapter { TextView title = (TextView) convertView.findViewById(android.R.id.text1); title.setText(discussion.getSubject()); - //CircleImageView avatar = (CircleImageView) convertView.findViewById(R.id.avatar); - //NetworkUtil.loadImage(discussion, avatar); + CircleImageView avatar = (CircleImageView) convertView.findViewById(R.id.avatar); + ForumDisplay.Thread.Reply[] replys = discussion.getReply(); + if (replys != null && replys.length > 0) { + Glide.with(mContext) + // Get first reply user avatar + .load(replys[0].getAvatar()) + .placeholder(R.mipmap.ic_launcher) + .into(avatar); + } else { + // No avatar, load default. + Glide.with(mContext) + .load(R.mipmap.ic_launcher) + .placeholder(R.mipmap.ic_launcher) + .into(avatar); + } + TextView context = (TextView) convertView.findViewById(android.R.id.text2); context.setText(mContext.getString(R.string.text_post_summary |