Added Avatar to video list, added config model.

This commit is contained in:
Stefan Schüller 2018-03-14 14:26:36 +01:00
parent 2502fc2cf0
commit 7145f04375
7 changed files with 88 additions and 42 deletions

View File

@ -48,6 +48,8 @@ dependencies {
// implementation "com.github.TorrentStream:TorrentStreamServer-Android:1.0.1" // implementation "com.github.TorrentStream:TorrentStreamServer-Android:1.0.1"
// implementation 'com.devbrackets.android:exomedia:4.1.0' // implementation 'com.devbrackets.android:exomedia:4.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:support-v4:27.1.0' implementation 'com.android.support:support-v4:27.1.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test:runner:1.0.1'

View File

@ -19,6 +19,8 @@ import net.schueller.peertube.R;
import net.schueller.peertube.activity.TorrentVideoPlayActivity; import net.schueller.peertube.activity.TorrentVideoPlayActivity;
import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.APIUrlHelper;
import net.schueller.peertube.helper.MetaDataHelper; import net.schueller.peertube.helper.MetaDataHelper;
import net.schueller.peertube.model.Account;
import net.schueller.peertube.model.Avatar;
import net.schueller.peertube.model.Video; import net.schueller.peertube.model.Video;
import java.util.ArrayList; import java.util.ArrayList;
@ -55,6 +57,16 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
.load(apiBaseURL + videoList.get(position).getPreviewPath()) .load(apiBaseURL + videoList.get(position).getPreviewPath())
.into(holder.thumb); .into(holder.thumb);
Avatar avatar = videoList.get(position).getAccount().getAvatar();
if (avatar != null) {
String avatarPath = avatar.getPath();
Picasso.with(this.context)
.load(apiBaseURL + avatarPath)
.into(holder.avatar);
}
holder.name.setText(videoList.get(position).getName()); holder.name.setText(videoList.get(position).getName());
// set age and view count // set age and view count
@ -67,8 +79,8 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
// set owner // set owner
holder.videoOwner.setText( holder.videoOwner.setText(
MetaDataHelper.getOwnerString(videoList.get(position).getAccountName(), MetaDataHelper.getOwnerString(videoList.get(position).getAccount().getName(),
videoList.get(position).getServerHost(), videoList.get(position).getAccount().getHost(),
context context
) )
); );
@ -103,13 +115,14 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
class VideoViewHolder extends RecyclerView.ViewHolder { class VideoViewHolder extends RecyclerView.ViewHolder {
TextView name, videoMeta, videoOwner; TextView name, videoMeta, videoOwner;
ImageView thumb; ImageView thumb, avatar;
View mView; View mView;
VideoViewHolder(View itemView) { VideoViewHolder(View itemView) {
super(itemView); super(itemView);
name = itemView.findViewById(R.id.name); name = itemView.findViewById(R.id.name);
thumb = itemView.findViewById(R.id.thumb); thumb = itemView.findViewById(R.id.thumb);
avatar = itemView.findViewById(R.id.avatar);
videoMeta = itemView.findViewById(R.id.videoMeta); videoMeta = itemView.findViewById(R.id.videoMeta);
videoOwner = itemView.findViewById(R.id.videoOwner); videoOwner = itemView.findViewById(R.id.videoOwner);
mView = itemView; mView = itemView;

View File

@ -0,0 +1,16 @@
package net.schueller.peertube.model;
public class Config {
// TODO: implement remaining items
private String serverVersion;
public String getServerVersion() {
return serverVersion;
}
public void setServerVersion(String serverVersion) {
this.serverVersion = serverVersion;
}
}

View File

@ -16,9 +16,7 @@ public class Video {
private String languageLabel; private String languageLabel;
private Boolean nsfw; private Boolean nsfw;
private String description; private String description;
private String serverHost;
private Boolean isLocal; private Boolean isLocal;
private String accountName;
private Integer duration; private Integer duration;
private Integer views; private Integer views;
private Integer likes; private Integer likes;
@ -133,14 +131,6 @@ public class Video {
this.description = description; this.description = description;
} }
public String getServerHost() {
return serverHost;
}
public void setServerHost(String serverHost) {
this.serverHost = serverHost;
}
public Boolean getLocal() { public Boolean getLocal() {
return isLocal; return isLocal;
} }
@ -149,14 +139,6 @@ public class Video {
isLocal = local; isLocal = local;
} }
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Integer getDuration() { public Integer getDuration() {
return duration; return duration;
} }

View File

@ -0,0 +1,12 @@
package net.schueller.peertube.network;
import net.schueller.peertube.model.Config;
import retrofit2.Call;
import retrofit2.http.GET;
public interface GetConfigDataService {
@GET("config")
Call<Config> getConfigData();
}

View File

@ -1,50 +1,64 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!-- START*** Root Container *** -->
<!-- START*** Root Container *** -->
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
card_view:cardCornerRadius="6dp" card_view:cardCornerRadius="0dp"
card_view:cardElevation="3dp" card_view:cardElevation="0dp"
card_view:cardUseCompatPadding="true"> card_view:cardUseCompatPadding="true">
<LinearLayout <RelativeLayout
android:id="@+id/linearLayout" android:id="@+id/linearLayout"
android:padding="8dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:padding="12dp">
<ImageView <ImageView
android:id="@+id/thumb" android:id="@+id/thumb"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/video_row_video_thumbnail"
android:scaleType="fitXY" android:scaleType="fitXY"
android:contentDescription="" />
<TextView
android:layout_marginStart="75dp"
android:id="@+id/name"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/> />
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/avatar"
android:layout_width="60dp"
android:layout_height="60dp"
android:paddingTop="12dp"
android:paddingEnd="12dp"
android:contentDescription="@string/video_row_account_avatar"
android:layout_below="@id/thumb"
android:layout_alignParentStart="true"/>
<TextView
android:id="@+id/name"
android:paddingTop="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/thumb"
android:layout_toEndOf="@id/avatar"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" />
<TextView <TextView
android:layout_marginStart="75dp"
android:id="@+id/videoMeta" android:id="@+id/videoMeta"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" android:layout_below="@id/name"
/> android:layout_toEndOf="@id/avatar"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" />
<TextView <TextView
android:layout_marginStart="75dp"
android:id="@+id/videoOwner" android:id="@+id/videoOwner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" android:layout_below="@id/videoMeta"
/> android:layout_toEndOf="@id/avatar"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" />
</LinearLayout> </RelativeLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>

View File

@ -29,6 +29,8 @@
<string name="bottom_nav_title_account">Account</string> <string name="bottom_nav_title_account">Account</string>
<!-- Strings related to Settings --> <!-- Strings related to Settings -->
<string name="peertube_required_server_version">1.0.0-alpha.7</string>
<string name="pref_default_api_base_url" formatted="false">https://troll.tv</string> <string name="pref_default_api_base_url" formatted="false">https://troll.tv</string>
<string name="pref_title_peertube_server">PeerTube Server</string> <string name="pref_title_peertube_server">PeerTube Server</string>
@ -38,4 +40,9 @@
<string name="meta_data_views">\u0020Views</string> <string name="meta_data_views">\u0020Views</string>
<string name="meta_data_owner_seperator">\@</string> <string name="meta_data_owner_seperator">\@</string>
<string name="video_row_video_thumbnail">Video Thumbnail</string>
<string name="video_row_account_avatar">Account Avatar</string>
</resources> </resources>