diff --git a/app/src/main/java/org/schabi/newpipe/database/history/model/WatchHistoryEntry.java b/app/src/main/java/org/schabi/newpipe/database/history/model/WatchHistoryEntry.java index 203b3fb7a..bfd84d377 100644 --- a/app/src/main/java/org/schabi/newpipe/database/history/model/WatchHistoryEntry.java +++ b/app/src/main/java/org/schabi/newpipe/database/history/model/WatchHistoryEntry.java @@ -48,7 +48,7 @@ public class WatchHistoryEntry extends HistoryEntry { } public WatchHistoryEntry(StreamInfo streamInfo) { - this(new Date(), streamInfo.service_id, streamInfo.name, streamInfo.url, + this(new Date(), streamInfo.getServiceId(), streamInfo.getName(), streamInfo.getUrl(), streamInfo.id, streamInfo.thumbnail_url, streamInfo.uploader_name, streamInfo.duration); } diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index b93f66d26..b217b91b3 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -108,8 +108,8 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); nameEditText = view.findViewById(R.id.file_name); - nameEditText.setText(FilenameUtils.createFilename(getContext(), currentInfo.name)); - selectedAudioIndex = ListHelper.getDefaultAudioFormat(getContext(), currentInfo.audio_streams); + nameEditText.setText(FilenameUtils.createFilename(getContext(), currentInfo.getName())); + selectedAudioIndex = ListHelper.getDefaultAudioFormat(getContext(), currentInfo.getAudioStreams()); streamsSpinner = view.findViewById(R.id.quality_spinner); streamsSpinner.setOnItemSelectedListener(this); @@ -183,7 +183,7 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck String[] items = new String[audioStreams.size()]; for (int i = 0; i < audioStreams.size(); i++) { AudioStream audioStream = audioStreams.get(i); - items[i] = MediaFormat.getNameById(audioStream.format) + " " + audioStream.average_bitrate + "kbps"; + items[i] = audioStream.getFormat().getName() + " " + audioStream.getAverageBitrate() + "kbps"; } ArrayAdapter itemAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, items); @@ -242,7 +242,7 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck RadioButton audioButton = view.findViewById(R.id.audio_button); RadioButton videoButton = view.findViewById(R.id.video_button); - if (currentInfo.audio_streams == null || currentInfo.audio_streams.size() == 0) { + if (currentInfo.getAudioStreams() == null || currentInfo.getAudioStreams().size() == 0) { audioButton.setVisibility(View.GONE); videoButton.setChecked(true); } else if (sortedStreamVideosList == null || sortedStreamVideosList.size() == 0) { @@ -256,14 +256,18 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck String url, location; String fileName = nameEditText.getText().toString().trim(); - if (fileName.isEmpty()) fileName = FilenameUtils.createFilename(getContext(), currentInfo.name); + if (fileName.isEmpty()) fileName = FilenameUtils.createFilename(getContext(), currentInfo.getName()); boolean isAudio = radioVideoAudioGroup.getCheckedRadioButtonId() == R.id.audio_button; - url = isAudio ? currentInfo.audio_streams.get(selectedAudioIndex).url : sortedStreamVideosList.get(selectedVideoIndex).url; - location = isAudio ? NewPipeSettings.getAudioDownloadPath(getContext()) : NewPipeSettings.getVideoDownloadPath(getContext()); - - if (isAudio) fileName += "." + MediaFormat.getSuffixById(currentInfo.audio_streams.get(selectedAudioIndex).format); - else fileName += "." + MediaFormat.getSuffixById(sortedStreamVideosList.get(selectedVideoIndex).format); + if (isAudio) { + url = currentInfo.getAudioStreams().get(selectedAudioIndex).getUrl(); + location = NewPipeSettings.getAudioDownloadPath(getContext()); + fileName += "." + currentInfo.getAudioStreams().get(selectedAudioIndex).getFormat().getSuffix(); + } else { + url = sortedStreamVideosList.get(selectedVideoIndex).getUrl(); + location = NewPipeSettings.getVideoDownloadPath(getContext()); + fileName += "." + sortedStreamVideosList.get(selectedVideoIndex).getFormat().getSuffix(); + } DownloadManagerService.startMission(getContext(), url, location, fileName, isAudio, threadsSeekBar.getProgress() + 1); getDialog().dismiss(); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 7992f88f0..e220654a4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.fragments; import android.content.SharedPreferences; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; @@ -30,30 +31,28 @@ import org.schabi.newpipe.fragments.list.kiosk.KioskFragment; import org.schabi.newpipe.fragments.subscription.SubscriptionFragment; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; -import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ThemeHelper; -import java.util.concurrent.ExecutionException; - public class MainFragment extends BaseFragment implements TabLayout.OnTabSelectedListener { private ViewPager viewPager; private boolean showBlankTab = false; - private static final int FALLBACK_SERVICE_ID = 0; // Youtbe + public int currentServiceId = -1; + + + /*////////////////////////////////////////////////////////////////////////// + // Constants + //////////////////////////////////////////////////////////////////////////*/ + + + private static final int FALLBACK_SERVICE_ID = 0; // Youtube private static final String FALLBACK_CHANNEL_URL = "https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ"; private static final String FALLBACK_CHANNEL_NAME = "Music"; private static final String FALLBACK_KIOSK_ID = "Trending"; - - public int currentServiceId = -1; - - /*////////////////////////////////////////////////////////////////////////// - // Konst - //////////////////////////////////////////////////////////////////////////*/ - - private static final int KIOSK_MENU_OFFSETT = 2000; + private static final int KIOSK_MENU_OFFSET = 2000; /*////////////////////////////////////////////////////////////////////////// // Fragment's LifeCycle @@ -66,7 +65,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte } @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { currentServiceId = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(getString(R.string.current_service_key), "0")); return inflater.inflate(R.layout.fragment_main, container, false); @@ -86,27 +85,27 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte tabLayout.setupWithViewPager(viewPager); - if(ThemeHelper.isLightThemeSelected(getActivity())) { + int channelIcon; + int whatsHotIcon; + + if (ThemeHelper.isLightThemeSelected(getActivity())) { tabLayout.setBackgroundColor(getResources().getColor(R.color.light_youtube_primary_color)); + channelIcon = R.drawable.ic_channel_black_24dp; + whatsHotIcon = R.drawable.ic_whatshot_black_24dp; + } else { + channelIcon = R.drawable.ic_channel_white_24dp; + whatsHotIcon = R.drawable.ic_whatshot_white_24dp; } - if(PreferenceManager.getDefaultSharedPreferences(getActivity()) + + if (PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(getString(R.string.main_page_content_key), getString(R.string.blank_page_key)) .equals(getString(R.string.subscription_page_key))) { - if(ThemeHelper.isLightThemeSelected(getActivity())) { - tabLayout.getTabAt(0).setIcon(R.drawable.ic_channel_black_24dp); - } else{ - tabLayout.getTabAt(0).setIcon(R.drawable.ic_channel_white_24dp); - } - } else { - if(ThemeHelper.isLightThemeSelected(getActivity())) { - tabLayout.getTabAt(0).setIcon(R.drawable.ic_whatshot_black_24dp); - tabLayout.getTabAt(1).setIcon(R.drawable.ic_channel_black_24dp); - } else { - tabLayout.getTabAt(0).setIcon(R.drawable.ic_whatshot_white_24dp); - tabLayout.getTabAt(1).setIcon(R.drawable.ic_channel_white_24dp); - } - } + tabLayout.getTabAt(0).setIcon(channelIcon); + } else { + tabLayout.getTabAt(0).setIcon(whatsHotIcon); + tabLayout.getTabAt(1).setIcon(channelIcon); + } } /*////////////////////////////////////////////////////////////////////////// @@ -182,7 +181,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte .equals(getString(R.string.subscription_page_key))) { return new SubscriptionFragment(); } else { - return getMainPageFramgent(); + return getMainPageFragment(); } case 1: return new SubscriptionFragment(); @@ -213,7 +212,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte // Main page content //////////////////////////////////////////////////////////////////////////*/ - private Fragment getMainPageFramgent() { + private Fragment getMainPageFragment() { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); @@ -268,7 +267,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte KioskList kl = service.getKioskList(); int i = 0; for(final String ks : kl.getAvailableKiosks()) { - menu.add(0, KIOSK_MENU_OFFSETT + i, Menu.NONE, + menu.add(0, KIOSK_MENU_OFFSET + i, Menu.NONE, KioskTranslator.getTranslatedKioskName(ks, getContext())) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/SpinnerToolbarAdapter.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/SpinnerToolbarAdapter.java index 94fe2cf5b..33f87be70 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/SpinnerToolbarAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/SpinnerToolbarAdapter.java @@ -60,7 +60,7 @@ public class SpinnerToolbarAdapter extends BaseAdapter { ImageView woSoundIcon = convertView.findViewById(R.id.wo_sound_icon); TextView text = convertView.findViewById(android.R.id.text1); VideoStream item = (VideoStream) getItem(position); - text.setText(MediaFormat.getNameById(item.format) + " " + item.resolution); + text.setText(item.getFormat().getName() + " " + item.getResolution()); int visibility = !showIconNoAudio ? View.GONE : item.isVideoOnly ? View.VISIBLE diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/StackItem.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/StackItem.java index f50f805c2..b8957f33c 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/StackItem.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/StackItem.java @@ -4,7 +4,8 @@ import java.io.Serializable; class StackItem implements Serializable { private int serviceId; - private String title, url; + private String title; + private String url; StackItem(int serviceId, String url, String title) { this.serviceId = serviceId; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index d0460c347..2f73e7582 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -13,6 +13,7 @@ import android.support.annotation.DrawableRes; import android.support.annotation.FloatRange; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; +import android.support.v4.text.TextUtilsCompat; import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; @@ -283,7 +284,7 @@ public class VideoDetailFragment extends BaseStateFragment implement // Check if the next video label and video is visible, // if it is, include the two elements in the next check - int nextCount = currentInfo != null && currentInfo.next_video != null ? 2 : 0; + int nextCount = currentInfo != null && currentInfo.getNextVideo() != null ? 2 : 0; if (relatedStreamsView != null && relatedStreamsView.getChildCount() > INITIAL_RELATED_VIDEOS + nextCount) { outState.putSerializable(WAS_RELATED_EXPANDED_KEY, true); } @@ -330,10 +331,14 @@ public class VideoDetailFragment extends BaseStateFragment implement openPopupPlayer(false); break; case R.id.detail_uploader_root_layout: - if (currentInfo.uploader_url == null || currentInfo.uploader_url.isEmpty()) { + if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) { Log.w(TAG, "Can't open channel because we got no channel URL"); } else { - NavigationHelper.openChannelFragment(getFragmentManager(), currentInfo.service_id, currentInfo.uploader_url, currentInfo.uploader_name); + NavigationHelper.openChannelFragment( + getFragmentManager(), + currentInfo.getServiceId(), + currentInfo.getUploaderUrl(), + currentInfo.getUploaderName()); } break; case R.id.detail_thumbnail_root_layout: @@ -380,7 +385,7 @@ public class VideoDetailFragment extends BaseStateFragment implement if (DEBUG) Log.d(TAG, "toggleExpandRelatedVideos() called with: info = [" + info + "]"); if (!showRelatedStreams) return; - int nextCount = info.next_video != null ? 2 : 0; + int nextCount = info.getNextVideo() != null ? 2 : 0; int initialCount = INITIAL_RELATED_VIDEOS + nextCount; if (relatedStreamsView.getChildCount() > initialCount) { @@ -390,8 +395,8 @@ public class VideoDetailFragment extends BaseStateFragment implement } //Log.d(TAG, "toggleExpandRelatedVideos() called with: info = [" + info + "], from = [" + INITIAL_RELATED_VIDEOS + "]"); - for (int i = INITIAL_RELATED_VIDEOS; i < info.related_streams.size(); i++) { - InfoItem item = info.related_streams.get(i); + for (int i = INITIAL_RELATED_VIDEOS; i < info.getRelatedStreams().size(); i++) { + InfoItem item = info.getRelatedStreams().get(i); //Log.d(TAG, "i = " + i); relatedStreamsView.addView(infoItemBuilder.buildView(relatedStreamsView, item)); } @@ -459,7 +464,7 @@ public class VideoDetailFragment extends BaseStateFragment implement infoItemBuilder.setOnStreamSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener() { @Override public void selected(StreamInfoItem selectedItem) { - selectAndLoadVideo(selectedItem.service_id, selectedItem.url, selectedItem.name); + selectAndLoadVideo(selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); } @Override @@ -532,35 +537,35 @@ public class VideoDetailFragment extends BaseStateFragment implement private void initThumbnailViews(StreamInfo info) { thumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark); - if (info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) { - imageLoader.displayImage(info.thumbnail_url, thumbnailImageView, DISPLAY_THUMBNAIL_OPTIONS, new SimpleImageLoadingListener() { + if (!TextUtils.isEmpty(info.getThumbnailUrl())) { + imageLoader.displayImage(info.getThumbnailUrl(), thumbnailImageView, DISPLAY_THUMBNAIL_OPTIONS, new SimpleImageLoadingListener() { @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { - ErrorActivity.reportError(activity, failReason.getCause(), null, activity.findViewById(android.R.id.content), ErrorActivity.ErrorInfo.make(UserAction.LOAD_IMAGE, NewPipe.getNameOfService(currentInfo.service_id), imageUri, R.string.could_not_load_thumbnails)); + ErrorActivity.reportError(activity, failReason.getCause(), null, activity.findViewById(android.R.id.content), ErrorActivity.ErrorInfo.make(UserAction.LOAD_IMAGE, NewPipe.getNameOfService(currentInfo.getServiceId()), imageUri, R.string.could_not_load_thumbnails)); } }); } - if (info.uploader_avatar_url != null && !info.uploader_avatar_url.isEmpty()) { - imageLoader.displayImage(info.uploader_avatar_url, uploaderThumb, DISPLAY_AVATAR_OPTIONS); + if (TextUtils.isEmpty(info.getUploaderAvatarUrl())) { + imageLoader.displayImage(info.getUploaderAvatarUrl(), uploaderThumb, DISPLAY_AVATAR_OPTIONS); } } private void initRelatedVideos(StreamInfo info) { if (relatedStreamsView.getChildCount() > 0) relatedStreamsView.removeAllViews(); - if (info.next_video != null && showRelatedStreams) { + if (info.getNextVideo() != null && showRelatedStreams) { nextStreamTitle.setVisibility(View.VISIBLE); - relatedStreamsView.addView(infoItemBuilder.buildView(relatedStreamsView, info.next_video)); + relatedStreamsView.addView(infoItemBuilder.buildView(relatedStreamsView, info.getNextVideo())); relatedStreamsView.addView(getSeparatorView()); relatedStreamRootLayout.setVisibility(View.VISIBLE); } else nextStreamTitle.setVisibility(View.GONE); if (info.related_streams != null && !info.related_streams.isEmpty() && showRelatedStreams) { //long first = System.nanoTime(), each; - int to = info.related_streams.size() >= INITIAL_RELATED_VIDEOS ? INITIAL_RELATED_VIDEOS : info.related_streams.size(); + int to = info.getRelatedStreams().size() >= INITIAL_RELATED_VIDEOS ? INITIAL_RELATED_VIDEOS : info.getRelatedStreams().size(); for (int i = 0; i < to; i++) { - InfoItem item = info.related_streams.get(i); + InfoItem item = info.getRelatedStreams().get(i); //each = System.nanoTime(); relatedStreamsView.addView(infoItemBuilder.buildView(relatedStreamsView, item)); //if (DEBUG) Log.d(TAG, "each took " + ((System.nanoTime() - each) / 1000000L) + "ms"); @@ -572,7 +577,7 @@ public class VideoDetailFragment extends BaseStateFragment implement relatedStreamExpandButton.setImageDrawable(ContextCompat.getDrawable(activity, resolveResourceIdFromAttr(R.attr.expand))); } else { - if (info.next_video == null) relatedStreamRootLayout.setVisibility(View.GONE); + if (info.getNextVideo() == null) relatedStreamRootLayout.setVisibility(View.GONE); relatedStreamExpandButton.setVisibility(View.GONE); } } @@ -616,14 +621,14 @@ public class VideoDetailFragment extends BaseStateFragment implement private void setupActionBarHandler(final StreamInfo info) { if (DEBUG) Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]"); - sortedStreamVideosList = new ArrayList<>(ListHelper.getSortedStreamVideosList(activity, info.video_streams, info.video_only_streams, false)); + sortedStreamVideosList = new ArrayList<>(ListHelper.getSortedStreamVideosList(activity, info.getVideoStreams(), info.getVideoOnlyStreams(), false)); actionBarHandler.setupStreamList(sortedStreamVideosList, spinnerToolbar); actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() { @Override public void onActionSelected(int selectedStreamId) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_TEXT, info.url); + intent.putExtra(Intent.EXTRA_TEXT, info.getUrl()); intent.setType("text/plain"); startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title))); } @@ -634,7 +639,7 @@ public class VideoDetailFragment extends BaseStateFragment implement public void onActionSelected(int selectedStreamId) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); - intent.setData(Uri.parse(info.url)); + intent.setData(Uri.parse(info.getUrl())); startActivity(Intent.createChooser(intent, activity.getString(R.string.choose_browser))); } }); @@ -643,7 +648,7 @@ public class VideoDetailFragment extends BaseStateFragment implement @Override public void onActionSelected(int selectedStreamId) { try { - NavigationHelper.playWithKore(activity, Uri.parse(info.url.replace("https", "http"))); + NavigationHelper.playWithKore(activity, Uri.parse(info.getUrl().replace("https", "http"))); if(activity instanceof HistoryListener) { ((HistoryListener) activity).onVideoPlayed(info, null); } @@ -742,7 +747,7 @@ public class VideoDetailFragment extends BaseStateFragment implement public void prepareAndHandleInfo(final StreamInfo info, boolean scrollToTop) { if (DEBUG) Log.d(TAG, "prepareAndHandleInfo() called with: info = [" + info + "], scrollToTop = [" + scrollToTop + "]"); - setInitialData(info.service_id, info.url, info.name); + setInitialData(info.getServiceId(), info.getUrl(), info.getName()); pushToStack(serviceId, url, name); showLoading(); @@ -798,7 +803,7 @@ public class VideoDetailFragment extends BaseStateFragment implement //////////////////////////////////////////////////////////////////////////*/ private void openBackgroundPlayer(final boolean append) { - AudioStream audioStream = currentInfo.audio_streams.get(ListHelper.getDefaultAudioFormat(activity, currentInfo.audio_streams)); + AudioStream audioStream = currentInfo.getAudioStreams().get(ListHelper.getDefaultAudioFormat(activity, currentInfo.getAudioStreams())); if (activity instanceof HistoryListener) { ((HistoryListener) activity).onAudioPlayed(currentInfo, audioStream); @@ -868,9 +873,9 @@ public class VideoDetailFragment extends BaseStateFragment implement intent = new Intent(); try { intent.setAction(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.parse(audioStream.url), MediaFormat.getMimeById(audioStream.format)); - intent.putExtra(Intent.EXTRA_TITLE, currentInfo.name); - intent.putExtra("title", currentInfo.name); + intent.setDataAndType(Uri.parse(audioStream.getUrl()), audioStream.getFormat().getMimeType()); + intent.putExtra(Intent.EXTRA_TITLE, currentInfo.getName()); + intent.putExtra("title", currentInfo.getName()); activity.startActivity(intent); } catch (Exception e) { e.printStackTrace(); @@ -903,14 +908,14 @@ public class VideoDetailFragment extends BaseStateFragment implement if (!useOldPlayer) { // ExoPlayer final PlayQueue playQueue = new SinglePlayQueue(currentInfo); - mIntent = NavigationHelper.getPlayerIntent(activity, MainVideoPlayer.class, playQueue, getSelectedVideoStream().resolution); + mIntent = NavigationHelper.getPlayerIntent(activity, MainVideoPlayer.class, playQueue, getSelectedVideoStream().getResolution()); } else { // Internal Player mIntent = new Intent(activity, PlayVideoActivity.class) - .putExtra(PlayVideoActivity.VIDEO_TITLE, currentInfo.name) - .putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.url) - .putExtra(PlayVideoActivity.VIDEO_URL, currentInfo.url) - .putExtra(PlayVideoActivity.START_POSITION, currentInfo.start_position); + .putExtra(PlayVideoActivity.VIDEO_TITLE, currentInfo.getName()) + .putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.getUrl()) + .putExtra(PlayVideoActivity.VIDEO_URL, currentInfo.getUrl()) + .putExtra(PlayVideoActivity.START_POSITION, currentInfo.getStartPosition()); } startActivity(mIntent); } @@ -920,9 +925,9 @@ public class VideoDetailFragment extends BaseStateFragment implement Intent intent = new Intent(); try { intent.setAction(Intent.ACTION_VIEW) - .setDataAndType(Uri.parse(selectedVideoStream.url), MediaFormat.getMimeById(selectedVideoStream.format)) - .putExtra(Intent.EXTRA_TITLE, currentInfo.name) - .putExtra("title", currentInfo.name); + .setDataAndType(Uri.parse(selectedVideoStream.getUrl()), selectedVideoStream.getFormat().getMimeType()) + .putExtra(Intent.EXTRA_TITLE, currentInfo.getName()) + .putExtra("title", currentInfo.getName()); this.startActivity(intent); } catch (Exception e) { e.printStackTrace(); @@ -1095,20 +1100,28 @@ public class VideoDetailFragment extends BaseStateFragment implement public void handleResult(@NonNull StreamInfo info) { super.handleResult(info); - setInitialData(info.service_id, info.url, info.name); + setInitialData(info.getServiceId(), info.getUrl(), info.getName()); pushToStack(serviceId, url, name); animateView(thumbnailPlayButton, true, 200); videoTitleTextView.setText(name); - if (!TextUtils.isEmpty(info.uploader_name)) uploaderTextView.setText(info.uploader_name); - uploaderTextView.setVisibility(!TextUtils.isEmpty(info.uploader_name) ? View.VISIBLE : View.GONE); + if (!TextUtils.isEmpty(info.getUploaderName())) { + uploaderTextView.setText(info.getUploaderName()); + uploaderTextView.setVisibility(View.VISIBLE); + } else { + uploaderTextView.setVisibility(View.GONE); + } uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy)); - if (info.view_count >= 0) videoCountView.setText(Localization.localizeViewCount(activity, info.view_count)); - videoCountView.setVisibility(info.view_count >= 0 ? View.VISIBLE : View.GONE); + if (info.getViewCount() >= 0) { + videoCountView.setText(Localization.localizeViewCount(activity, info.getViewCount())); + videoCountView.setVisibility(View.VISIBLE); + } else { + videoCountView.setVisibility(View.GONE); + } - if (info.dislike_count == -1 && info.like_count == -1) { + if (info.getDislikeCount() == -1 && info.getLikeCount() == -1) { thumbsDownImageView.setVisibility(View.VISIBLE); thumbsUpImageView.setVisibility(View.VISIBLE); thumbsUpTextView.setVisibility(View.GONE); @@ -1116,14 +1129,23 @@ public class VideoDetailFragment extends BaseStateFragment implement thumbsDisabledTextView.setVisibility(View.VISIBLE); } else { - if (info.dislike_count >= 0) thumbsDownTextView.setText(Localization.shortCount(activity, info.dislike_count)); - thumbsDownTextView.setVisibility(info.dislike_count >= 0 ? View.VISIBLE : View.GONE); - thumbsDownImageView.setVisibility(info.dislike_count >= 0 ? View.VISIBLE : View.GONE); - - if (info.like_count >= 0) thumbsUpTextView.setText(Localization.shortCount(activity, info.like_count)); - thumbsUpTextView.setVisibility(info.like_count >= 0 ? View.VISIBLE : View.GONE); - thumbsUpImageView.setVisibility(info.like_count >= 0 ? View.VISIBLE : View.GONE); + if (info.getDislikeCount() >= 0) { + thumbsDownTextView.setText(Localization.shortCount(activity, info.getDislikeCount())); + thumbsDownTextView.setVisibility(View.VISIBLE); + thumbsDownImageView.setVisibility(View.VISIBLE); + } else { + thumbsDownTextView.setVisibility(View.GONE); + thumbsDownImageView.setVisibility(View.GONE); + } + if (info.getLikeCount() >= 0) { + thumbsUpTextView.setText(Localization.shortCount(activity, info.getLikeCount())); + thumbsUpTextView.setVisibility(View.VISIBLE); + thumbsUpImageView.setVisibility(View.VISIBLE); + } else { + thumbsUpTextView.setVisibility(View.GONE); + thumbsUpImageView.setVisibility(View.GONE); + } thumbsDisabledTextView.setVisibility(View.GONE); } @@ -1132,10 +1154,10 @@ public class VideoDetailFragment extends BaseStateFragment implement videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); videoDescriptionView.setVisibility(View.GONE); videoDescriptionRootLayout.setVisibility(View.GONE); - if (!TextUtils.isEmpty(info.upload_date)) { - videoUploadDateView.setText(Localization.localizeDate(activity, info.upload_date)); + if (!TextUtils.isEmpty(info.getUploadDate())) { + videoUploadDateView.setText(Localization.localizeDate(activity, info.getUploadDate())); } - prepareDescription(info.description); + prepareDescription(info.getDescription()); animateView(spinnerToolbar, true, 500); setupActionBarHandler(info); @@ -1145,10 +1167,10 @@ public class VideoDetailFragment extends BaseStateFragment implement toggleExpandRelatedVideos(currentInfo); wasRelatedStreamsExpanded = false; } - setTitleToUrl(info.service_id, info.url, info.name); + setTitleToUrl(info.getServiceId(), info.getUrl(), info.getName()); - if (!info.errors.isEmpty()) { - showSnackBarError(info.errors, UserAction.REQUESTED_STREAM, NewPipe.getNameOfService(info.service_id), info.url, 0); + if (!info.getErrors().isEmpty()) { + showSnackBarError(info.getErrors(), UserAction.REQUESTED_STREAM, NewPipe.getNameOfService(info.getServiceId()), info.getUrl(), 0); } if (autoPlayEnabled) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index ae17dafff..8b20f0122 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -140,7 +140,7 @@ public abstract class BaseListFragment extends BaseStateFragment implem onItemSelected(selectedItem); NavigationHelper.openVideoDetailFragment( useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(), - selectedItem.service_id, selectedItem.url, selectedItem.name); + selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); } @Override @@ -155,7 +155,7 @@ public abstract class BaseListFragment extends BaseStateFragment implem onItemSelected(selectedItem); NavigationHelper.openChannelFragment( useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(), - selectedItem.service_id, selectedItem.url, selectedItem.name); + selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); } @Override @@ -168,7 +168,7 @@ public abstract class BaseListFragment extends BaseStateFragment implem onItemSelected(selectedItem); NavigationHelper.openPlaylistFragment( useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(), - selectedItem.service_id, selectedItem.url, selectedItem.name); + selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName()); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java index 4baf323ff..41561af66 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java @@ -190,8 +190,8 @@ public abstract class BaseListInfoFragment extends BaseListF public void handleResult(@NonNull I result) { super.handleResult(result); - url = result.url; - name = result.name; + url = result.getUrl(); + name = result.getName(); setTitle(name); if (infoListAdapter.getItemsList().size() == 0) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 857fb81e0..7a2c65898 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -105,7 +105,7 @@ public class ChannelFragment extends BaseListInfoFragment { && useAsFrontPage && isVisibleToUser) { try { - activity.getSupportActionBar().setTitle(currentInfo.name); + activity.getSupportActionBar().setTitle(currentInfo.getName()); } catch (Exception e) { onError(e); } @@ -208,7 +208,7 @@ public class ChannelFragment extends BaseListInfoFragment { if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + "], inflater = [" + inflater + "]"); menuRssButton = menu.findItem(R.id.menu_item_rss); if (currentInfo != null) { - menuRssButton.setVisible(!TextUtils.isEmpty(currentInfo.feed_url)); + menuRssButton.setVisible(!TextUtils.isEmpty(currentInfo.getFeedUrl())); } } @@ -217,7 +217,7 @@ public class ChannelFragment extends BaseListInfoFragment { private void openRssFeed() { final ChannelInfo info = currentInfo; if(info != null) { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(info.feed_url)); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(info.getFeedUrl())); startActivity(intent); } } @@ -264,12 +264,12 @@ public class ChannelFragment extends BaseListInfoFragment { @Override public void accept(Throwable throwable) throws Exception { animateView(headerSubscribeButton, false, 100); - showSnackBarError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(currentInfo.service_id), "Get subscription status", 0); + showSnackBarError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(currentInfo.getServiceId()), "Get subscription status", 0); } }; final Observable> observable = subscriptionService.subscriptionTable() - .getSubscription(info.service_id, info.url) + .getSubscription(info.getServiceId(), info.getUrl()) .toObservable(); disposables.add(observable @@ -315,14 +315,14 @@ public class ChannelFragment extends BaseListInfoFragment { final Action onComplete = new Action() { @Override public void run() throws Exception { - if (DEBUG) Log.d(TAG, "Updated subscription: " + info.url); + if (DEBUG) Log.d(TAG, "Updated subscription: " + info.getUrl()); } }; final Consumer onError = new Consumer() { @Override public void accept(@NonNull Throwable throwable) throws Exception { - onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(info.service_id), "Updating Subscription for " + info.url, R.string.subscription_update_failed); + onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(info.getServiceId()), "Updating Subscription for " + info.getUrl(), R.string.subscription_update_failed); } }; @@ -343,7 +343,7 @@ public class ChannelFragment extends BaseListInfoFragment { final Consumer onError = new Consumer() { @Override public void accept(@NonNull Throwable throwable) throws Exception { - onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(currentInfo.service_id), "Subscription Change", R.string.subscription_change_failed); + onUnrecoverableError(throwable, UserAction.SUBSCRIPTION, NewPipe.getNameOfService(currentInfo.getServiceId()), "Subscription Change", R.string.subscription_change_failed); } }; @@ -367,9 +367,9 @@ public class ChannelFragment extends BaseListInfoFragment { if (subscriptionEntities.isEmpty()) { if (DEBUG) Log.d(TAG, "No subscription to this channel!"); SubscriptionEntity channel = new SubscriptionEntity(); - channel.setServiceId(info.service_id); - channel.setUrl(info.url); - channel.setData(info.name, info.avatar_url, info.description, info.subscriber_count); + channel.setServiceId(info.getServiceId()); + channel.setUrl(info.getUrl()); + channel.setData(info.getName(), info.getAvatarUrl(), info.getDescription(), info.getSubscriberCount()); subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnSubscribe(channel)); } else { if (DEBUG) Log.d(TAG, "Found subscription to this channel!"); @@ -440,16 +440,16 @@ public class ChannelFragment extends BaseListInfoFragment { imageLoader.displayImage(result.banner_url, headerChannelBanner, DISPLAY_BANNER_OPTIONS); imageLoader.displayImage(result.avatar_url, headerAvatarView, DISPLAY_AVATAR_OPTIONS); - if (result.subscriber_count != -1) { - headerSubscribersTextView.setText(Localization.localizeSubscribersCount(activity, result.subscriber_count)); + if (result.getSubscriberCount() != -1) { + headerSubscribersTextView.setText(Localization.localizeSubscribersCount(activity, result.getSubscriberCount())); headerSubscribersTextView.setVisibility(View.VISIBLE); } else headerSubscribersTextView.setVisibility(View.GONE); - if (menuRssButton != null) menuRssButton.setVisible(!TextUtils.isEmpty(result.feed_url)); + if (menuRssButton != null) menuRssButton.setVisible(!TextUtils.isEmpty(result.getFeedUrl())); playlistCtrl.setVisibility(View.VISIBLE); if (!result.errors.isEmpty()) { - showSnackBarError(result.errors, UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(result.service_id), result.url, 0); + showSnackBarError(result.errors, UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(result.getServiceId()), result.getUrl(), 0); } if (disposables != null) disposables.clear(); @@ -490,9 +490,9 @@ public class ChannelFragment extends BaseListInfoFragment { private PlayQueue getPlayQueue(final int index) { return new ChannelPlayQueue( - currentInfo.service_id, - currentInfo.url, - currentInfo.next_streams_url, + currentInfo.getServiceId(), + currentInfo.getUrl(), + currentInfo.getNextStreamsUrl(), infoListAdapter.getItemsList(), index ); @@ -502,8 +502,8 @@ public class ChannelFragment extends BaseListInfoFragment { public void handleNextItems(ListExtractor.NextItemsResult result) { super.handleNextItems(result); - if (!result.errors.isEmpty()) { - showSnackBarError(result.errors, UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(serviceId), + if (!result.getErrors().isEmpty()) { + showSnackBarError(result.getErrors(), UserAction.REQUESTED_CHANNEL, NewPipe.getNameOfService(serviceId), "Get next page of: " + url, R.string.general_error); } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/feed/FeedFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/feed/FeedFragment.java index 835647eec..a62593047 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/feed/FeedFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/feed/FeedFragment.java @@ -297,12 +297,12 @@ public class FeedFragment extends BaseListFragment, Voi // Called only when response is non-empty @Override public void onSuccess(final ChannelInfo channelInfo) { - if (infoListAdapter == null || channelInfo.related_streams.isEmpty()) { + if (infoListAdapter == null || channelInfo.getRelatedStreams().isEmpty()) { onDone(); return; } - final InfoItem item = channelInfo.related_streams.get(0); + final InfoItem item = channelInfo.getRelatedStreams().get(0); // Keep requesting new items if the current one already exists boolean itemExists = doesItemExist(infoListAdapter.getItemsList(), item); if (!itemExists) { @@ -412,9 +412,9 @@ public class FeedFragment extends BaseListFragment, Voi private boolean doesItemExist(final List items, final InfoItem item) { for (final InfoItem existingItem : items) { if (existingItem.info_type == item.info_type && - existingItem.service_id == item.service_id && - existingItem.name.equals(item.name) && - existingItem.url.equals(item.url)) return true; + existingItem.getServiceId() == item.getServiceId() && + existingItem.getName().equals(item.getName()) && + existingItem.getUrl().equals(item.getUrl())) return true; } return false; } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java index 3e224efdc..29d5ddfeb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java @@ -155,10 +155,10 @@ public class KioskFragment extends BaseListInfoFragment { ActionBar supportActionBar = activity.getSupportActionBar(); supportActionBar.setTitle(title); - if (!result.errors.isEmpty()) { - showSnackBarError(result.errors, + if (!result.getErrors().isEmpty()) { + showSnackBarError(result.getErrors(), UserAction.REQUESTED_PLAYLIST, - NewPipe.getNameOfService(result.service_id), result.url, 0); + NewPipe.getNameOfService(result.getServiceId()), result.getUrl(), 0); } } @@ -166,8 +166,8 @@ public class KioskFragment extends BaseListInfoFragment { public void handleNextItems(ListExtractor.NextItemsResult result) { super.handleNextItems(result); - if (!result.errors.isEmpty()) { - showSnackBarError(result.errors, + if (!result.getErrors().isEmpty()) { + showSnackBarError(result.getErrors(), UserAction.REQUESTED_PLAYLIST, NewPipe.getNameOfService(serviceId) , "Get next page of: " + url, 0); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index e7f7e9968..4f87228a5 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -181,13 +181,13 @@ public class PlaylistFragment extends BaseListInfoFragment { animateView(headerRootLayout, true, 100); animateView(headerUploaderLayout, true, 300); headerUploaderLayout.setOnClickListener(null); - if (!TextUtils.isEmpty(result.uploader_name)) { - headerUploaderName.setText(result.uploader_name); - if (!TextUtils.isEmpty(result.uploader_url)) { + if (!TextUtils.isEmpty(result.getUploaderName())) { + headerUploaderName.setText(result.getUploaderName()); + if (!TextUtils.isEmpty(result.getUploaderUrl())) { headerUploaderLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - NavigationHelper.openChannelFragment(getFragmentManager(), result.service_id, result.uploader_url, result.uploader_name); + NavigationHelper.openChannelFragment(getFragmentManager(), result.getServiceId(), result.getUploaderUrl(), result.getUploaderName()); } }); } @@ -195,11 +195,11 @@ public class PlaylistFragment extends BaseListInfoFragment { playlistCtrl.setVisibility(View.VISIBLE); - imageLoader.displayImage(result.uploader_avatar_url, headerUploaderAvatar, DISPLAY_AVATAR_OPTIONS); + imageLoader.displayImage(result.getUploaderAvatarUrl(), headerUploaderAvatar, DISPLAY_AVATAR_OPTIONS); headerStreamCount.setText(getResources().getQuantityString(R.plurals.videos, (int) result.stream_count, (int) result.stream_count)); - if (!result.errors.isEmpty()) { - showSnackBarError(result.errors, UserAction.REQUESTED_PLAYLIST, NewPipe.getNameOfService(result.service_id), result.url, 0); + if (!result.getErrors().isEmpty()) { + showSnackBarError(result.getErrors(), UserAction.REQUESTED_PLAYLIST, NewPipe.getNameOfService(result.getServiceId()), result.getUrl(), 0); } headerPlayAllButton.setOnClickListener(new View.OnClickListener() { @@ -235,9 +235,9 @@ public class PlaylistFragment extends BaseListInfoFragment { private PlayQueue getPlayQueue(final int index) { return new PlaylistPlayQueue( - currentInfo.service_id, - currentInfo.url, - currentInfo.next_streams_url, + currentInfo.getServiceId(), + currentInfo.getUrl(), + currentInfo.getNextStreamsUrl(), infoListAdapter.getItemsList(), index ); @@ -247,8 +247,8 @@ public class PlaylistFragment extends BaseListInfoFragment { public void handleNextItems(ListExtractor.NextItemsResult result) { super.handleNextItems(result); - if (!result.errors.isEmpty()) { - showSnackBarError(result.errors, UserAction.REQUESTED_PLAYLIST, NewPipe.getNameOfService(serviceId) + if (!result.getErrors().isEmpty()) { + showSnackBarError(result.getErrors(), UserAction.REQUESTED_PLAYLIST, NewPipe.getNameOfService(serviceId) , "Get next page of: " + url, 0); } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index fb54a15c3..b30a73455 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -861,8 +861,8 @@ public class SearchFragment extends BaseListFragment 0) { - infoListAdapter.addInfoItemList(result.resultList); + if (!result.getResults().isEmpty()) { + infoListAdapter.addInfoItemList(result.getResults()); } else { infoListAdapter.clearStreamItemList(); showEmptyState(); @@ -876,11 +876,11 @@ public class SearchFragment extends BaseListFragment 0) { diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index 443da74d4..f260b86a6 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -393,7 +393,7 @@ public final class BackgroundPlayer extends Service { if (index < 0 || index >= info.audio_streams.size()) return null; final AudioStream audio = info.audio_streams.get(index); - return buildMediaSource(audio.url, MediaFormat.getSuffixById(audio.format)); + return buildMediaSource(audio.getUrl(), MediaFormat.getSuffixById(audio.format)); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 5f8b36449..d141dfaae 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -462,7 +462,7 @@ public final class PopupVideoPlayer extends Service { } else { intent = new Intent(PopupVideoPlayer.this, PlayVideoActivity.class) .putExtra(PlayVideoActivity.VIDEO_TITLE, getVideoTitle()) - .putExtra(PlayVideoActivity.STREAM_URL, getSelectedVideoStream().url) + .putExtra(PlayVideoActivity.STREAM_URL, getSelectedVideoStream().getUrl()) .putExtra(PlayVideoActivity.VIDEO_URL, getVideoUrl()) .putExtra(PlayVideoActivity.START_POSITION, Math.round(getPlayer().getCurrentPosition() / 1000f)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 0f8da3711..37b8920b5 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -529,7 +529,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity @Override public void onMetadataUpdate(StreamInfo info) { if (info != null) { - metadataTitle.setText(info.name); + metadataTitle.setText(info.getName()); metadataArtist.setText(info.uploader_name); scrollToSelected(); } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 60f15372a..c3d52aeae 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -282,12 +282,12 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer. if (index < 0 || index >= videos.size()) return null; final VideoStream video = videos.get(index); - final MediaSource streamSource = buildMediaSource(video.url, MediaFormat.getSuffixById(video.format)); + final MediaSource streamSource = buildMediaSource(video.getUrl(), MediaFormat.getSuffixById(video.format)); final AudioStream audio = ListHelper.getHighestQualityAudio(info.audio_streams); if (!video.isVideoOnly || audio == null) return streamSource; // Merge with audio stream in case if video does not contain audio - final MediaSource audioSource = buildMediaSource(audio.url, MediaFormat.getSuffixById(audio.format)); + final MediaSource audioSource = buildMediaSource(audio.getUrl(), MediaFormat.getSuffixById(audio.format)); return new MergingMediaSource(streamSource, audioSource); } diff --git a/app/src/main/java/org/schabi/newpipe/playlist/AbstractInfoPlayQueue.java b/app/src/main/java/org/schabi/newpipe/playlist/AbstractInfoPlayQueue.java index 74a68b880..58ec3c997 100644 --- a/app/src/main/java/org/schabi/newpipe/playlist/AbstractInfoPlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/playlist/AbstractInfoPlayQueue.java @@ -26,7 +26,7 @@ abstract class AbstractInfoPlayQueue ext transient Disposable fetchReactor; AbstractInfoPlayQueue(final U item) { - this(item.service_id, item.url, null, Collections.emptyList(), 0); + this(item.getServiceId(), item.getUrl(), null, Collections.emptyList(), 0); } AbstractInfoPlayQueue(final int serviceId, diff --git a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java index 969581f2f..9b14e8f03 100644 --- a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java +++ b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java @@ -30,12 +30,12 @@ public class PlayQueueItem implements Serializable { private transient Single stream; PlayQueueItem(@NonNull final StreamInfo info) { - this(info.name, info.url, info.service_id, info.duration, info.thumbnail_url, info.uploader_name); + this(info.getName(), info.getUrl(), info.getServiceId(), info.duration, info.thumbnail_url, info.uploader_name); this.stream = Single.just(info); } PlayQueueItem(@NonNull final StreamInfoItem item) { - this(item.name, item.url, item.service_id, item.duration, item.thumbnail_url, item.uploader_name); + this(item.getName(), item.getUrl(), item.getServiceId(), item.duration, item.thumbnail_url, item.uploader_name); } private PlayQueueItem(final String name, final String url, final int serviceId, diff --git a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java index 794c3dd78..0f082cc11 100644 --- a/app/src/main/java/org/schabi/newpipe/util/InfoCache.java +++ b/app/src/main/java/org/schabi/newpipe/util/InfoCache.java @@ -103,7 +103,7 @@ public final class InfoCache { } private static String keyOf(@NonNull final Info info) { - return keyOf(info.service_id, info.url); + return keyOf(info.getServiceId(), info.getUrl()); } private static String keyOf(final int serviceId, @NonNull final String url) { diff --git a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java index 697a0c7c1..79fd1e496 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -95,7 +95,7 @@ public final class ListHelper { int highestQualityIndex = 0; if (audioStreams.size() > 1) for (int i = 1; i < audioStreams.size(); i++) { AudioStream audioStream = audioStreams.get(i); - if (audioStream.average_bitrate >= audioStreams.get(highestQualityIndex).average_bitrate) highestQualityIndex = i; + if (audioStream.getAverageBitrate() >= audioStreams.get(highestQualityIndex).getAverageBitrate()) highestQualityIndex = i; } return highestQualityIndex; } @@ -124,10 +124,10 @@ public final class ListHelper { int highestQualityIndex = -1; for (int i = 0; i < audioStreams.size(); i++) { AudioStream audioStream = audioStreams.get(i); - if (highestQualityIndex == -1 && audioStream.format == defaultFormat.id) highestQualityIndex = i; + if (highestQualityIndex == -1 && audioStream.getFormat() == defaultFormat) highestQualityIndex = i; - if (highestQualityIndex != -1 && audioStream.format == defaultFormat.id - && audioStream.average_bitrate > audioStreams.get(highestQualityIndex).average_bitrate) { + if (highestQualityIndex != -1 && audioStream.getFormat() == defaultFormat + && audioStream.getAverageBitrate() > audioStreams.get(highestQualityIndex).getAverageBitrate()) { highestQualityIndex = i; } } @@ -171,23 +171,23 @@ public final class ListHelper { if (videoOnlyStreams != null) { for (VideoStream stream : videoOnlyStreams) { - if (!showHigherResolutions && HIGH_RESOLUTION_LIST.contains(stream.resolution)) continue; + if (!showHigherResolutions && HIGH_RESOLUTION_LIST.contains(stream.getResolution())) continue; retList.add(stream); } } if (videoStreams != null) { for (VideoStream stream : videoStreams) { - if (!showHigherResolutions && HIGH_RESOLUTION_LIST.contains(stream.resolution)) continue; + if (!showHigherResolutions && HIGH_RESOLUTION_LIST.contains(stream.getResolution())) continue; retList.add(stream); } } // Add all to the hashmap - for (VideoStream videoStream : retList) hashMap.put(videoStream.resolution, videoStream); + for (VideoStream videoStream : retList) hashMap.put(videoStream.getResolution(), videoStream); // Override the values when the key == resolution, with the defaultFormat for (VideoStream videoStream : retList) { - if (videoStream.format == defaultFormat.id) hashMap.put(videoStream.resolution, videoStream); + if (videoStream.getFormat() == defaultFormat) hashMap.put(videoStream.getResolution(), videoStream); } retList.clear(); @@ -219,8 +219,8 @@ public final class ListHelper { Collections.sort(videoStreams, new Comparator() { @Override public int compare(VideoStream o1, VideoStream o2) { - int res1 = Integer.parseInt(o1.resolution.replace("0p60", "1").replaceAll("[^\\d.]", "")); - int res2 = Integer.parseInt(o2.resolution.replace("0p60", "1").replaceAll("[^\\d.]", "")); + int res1 = Integer.parseInt(o1.getResolution().replace("0p60", "1").replaceAll("[^\\d.]", "")); + int res2 = Integer.parseInt(o2.getResolution().replace("0p60", "1").replaceAll("[^\\d.]", "")); return ascendingOrder ? res1 - res2 : res2 - res1; } @@ -235,9 +235,9 @@ public final class ListHelper { int defaultStreamIndex = -1; for (int i = 0; i < videoStreams.size(); i++) { VideoStream stream = videoStreams.get(i); - if (defaultStreamIndex == -1 && stream.resolution.equals(defaultResolution)) defaultStreamIndex = i; + if (defaultStreamIndex == -1 && stream.getResolution().equals(defaultResolution)) defaultStreamIndex = i; - if (stream.format == defaultFormat.id && stream.resolution.equals(defaultResolution)) { + if (stream.getFormat() == defaultFormat && stream.getResolution().equals(defaultResolution)) { return i; } } diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 07fc4ba7b..e59ad10b2 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -20,7 +20,9 @@ import org.schabi.newpipe.download.DownloadActivity; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamingService; +import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.fragments.MainFragment; import org.schabi.newpipe.fragments.detail.VideoDetailFragment; import org.schabi.newpipe.fragments.list.channel.ChannelFragment;