summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java13
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java4
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java15
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/ShownotesProvider.java16
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java10
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java30
-rw-r--r--core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java16
-rw-r--r--core/src/test/java/de/danoeh/antennapod/core/feed/FeedItemTest.java20
-rw-r--r--core/src/test/java/de/danoeh/antennapod/core/util/playback/TimelineTest.java85
11 files changed, 82 insertions, 151 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java
index 3466f6ce8..2e13bbd79 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java
@@ -10,6 +10,9 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.core.feed.FeedMedia;
+import de.danoeh.antennapod.core.storage.DBReader;
+import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackController;
import de.danoeh.antennapod.core.util.playback.Timeline;
import de.danoeh.antennapod.view.ShownotesWebView;
@@ -82,7 +85,15 @@ public class ItemDescriptionFragment extends Fragment {
webViewLoader.dispose();
}
webViewLoader = Maybe.<String>create(emitter -> {
- Timeline timeline = new Timeline(getActivity(), controller.getMedia());
+ Playable media = controller.getMedia();
+ if (media instanceof FeedMedia) {
+ FeedMedia feedMedia = ((FeedMedia) media);
+ if (feedMedia.getItem() == null) {
+ feedMedia.setItem(DBReader.getFeedItem(feedMedia.getItemId()));
+ }
+ DBReader.loadDescriptionOfFeedItem(feedMedia.getItem());
+ }
+ Timeline timeline = new Timeline(getActivity(), media.getDescription(), media.getDuration());
emitter.onSuccess(timeline.processShownotes());
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java
index 48eae9583..224210d63 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java
@@ -439,7 +439,9 @@ public class ItemFragment extends Fragment {
FeedItem feedItem = DBReader.getFeedItem(itemId);
Context context = getContext();
if (feedItem != null && context != null) {
- Timeline t = new Timeline(context, feedItem);
+ int duration = feedItem.getMedia() != null ? feedItem.getMedia().getDuration() : Integer.MAX_VALUE;
+ DBReader.loadDescriptionOfFeedItem(feedItem);
+ Timeline t = new Timeline(context, feedItem.getDescription(), duration);
webviewData = t.processShownotes();
}
return feedItem;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
index 133caaebd..d6926385e 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
@@ -13,19 +13,16 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
-import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
-import de.danoeh.antennapod.core.util.ShownotesProvider;
/**
* Item (episode) within a feed.
*
* @author daniel
*/
-public class FeedItem extends FeedComponent implements ShownotesProvider, Serializable {
+public class FeedItem extends FeedComponent implements Serializable {
/** tag that indicates this item is in the queue */
public static final String TAG_QUEUE = "Queue";
@@ -352,16 +349,6 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Serial
return media != null && media.isPlaying();
}
- @Override
- public Callable<String> loadShownotes() {
- return () -> {
- if (description == null) {
- DBReader.loadDescriptionOfFeedItem(FeedItem.this);
- }
- return description;
- };
- }
-
public String getImageLocation() {
if (imageUrl != null) {
return imageUrl;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
index 34c9b8ca7..3070f882c 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
@@ -14,7 +14,6 @@ import android.support.v4.media.MediaDescriptionCompat;
import java.util.Date;
import java.util.List;
-import java.util.concurrent.Callable;
import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
@@ -286,6 +285,14 @@ public class FeedMedia extends FeedFile implements Playable {
this.size = size;
}
+ @Override
+ public String getDescription() {
+ if (item != null) {
+ return item.getDescription();
+ }
+ return null;
+ }
+
/**
* Indicates we asked the service what the size was, but didn't
* get a valid answer and we shoudln't check using the network again.
@@ -529,16 +536,6 @@ public class FeedMedia extends FeedFile implements Playable {
}
}
- @Override
- public Callable<String> loadShownotes() {
- return () -> {
- if (item == null) {
- item = DBReader.getFeedItem(itemID);
- }
- return item.loadShownotes().call();
- };
- }
-
public static final Parcelable.Creator<FeedMedia> CREATOR = new Parcelable.Creator<FeedMedia>() {
public FeedMedia createFromParcel(Parcel in) {
final long id = in.readLong();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/ShownotesProvider.java b/core/src/main/java/de/danoeh/antennapod/core/util/ShownotesProvider.java
deleted file mode 100644
index a4cd83f70..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/util/ShownotesProvider.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package de.danoeh.antennapod.core.util;
-
-import java.util.concurrent.Callable;
-
-/**
- * Created by daniel on 04.08.13.
- */
-public interface ShownotesProvider {
- /**
- * Loads shownotes. If the shownotes have to be loaded from a file or from a
- * database, it should be done in a separate thread. After the shownotes
- * have been loaded, callback.onShownotesLoaded should be called.
- */
- Callable<String> loadShownotes();
-
-}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java
index f103b32bf..feba6db1c 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Playable.java
@@ -7,14 +7,13 @@ import android.os.Parcelable;
import androidx.annotation.Nullable;
import de.danoeh.antennapod.core.feed.Chapter;
import de.danoeh.antennapod.core.feed.MediaType;
-import de.danoeh.antennapod.core.util.ShownotesProvider;
import java.util.Date;
import java.util.List;
/**
* Interface for objects that can be played by the PlaybackService.
*/
-public interface Playable extends Parcelable, ShownotesProvider {
+public interface Playable extends Parcelable {
public static final int INVALID_TIME = -1;
/**
@@ -83,6 +82,13 @@ public interface Playable extends Parcelable, ShownotesProvider {
long getLastPlayedTime();
/**
+ * Returns the description of the item, if available.
+ * For FeedItems, the description needs to be loaded from the database first.
+ */
+ @Nullable
+ String getDescription();
+
+ /**
* Returns the type of media. This method should return the correct value
* BEFORE loadMetadata() is called.
*/
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java
index 219edd2e7..926eaa315 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/RemoteMedia.java
@@ -13,7 +13,6 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.MediaType;
import java.util.Date;
import java.util.List;
-import java.util.concurrent.Callable;
import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
@@ -260,8 +259,8 @@ public class RemoteMedia implements Playable {
}
@Override
- public Callable<String> loadShownotes() {
- return () -> (notes != null) ? notes : "";
+ public String getDescription() {
+ return notes;
}
@Override
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java
index 40849a262..e125c7e66 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java
@@ -9,7 +9,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
-import de.danoeh.antennapod.core.feed.FeedItem;
+import androidx.annotation.Nullable;
import org.apache.commons.io.IOUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@@ -24,7 +24,6 @@ import java.util.regex.Pattern;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.util.Converter;
-import de.danoeh.antennapod.core.util.ShownotesProvider;
/**
* Connects chapter information and shownotes of a shownotesProvider, for example by making it possible to use the
@@ -42,17 +41,16 @@ public class Timeline {
private static final Pattern TIMECODE_REGEX = Pattern.compile("\\b((\\d+):)?(\\d+):(\\d{2})\\b");
private static final Pattern LINE_BREAK_REGEX = Pattern.compile("<br */?>");
- private final ShownotesProvider shownotesProvider;
+ private final String rawShownotes;
private final String noShownotesLabel;
+ private final int playableDuration;
private final String webviewStyle;
- public Timeline(Context context, ShownotesProvider shownotesProvider) {
- if (shownotesProvider == null) {
- throw new IllegalArgumentException("shownotesProvider = null");
- }
- this.shownotesProvider = shownotesProvider;
+ public Timeline(Context context, @Nullable String rawShownotes, int playableDuration) {
+ this.rawShownotes = rawShownotes;
noShownotesLabel = context.getString(R.string.no_shownotes_label);
+ this.playableDuration = playableDuration;
final String colorPrimary = colorToHtml(context, android.R.attr.textColorPrimary);
final String colorAccent = colorToHtml(context, R.attr.colorAccent);
final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
@@ -87,13 +85,7 @@ public class Timeline {
*/
@NonNull
public String processShownotes() {
- String shownotes;
- try {
- shownotes = shownotesProvider.loadShownotes().call();
- } catch (Exception e) {
- Log.e(TAG, "processShownotes() - encounters exceptions unexpectedly in load, treat as if no shownotes.", e);
- shownotes = "";
- }
+ String shownotes = rawShownotes;
if (TextUtils.isEmpty(shownotes)) {
Log.d(TAG, "shownotesProvider contained no shownotes. Returning 'no shownotes' message");
@@ -147,14 +139,6 @@ public class Timeline {
// No elements with timecodes
return;
}
-
- int playableDuration = Integer.MAX_VALUE;
- if (shownotesProvider instanceof Playable) {
- playableDuration = ((Playable) shownotesProvider).getDuration();
- } else if (shownotesProvider instanceof FeedItem && ((FeedItem) shownotesProvider).getMedia() != null) {
- playableDuration = ((FeedItem) shownotesProvider).getMedia().getDuration();
- }
-
boolean useHourFormat = true;
if (playableDuration != Integer.MAX_VALUE) {
diff --git a/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java b/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java
index ffb70adb4..3884041b6 100644
--- a/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java
+++ b/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java
@@ -130,18 +130,12 @@ public class CastUtils {
if (!TextUtils.isEmpty(feedItem.getLink())) {
metadata.putString(KEY_EPISODE_LINK, feedItem.getLink());
}
- }
- String notes = null;
- try {
- notes = media.loadShownotes().call();
- } catch (Exception e) {
- Log.e(TAG, "Unable to load FeedMedia notes", e);
- }
- if (notes != null) {
- if (notes.length() > EPISODE_NOTES_MAX_LENGTH) {
- notes = notes.substring(0, EPISODE_NOTES_MAX_LENGTH);
+ try {
+ DBReader.loadDescriptionOfFeedItem(feedItem);
+ metadata.putString(KEY_EPISODE_NOTES, feedItem.getDescription());
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to load FeedMedia notes", e);
}
- metadata.putString(KEY_EPISODE_NOTES, notes);
}
// This field only identifies the id on the device that has the original version.
// Idea is to perhaps, on a first approach, check if the version on the local DB with the
diff --git a/core/src/test/java/de/danoeh/antennapod/core/feed/FeedItemTest.java b/core/src/test/java/de/danoeh/antennapod/core/feed/FeedItemTest.java
index f375adf5d..4d9c247f7 100644
--- a/core/src/test/java/de/danoeh/antennapod/core/feed/FeedItemTest.java
+++ b/core/src/test/java/de/danoeh/antennapod/core/feed/FeedItemTest.java
@@ -2,14 +2,10 @@ package de.danoeh.antennapod.core.feed;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockedStatic;
-import org.mockito.Mockito;
import java.text.SimpleDateFormat;
import java.util.Date;
-import de.danoeh.antennapod.core.storage.DBReader;
-
import static de.danoeh.antennapod.core.feed.FeedItemMother.anyFeedItemWithImage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -113,7 +109,7 @@ public class FeedItemTest {
* If one of `description` or `content:encoded` is null, use the other one.
*/
@Test
- public void testShownotesNullValues() throws Exception {
+ public void testShownotesNullValues() {
testShownotes(null, TEXT_LONG);
testShownotes(TEXT_LONG, null);
}
@@ -122,7 +118,7 @@ public class FeedItemTest {
* If `description` is reasonably longer than `content:encoded`, use `description`.
*/
@Test
- public void testShownotesLength() throws Exception {
+ public void testShownotesLength() {
testShownotes(TEXT_SHORT, TEXT_LONG);
testShownotes(TEXT_LONG, TEXT_SHORT);
}
@@ -133,12 +129,10 @@ public class FeedItemTest {
* @param description Description of the feed item
* @param contentEncoded `content:encoded` of the feed item
*/
- private void testShownotes(String description, String contentEncoded) throws Exception {
- try (MockedStatic<DBReader> ignore = Mockito.mockStatic(DBReader.class)) {
- FeedItem item = new FeedItem();
- item.setDescriptionIfLonger(description);
- item.setDescriptionIfLonger(contentEncoded);
- assertEquals(TEXT_LONG, item.loadShownotes().call());
- }
+ private void testShownotes(String description, String contentEncoded) {
+ FeedItem item = new FeedItem();
+ item.setDescriptionIfLonger(description);
+ item.setDescriptionIfLonger(contentEncoded);
+ assertEquals(TEXT_LONG, item.getDescription());
}
} \ No newline at end of file
diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/playback/TimelineTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/playback/TimelineTest.java
index 2b354dcb9..987a75981 100644
--- a/core/src/test/java/de/danoeh/antennapod/core/util/playback/TimelineTest.java
+++ b/core/src/test/java/de/danoeh/antennapod/core/util/playback/TimelineTest.java
@@ -7,13 +7,6 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
-
-import java.util.Date;
-import java.util.List;
-
-import de.danoeh.antennapod.core.feed.Chapter;
-import de.danoeh.antennapod.core.feed.FeedItem;
-import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.storage.DBReader;
import org.junit.After;
@@ -51,25 +44,13 @@ public class TimelineTest {
dbReaderMock.close();
}
- @SuppressWarnings("SameParameterValue")
- private Playable newTestPlayable(List<Chapter> chapters, String shownotes, int duration) {
- FeedItem item = new FeedItem(0, "Item", "item-id", "http://example.com/item", new Date(), FeedItem.PLAYED, null);
- item.setChapters(chapters);
- item.setDescriptionIfLonger(shownotes);
- FeedMedia media = new FeedMedia(item, "http://example.com/episode", 100, "audio/mp3");
- media.setDuration(duration);
- item.setMedia(media);
- return media;
- }
-
@Test
public void testProcessShownotesAddTimecodeHhmmssNoChapters() {
final String timeStr = "10:11:12";
final long time = 3600 * 1000 * 10 + 60 * 1000 * 11 + 12 * 1000;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStr + " here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -79,9 +60,8 @@ public class TimelineTest {
final String timeStr = "25:00:00";
final long time = 25 * 60 * 60 * 1000;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStr + " here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -91,9 +71,8 @@ public class TimelineTest {
final String timeStr = "10:11";
final long time = 3600 * 1000 * 10 + 60 * 1000 * 11;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStr + " here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -103,9 +82,8 @@ public class TimelineTest {
final String timeStr = "10:11";
final long time = 10 * 60 * 1000 + 11 * 1000;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStr + " here.</p>", 11 * 60 * 1000);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, 11 * 60 * 1000);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -114,9 +92,9 @@ public class TimelineTest {
public void testProcessShownotesAddTimecodeHmmssNoChapters() {
final String timeStr = "2:11:12";
final long time = 2 * 60 * 60 * 1000 + 11 * 60 * 1000 + 12 * 1000;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStr + " here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -126,9 +104,8 @@ public class TimelineTest {
final String timeStr = "1:12";
final long time = 60 * 1000 + 12 * 1000;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStr + " here.</p>", 2 * 60 * 1000);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, 2 * 60 * 1000);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -137,9 +114,9 @@ public class TimelineTest {
public void testProcessShownotesAddNoTimecodeDuration() {
final String timeStr = "2:11:12";
final int time = 2 * 60 * 60 * 1000 + 11 * 60 * 1000 + 12 * 1000;
- String originalText = "<p> Some test text with a timecode " + timeStr + " here.</p>";
- Playable p = newTestPlayable(null, originalText, time);
- Timeline t = new Timeline(context, p);
+
+ String shownotes = "<p> Some test text with a timecode " + timeStr + " here.</p>";
+ Timeline t = new Timeline(context, shownotes, time);
String res = t.processShownotes();
Document d = Jsoup.parse(res);
assertEquals("Should not parse time codes that equal duration", 0, d.body().getElementsByTag("a").size());
@@ -149,9 +126,9 @@ public class TimelineTest {
public void testProcessShownotesAddTimecodeMultipleFormatsNoChapters() {
final String[] timeStrings = new String[]{ "10:12", "1:10:12" };
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStrings[0] + " here. Hey look another one " + timeStrings[1] + " here!</p>", 2 * 60 * 60 * 1000);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStrings[0]
+ + " here. Hey look another one " + timeStrings[1] + " here!</p>";
+ Timeline t = new Timeline(context, shownotes, 2 * 60 * 60 * 1000);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{10 * 60 * 1000 + 12 * 1000,
60 * 60 * 1000 + 10 * 60 * 1000 + 12 * 1000}, timeStrings);
@@ -163,9 +140,9 @@ public class TimelineTest {
// One of these timecodes fits as HH:MM and one does not so both should be parsed as MM:SS.
final String[] timeStrings = new String[]{ "10:12", "2:12" };
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode "
- + timeStrings[0] + " here. Hey look another one " + timeStrings[1] + " here!</p>", 3 * 60 * 60 * 1000);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode " + timeStrings[0]
+ + " here. Hey look another one " + timeStrings[1] + " here!</p>";
+ Timeline t = new Timeline(context, shownotes, 3 * 60 * 60 * 1000);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{10 * 60 * 1000 + 12 * 1000, 2 * 60 * 1000 + 12 * 1000}, timeStrings);
}
@@ -175,9 +152,8 @@ public class TimelineTest {
final String timeStr = "10:11";
final long time = 3600 * 1000 * 10 + 60 * 1000 * 11;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode ("
- + timeStr + ") here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode (" + timeStr + ") here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -187,9 +163,8 @@ public class TimelineTest {
final String timeStr = "10:11";
final long time = 3600 * 1000 * 10 + 60 * 1000 * 11;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode ["
- + timeStr + "] here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode [" + timeStr + "] here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -199,9 +174,8 @@ public class TimelineTest {
final String timeStr = "10:11";
final long time = 3600 * 1000 * 10 + 60 * 1000 * 11;
- Playable p = newTestPlayable(null, "<p> Some test text with a timecode <"
- + timeStr + "> here.</p>", Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ String shownotes = "<p> Some test text with a timecode <" + timeStr + "> here.</p>";
+ Timeline t = new Timeline(context, shownotes, Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[]{time}, new String[]{timeStr});
}
@@ -216,8 +190,7 @@ public class TimelineTest {
}
shownotes.append("here.</p>");
- Playable p = newTestPlayable(null, shownotes.toString(), Integer.MAX_VALUE);
- Timeline t = new Timeline(context, p);
+ Timeline t = new Timeline(context, shownotes.toString(), Integer.MAX_VALUE);
String res = t.processShownotes();
checkLinkCorrect(res, new long[0], new String[0]);
}