From 359a795efe1953a844e7c898f36419e7fec75f0f Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 27 Jan 2019 16:29:59 +0100 Subject: [PATCH] - Added avatar to account view --- .../peertube/activity/AccountActivity.java | 14 ++++++++++++++ app/src/main/res/layout/activity_account.xml | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java b/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java index 3c15e1e..0c70e66 100644 --- a/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java @@ -23,6 +23,7 @@ import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -30,6 +31,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.LabelVisibilityMode; import com.mikepenz.fontawesome_typeface_library.FontAwesome; import com.mikepenz.iconics.IconicsDrawable; +import com.squareup.picasso.Picasso; import net.schueller.peertube.R; import net.schueller.peertube.adapter.ChannelAdapter; @@ -37,6 +39,7 @@ import net.schueller.peertube.adapter.VideoAdapter; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.MetaDataHelper; import net.schueller.peertube.model.Account; +import net.schueller.peertube.model.Avatar; import net.schueller.peertube.model.ChannelList; import net.schueller.peertube.model.VideoList; import net.schueller.peertube.network.GetUserService; @@ -191,6 +194,17 @@ public class AccountActivity extends CommonActivity { joined.setText(account.getCreatedAt().toString()); + ImageView accountAvatar = findViewById(R.id.account_avatar); + + // set Avatar + Avatar avatar = account.getAvatar(); + if (avatar != null) { + String avatarPath = avatar.getPath(); + Picasso.with(AccountActivity.this) + .load(APIUrlHelper.getUrl(AccountActivity.this) + avatarPath) + .into(accountAvatar); + } + } else { Toast.makeText(AccountActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 15b09c1..0a1283b 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -45,6 +45,15 @@ android:layout_marginEnd="12dp" android:orientation="vertical"> + +