some checks
This commit is contained in:
parent
30d344987c
commit
8548777c50
|
@ -9,4 +9,10 @@
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
|
@ -8,4 +8,10 @@
|
||||||
<item name="colorAccent">@color/colorAccent_full</item>
|
<item name="colorAccent">@color/colorAccent_full</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary_full</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark_full</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent_full</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
|
@ -27,8 +27,10 @@
|
||||||
tools:replace="android:allowBackup">
|
tools:replace="android:allowBackup">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
android:theme="@style/AppThemeNoActionBar"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|
|
@ -31,6 +31,7 @@ import android.widget.Toast;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.NavGraph;
|
import androidx.navigation.NavGraph;
|
||||||
import androidx.navigation.NavInflater;
|
import androidx.navigation.NavInflater;
|
||||||
|
@ -75,6 +76,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
BottomNavigationView navView = findViewById(R.id.nav_view);
|
BottomNavigationView navView = findViewById(R.id.nav_view);
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
|
|
|
@ -98,15 +98,14 @@ import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.entities.File;
|
import app.fedilab.fedilabtube.client.entities.File;
|
||||||
import app.fedilab.fedilabtube.client.entities.ItemStr;
|
import app.fedilab.fedilabtube.client.entities.ItemStr;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Report;
|
import app.fedilab.fedilabtube.client.entities.Report;
|
||||||
import app.fedilab.fedilabtube.drawer.CommentListAdapter;
|
import app.fedilab.fedilabtube.drawer.CommentListAdapter;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
|
||||||
import app.fedilab.fedilabtube.helper.CacheDataSourceFactory;
|
import app.fedilab.fedilabtube.helper.CacheDataSourceFactory;
|
||||||
import app.fedilab.fedilabtube.helper.FullScreenMediaController;
|
import app.fedilab.fedilabtube.helper.FullScreenMediaController;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||||
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
import app.fedilab.fedilabtube.viewmodel.AccountsVM;
|
|
||||||
import app.fedilab.fedilabtube.viewmodel.CaptionsVM;
|
import app.fedilab.fedilabtube.viewmodel.CaptionsVM;
|
||||||
import app.fedilab.fedilabtube.viewmodel.CommentVM;
|
import app.fedilab.fedilabtube.viewmodel.CommentVM;
|
||||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
||||||
|
@ -125,7 +124,6 @@ import static app.fedilab.fedilabtube.helper.Helper.getAttColor;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance;
|
import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
|
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
|
||||||
import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_PLAYLISTS;
|
import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_PLAYLISTS;
|
||||||
import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_PLAYLIST_FOR_VIDEO;
|
|
||||||
|
|
||||||
|
|
||||||
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved {
|
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved {
|
||||||
|
@ -148,7 +146,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
private ImageView send;
|
private ImageView send;
|
||||||
private TextView add_comment_read;
|
private TextView add_comment_read;
|
||||||
private EditText add_comment_write;
|
private EditText add_comment_write;
|
||||||
private List<Playlist> playlistForVideo;
|
private List<String> playlistForVideo;
|
||||||
private List<Playlist> playlists;
|
private List<Playlist> playlists;
|
||||||
private PlaylistsVM playlistsViewModel;
|
private PlaylistsVM playlistsViewModel;
|
||||||
private boolean playInMinimized;
|
private boolean playInMinimized;
|
||||||
|
@ -365,7 +363,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
|
|
||||||
peertube_playlist.setVisibility(View.VISIBLE);
|
peertube_playlist.setVisibility(View.VISIBLE);
|
||||||
peertube_bookmark.setVisibility(View.GONE);
|
peertube_bookmark.setVisibility(View.GONE);
|
||||||
|
List<String> videoIds = new ArrayList<>();
|
||||||
|
videoIds.add(videoId);
|
||||||
|
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||||
|
playlistsViewModel.videoExists(videoIds).observe(PeertubeActivity.this, this::manageVIewVideosExist);
|
||||||
|
}
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
||||||
feedsViewModel.getVideo(videoId).observe(PeertubeActivity.this, this::manageVIewVideo);
|
feedsViewModel.getVideo(videoId).observe(PeertubeActivity.this, this::manageVIewVideo);
|
||||||
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
||||||
|
@ -509,8 +511,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
|
|
||||||
|
|
||||||
peertube = apiResponse.getPeertubes().get(0);
|
peertube = apiResponse.getPeertubes().get(0);
|
||||||
//TODO: currently streaming service gives the wrong values for duration
|
|
||||||
playlistsViewModel.manage(GET_PLAYLIST_FOR_VIDEO, null, peertube.getId()).observe(PeertubeActivity.this, apiResponse2 -> manageVIewPlaylists(GET_PLAYLIST_FOR_VIDEO, apiResponse2));
|
|
||||||
|
|
||||||
add_comment_read.setOnClickListener(v -> {
|
add_comment_read.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this)) {
|
if (isLoggedIn(PeertubeActivity.this)) {
|
||||||
|
@ -550,13 +552,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
String title = null;
|
String title = null;
|
||||||
boolean isPresent = false;
|
boolean isPresent = false;
|
||||||
String elementId = null;
|
String elementId = null;
|
||||||
Playlist playlistElementFinal = null;
|
for (String playlistId : playlistForVideo) {
|
||||||
for (Playlist playlistElement : playlistForVideo) {
|
if (playlist.getId().compareTo(playlistId) == 0) {
|
||||||
if (playlist.getId().equals(playlistElement.getId())) {
|
|
||||||
title = "✔ " + playlist.getDisplayName();
|
title = "✔ " + playlist.getDisplayName();
|
||||||
isPresent = true;
|
isPresent = true;
|
||||||
elementId = playlistElement.getId();
|
elementId = playlistId;
|
||||||
playlistElementFinal = playlistElement;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title);
|
MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title);
|
||||||
boolean finalIsPresent = isPresent;
|
boolean finalIsPresent = isPresent;
|
||||||
String finalElementId = elementId;
|
String finalElementId = elementId;
|
||||||
Playlist finalPlaylistElementFinal = playlistElementFinal;
|
|
||||||
item.setOnMenuItemClickListener(item1 -> {
|
item.setOnMenuItemClickListener(item1 -> {
|
||||||
item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||||
item1.setActionView(new View(PeertubeActivity.this));
|
item1.setActionView(new View(PeertubeActivity.this));
|
||||||
|
@ -584,13 +583,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
if (finalIsPresent) {
|
if (finalIsPresent) {
|
||||||
item1.setTitle(playlist.getDisplayName());
|
item1.setTitle(playlist.getDisplayName());
|
||||||
playlistsViewModel.manage(PlaylistsVM.action.DELETE_VIDEOS, playlist, finalElementId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.DELETE_VIDEOS, apiResponse3));
|
playlistsViewModel.manage(PlaylistsVM.action.DELETE_VIDEOS, playlist, finalElementId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.DELETE_VIDEOS, apiResponse3));
|
||||||
playlistForVideo.remove(finalPlaylistElementFinal);
|
playlistForVideo.remove(playlist.getId());
|
||||||
} else {
|
} else {
|
||||||
item1.setTitle("✔ " + playlist.getDisplayName());
|
item1.setTitle("✔ " + playlist.getDisplayName());
|
||||||
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, peertube.getId()).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
|
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, peertube.getId()).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
|
||||||
Playlist playlistElement = new Playlist();
|
playlistForVideo.add(playlist.getId());
|
||||||
playlistElement.setId(playlist.getId());
|
|
||||||
playlistForVideo.add(playlistElement);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -1078,13 +1075,22 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
|
|
||||||
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
|
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
|
||||||
|
|
||||||
if (actionType == GET_PLAYLIST_FOR_VIDEO && apiResponse != null) {
|
if (actionType == GET_PLAYLISTS && apiResponse != null) {
|
||||||
playlistForVideo = apiResponse.getPlaylists();
|
|
||||||
} else if (actionType == GET_PLAYLISTS && apiResponse != null) {
|
|
||||||
playlists = apiResponse.getPlaylists();
|
playlists = apiResponse.getPlaylists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void manageVIewVideosExist(APIResponse apiResponse) {
|
||||||
|
playlistForVideo = new ArrayList<>();
|
||||||
|
if( apiResponse.getError() == null && apiResponse.getVideoExistPlaylist() != null) {
|
||||||
|
|
||||||
|
List<PlaylistExist.VideoId> videoIds = apiResponse.getVideoExistPlaylist();
|
||||||
|
for(PlaylistExist.VideoId videoId: videoIds) {
|
||||||
|
playlistForVideo.add(videoId.getPlaylistId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAllCommentRemoved() {
|
public void onAllCommentRemoved() {
|
||||||
no_action_text.setVisibility(View.VISIBLE);
|
no_action_text.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoPlaylistData.VideoPlaylist;
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData.VideoPlaylist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Error;
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist.VideoId;
|
||||||
import app.fedilab.fedilabtube.client.entities.Rating;
|
import app.fedilab.fedilabtube.client.entities.Rating;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
|
@ -40,6 +41,7 @@ public class APIResponse {
|
||||||
private String actionReturn = null;
|
private String actionReturn = null;
|
||||||
private Rating rating;
|
private Rating rating;
|
||||||
private OverviewVideo overviewVideo = null;
|
private OverviewVideo overviewVideo = null;
|
||||||
|
private List<VideoId> videoExistPlaylist = null;
|
||||||
private List<VideoData.Video> peertubes = null;
|
private List<VideoData.Video> peertubes = null;
|
||||||
private List<CommentData.Comment> comments = null;
|
private List<CommentData.Comment> comments = null;
|
||||||
private List<Block> muted;
|
private List<Block> muted;
|
||||||
|
@ -237,4 +239,12 @@ public class APIResponse {
|
||||||
public void setVideoPlaylist(List<VideoPlaylist> videoPlaylist) {
|
public void setVideoPlaylist(List<VideoPlaylist> videoPlaylist) {
|
||||||
this.videoPlaylist = videoPlaylist;
|
this.videoPlaylist = videoPlaylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VideoId> getVideoExistPlaylist() {
|
||||||
|
return videoExistPlaylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoExistPlaylist(List<VideoId> videoExistPlaylist) {
|
||||||
|
this.videoExistPlaylist = videoExistPlaylist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ public interface PeertubeService {
|
||||||
Call<VideoPlaylistData> getVideosPlayList(@Header("Authorization") String credentials, @Path("id") String id);
|
Call<VideoPlaylistData> getVideosPlayList(@Header("Authorization") String credentials, @Path("id") String id);
|
||||||
|
|
||||||
@GET("users/me/video-playlists/videos-exist")
|
@GET("users/me/video-playlists/videos-exist")
|
||||||
Call<List<PlaylistExist>> getVideoExistsInPlaylist(@Query("videoIds") List<String> videoIds);
|
Call<PlaylistExist> getVideoExistsInPlaylist(@Header("Authorization") String credentials, @Query("videoIds") List<String> videoIds);
|
||||||
|
|
||||||
@Multipart
|
@Multipart
|
||||||
@POST("video-playlists")
|
@POST("video-playlists")
|
||||||
|
@ -262,8 +262,9 @@ public interface PeertubeService {
|
||||||
@Part MultipartBody.Part thumbnailfil);
|
@Part MultipartBody.Part thumbnailfil);
|
||||||
|
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
@POST("video-playlists/{id}/videos")
|
@POST("video-playlists/{id}/videos")
|
||||||
Call<String> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Query("videoId") String videoId);
|
Call<String> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Field("videoId") String videoId);
|
||||||
|
|
||||||
|
|
||||||
@DELETE("video-playlists/{id}")
|
@DELETE("video-playlists/{id}")
|
||||||
|
|
|
@ -54,6 +54,7 @@ import app.fedilab.fedilabtube.client.entities.Oauth;
|
||||||
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
||||||
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
||||||
import app.fedilab.fedilabtube.client.entities.PeertubeInformation;
|
import app.fedilab.fedilabtube.client.entities.PeertubeInformation;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
||||||
import app.fedilab.fedilabtube.client.entities.Rating;
|
import app.fedilab.fedilabtube.client.entities.Rating;
|
||||||
import app.fedilab.fedilabtube.client.entities.Report;
|
import app.fedilab.fedilabtube.client.entities.Report;
|
||||||
|
@ -1052,6 +1053,31 @@ public class RetrofitPeertubeAPI {
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves playlists for a video *synchronously*
|
||||||
|
*
|
||||||
|
* @param videoIds List<String> ids of videos
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getVideosExist(List<String> videoIds) {
|
||||||
|
PeertubeService peertubeService = init();
|
||||||
|
APIResponse apiResponse = new APIResponse();
|
||||||
|
try {
|
||||||
|
Call<PlaylistExist> videoExistsInPlaylist = peertubeService.getVideoExistsInPlaylist(getToken(), videoIds);
|
||||||
|
Response<PlaylistExist> response = videoExistsInPlaylist.execute();
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
apiResponse.setVideoExistPlaylist(response.body().getVideoId());
|
||||||
|
} else {
|
||||||
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves playlist *synchronously*
|
* Retrieves playlist *synchronously*
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,8 +16,22 @@ package app.fedilab.fedilabtube.client.entities;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PlaylistExist {
|
public class PlaylistExist {
|
||||||
|
|
||||||
|
@SerializedName("videoId")
|
||||||
|
private List<VideoId> videoId;
|
||||||
|
|
||||||
|
public List<VideoId> getVideoId() {
|
||||||
|
return videoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoId(List<VideoId> videoId) {
|
||||||
|
this.videoId = videoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VideoId {
|
||||||
@SerializedName("playlistElementId")
|
@SerializedName("playlistElementId")
|
||||||
private String playlistElementId;
|
private String playlistElementId;
|
||||||
@SerializedName("playlistId")
|
@SerializedName("playlistId")
|
||||||
|
@ -58,4 +72,5 @@ public class PlaylistExist {
|
||||||
public void setStopTimestamp(long stopTimestamp) {
|
public void setStopTimestamp(long stopTimestamp) {
|
||||||
this.stopTimestamp = stopTimestamp;
|
this.stopTimestamp = stopTimestamp;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
|
@ -52,16 +53,16 @@ public class PlaylistsVM extends AndroidViewModel {
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> updateCreate(action apiAction, String playlistId, PlaylistParams playlistParams, File thumbnail) {
|
public LiveData<APIResponse> videoExists(List<String> videoIds) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
createOrUpdate(apiAction, playlistId, playlistParams, thumbnail);
|
checkVideosExist(videoIds);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOrUpdate(action apiAction, String playlistId, PlaylistParams playlistParams, File thumbnail) {
|
private void checkVideosExist(List<String> videoIds) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
APIResponse apiResponse = new RetrofitPeertubeAPI(_mContext).createOrUpdatePlaylist(apiAction, playlistId, playlistParams, thumbnail);
|
APIResponse apiResponse = new RetrofitPeertubeAPI(_mContext).getVideosExist(videoIds);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
|
@ -106,7 +107,6 @@ public class PlaylistsVM extends AndroidViewModel {
|
||||||
UPDATE_PLAYLIST,
|
UPDATE_PLAYLIST,
|
||||||
DELETE_PLAYLIST,
|
DELETE_PLAYLIST,
|
||||||
ADD_VIDEOS,
|
ADD_VIDEOS,
|
||||||
DELETE_VIDEOS,
|
DELETE_VIDEOS
|
||||||
GET_PLAYLIST_FOR_VIDEO,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,36 +14,59 @@
|
||||||
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
see <http://www.gnu.org/licenses>.
|
see <http://www.gnu.org/licenses>.
|
||||||
-->
|
-->
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
|
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
tools:openDrawer="start">
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
>
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?colorPrimary"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
/>
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:id="@+id/nav_host_fragment"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:defaultNavHost="true"
|
||||||
|
app:navGraph="@navigation/mobile_navigation" />
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/nav_view"
|
android:id="@+id/nav_view"
|
||||||
android:layout_width="0dp"
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="0dp"
|
||||||
android:layout_marginEnd="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
android:background="?android:attr/windowBackground"
|
android:background="?android:attr/windowBackground"
|
||||||
app:itemIconTint="@color/bottom_nav_color"
|
app:itemIconTint="@color/bottom_nav_color"
|
||||||
app:itemTextColor="@color/bottom_nav_color"
|
app:itemTextColor="@color/bottom_nav_color"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
/>
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
|
||||||
|
|
||||||
<fragment
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
android:id="@+id/nav_host_fragment"
|
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
app:defaultNavHost="true"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/nav_view"
|
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:navGraph="@navigation/mobile_navigation" />
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
Loading…
Reference in New Issue