Skip to content

Commit

Permalink
Move things back to its original place
Browse files Browse the repository at this point in the history
  • Loading branch information
wb9688 committed Apr 2, 2020
1 parent fda5405 commit 63bcc04
Show file tree
Hide file tree
Showing 35 changed files with 629 additions and 498 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected void onPostExecute(final String response) {
*
* @param versionName Name of new version
* @param apkLocationUrl Url with the new apk
* @param versionCode V
* @param versionCode Code of new version
*/
private void compareAppVersionAndShowNotification(final String versionName,
final String apkLocationUrl,
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,41 @@ public class DownloadDialog extends DialogFragment
private static final String TAG = "DialogFragment";
private static final boolean DEBUG = MainActivity.DEBUG;
private static final int REQUEST_DOWNLOAD_SAVE_AS = 0x1230;
private final CompositeDisposable disposables = new CompositeDisposable();

@State
protected StreamInfo currentInfo;
StreamInfo currentInfo;
@State
protected StreamSizeWrapper<AudioStream> wrappedAudioStreams = StreamSizeWrapper.empty();
StreamSizeWrapper<AudioStream> wrappedAudioStreams = StreamSizeWrapper.empty();
@State
protected StreamSizeWrapper<VideoStream> wrappedVideoStreams = StreamSizeWrapper.empty();
StreamSizeWrapper<VideoStream> wrappedVideoStreams = StreamSizeWrapper.empty();
@State
protected StreamSizeWrapper<SubtitlesStream> wrappedSubtitleStreams = StreamSizeWrapper.empty();
StreamSizeWrapper<SubtitlesStream> wrappedSubtitleStreams = StreamSizeWrapper.empty();
@State
protected int selectedVideoIndex = 0;
int selectedVideoIndex = 0;
@State
protected int selectedAudioIndex = 0;
int selectedAudioIndex = 0;
@State
protected int selectedSubtitleIndex = 0;
int selectedSubtitleIndex = 0;

private StoredDirectoryHelper mainStorageAudio = null;
private StoredDirectoryHelper mainStorageVideo = null;
private DownloadManager downloadManager = null;
private ActionMenuItemView okButton = null;
private Context context;
private boolean askForSavePath;

private StreamItemAdapter<AudioStream, Stream> audioStreamsAdapter;
private StreamItemAdapter<VideoStream, AudioStream> videoStreamsAdapter;
private StreamItemAdapter<SubtitlesStream, Stream> subtitleStreamsAdapter;

private final CompositeDisposable disposables = new CompositeDisposable();

private EditText nameEditText;
private Spinner streamsSpinner;
private RadioGroup radioStreamsGroup;
private TextView threadsCountTextView;
private SeekBar threadsSeekBar;

private SharedPreferences prefs;

public static DownloadDialog newInstance(final StreamInfo info) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,92 +109,110 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
implements BackPressable, SharedPreferences.OnSharedPreferenceChangeListener,
View.OnClickListener, View.OnLongClickListener {
public static final String AUTO_PLAY = "auto_play";

private int updateFlags = 0;
private static final int RELATED_STREAMS_UPDATE_FLAG = 0x1;
private static final int RESOLUTIONS_MENU_UPDATE_FLAG = 0x2;
private static final int TOOLBAR_ITEMS_UPDATE_FLAG = 0x4;
private static final int COMMENTS_UPDATE_FLAG = 0x8;
private static final String COMMENTS_TAB_TAG = "COMMENTS";
private static final String RELATED_TAB_TAG = "NEXT VIDEO";
private static final String EMPTY_TAB_TAG = "EMPTY TAB";
private static final String INFO_KEY = "info_key";
private static final String STACK_KEY = "stack_key";
/**
* Stack that contains the "navigation history".<br>
* The peek is the current video.
*/
private final LinkedList<StackItem> stack = new LinkedList<>();

private boolean autoPlayEnabled;
private boolean showRelatedStreams;
private boolean showComments;
private String selectedTabTag;

@State
protected int serviceId = Constants.NO_SERVICE_ID;
@State
protected String name;
@State
protected String url;
private int updateFlags = 0;
private boolean autoPlayEnabled;
private boolean showRelatedStreams;
private boolean showComments;
private String selectedTabTag;

/*//////////////////////////////////////////////////////////////////////////
// Views
//////////////////////////////////////////////////////////////////////////*/
private StreamInfo currentInfo;
private Disposable currentWorker;
@NonNull
private CompositeDisposable disposables = new CompositeDisposable();
@Nullable
private Disposable positionSubscriber = null;

private List<VideoStream> sortedVideoStreams;
private int selectedVideoStreamIndex = -1;

/*//////////////////////////////////////////////////////////////////////////
// Views
//////////////////////////////////////////////////////////////////////////*/

private Menu menu;

private Spinner spinnerToolbar;

private LinearLayout contentRootLayoutHiding;

private View thumbnailBackgroundButton;
private ImageView thumbnailImageView;
private ImageView thumbnailPlayButton;
private AnimatedProgressBar positionView;

private View videoTitleRoot;
private TextView videoTitleTextView;
private ImageView videoTitleToggleArrow;
private TextView videoCountView;

private TextView detailControlsBackground;
private TextView detailControlsPopup;
private TextView detailControlsAddToPlaylist;
private TextView detailControlsDownload;
private TextView appendControlsDetail;
private TextView detailDurationView;
private TextView detailPositionView;

private LinearLayout videoDescriptionRootLayout;
private TextView videoUploadDateView;
private TextView videoDescriptionView;

private View uploaderRootLayout;
private TextView uploaderTextView;
private ImageView uploaderThumb;

private TextView thumbsUpTextView;
private ImageView thumbsUpImageView;
private TextView thumbsDownTextView;
private ImageView thumbsDownImageView;
private TextView thumbsDisabledTextView;

private AppBarLayout appBarLayout;
private ViewPager viewPager;


/*////////////////////////////////////////////////////////////////////////*/
private TabAdaptor pageAdapter;

/*//////////////////////////////////////////////////////////////////////////
// Fragment's Lifecycle
//////////////////////////////////////////////////////////////////////////*/
private TabLayout tabLayout;
private FrameLayout relatedStreamsLayout;

/*////////////////////////////////////////////////////////////////////////*/

private static final String COMMENTS_TAB_TAG = "COMMENTS";
private static final String RELATED_TAB_TAG = "NEXT VIDEO";
private static final String EMPTY_TAB_TAG = "EMPTY TAB";

private static final String INFO_KEY = "info_key";
private static final String STACK_KEY = "stack_key";

/**
* Stack that contains the "navigation history".<br>
* The peek is the current video.
*/
private final LinkedList<StackItem> stack = new LinkedList<>();

public static VideoDetailFragment getInstance(final int serviceId, final String videoUrl,
final String name) {
VideoDetailFragment instance = new VideoDetailFragment();
instance.setInitialData(serviceId, videoUrl, name);
return instance;
}


/*//////////////////////////////////////////////////////////////////////////
// Fragment's Lifecycle
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -285,10 +303,6 @@ public void onDestroy() {
disposables = null;
}

/*//////////////////////////////////////////////////////////////////////////
// State Saving
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onDestroyView() {
if (DEBUG) {
Expand Down Expand Up @@ -336,6 +350,10 @@ public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
}
}

/*//////////////////////////////////////////////////////////////////////////
// State Saving
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
Expand All @@ -351,10 +369,6 @@ public void onSaveInstanceState(final Bundle outState) {
outState.putSerializable(STACK_KEY, stack);
}

/*//////////////////////////////////////////////////////////////////////////
// OnClick
//////////////////////////////////////////////////////////////////////////*/

@Override
protected void onRestoreInstanceState(@NonNull final Bundle savedState) {
super.onRestoreInstanceState(savedState);
Expand All @@ -371,9 +385,12 @@ protected void onRestoreInstanceState(@NonNull final Bundle savedState) {
//noinspection unchecked
stack.addAll((Collection<? extends StackItem>) serializable);
}

}

/*//////////////////////////////////////////////////////////////////////////
// OnClick
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onClick(final View v) {
if (isLoading.get() || currentInfo == null) {
Expand Down Expand Up @@ -449,10 +466,6 @@ public boolean onLongClick(final View v) {
return true;
}

/*//////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////*/

private void toggleTitleAndDescription() {
if (videoDescriptionRootLayout.getVisibility() == View.VISIBLE) {
videoTitleTextView.setMaxLines(1);
Expand All @@ -465,6 +478,10 @@ private void toggleTitleAndDescription() {
}
}

/*//////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////*/

@Override
protected void initViews(final View rootView, final Bundle savedInstanceState) {
super.initViews(rootView, savedInstanceState);
Expand Down Expand Up @@ -553,11 +570,6 @@ private View.OnTouchListener getOnControlsTouchListener() {
};
}


/*//////////////////////////////////////////////////////////////////////////
// Menu
//////////////////////////////////////////////////////////////////////////*/

private void initThumbnailViews(@NonNull final StreamInfo info) {
thumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark);
if (!TextUtils.isEmpty(info.getThumbnailUrl())) {
Expand All @@ -581,6 +593,10 @@ public void onLoadingFailed(final String imageUri, final View view,
}
}

/*//////////////////////////////////////////////////////////////////////////
// Menu
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onCreateOptionsMenu(final Menu m, final MenuInflater inflater) {
this.menu = m;
Expand Down Expand Up @@ -654,10 +670,6 @@ private void setupActionBarOnError(final String u) {
Log.e("-----", "missing code");
}

/*//////////////////////////////////////////////////////////////////////////
// OwnStack
//////////////////////////////////////////////////////////////////////////*/

private void setupActionBar(final StreamInfo info) {
if (DEBUG) {
Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]");
Expand Down Expand Up @@ -687,7 +699,11 @@ public void onNothingSelected(final AdapterView<?> parent) { }
});
}

public void pushToStack(final int sid, final String videoUrl, final String title) {
/*//////////////////////////////////////////////////////////////////////////
// OwnStack
//////////////////////////////////////////////////////////////////////////*/

private void pushToStack(final int sid, final String videoUrl, final String title) {
if (DEBUG) {
Log.d(TAG, "pushToStack() called with: serviceId = ["
+ sid + "], videoUrl = [" + videoUrl + "], title = [" + title + "]");
Expand All @@ -706,7 +722,7 @@ public void pushToStack(final int sid, final String videoUrl, final String title
stack.push(new StackItem(sid, videoUrl, title));
}

public void setTitleToUrl(final int sid, final String videoUrl, final String title) {
private void setTitleToUrl(final int sid, final String videoUrl, final String title) {
if (title != null && !title.isEmpty()) {
for (StackItem stackItem : stack) {
if (stack.peek().getServiceId() == sid
Expand Down Expand Up @@ -755,7 +771,7 @@ public void selectAndLoadVideo(final int sid, final String videoUrl, final Strin
prepareAndLoadInfo();
}

public void prepareAndHandleInfo(final StreamInfo info, final boolean scrollToTop) {
private void prepareAndHandleInfo(final StreamInfo info, final boolean scrollToTop) {
if (DEBUG) {
Log.d(TAG, "prepareAndHandleInfo() called with: "
+ "info = [" + info + "], scrollToTop = [" + scrollToTop + "]");
Expand All @@ -774,7 +790,7 @@ public void prepareAndHandleInfo(final StreamInfo info, final boolean scrollToTo

}

protected void prepareAndLoadInfo() {
private void prepareAndLoadInfo() {
appBarLayout.setExpanded(true, true);
pushToStack(serviceId, url, name);
startLoading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,22 @@
public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
implements ListViewContract<I, N>, StateSaver.WriteRead,
SharedPreferences.OnSharedPreferenceChangeListener {
private static final int LIST_MODE_UPDATE_FLAG = 0x32;
protected StateSaver.SavedState savedState;

private boolean useDefaultStateSaving = true;
private int updateFlags = 0;

/*//////////////////////////////////////////////////////////////////////////
// Views
//////////////////////////////////////////////////////////////////////////*/

private static final int LIST_MODE_UPDATE_FLAG = 0x32;
protected InfoListAdapter infoListAdapter;
protected RecyclerView itemsList;
protected StateSaver.SavedState savedState;

/*//////////////////////////////////////////////////////////////////////////
// LifeCycle
//////////////////////////////////////////////////////////////////////////*/
private boolean useDefaultStateSaving = true;
private int updateFlags = 0;

@Override
public void onAttach(final Context context) {
Expand All @@ -81,10 +83,6 @@ public void onCreate(final Bundle savedInstanceState) {
.registerOnSharedPreferenceChangeListener(this);
}

/*//////////////////////////////////////////////////////////////////////////
// State Saving
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onDestroy() {
super.onDestroy();
Expand All @@ -111,6 +109,10 @@ public void onResume() {
}
}

/*//////////////////////////////////////////////////////////////////////////
// State Saving
//////////////////////////////////////////////////////////////////////////*/

/**
* If the default implementation of {@link StateSaver.WriteRead} should be used.
*
Expand Down
Loading

0 comments on commit 63bcc04

Please sign in to comment.