Last fixes

This commit is contained in:
Thomas 2020-10-03 18:37:34 +02:00
parent 48fe22c8db
commit c774dcee96
16 changed files with 115 additions and 122 deletions

View File

@ -215,7 +215,7 @@ public class AccountActivity extends AppCompatActivity {
AlertDialog.Builder builderSingle = new AlertDialog.Builder(AccountActivity.this);
builderSingle.setTitle(getString(R.string.list_of_accounts));
if( accounts != null) {
if (accounts != null) {
final OwnAccountsAdapter accountsListAdapter = new OwnAccountsAdapter(AccountActivity.this, accounts);
final Account[] accountArray = new Account[accounts.size()];
int i = 0;

View File

@ -354,7 +354,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
idChannel = channelId[position];
if( position > 0 ) {
if (position > 0) {
selectedChannel = myChannels.get(position - 1);
}
}

View File

@ -98,12 +98,12 @@ public class MainActivity extends AppCompatActivity {
new Thread(() -> {
try {
Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
if( token == null) {
if (token == null) {
runOnUiThread(() -> Helper.logoutCurrentUser(MainActivity.this, account));
return;
}
UserMe userMe = new RetrofitPeertubeAPI(MainActivity.this, instance, token.getAccess_token()).verifyCredentials();
if( userMe != null && userMe.getAccount() != null) {
if (userMe != null && userMe.getAccount() != null) {
new AccountDAO(MainActivity.this, db).updateAccount(userMe.getAccount());
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_ID, account.getId());
@ -113,7 +113,7 @@ public class MainActivity extends AppCompatActivity {
Set<String> videoLanguageServerSet = new TreeSet<>(videoLanguageServer);
videoLanguageServerSet.addAll(videoLanguageServer);
Set<String> videoLanguageLocal = sharedpreferences.getStringSet(getString(R.string.set_video_language_choice), null);
if( videoLanguageServerSet.size() > 0 && videoLanguageLocal != null) {
if (videoLanguageServerSet.size() > 0 && videoLanguageLocal != null) {
videoLanguageServer.addAll(videoLanguageLocal);
}
editor.putStringSet(getString(R.string.set_video_language_choice), videoLanguageServerSet);

View File

@ -86,7 +86,9 @@ import com.google.android.exoplayer2.util.Util;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import app.fedilab.fedilabtube.client.APIResponse;
@ -154,7 +156,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
private List<Caption> captions;
private TextView no_action_text;
private String max_id;
private RecyclerView lv_comments;
private RecyclerView lv_comments;
private boolean flag_loading;
private List<Comment> comments;
@ -197,7 +199,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
if( Helper.isLoggedIn(PeertubeActivity.this)) {
if (Helper.isLoggedIn(PeertubeActivity.this)) {
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp);
}
@ -255,7 +257,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
getWindow().setAttributes(attrs);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
peertube_information_container.setVisibility(View.GONE);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
@ -303,7 +305,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, apiresponse ->manageVIewComment(apiresponse));
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
}
}
}
@ -363,11 +365,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube_playlist.setVisibility(View.VISIBLE);
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);
feedsViewModel.getVideo(videoId).observe(PeertubeActivity.this, this::manageVIewVideo);
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
@ -513,7 +510,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube = apiResponse.getPeertubes().get(0);
add_comment_read.setOnClickListener(v -> {
if (isLoggedIn(PeertubeActivity.this)) {
add_comment_read.setVisibility(View.GONE);
@ -545,7 +541,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube_playlist.setOnClickListener(v -> {
if (playlists != null && peertube.getId() != null) {
if (playlists != null && videoId != null) {
PopupMenu popup = new PopupMenu(PeertubeActivity.this, peertube_playlist);
for (Playlist playlist : playlists) {
@ -586,7 +582,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
playlistForVideo.remove(playlist.getId());
} else {
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, videoId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
playlistForVideo.add(playlist.getId());
}
return false;
@ -846,7 +842,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
@Override
public void onDestroy() {
super.onDestroy();
@ -931,7 +926,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(PeertubeActivity.this, android.R.layout.select_dialog_item);
for (File file : peertube.getFiles()) {
if (file.getResolutions() != null) {
if( file.getResolutions().getLabel().compareTo("0p") != 0) {
if (file.getResolutions().getLabel().compareTo("0p") != 0) {
arrayAdapter.add(file.getResolutions().getLabel());
}
}
@ -1026,10 +1021,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
fullScreenButton.setOnClickListener(v -> {
if (!fullScreenMode) {
openFullscreenDialog();
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
closeFullscreenDialog();
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Handler handler = new Handler();
handler.postDelayed(() -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR), 2000);
@ -1074,19 +1069,23 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
if (actionType == GET_PLAYLISTS && apiResponse != null) {
playlists = apiResponse.getPlaylists();
playlistsViewModel.videoExists(videoId).observe(PeertubeActivity.this, this::manageVIewVideosExist);
}
}
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());
if (apiResponse.getError() == null && apiResponse.getVideoExistPlaylist() != null) {
Map<String, List<PlaylistExist>> videoIds = apiResponse.getVideoExistPlaylist();
Iterator<Map.Entry<String, List<PlaylistExist>>> it = videoIds.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, List<PlaylistExist>> pair = it.next();
List<PlaylistExist> playlistExistVideo = pair.getValue();
for (PlaylistExist playlistExist : playlistExistVideo) {
playlistForVideo.add(playlistExist.getPlaylistId());
}
it.remove();
}
}
}

View File

@ -29,7 +29,7 @@ import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.client.data.VideoPlaylistData.VideoPlaylist;
import app.fedilab.fedilabtube.client.entities.Error;
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
import app.fedilab.fedilabtube.client.entities.PlaylistExist.VideoId;
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
import app.fedilab.fedilabtube.client.entities.Rating;
@SuppressWarnings({"unused", "RedundantSuppression"})
@ -41,7 +41,7 @@ public class APIResponse {
private String actionReturn = null;
private Rating rating;
private OverviewVideo overviewVideo = null;
private List<VideoId> videoExistPlaylist = null;
private Map<String, List<PlaylistExist>> videoExistPlaylist = null;
private List<VideoData.Video> peertubes = null;
private List<CommentData.Comment> comments = null;
private List<Block> muted;
@ -240,11 +240,11 @@ public class APIResponse {
this.videoPlaylist = videoPlaylist;
}
public List<VideoId> getVideoExistPlaylist() {
public Map<String, List<PlaylistExist>> getVideoExistPlaylist() {
return videoExistPlaylist;
}
public void setVideoExistPlaylist(List<VideoId> videoExistPlaylist) {
public void setVideoExistPlaylist(Map<String, List<PlaylistExist>> videoExistPlaylist) {
this.videoExistPlaylist = videoExistPlaylist;
}
}

View File

@ -238,7 +238,7 @@ public interface PeertubeService {
Call<VideoPlaylistData> getVideosPlayList(@Header("Authorization") String credentials, @Path("id") String id);
@GET("users/me/video-playlists/videos-exist")
Call<PlaylistExist> getVideoExistsInPlaylist(@Header("Authorization") String credentials, @Query("videoIds") List<String> videoIds);
Call<Map<String, List<PlaylistExist>>> getVideoExistsInPlaylist(@Header("Authorization") String credentials, @Query("videoIds") String videoIds);
@Multipart
@POST("video-playlists")
@ -264,7 +264,7 @@ public interface PeertubeService {
@FormUrlEncoded
@POST("video-playlists/{id}/videos")
Call<String> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Field("videoId") String videoId);
Call<VideoPlaylistData.PlaylistElement> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Field("videoId") String videoId);
@DELETE("video-playlists/{id}")

View File

@ -1060,14 +1060,14 @@ public class RetrofitPeertubeAPI {
* @param videoIds List<String> ids of videos
* @return APIResponse
*/
public APIResponse getVideosExist(List<String> videoIds) {
public APIResponse getVideosExist(String videoIds) {
PeertubeService peertubeService = init();
APIResponse apiResponse = new APIResponse();
try {
Call<PlaylistExist> videoExistsInPlaylist = peertubeService.getVideoExistsInPlaylist(getToken(), videoIds);
Response<PlaylistExist> response = videoExistsInPlaylist.execute();
Call<Map<String, List<PlaylistExist>>> videoExistsInPlaylist = peertubeService.getVideoExistsInPlaylist(getToken(), videoIds);
Response<Map<String, List<PlaylistExist>>> response = videoExistsInPlaylist.execute();
if (response.isSuccessful() && response.body() != null) {
apiResponse.setVideoExistPlaylist(response.body().getVideoId());
apiResponse.setVideoExistPlaylist(response.body());
} else {
setError(apiResponse, response.code(), response.errorBody());
}
@ -1111,7 +1111,7 @@ public class RetrofitPeertubeAPI {
} else {
setError(apiResponse, response.code(), response.errorBody());
}
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
Call<VideoPlaylistData> videosPlayList = peertubeService.getVideosPlayList(getToken(), playlistId);
Response<VideoPlaylistData> response = videosPlayList.execute();
if (response.isSuccessful() && response.body() != null) {
@ -1128,10 +1128,10 @@ public class RetrofitPeertubeAPI {
setError(apiResponse, response.code(), response.errorBody());
}
} else if (type == PlaylistsVM.action.ADD_VIDEOS) {
Call<String> stringCall = peertubeService.addVideoInPlaylist(getToken(), playlistId, videoId);
Response<String> response = stringCall.execute();
if (response.isSuccessful()) {
apiResponse.setActionReturn(response.body());
Call<VideoPlaylistData.PlaylistElement> stringCall = peertubeService.addVideoInPlaylist(getToken(), playlistId, videoId);
Response<VideoPlaylistData.PlaylistElement> response = stringCall.execute();
if (response.isSuccessful() && response.body() != null) {
apiResponse.setActionReturn(response.body().getVideoPlaylistElement().getId());
} else {
setError(apiResponse, response.code(), response.errorBody());
}

View File

@ -120,6 +120,19 @@ public class VideoPlaylistData {
}
}
public static class PlaylistElement {
@SerializedName("videoPlaylistElement")
private VideoPlaylistCreationItem videoPlaylistElement;
public VideoPlaylistCreationItem getVideoPlaylistElement() {
return videoPlaylistElement;
}
public void setVideoPlaylistElement(VideoPlaylistCreationItem videoPlaylistElement) {
this.videoPlaylistElement = videoPlaylistElement;
}
}
public static class VideoPlaylistCreationItem {
@SerializedName("id")
String id;

View File

@ -16,61 +16,48 @@ package app.fedilab.fedilabtube.client.entities;
import com.google.gson.annotations.SerializedName;
import java.util.List;
@SuppressWarnings({"unused", "RedundantSuppression"})
public class PlaylistExist {
@SerializedName("videoId")
private List<VideoId> videoId;
@SerializedName("playlistElementId")
private String playlistElementId;
@SerializedName("playlistId")
private String playlistId;
@SerializedName("startTimestamp")
private long startTimestamp;
@SerializedName("stopTimestamp")
private long stopTimestamp;
public List<VideoId> getVideoId() {
return videoId;
public String getPlaylistElementId() {
return playlistElementId;
}
public void setVideoId(List<VideoId> videoId) {
this.videoId = videoId;
public void setPlaylistElementId(String playlistElementId) {
this.playlistElementId = playlistElementId;
}
public static class VideoId {
@SerializedName("playlistElementId")
private String playlistElementId;
@SerializedName("playlistId")
private String playlistId;
@SerializedName("startTimestamp")
private long startTimestamp;
@SerializedName("stopTimestamp")
private long stopTimestamp;
public String getPlaylistId() {
return playlistId;
}
public String getPlaylistElementId() {
return playlistElementId;
}
public void setPlaylistId(String playlistId) {
this.playlistId = playlistId;
}
public void setPlaylistElementId(String playlistElementId) {
this.playlistElementId = playlistElementId;
}
public long getStartTimestamp() {
return startTimestamp;
}
public String getPlaylistId() {
return playlistId;
}
public void setStartTimestamp(long startTimestamp) {
this.startTimestamp = startTimestamp;
}
public void setPlaylistId(String playlistId) {
this.playlistId = playlistId;
}
public long getStopTimestamp() {
return stopTimestamp;
}
public long getStartTimestamp() {
return startTimestamp;
}
public void setStartTimestamp(long startTimestamp) {
this.startTimestamp = startTimestamp;
}
public long getStopTimestamp() {
return stopTimestamp;
}
public void setStopTimestamp(long stopTimestamp) {
this.stopTimestamp = stopTimestamp;
}
public void setStopTimestamp(long stopTimestamp) {
this.stopTimestamp = stopTimestamp;
}
}

View File

@ -124,7 +124,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
holder.bottom_container.setOnClickListener(v -> {
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putString("video_id", video.getUuid());
b.putString("video_id", video.getId());
intent.putExtras(b);
context.startActivity(intent);
});
@ -140,7 +140,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
holder.peertube_video_image.setOnClickListener(v -> {
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putString("video_id", video.getUuid());
b.putString("video_id", video.getId());
intent.putExtras(b);
context.startActivity(intent);
});

View File

@ -108,7 +108,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putString("peertube_instance", finalAccountAction1.getHost());
b.putString("video_id", notification.getComment().getVideo().getUuid());
b.putString("video_id", notification.getComment().getVideo().getId());
intent.putExtras(b);
context.startActivity(intent);
});
@ -142,11 +142,11 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putString("peertube_instance", Helper.getLiveInstance(context));
b.putString("video_id", notification.getVideo().getUuid());
b.putString("video_id", notification.getVideo().getId());
intent.putExtras(b);
context.startActivity(intent);
});
}else if (notification.getVideoAbuse() != null && notification.getVideoAbuse().getVideo() != null) {
} else if (notification.getVideoAbuse() != null && notification.getVideoAbuse().getVideo() != null) {
message = context.getString(R.string.peertube_video_abuse, notification.getVideoAbuse().getVideo().getName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));

View File

@ -44,6 +44,14 @@ import es.dmoral.toasty.Toasty;
public class DisplayNotificationsFragment extends Fragment {
//Peertube notification type
public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
public static int NEW_REPORT = 3;
public static int BLACKLIST_ON_MY_VIDEO = 4;
public static int UNBLACKLIST_ON_MY_VIDEO = 5;
public static int MY_VIDEO_PUBLISHED = 6;
public static int MY_VIDEO_IMPORT_SUCCESS = 7;
public static int MY_VIDEO_IMPORT_ERROR = 8;
private boolean flag_loading;
private Context context;
private PeertubeNotificationsListAdapter peertubeNotificationsListAdapter;
@ -56,16 +64,6 @@ public class DisplayNotificationsFragment extends Fragment {
private RecyclerView lv_notifications;
private View rootView;
//Peertube notification type
public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
public static int NEW_REPORT = 3;
public static int BLACKLIST_ON_MY_VIDEO = 4;
public static int UNBLACKLIST_ON_MY_VIDEO = 5;
public static int MY_VIDEO_PUBLISHED = 6;
public static int MY_VIDEO_IMPORT_SUCCESS = 7;
public static int MY_VIDEO_IMPORT_ERROR = 8;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View File

@ -109,8 +109,8 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
SeekBarPreference set_video_cache_choice = findPreference(getString(R.string.set_video_cache_choice));
assert set_video_cache_choice != null;
final int progress = set_video_cache_choice.getValue();
set_video_cache_choice.setSummary(getActivity().getString(R.string.video_cache_value, progress*10));
editor.putInt(Helper.SET_VIDEO_CACHE, progress*10);
set_video_cache_choice.setSummary(getActivity().getString(R.string.video_cache_value, progress * 10));
editor.putInt(Helper.SET_VIDEO_CACHE, progress * 10);
}
if (key.compareTo(getString(R.string.set_video_minimize_choice)) == 0) {
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
@ -171,7 +171,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
SeekBarPreference set_video_cache_choice = findPreference(getString(R.string.set_video_cache_choice));
int video_cache = sharedpref.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
assert set_video_cache_choice != null;
set_video_cache_choice.setValue(video_cache/10);
set_video_cache_choice.setValue(video_cache / 10);
boolean minimized = sharedpref.getBoolean(getString(R.string.set_video_minimize_choice), true);
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));

View File

@ -386,7 +386,7 @@ public class Helper {
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault());
df.applyPattern(df.toPattern().replaceAll("[^\\p{Alpha}]*y+[^\\p{Alpha}]*", ""));
return df.format(dateToot);
}catch (Exception e) {
} catch (Exception e) {
return format;
}
} else if (days > 0)
@ -699,18 +699,18 @@ public class Helper {
* @param files List<File>
* @return File
*/
public static File defaultFile(Context context, List<File> files){
public static File defaultFile(Context context, List<File> files) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
if( video_quality == QUALITY_HIGH) {
if (video_quality == QUALITY_HIGH) {
return files.get(0);
}else if( video_quality == QUALITY_LOW) {
return files.get(files.size() -1);
}else{
if( files.size() < 3) {
return files.get(files.size() -1);
}else{
int middle = files.size()/2 -1;
} else if (video_quality == QUALITY_LOW) {
return files.get(files.size() - 1);
} else {
if (files.size() < 3) {
return files.get(files.size() - 1);
} else {
int middle = files.size() / 2 - 1;
return files.get(middle);
}
}

View File

@ -300,7 +300,7 @@ public class AccountDAO {
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
//Close the cursor
c.close();
c.close();
//User is returned
return account;
@ -348,5 +348,4 @@ public class AccountDAO {
}
}

View File

@ -26,15 +26,12 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
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.Playlist;
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.sqlite.AccountDAO;
import app.fedilab.fedilabtube.sqlite.Sqlite;
@ -53,13 +50,13 @@ public class PlaylistsVM extends AndroidViewModel {
return apiResponseMutableLiveData;
}
public LiveData<APIResponse> videoExists(List<String> videoIds) {
public LiveData<APIResponse> videoExists(String videoIds) {
apiResponseMutableLiveData = new MutableLiveData<>();
checkVideosExist(videoIds);
return apiResponseMutableLiveData;
}
private void checkVideosExist(List<String> videoIds) {
private void checkVideosExist(String videoIds) {
Context _mContext = getApplication().getApplicationContext();
new Thread(() -> {
APIResponse apiResponse = new RetrofitPeertubeAPI(_mContext).getVideosExist(videoIds);