From f4698f13129f2c2273223dd26f0dbcd854a1011d Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 6 Dec 2020 10:46:18 +0100 Subject: [PATCH] Issue #133 - history not working in URL --- .../java/app/fedilab/fedilabtube/MainActivity.java | 2 +- .../app/fedilab/fedilabtube/PeertubeActivity.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java index 2479668..6388aca 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java @@ -549,7 +549,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { - Pattern link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$"); + Pattern link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})(\\?start=(\\d+[hH])?(\\d+[mM])?(\\d+[sS])?)?$"); Matcher matcherLink = link.matcher(query.trim()); if (matcherLink.find()) { Intent intent = new Intent(MainActivity.this, PeertubeActivity.class); diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 38db5e8..6ffb008 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -610,7 +610,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd peertube.setEmbedUrl(url); if (totalSeconds > 0) { VideoData.UserHistory userHistory = new VideoData.UserHistory(); - userHistory.setCurrentTime(totalSeconds * 1000); + userHistory.setCurrentTime(totalSeconds); peertube.setUserHistory(userHistory); } TimelineVM viewModelTimeline = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class); @@ -925,7 +925,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd isRemote = true; if (totalSeconds > 0) { VideoData.UserHistory userHistory = new VideoData.UserHistory(); - userHistory.setCurrentTime(totalSeconds * 1000); + userHistory.setCurrentTime(totalSeconds); peertube.setUserHistory(userHistory); } TimelineVM viewModelTimeline = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class); @@ -951,7 +951,14 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd } long position = -1; + long previousPositionHistory = 0; + if (peertube != null && peertube.getUserHistory() != null) { + previousPositionHistory = peertube.getUserHistory().getCurrentTime(); + } peertube = apiResponse.getPeertubes().get(0); + VideoData.UserHistory userHistory = new VideoData.UserHistory(); + userHistory.setCurrentTime(previousPositionHistory); + peertube.setUserHistory(userHistory); if (peertube.getUserHistory() != null) { position = peertube.getUserHistory().getCurrentTime() * 1000;