diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a9d98d4..6b8b761 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -86,7 +86,7 @@
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" />
diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java
index d35c5f1..40241cf 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java
@@ -148,8 +148,8 @@ public class MainActivity extends AppCompatActivity {
if (!Helper.isLoggedIn(MainActivity.this)) {
fm.beginTransaction().add(R.id.nav_host_fragment, recentFragment, "4").hide(recentFragment).commit();
- fm.beginTransaction().add(R.id.nav_host_fragment, mostLikedFragment, "3").hide(trendingFragment).commit();
- fm.beginTransaction().add(R.id.nav_host_fragment, trendingFragment, "2").hide(subscriptionFragment).commit();
+ fm.beginTransaction().add(R.id.nav_host_fragment, mostLikedFragment, "3").hide(mostLikedFragment).commit();
+ fm.beginTransaction().add(R.id.nav_host_fragment, trendingFragment, "2").hide(trendingFragment).commit();
fm.beginTransaction().add(R.id.nav_host_fragment, overviewFragment, "1").commit();
}
@@ -304,21 +304,21 @@ public class MainActivity extends AppCompatActivity {
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_myvideos) {
- Intent intent = new Intent(MainActivity.this, MyVideosActivity.class);
+ Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.MY_VIDEOS);
intent.putExtras(bundle);
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_history) {
- Intent intent = new Intent(MainActivity.this, MyVideosActivity.class);
+ Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.HISTORY);
intent.putExtras(bundle);
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_most_liked) {
- Intent intent = new Intent(MainActivity.this, MyVideosActivity.class);
+ Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("type", TimelineVM.TimelineType.MOST_LIKED);
intent.putExtras(bundle);
diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
index 0e7cf3a..1c7fe45 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
@@ -160,7 +160,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
private String max_id;
private RecyclerView lv_comments;
private boolean flag_loading;
-
+ private boolean isMyVideo;
private List comments;
private CommentListAdapter commentListAdapter;
@@ -232,6 +232,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
videoId = b.getString("video_id", null);
videoUuid = b.getString("video_uuid", null);
+ isMyVideo = b.getBoolean("isMyVideo", false);
}
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
@@ -368,7 +369,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube_playlist.setVisibility(View.VISIBLE);
peertube_bookmark.setVisibility(View.GONE);
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
- feedsViewModel.getVideo(videoUuid).observe(PeertubeActivity.this, this::manageVIewVideo);
+ feedsViewModel.getVideo(videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
captionsViewModel.getCaptions(videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/MyVideosActivity.java b/app/src/main/java/app/fedilab/fedilabtube/VideosTimelineActivity.java
similarity index 91%
rename from app/src/main/java/app/fedilab/fedilabtube/MyVideosActivity.java
rename to app/src/main/java/app/fedilab/fedilabtube/VideosTimelineActivity.java
index e3d692e..7a9e4d3 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/MyVideosActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/VideosTimelineActivity.java
@@ -21,10 +21,11 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
+import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
-public class MyVideosActivity extends AppCompatActivity {
+public class VideosTimelineActivity extends AppCompatActivity {
private TimelineVM.TimelineType type;
@@ -43,8 +44,6 @@ public class MyVideosActivity extends AppCompatActivity {
if (type == TimelineVM.TimelineType.MY_VIDEOS) {
setTitle(R.string.my_videos);
- } else if (type == TimelineVM.TimelineType.SUBSCRIBTIONS) {
- setTitle(R.string.subscriptions);
} else if (type == TimelineVM.TimelineType.HISTORY) {
setTitle(R.string.my_history);
} else if (type == TimelineVM.TimelineType.MOST_LIKED) {
@@ -54,7 +53,7 @@ public class MyVideosActivity extends AppCompatActivity {
if (savedInstanceState == null) {
DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
Bundle bundle = new Bundle();
- bundle.putSerializable("type", type);
+ bundle.putSerializable(Helper.TIMELINE_TYPE, type);
displayVideosFragment.setArguments(bundle);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.container, displayVideosFragment).commit();
diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java
index 120e42b..bffd7d0 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java
@@ -64,7 +64,6 @@ public class PeertubeAdapter extends RecyclerView.Adapter videos;
private Context context;
private TimelineVM.TimelineType timelineType;
@@ -201,53 +200,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter ownerPlaylists = ownerPlaylistsListener.getOwnerPlaylists();
- if( ownerPlaylists == null){
- return false;
- }
- String[] label = new String[ownerPlaylists.size()];
- boolean[] checked = new boolean[ownerPlaylists.size()];
- int i = 0;
- List playlistsForVideo = playlistListener.getPlaylist().get(video.getId());
-
-
- for (PlaylistData.Playlist playlist : ownerPlaylists) {
- checked[i] = false;
- if (playlistsForVideo != null) {
- for (PlaylistExist playlistExist : playlistsForVideo) {
- if (playlistExist != null && playlistExist.getPlaylistId().compareTo(playlist.getId()) == 0) {
- checked[i] = true;
- break;
- }
- }
- }
- label[i] = playlist.getDisplayName();
- i++;
- }
-
- builder.setMultiChoiceItems(label, checked, (dialog, which, isChecked) -> {
- PlaylistsVM playlistsViewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
- if (isChecked) { //Add to playlist
- playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, ownerPlaylistsListener.getOwnerPlaylists().get(which), video.getUuid()).observe((LifecycleOwner) context, apiResponse3 -> addElement(ownerPlaylistsListener.getOwnerPlaylists().get(which).getId(), video.getId(), apiResponse3));
- } else { //Remove from playlist
- String elementInPlaylistId = null;
- for (PlaylistExist playlistExist : video.getPlaylistExists()) {
- if (playlistExist.getPlaylistId().compareTo(ownerPlaylistsListener.getOwnerPlaylists().get(which).getId()) == 0) {
- elementInPlaylistId = playlistExist.getPlaylistElementId();
- }
- }
- playlistsViewModel.manage(PlaylistsVM.action.DELETE_VIDEOS, ownerPlaylistsListener.getOwnerPlaylists().get(which), elementInPlaylistId);
- playlistListener.getPlaylist().remove(video.getId());
- }
- });
- builder.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
- androidx.appcompat.app.AlertDialog dialog = builder.create();
- dialog.show();
-
+ PlaylistsVM viewModelOwnerPlaylist = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
+ viewModelOwnerPlaylist.manage(PlaylistsVM.action.GET_PLAYLISTS, null, null).observe((LifecycleOwner) context, apiResponse -> manageVIewPlaylists(video, apiResponse));
break;
case R.id.action_edit:
Intent intent = new Intent(context, PeertubeEditUploadActivity.class);
@@ -290,6 +244,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter 0) {
+ androidx.appcompat.app.AlertDialog.Builder builder = new androidx.appcompat.app.AlertDialog.Builder(context);
+ builder.setTitle(R.string.modify_playlists);
+
+ List ownerPlaylists = apiResponse.getPlaylists();
+ if( ownerPlaylists == null){
+ return;
+ }
+ String[] label = new String[ownerPlaylists.size()];
+ boolean[] checked = new boolean[ownerPlaylists.size()];
+ int i = 0;
+ List playlistsForVideo = playlistListener.getPlaylist().get(video.getId());
+
+
+ for (PlaylistData.Playlist playlist : ownerPlaylists) {
+ checked[i] = false;
+ if (playlistsForVideo != null) {
+ for (PlaylistExist playlistExist : playlistsForVideo) {
+ if (playlistExist != null && playlistExist.getPlaylistId().compareTo(playlist.getId()) == 0) {
+ checked[i] = true;
+ break;
+ }
+ }
+ }
+ label[i] = playlist.getDisplayName();
+ i++;
+ }
+
+ builder.setMultiChoiceItems(label, checked, (dialog, which, isChecked) -> {
+ PlaylistsVM playlistsViewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
+ if (isChecked) { //Add to playlist
+ playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, ownerPlaylists.get(which), video.getUuid()).observe((LifecycleOwner) context, apiResponse3 -> addElement(ownerPlaylists.get(which).getId(), video.getId(), apiResponse3));
+ } else { //Remove from playlist
+ String elementInPlaylistId = null;
+ for (PlaylistExist playlistExist : video.getPlaylistExists()) {
+ if (playlistExist.getPlaylistId().compareTo(ownerPlaylists.get(which).getId()) == 0) {
+ elementInPlaylistId = playlistExist.getPlaylistElementId();
+ }
+ }
+ playlistsViewModel.manage(PlaylistsVM.action.DELETE_VIDEOS, ownerPlaylists.get(which), elementInPlaylistId);
+ playlistListener.getPlaylist().remove(video.getId());
+ }
+ });
+ builder.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
+ androidx.appcompat.app.AlertDialog dialog = builder.create();
+ dialog.show();
+ }
+ }
+
public void addElement(String playlistId, String videoId, APIResponse apiResponse) {
if (apiResponse != null && apiResponse.getActionReturn() != null) {
@@ -348,9 +358,6 @@ public class PeertubeAdapter extends RecyclerView.Adapter> getPlaylist();
}
- public interface OwnerPlaylistsListener {
- List getOwnerPlaylists();
- }
static class ViewHolder extends RecyclerView.ViewHolder {
diff --git a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayOverviewFragment.java b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayOverviewFragment.java
index 64d3eaf..b882309 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayOverviewFragment.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayOverviewFragment.java
@@ -42,7 +42,6 @@ import java.util.Map;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.APIResponse;
-import app.fedilab.fedilabtube.client.data.PlaylistData;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
@@ -58,7 +57,7 @@ import static app.fedilab.fedilabtube.client.data.VideoData.Video.titleType.CHAN
import static app.fedilab.fedilabtube.client.data.VideoData.Video.titleType.TAG;
-public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter.RelationShipListener, PeertubeAdapter.PlaylistListener, PeertubeAdapter.OwnerPlaylistsListener {
+public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter.RelationShipListener, PeertubeAdapter.PlaylistListener {
private LinearLayoutManager mLayoutManager;
@@ -77,7 +76,7 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
private TimelineVM viewModelFeeds;
private Map relationship;
private Map> playlists;
- private List ownerPlaylists;
+
public DisplayOverviewFragment() {
}
@@ -107,7 +106,6 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
peertubeAdapater.playlistListener = this;
peertubeAdapater.relationShipListener = this;
- peertubeAdapater.ownerPlaylistsListener = this;
lv_status.setAdapter(peertubeAdapater);
@@ -162,10 +160,6 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
}
});
- if (Helper.isLoggedIn(context)) {
- PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
- viewModel.manage(PlaylistsVM.action.GET_PLAYLISTS, null, null).observe(DisplayOverviewFragment.this.requireActivity(), apiResponse -> manageVIewPlaylists(PlaylistsVM.action.GET_PLAYLISTS, apiResponse));
- }
return rootView;
}
@@ -315,7 +309,6 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
peertubeAdapater = new PeertubeAdapter(this.peertubes);
peertubeAdapater.playlistListener = DisplayOverviewFragment.this;
peertubeAdapater.relationShipListener = DisplayOverviewFragment.this;
- peertubeAdapater.ownerPlaylistsListener = DisplayOverviewFragment.this;
lv_status.setAdapter(peertubeAdapater);
} else
peertubeAdapater.notifyItemRangeInserted(previousPosition, totalAdded);
@@ -438,20 +431,6 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
relationship.putAll(apiResponse.getRelationships());
}
- public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
- if (apiResponse.getError() != null) {
- return;
- }
- if (actionType == PlaylistsVM.action.GET_PLAYLISTS) {
- if (apiResponse.getPlaylists() != null && apiResponse.getPlaylists().size() > 0) {
- if (this.ownerPlaylists == null) {
- this.ownerPlaylists = new ArrayList<>();
- }
- this.ownerPlaylists.addAll(apiResponse.getPlaylists());
- }
- }
- }
-
@Override
public Map getRelationShip() {
return relationship;
@@ -462,8 +441,4 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
return playlists;
}
- @Override
- public List getOwnerPlaylists() {
- return ownerPlaylists;
- }
}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java
index a89061e..e23a4c5 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java
@@ -48,7 +48,6 @@ import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.AccountData.Account;
-import app.fedilab.fedilabtube.client.data.PlaylistData;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
@@ -63,7 +62,7 @@ import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import es.dmoral.toasty.Toasty;
-public class DisplayVideosFragment extends Fragment implements AccountsHorizontalListAdapter.EventListener, PeertubeAdapter.RelationShipListener, PeertubeAdapter.PlaylistListener, PeertubeAdapter.OwnerPlaylistsListener {
+public class DisplayVideosFragment extends Fragment implements AccountsHorizontalListAdapter.EventListener, PeertubeAdapter.RelationShipListener, PeertubeAdapter.PlaylistListener {
private LinearLayoutManager mLayoutManager;
@@ -93,7 +92,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
private String channelId;
private Map relationship;
private Map> playlists;
- private List ownerPlaylists;
private String playlistId;
public DisplayVideosFragment() {
@@ -141,7 +139,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
peertubeAdapater = new PeertubeAdapter(this.peertubes, type);
peertubeAdapater.playlistListener = this;
peertubeAdapater.relationShipListener = this;
- peertubeAdapater.ownerPlaylistsListener = this;
lv_status.setAdapter(peertubeAdapater);
accountsHorizontalListAdapter = new AccountsHorizontalListAdapter(this.accounts, this);
@@ -233,10 +230,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
AccountsVM viewModel = new ViewModelProvider(this).get(AccountsVM.class);
viewModel.getAccounts(RetrofitPeertubeAPI.DataType.SUBSCRIBER, max_id).observe(DisplayVideosFragment.this.requireActivity(), this::manageViewAccounts);
}
- if (Helper.isLoggedIn(context)) {
- PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
- viewModel.manage(PlaylistsVM.action.GET_PLAYLISTS, null, null).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageVIewPlaylists(PlaylistsVM.action.GET_PLAYLISTS, apiResponse));
- }
loadTimeline(max_id);
display_all.setOnClickListener(v -> {
forAccount = null;
@@ -246,20 +239,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
}
- public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
- if (apiResponse.getError() != null) {
- return;
- }
- if (actionType == PlaylistsVM.action.GET_PLAYLISTS) {
- if (apiResponse.getPlaylists() != null && apiResponse.getPlaylists().size() > 0) {
- if (this.ownerPlaylists == null) {
- this.ownerPlaylists = new ArrayList<>();
- }
- this.ownerPlaylists.addAll(apiResponse.getPlaylists());
- }
- }
- }
-
@Override
public void onPause() {
@@ -356,7 +335,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
peertubeAdapater = new PeertubeAdapter(this.peertubes, type);
peertubeAdapater.playlistListener = DisplayVideosFragment.this;
peertubeAdapater.relationShipListener = DisplayVideosFragment.this;
- peertubeAdapater.ownerPlaylistsListener = DisplayVideosFragment.this;
lv_status.setAdapter(peertubeAdapater);
} else
peertubeAdapater.notifyItemRangeInserted(previousPosition, apiResponse.getPeertubes().size());
@@ -501,10 +479,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
return playlists;
}
- @Override
- public List getOwnerPlaylists() {
- return ownerPlaylists;
- }
static class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
diff --git a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java
index 72ff98b..47bfbd1 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java
@@ -51,9 +51,9 @@ public class TimelineVM extends AndroidViewModel {
}
- public LiveData getVideo(String videoId) {
+ public LiveData getVideo(String videoId, boolean isMyVideo) {
apiResponseMutableLiveData = new MutableLiveData<>();
- getSingle(videoId, false);
+ getSingle(videoId, isMyVideo);
return apiResponseMutableLiveData;
}