Format code and remove unused methods

This commit is contained in:
Coffeemakr 2017-06-18 15:43:11 +02:00
parent 71e963c853
commit ae2b0cc76b
4 changed files with 213 additions and 237 deletions

View File

@ -19,8 +19,6 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
@ -56,11 +54,9 @@ import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.stream_info.AudioStream;
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
import org.schabi.newpipe.extractor.stream_info.StreamInfoItem;
import org.schabi.newpipe.extractor.stream_info.VideoStream;
import org.schabi.newpipe.fragments.BaseFragment;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.info_list.InfoListAdapter;
import org.schabi.newpipe.player.MainVideoPlayer;
import org.schabi.newpipe.player.PlayVideoActivity;
import org.schabi.newpipe.player.PopupVideoPlayer;

View File

@ -57,10 +57,14 @@ public class InfoItemBuilder {
}
private ImageLoader imageLoader = ImageLoader.getInstance();
/** Base display options */
private static final DisplayImageOptions DISPLAY_IMAGE_OPTIONS =
new DisplayImageOptions.Builder()
.cacheInMemory(true)
.build();
/** Display options for stream thumbnails */
private static final DisplayImageOptions DISPLAY_STREAM_THUMBNAIL_OPTIONS =
new DisplayImageOptions.Builder()
.cloneFrom(DISPLAY_IMAGE_OPTIONS)
@ -69,6 +73,7 @@ public class InfoItemBuilder {
.showImageOnLoading(R.drawable.dummy_thumbnail)
.build();
/** Display options for channel thumbnails */
private static final DisplayImageOptions DISPLAY_CHANNEL_THUMBNAIL_OPTIONS =
new DisplayImageOptions.Builder()
.cloneFrom(DISPLAY_IMAGE_OPTIONS)

View File

@ -38,7 +38,7 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
private static final String TAG = InfoListAdapter.class.toString();
private final InfoItemBuilder infoItemBuilder;
private final InfoItemList infoItemList;
private final ArrayList<InfoItem> infoItemList;
private boolean showFooter = false;
private View header = null;
private View footer = null;
@ -58,7 +58,7 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
public InfoListAdapter(Activity a) {
infoItemBuilder = new InfoItemBuilder(a);
infoItemList = new InfoItemList();
infoItemList = new ArrayList<>();
}
public void setOnStreamInfoItemSelectedListener
@ -79,14 +79,6 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
}
public void addInfoItem(InfoItem infoItem) {
if(infoItem == null) {
throw new NullPointerException("infoItem is null");
}
infoItemList.add(infoItem);
notifyItemInserted(infoItemList.size());
}
public void clearStreamItemList() {
if(infoItemList.isEmpty()) {
return;
@ -109,15 +101,6 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
return infoItemList;
}
/**
* Removes all items in a given range
* @param fromIndex from index inclusive
* @param toIndex to index excluseive
*/
public void removeItemRange(int fromIndex, int toIndex) {
infoItemList.removeRange(fromIndex, toIndex);
}
@Override
public int getItemCount() {
int count = infoItemList.size();
@ -186,11 +169,4 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
((HFHolder) holder).view = footer;
}
}
private class InfoItemList extends ArrayList<InfoItem> {
@Override
protected void removeRange(int fromIndex, int toIndex) {
super.removeRange(fromIndex, toIndex);
}
}
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/video_item_detail"
@ -43,12 +42,12 @@
android:id="@+id/detail_thumbnail_play_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:src="@drawable/new_play_arrow"
android:visibility="invisible"
tools:ignore="ContentDescription"
tools:visibility="visible"
android:layout_gravity="center"/>
tools:visibility="visible" />
</FrameLayout>
@ -57,9 +56,9 @@
android:id="@+id/detail_content_root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?android:windowBackground"
android:gravity="center_horizontal"
android:background="?android:windowBackground">
android:orientation="vertical">
<!-- TITLE -->
<FrameLayout
@ -75,11 +74,11 @@
android:id="@+id/detail_video_title_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="8dp"
android:paddingTop="12dp"
android:layout_marginRight="20dp"
android:ellipsize="end"
android:maxLines="1"
android:layout_marginRight="20dp"
android:paddingBottom="8dp"
android:paddingTop="12dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_title_text_size"
tools:ignore="RtlHardcoded"
@ -89,9 +88,9 @@
android:id="@+id/detail_toggle_description_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:src="@drawable/arrow_down"
android:layout_gravity="center_vertical|right"
tools:ignore="ContentDescription,RtlHardcoded" />
</FrameLayout>
@ -100,9 +99,9 @@
android:id="@+id/detail_content_root_hiding"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible"
android:orientation="vertical">
tools:visibility="visible">
<!--DETAIL-->
<RelativeLayout
@ -111,9 +110,9 @@
android:layout_height="55dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="6dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:layout_marginTop="6dp">
android:orientation="horizontal">
<!-- VIEW & THUMBS -->
@ -123,30 +122,30 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_views_text_size"
tools:ignore="RtlHardcoded"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
tools:text="2,816,821,505 views" />
<ImageView
android:id="@+id/detail_thumbs_up_img_view"
android:layout_below="@id/detail_view_count_view"
android:layout_width="@dimen/video_item_detail_like_image_width"
android:layout_height="@dimen/video_item_detail_like_image_height"
android:layout_below="@id/detail_view_count_view"
android:contentDescription="@string/detail_likes_img_view_description"
android:src="?attr/thumbs_up" />
<TextView
android:id="@+id/detail_thumbs_up_count_view"
android:layout_below="@id/detail_view_count_view"
android:layout_toRightOf="@id/detail_thumbs_up_img_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/video_item_detail_like_image_height"
android:layout_below="@id/detail_view_count_view"
android:layout_marginLeft="@dimen/video_item_detail_like_margin"
android:layout_toRightOf="@id/detail_thumbs_up_img_view"
android:gravity="left|center_vertical"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceMedium"
@ -156,34 +155,34 @@
<ImageView
android:id="@+id/detail_thumbs_down_img_view"
android:layout_below="@id/detail_view_count_view"
android:layout_toRightOf="@id/detail_thumbs_up_count_view"
android:layout_width="@dimen/video_item_detail_like_image_width"
android:layout_height="@dimen/video_item_detail_like_image_height"
android:layout_below="@id/detail_view_count_view"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@id/detail_thumbs_up_count_view"
android:contentDescription="@string/detail_dislikes_img_view_description"
android:src="?attr/thumbs_down"
tools:ignore="RtlHardcoded" />
<TextView
android:id="@+id/detail_thumbs_down_count_view"
android:layout_below="@id/detail_view_count_view"
android:layout_toRightOf="@id/detail_thumbs_down_img_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/video_item_detail_like_image_height"
android:lines="1"
android:layout_below="@id/detail_view_count_view"
android:layout_marginLeft="@dimen/video_item_detail_like_margin"
android:layout_toRightOf="@id/detail_thumbs_down_img_view"
android:gravity="left|center_vertical"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/video_item_detail_likes_text_size"
tools:ignore="RtlHardcoded"
tools:text="10K" />
<TextView
android:layout_below="@id/detail_view_count_view"
android:id="@+id/detail_thumbs_disabled_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/detail_view_count_view"
android:layout_marginLeft="15dp"
android:gravity="left|center_vertical"
android:text="@string/disabled"
@ -196,10 +195,10 @@
<!-- CONTROLS -->
<TextView
android:id="@+id/detail_controls_popup"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
@ -213,11 +212,11 @@
<TextView
android:id="@+id/detail_controls_background"
android:layout_toLeftOf="@id/detail_controls_popup"
android:layout_alignParentTop="true"
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:layout_toLeftOf="@id/detail_controls_popup"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/play_audio"
@ -238,9 +237,9 @@
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:background="?attr/selectableItemBackground">
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
@ -298,9 +297,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible"
android:orientation="vertical">
tools:visibility="visible">
<TextView
android:id="@+id/detail_upload_date_view"