Fix issue #14
This commit is contained in:
parent
aecb4034ad
commit
4f909417f1
|
@ -481,7 +481,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
setFullscreen(FullScreenMediaController.fullscreen.OFF);
|
setFullscreen(FullScreenMediaController.fullscreen.OFF);
|
||||||
fullScreenMode = false;
|
fullScreenMode = false;
|
||||||
}
|
}
|
||||||
|
updateHistory(0);
|
||||||
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
||||||
binding.peertubeBookmark.setVisibility(View.GONE);
|
binding.peertubeBookmark.setVisibility(View.GONE);
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
||||||
|
@ -944,6 +944,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
if( player != null) {
|
||||||
|
updateHistory(player.getCurrentPosition()/1000);
|
||||||
|
}
|
||||||
if (player != null && !isPlayInMinimized) {
|
if (player != null && !isPlayInMinimized) {
|
||||||
player.setPlayWhenReady(false);
|
player.setPlayWhenReady(false);
|
||||||
}
|
}
|
||||||
|
@ -1393,6 +1396,20 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateHistory(long position) {
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
boolean storeInHistory = sharedpreferences.getBoolean(getString(R.string.set_store_in_history), true);
|
||||||
|
if( Helper.isLoggedIn(PeertubeActivity.this) && peertube != null && storeInHistory) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(PeertubeActivity.this);
|
||||||
|
api.updateHistory(peertube.getUuid(), position);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAllCommentRemoved() {
|
public void onAllCommentRemoved() {
|
||||||
|
|
|
@ -114,6 +114,15 @@ public interface PeertubeService {
|
||||||
@GET("users/me")
|
@GET("users/me")
|
||||||
Call<UserMe> verifyCredentials(@Header("Authorization") String credentials);
|
Call<UserMe> verifyCredentials(@Header("Authorization") String credentials);
|
||||||
|
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@PUT("videos/{id}/watching")
|
||||||
|
Call<String> addToHistory(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id,
|
||||||
|
@Field("currentTime") long currentTime);
|
||||||
|
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@PUT("users/me")
|
@PUT("users/me")
|
||||||
Call<String> updateUser(
|
Call<String> updateUser(
|
||||||
|
|
|
@ -421,14 +421,37 @@ public class RetrofitPeertubeAPI {
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update history
|
||||||
|
*
|
||||||
|
* @param videoId String
|
||||||
|
* @param currentTime int
|
||||||
|
*/
|
||||||
|
public void updateHistory(String videoId, long currentTime) {
|
||||||
|
APIResponse apiResponse = new APIResponse();
|
||||||
|
PeertubeService peertubeService = init();
|
||||||
|
Call<String> updateUser = peertubeService.addToHistory(getToken(),
|
||||||
|
videoId,
|
||||||
|
currentTime
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
Response<String> response = updateUser.execute();
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
apiResponse.setActionReturn(response.body());
|
||||||
|
} else {
|
||||||
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update account information
|
* Update account information
|
||||||
*
|
*
|
||||||
* @param userSettings UserSettings
|
* @param userSettings UserSettings
|
||||||
* @return APIResponse
|
|
||||||
*/
|
*/
|
||||||
public APIResponse updateUser(UserSettings userSettings) {
|
public void updateUser(UserSettings userSettings) {
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<String> updateUser = peertubeService.updateUser(getToken(),
|
Call<String> updateUser = peertubeService.updateUser(getToken(),
|
||||||
|
@ -454,7 +477,6 @@ public class RetrofitPeertubeAPI {
|
||||||
MultipartBody.Part bodyThumbnail = MultipartBody.Part.createFormData("avatarfile", userSettings.getAvatarfile().getName(), requestFile);
|
MultipartBody.Part bodyThumbnail = MultipartBody.Part.createFormData("avatarfile", userSettings.getAvatarfile().getName(), requestFile);
|
||||||
Call<String> updateProfilePicture = peertubeService.updateProfilePicture(getToken(), bodyThumbnail);
|
Call<String> updateProfilePicture = peertubeService.updateProfilePicture(getToken(), bodyThumbnail);
|
||||||
}
|
}
|
||||||
return apiResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue