Эх сурвалжийг харах

Fix avatars

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 жил өмнө
parent
commit
be66bbfe16

+ 11 - 2
src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -22,6 +22,7 @@
 package com.owncloud.android.datamodel;
 
 import android.accounts.Account;
+import android.accounts.AccountManager;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.CompressFormat;
@@ -34,6 +35,7 @@ import android.media.MediaMetadataRetriever;
 import android.media.ThumbnailUtils;
 import android.net.Uri;
 import android.os.AsyncTask;
+import android.text.TextUtils;
 import android.view.MenuItem;
 import android.widget.ImageView;
 
@@ -653,8 +655,15 @@ public class ThumbnailsCacheManager {
                     if (serverOCVersion.supportsRemoteThumbnails()) {
                         GetMethod get = null;
                         try {
-                            String uri = mClient.getBaseUri() + "" +
-                                    "/index.php/avatar/" + AccountUtils.getAccountUsername(username) + "/" + px;
+
+                            String userId = AccountManager.get(MainApp.getAppContext()).getUserData(mAccount,
+                                    com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
+
+                            if (TextUtils.isEmpty(userId)) {
+                                userId = AccountUtils.getAccountUsername(username);
+                            }
+
+                            String uri = mClient.getBaseUri() + "" + "/index.php/avatar/" + userId + "/" + px;
                             Log_OC.d("Avatar", "URI: " + uri);
                             get = new GetMethod(uri);
                             int status = mClient.executeMethod(get);