Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@

import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
import static org.schabi.newpipe.extractor.stream.StreamExtractor.NO_AGE_LIMIT;
import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_LONG_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
Expand Down Expand Up @@ -564,8 +566,8 @@ private View.OnTouchListener getOnControlsTouchListener() {
}

if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
animateView(appendControlsDetail, true, 250, 0, () ->
animateView(appendControlsDetail, false, 1500, 1000));
animateView(appendControlsDetail, true, DEFAULT_SHORT_ANIM_DURATION, 0, () ->
animateView(appendControlsDetail, false, DEFAULT_LONG_ANIM_DURATION, 1000));
}
return false;
};
Expand Down Expand Up @@ -639,6 +641,8 @@ public boolean onOptionsItemSelected(final MenuItem item) {
switch (id) {
case R.id.menu_item_share:
if (currentInfo != null) {
Log.i(TAG, "onOptionsItemSelected: " + currentInfo.getUrl());
Log.i(TAG, "onOptionsItemSelected: " + currentInfo.getOriginalUrl());
ShareUtils.shareUrl(requireContext(), currentInfo.getName(),
currentInfo.getOriginalUrl());
}
Expand Down Expand Up @@ -1029,8 +1033,8 @@ private void setErrorImage(final int imageResource) {
}

thumbnailImageView.setImageDrawable(ContextCompat.getDrawable(activity, imageResource));
animateView(thumbnailImageView, false, 0, 0,
() -> animateView(thumbnailImageView, true, 500));
animateView(thumbnailImageView, false, DEFAULT_SHORT_ANIM_DURATION, 0,
() -> animateView(thumbnailImageView, true, DEFAULT_SHORT_ANIM_DURATION));
}

@Override
Expand Down Expand Up @@ -1058,15 +1062,15 @@ public void showLoading() {
contentRootLayoutHiding.setVisibility(View.INVISIBLE);
}

animateView(spinnerToolbar, false, 200);
animateView(thumbnailPlayButton, false, 50);
animateView(detailDurationView, false, 100);
animateView(detailPositionView, false, 100);
animateView(positionView, false, 50);
animateView(spinnerToolbar, false, DEFAULT_SHORT_ANIM_DURATION);
animateView(thumbnailPlayButton, false, DEFAULT_SHORT_ANIM_DURATION);
animateView(detailDurationView, false, DEFAULT_SHORT_ANIM_DURATION);
animateView(detailPositionView, false, DEFAULT_SHORT_ANIM_DURATION);
animateView(positionView, false, DEFAULT_SHORT_ANIM_DURATION);

videoTitleTextView.setText(name != null ? name : "");
videoTitleTextView.setMaxLines(1);
animateView(videoTitleTextView, true, 0);
animateView(videoTitleTextView, true, DEFAULT_SHORT_ANIM_DURATION);

videoDescriptionRootLayout.setVisibility(View.GONE);
videoTitleToggleArrow.setImageResource(R.drawable.arrow_down);
Expand Down Expand Up @@ -1109,7 +1113,7 @@ public void handleResult(@NonNull final StreamInfo info) {

//pushToStack(serviceId, url, name);

animateView(thumbnailPlayButton, true, 200);
animateView(thumbnailPlayButton, true, DEFAULT_SHORT_ANIM_DURATION);
videoTitleTextView.setText(name);

if (!TextUtils.isEmpty(info.getUploaderName())) {
Expand Down Expand Up @@ -1169,12 +1173,12 @@ public void handleResult(@NonNull final StreamInfo info) {
detailDurationView.setText(Localization.getDurationString(info.getDuration()));
detailDurationView.setBackgroundColor(
ContextCompat.getColor(activity, R.color.duration_background_color));
animateView(detailDurationView, true, 100);
animateView(detailDurationView, true, DEFAULT_SHORT_ANIM_DURATION);
} else if (info.getStreamType() == StreamType.LIVE_STREAM) {
detailDurationView.setText(R.string.duration_live);
detailDurationView.setBackgroundColor(
ContextCompat.getColor(activity, R.color.live_duration_background_color));
animateView(detailDurationView, true, 100);
animateView(detailDurationView, true, DEFAULT_SHORT_ANIM_DURATION);
} else {
detailDurationView.setVisibility(View.GONE);
}
Expand All @@ -1197,7 +1201,7 @@ public void handleResult(@NonNull final StreamInfo info) {
prepareDescription(info.getDescription());
updateProgressInfo(info);

animateView(spinnerToolbar, true, 500);
animateView(spinnerToolbar, true, DEFAULT_SHORT_ANIM_DURATION);
setupActionBar(info);
initThumbnailViews(info);

Expand Down Expand Up @@ -1331,15 +1335,15 @@ private void updateProgressInfo(@NonNull final StreamInfo info) {
positionView.setMax((int) info.getDuration());
positionView.setProgressAnimated(seconds);
detailPositionView.setText(Localization.getDurationString(seconds));
animateView(positionView, true, 500);
animateView(detailPositionView, true, 500);
animateView(positionView, true, DEFAULT_SHORT_ANIM_DURATION);
animateView(detailPositionView, true, DEFAULT_SHORT_ANIM_DURATION);
}, e -> {
if (DEBUG) {
e.printStackTrace();
}
}, () -> {
animateView(positionView, false, 500);
animateView(detailPositionView, false, 500);
animateView(positionView, false, DEFAULT_SHORT_ANIM_DURATION);
animateView(detailPositionView, false, DEFAULT_SHORT_ANIM_DURATION);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.List;
import java.util.Queue;

import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
Expand Down Expand Up @@ -116,8 +117,8 @@ public void onResume() {
/**
* If the default implementation of {@link StateSaver.WriteRead} should be used.
*
* @see StateSaver
* @param useDefaultStateSaving Whether the default implementation should be used
* @see StateSaver
*/
public void setUseDefaultStateSaving(final boolean useDefaultStateSaving) {
this.useDefaultStateSaving = useDefaultStateSaving;
Expand Down Expand Up @@ -354,14 +355,14 @@ public void showLoading() {
@Override
public void hideLoading() {
super.hideLoading();
animateView(itemsList, true, 300);
animateView(itemsList, true, DEFAULT_SHORT_ANIM_DURATION);
}

@Override
public void showError(final String message, final boolean showRetryButton) {
super.showError(message, showRetryButton);
showListFooter(false);
animateView(itemsList, false, 200);
animateView(itemsList, false, DEFAULT_SHORT_ANIM_DURATION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;

import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateBackgroundColor;
import static org.schabi.newpipe.util.AnimationUtils.animateTextColor;
import static org.schabi.newpipe.util.AnimationUtils.animateView;
Expand Down Expand Up @@ -225,7 +226,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {

private void monitorSubscription(final ChannelInfo info) {
final Consumer<Throwable> onError = (Throwable throwable) -> {
animateView(headerSubscribeButton, false, 100);
animateView(headerSubscribeButton, false, DEFAULT_SHORT_ANIM_DURATION);
showSnackBarError(throwable, UserAction.SUBSCRIPTION,
NewPipe.getNameOfService(currentInfo.getServiceId()),
"Get subscription status", 0);
Expand Down Expand Up @@ -377,7 +378,8 @@ private void updateSubscribeButton(final boolean isSubscribed) {
animateTextColor(headerSubscribeButton, textDuration, subscribeText, subscribedText);
}

animateView(headerSubscribeButton, AnimationUtils.Type.LIGHT_SCALE_AND_ALPHA, true, 100);
animateView(headerSubscribeButton, AnimationUtils.Type.LIGHT_SCALE_AND_ALPHA,
true, DEFAULT_SHORT_ANIM_DURATION);
}

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -404,7 +406,7 @@ public void showLoading() {

IMAGE_LOADER.cancelDisplayTask(headerChannelBanner);
IMAGE_LOADER.cancelDisplayTask(headerAvatarView);
animateView(headerSubscribeButton, false, 100);
animateView(headerSubscribeButton, false, DEFAULT_SHORT_ANIM_DURATION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import icepick.State;
import io.reactivex.Single;

import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

/**
Expand Down Expand Up @@ -160,7 +161,7 @@ public Single<ListExtractor.InfoItemsPage> loadMoreItemsLogic() {
@Override
public void showLoading() {
super.showLoading();
animateView(itemsList, false, 100);
animateView(itemsList, false, DEFAULT_SHORT_ANIM_DURATION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import io.reactivex.disposables.Disposable;
import io.reactivex.disposables.Disposables;

import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
Expand Down Expand Up @@ -266,19 +267,19 @@ public boolean onOptionsItemSelected(final MenuItem item) {
@Override
public void showLoading() {
super.showLoading();
animateView(headerRootLayout, false, 200);
animateView(itemsList, false, 100);
animateView(headerRootLayout, false, DEFAULT_SHORT_ANIM_DURATION);
animateView(itemsList, false, DEFAULT_SHORT_ANIM_DURATION);

IMAGE_LOADER.cancelDisplayTask(headerUploaderAvatar);
animateView(headerUploaderLayout, false, 200);
animateView(headerUploaderLayout, false, DEFAULT_SHORT_ANIM_DURATION);
}

@Override
public void handleResult(@NonNull final PlaylistInfo result) {
super.handleResult(result);

animateView(headerRootLayout, true, 100);
animateView(headerUploaderLayout, true, 300);
animateView(headerRootLayout, true, DEFAULT_SHORT_ANIM_DURATION);
animateView(headerUploaderLayout, true, DEFAULT_SHORT_ANIM_DURATION);
headerUploaderLayout.setOnClickListener(null);
// If we have an uploader put them into the UI
if (!TextUtils.isEmpty(result.getUploaderName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

import static androidx.recyclerview.widget.ItemTouchHelper.Callback.makeMovementFlags;
import static java.util.Arrays.asList;
import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.InfoItemsPage>
Expand All @@ -93,45 +94,35 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
*/
private static final int SUGGESTIONS_DEBOUNCE = 120; //ms
private final PublishSubject<String> suggestionPublisher = PublishSubject.create();

@State
int filterItemCheckedId = -1;

private final CompositeDisposable disposables = new CompositeDisposable();
@State
protected int serviceId = Constants.NO_SERVICE_ID;

@State
int filterItemCheckedId = -1;
// these three represents the current search query
@State
String searchString;

/**
* No content filter should add like contentFilter = all
* be aware of this when implementing an extractor.
*/
@State
String[] contentFilter = new String[0];

@State
String sortFilter;

// these represents the last search
@State
String lastSearchedString;

@State
boolean wasSearchFocused = false;

private Map<Integer, String> menuItemToFilterName;
private StreamingService service;
private String currentPageUrl;
private String nextPageUrl;
private String contentCountry;
private boolean isSuggestionsEnabled = true;

private Disposable searchDisposable;
private Disposable suggestionDisposable;
private final CompositeDisposable disposables = new CompositeDisposable();

private SuggestionListAdapter suggestionListAdapter;
private HistoryRecordManager historyRecordManager;

Expand Down Expand Up @@ -389,7 +380,7 @@ public void reloadContent() {
searchEditText.setText("");
showKeyboardSearch();
}
animateView(errorPanelRoot, false, 200);
animateView(errorPanelRoot, false, DEFAULT_SHORT_ANIM_DURATION);
}
}

Expand Down Expand Up @@ -554,11 +545,13 @@ public void onSuggestionItemLongClick(final SuggestionItem item) {
textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(final CharSequence s, final int start,
final int count, final int after) { }
final int count, final int after) {
}

@Override
public void onTextChanged(final CharSequence s, final int start,
final int before, final int count) { }
final int before, final int count) {
}

@Override
public void afterTextChanged(final Editable s) {
Expand Down Expand Up @@ -609,14 +602,16 @@ private void showSuggestionsPanel() {
if (DEBUG) {
Log.d(TAG, "showSuggestionsPanel() called");
}
animateView(suggestionsPanel, AnimationUtils.Type.LIGHT_SLIDE_AND_ALPHA, true, 200);
animateView(suggestionsPanel, AnimationUtils.Type.LIGHT_SLIDE_AND_ALPHA, true,
DEFAULT_SHORT_ANIM_DURATION);
}

private void hideSuggestionsPanel() {
if (DEBUG) {
Log.d(TAG, "hideSuggestionsPanel() called");
}
animateView(suggestionsPanel, AnimationUtils.Type.LIGHT_SLIDE_AND_ALPHA, false, 200);
animateView(suggestionsPanel, AnimationUtils.Type.LIGHT_SLIDE_AND_ALPHA, false,
DEFAULT_SHORT_ANIM_DURATION);
}

private void showKeyboardSearch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.util.AnimationUtils;
import org.schabi.newpipe.util.ImageDisplayConstants;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.views.AnimatedProgressBar;

import java.util.concurrent.TimeUnit;

import static org.schabi.newpipe.util.AnimationUtils.DEFAULT_SHORT_ANIM_DURATION;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

public class StreamMiniInfoItemHolder extends InfoItemHolder {
public final ImageView itemThumbnailView;
public final TextView itemVideoTitleView;
Expand Down Expand Up @@ -123,10 +125,10 @@ public void updateState(final InfoItem infoItem,
} else {
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
.toSeconds(state.getProgressTime()));
AnimationUtils.animateView(itemProgressView, true, 500);
animateView(itemProgressView, true, DEFAULT_SHORT_ANIM_DURATION);
}
} else if (itemProgressView.getVisibility() == View.VISIBLE) {
AnimationUtils.animateView(itemProgressView, false, 500);
animateView(itemProgressView, false, DEFAULT_SHORT_ANIM_DURATION);
}
}

Expand Down
Loading