From af506639a98f61e753850300e5efb80b879657d7 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 13 Nov 2015 12:46:55 +0300 Subject: [PATCH 1/2] remove quotation marks added by weblate --- app/src/main/res/values-ru/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 1a1777db9..73475f175 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -4,7 +4,7 @@ NewPipe Ничего не найдено просмотров - "Опубликовано: " + Опубликовано: Ни одного потокового проигрывателя не было найдено. Установить? Установить Отмена From cc7ce5cf93b53754c97e21171cea55d7652606d1 Mon Sep 17 00:00:00 2001 From: Adam Howard Date: Fri, 13 Nov 2015 10:47:05 +0000 Subject: [PATCH 2/2] fixed inefficient double-conversion of parceled VideoInfoItems, from being cast from VideoInfoItem[] to Vector<>, to using ArrayList as an implementation of List --- app/src/main/java/org/schabi/newpipe/VideoInfo.java | 2 +- app/src/main/java/org/schabi/newpipe/VideoInfoItem.java | 1 + .../java/org/schabi/newpipe/VideoItemListActivity.java | 7 ++++--- .../java/org/schabi/newpipe/VideoItemListFragment.java | 9 ++++----- .../main/java/org/schabi/newpipe/VideoListAdapter.java | 3 ++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/VideoInfo.java b/app/src/main/java/org/schabi/newpipe/VideoInfo.java index 2b8dfc8e9..e0d985d8e 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoInfo.java +++ b/app/src/main/java/org/schabi/newpipe/VideoInfo.java @@ -26,7 +26,7 @@ import java.util.Vector; * along with NewPipe. If not, see . */ - +/**Info object for opened videos, ie the video ready to play.*/ public class VideoInfo { public String id = ""; public String title = ""; diff --git a/app/src/main/java/org/schabi/newpipe/VideoInfoItem.java b/app/src/main/java/org/schabi/newpipe/VideoInfoItem.java index dca5f0edc..7516723b6 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoInfoItem.java +++ b/app/src/main/java/org/schabi/newpipe/VideoInfoItem.java @@ -24,6 +24,7 @@ import android.os.Parcelable; * along with NewPipe. If not, see . */ +/**Info object for previews of unopened videos, eg search results, related videos*/ public class VideoInfoItem implements Parcelable { public String id = ""; public String title = ""; diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java index 856497649..90892ca5e 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java @@ -16,6 +16,7 @@ import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.ImageView; +import java.util.ArrayList; import java.util.Arrays; /** @@ -114,13 +115,13 @@ public class VideoItemListActivity extends AppCompatActivity Bundle arguments = getIntent().getExtras(); if(arguments != null) { - Parcelable[] p = arguments.getParcelableArray(VIDEO_INFO_ITEMS); + //Parcelable[] p = arguments.getParcelableArray(VIDEO_INFO_ITEMS); + ArrayList p = arguments.getParcelableArrayList(VIDEO_INFO_ITEMS); if(p != null) { mode = PRESENT_VIDEOS_MODE; getSupportActionBar().setDisplayHomeAsUpEnabled(true); - //todo: make this more efficient - listFragment.present(Arrays.copyOf(p, p.length, VideoInfoItem[].class)); + listFragment.present(p); } } diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java index c9f6c0cd7..5bab9669b 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java @@ -16,6 +16,7 @@ import android.widget.Toast; import java.net.URL; import java.util.Arrays; +import java.util.List; import java.util.Vector; @@ -167,14 +168,12 @@ public class VideoItemListFragment extends ListFragment { } } - public void present(VideoInfoItem[] videoList) { + public void present(List videoList) { mode = PRESENT_VIDEOS_MODE; setListShown(true); getListView().smoothScrollToPosition(0); - // inefficient like hell i know (welcome to the world of java) - //todo: make this more efficient - updateList(new Vector<>(Arrays.asList(videoList))); + updateList(videoList); } public void search(String query) { @@ -221,7 +220,7 @@ public class VideoItemListFragment extends ListFragment { } } - private void updateList(Vector list) { + private void updateList(List list) { try { videoListAdapter.addVideoList(list); terminateThreads(); diff --git a/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java b/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java index c174528c6..87bd3b8aa 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java @@ -9,6 +9,7 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ListView; +import java.util.List; import java.util.Vector; /** @@ -48,7 +49,7 @@ public class VideoListAdapter extends BaseAdapter { this.context = context; } - public void addVideoList(Vector videos) { + public void addVideoList(List videos) { videoList.addAll(videos); for(int i = 0; i < videos.size(); i++) { downloadedThumbnailList.add(false);