Search in sources :

Example 1 with Format

use of butter.droid.provider.base.model.Format in project butter-android by butterproject.

the class EpisodeDialogFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (!TextUtils.isEmpty(episode.getTitle())) {
        title.setText(episode.getTitle());
        headerImage.setContentDescription(episode.getTitle());
    } else {
        title.setText(R.string.no_title_available);
        headerImage.setContentDescription(getString(R.string.no_title_available));
    }
    // TODO: 6/17/17 meta provider
    // aired.setVisibility(episode.aired > 0 ? View.VISIBLE : View.GONE);
    // Date airedDate = new Date((long) episode.aired * 1000);
    // aired.setText(String.format(getString(R.string.aired), new SimpleDateFormat("MMMM dd, yyyy", LocaleUtils.getCurrent())
    // .format(airedDate)));
    // if (!TextUtils.isEmpty(episode.getOverview())) {
    // synopsis.setText(episode.getOverview());
    // } else {
    // synopsis.setText(R.string.no_synopsis_available);
    // }
    // info.setText(String.format(Locale.US, "S%02dE%02d", episode.getSeasion(), episode.getEpisode()));
    // subtitlesPreview.setFragmentManager(getFragmentManager());
    subtitlesPreview.setOnClickListener(v -> showSubsPickerDialog());
    quality.setFragmentManager(getFragmentManager());
    final Format[] formats = mediaDisplayManager.getSortedTorrentFormats(episode.getTorrents());
    String[] formatDisplay = new String[formats.length];
    for (int i = 0; i < formats.length; i++) {
        formatDisplay[i] = mediaDisplayManager.getFormatDisplayName(formats[i]);
    }
    quality.setData(formatDisplay);
    int defaultFormatIndex = mediaDisplayManager.getDefaultFormatIndex(formats);
    // // TODO: 7/30/17 Handle sorting
    selectedTorrent = episode.getTorrents()[defaultFormatIndex];
    this.quality.setText(formatDisplay[defaultFormatIndex]);
    this.quality.setDefault(defaultFormatIndex);
    updateMagnet();
    this.quality.setListener((position, value) -> {
        selectedTorrent = episode.getTorrents()[position];
        updateMagnet();
    });
    if (providerManager.hasSubsProvider(mediaMeta.getProviderId())) {
        subtitlesPreview.setText(R.string.loading_subs);
        subtitlesPreview.setClickable(false);
        providerManager.getSubsProvider(mediaMeta.getProviderId()).list(episode).flatMap(subs -> {
            if (subs.isEmpty()) {
                return Single.<List<UiSubItem>>just(Collections.EMPTY_LIST);
            } else {
                final String defaultSubtitle = preferencesHandler.getSubtitleDefaultLanguage();
                return Observable.fromIterable(subs).map(sub -> new UiSubItem(sub, sub.equals(defaultSubtitle))).startWith(new UiSubItem(null, defaultSubtitle == null)).toList();
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<List<UiSubItem>>() {

            @Override
            public void onSubscribe(final Disposable d) {
            // TODO dispose
            }

            @Override
            public void onSuccess(final List<UiSubItem> subs) {
                if (subs.isEmpty()) {
                    subtitlesPreview.setText(R.string.no_subs_available);
                    subtitleList = null;
                } else {
                    subtitlesPreview.setClickable(true);
                    subtitleList = subs;
                    UiSubItem selectedItem = null;
                    for (final UiSubItem sub : subs) {
                        if (sub.isSelected()) {
                            selectedItem = sub;
                            String name = sub.getName();
                            if (TextUtils.isEmpty(name)) {
                                subtitlesPreview.setText(R.string.no_subs);
                            } else {
                                subtitlesPreview.setText(name);
                            }
                            break;
                        }
                    }
                    if (selectedItem == null) {
                        selectedItem = subs.get(0);
                    }
                    selectedSub = selectedItem;
                }
            }

            @Override
            public void onError(final Throwable e) {
                // subtitleList = null;
                subtitlesPreview.setText(R.string.no_subs_available);
                subtitlesPreview.setClickable(false);
            }
        });
    } else {
        subtitlesPreview.setText(R.string.no_subs_available);
        subtitlesPreview.setClickable(false);
    }
    scrollView.setListener(new BottomSheetScrollView.Listener() {

        @Override
        public void onScroll(int scrollY, BottomSheetScrollView.Direction direction) {
        }

        @Override
        public void onTouch(boolean touching) {
            EpisodeDialogFragment.this.touching = touching;
            int scrollY = scrollView.getScrollY();
            if (!EpisodeDialogFragment.this.touching && opened && scrollY <= threshold) {
                smoothDismiss();
            }
        }

        @Override
        public void onScrollStart() {
        }

        @Override
        public void onScrollEnd() {
            if (!touching && opened && scrollView.getScrollY() <= threshold) {
                smoothDismiss();
            }
        }
    });
    if (metaProvider != null) {
    // TODO: 6/17/17 meta
    // metaProvider.getEpisodeMeta(episode.imdbId, episode.getSeasion(), episode.getEpisode(),
    // (Callback) (metaData, ex) -> {
    // String imageUrl = episode.getBackdrop();
    // if (ex == null) {
    // imageUrl = metaData.images.poster;
    // }
    // Picasso.with(headerImage.getContext()).load(imageUrl).into(headerImage);
    // });
    } else {
        Picasso.with(headerImage.getContext()).load(episode.getBackdrop()).into(headerImage);
    }
}
Also used : ImageButton(android.widget.ImageButton) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) OnClick(butterknife.OnClick) BindView(butterknife.BindView) Picasso(com.squareup.picasso.Picasso) ProviderManager(butter.droid.base.manager.internal.provider.ProviderManager) ContextThemeWrapper(android.view.ContextThemeWrapper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper) PreferencesHandler(butter.droid.base.content.preferences.PreferencesHandler) ViewGroup(android.view.ViewGroup) OptionPreview(butter.droid.widget.OptionPreview) SubsPickerCallback(butter.droid.ui.media.detail.dialog.subs.SubsPickerDialog.SubsPickerCallback) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable) SubsPickerDialog(butter.droid.ui.media.detail.dialog.subs.SubsPickerDialog) KeyEvent(android.view.KeyEvent) DaggerAppCompatDialogFragment(dagger.android.support.DaggerAppCompatDialogFragment) ButterKnife(butterknife.ButterKnife) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull) StreamInfo(butter.droid.base.providers.media.model.StreamInfo) Single(io.reactivex.Single) Format(butter.droid.provider.base.model.Format) SynopsisDialogFragment(butter.droid.ui.media.detail.streamable.dialog.SynopsisDialogFragment) Inject(javax.inject.Inject) Episode(butter.droid.provider.base.model.Episode) Observable(io.reactivex.Observable) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) OptionSelector(butter.droid.widget.OptionSelector) DialogInterface(android.content.DialogInterface) MediaDisplayManager(butter.droid.base.manager.internal.media.MediaDisplayManager) R(butter.droid.R) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) MediaMeta(butter.droid.base.providers.media.model.MediaMeta) Torrent(butter.droid.provider.base.model.Torrent) BottomSheetScrollView(butter.droid.widget.BottomSheetScrollView) Magnet(butter.droid.base.torrent.Magnet) SingleObserver(io.reactivex.SingleObserver) MetaProvider(butter.droid.base.providers.meta.MetaProvider) UiSubItem(butter.droid.ui.media.detail.model.UiSubItem) PixelUtils(butter.droid.base.utils.PixelUtils) Activity(android.app.Activity) Collections(java.util.Collections) Disposable(io.reactivex.disposables.Disposable) Format(butter.droid.provider.base.model.Format) UiSubItem(butter.droid.ui.media.detail.model.UiSubItem) List(java.util.List) BottomSheetScrollView(butter.droid.widget.BottomSheetScrollView)

Example 2 with Format

use of butter.droid.provider.base.model.Format in project butter-android by butterproject.

the class MockMediaProvider method mapEpisodes.

private Episode[] mapEpisodes(MockEpisode[] mockEpisodes) {
    Episode[] episodes = new Episode[mockEpisodes.length];
    for (int i = 0; i < mockEpisodes.length; i++) {
        MockEpisode episode = mockEpisodes[i];
        episodes[i] = new Episode(String.valueOf(episode.getId()), episode.getTitle(), episode.getYear(), new Genre[0], -1, episode.getPoster(), episode.getBackdrop(), episode.getSynopsis(), new Torrent[] { new Torrent(episode.getTorrent(), new Format(episode.getQuality(), Format.FORMAT_NORMAL), 0) }, episode.getEpisdoe());
    }
    return episodes;
}
Also used : MockEpisode(butter.droid.provider.mock.model.MockEpisode) Episode(butter.droid.provider.base.model.Episode) MockEpisode(butter.droid.provider.mock.model.MockEpisode) Torrent(butter.droid.provider.base.model.Torrent) Format(butter.droid.provider.base.model.Format) Genre(butter.droid.provider.base.filter.Genre)

Example 3 with Format

use of butter.droid.provider.base.model.Format in project butter-android by butterproject.

the class PreferencesHandler method getPreferenceItem.

@NonNull
public PrefItem getPreferenceItem(@PrefKey String key) {
    switch(key) {
        case DEFAULT_PROVIDER:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_default_view).setTitleResource(R.string.default_view).setPreferenceKey(DEFAULT_PROVIDER).setValue(getDefaultProvider()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    String[] items = resources.getStringArray(R.array.prefs_providers);
                    return items[(Integer) item.getValue()];
                }
            }).build();
        case Prefs.DEFAULT_PLAYER:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_default_player).setTitleResource(R.string.default_player).setPreferenceKey(Prefs.DEFAULT_PLAYER).setValue(prefManager.get(Prefs.DEFAULT_PLAYER_NAME, context.getString(R.string.internal_player))).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return (String) item.getValue();
                }
            }).build();
        case Prefs.QUALITY_DEFAULT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_action_quality).setTitleResource(R.string.quality).setPreferenceKey(Prefs.QUALITY_DEFAULT).hasNext(true).setValue(getDefaultQuality()).setSubtitleGenerator(item -> String.format(Locale.US, "%dp", (Integer) item.getValue())).build();
        case Prefs.LOCALE:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_app_language).setTitleResource(R.string.i18n_language).setPreferenceKey(Prefs.LOCALE).hasNext(true).setValue(prefManager.get(Prefs.LOCALE, resources.getString(R.string.device_language))).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    Locale locale = LocaleUtils.toLocale((String) item.getValue());
                    return locale.getDisplayName(locale);
                }
            }).build();
        case Prefs.WIFI_ONLY:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_wifi_only).setTitleResource(R.string.stream_over_wifi_only).setPreferenceKey(Prefs.WIFI_ONLY).setValue(wifiOnly()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return ((Boolean) item.getValue()) ? resources.getString(R.string.enabled) : resources.getString(R.string.disabled);
                }
            }).build();
        case Prefs.SUBTITLE_COLOR:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_subtitle_color).setTitleResource(R.string.subtitle_color).setPreferenceKey(Prefs.SUBTITLE_COLOR).hasNext(true).setValue(getSubtitleColor()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return String.format("#%06X", 0xFFFFFF & (Integer) item.getValue());
                }
            }).build();
        case Prefs.SUBTITLE_SIZE:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_subtitle_size).setTitleResource(R.string.subtitle_size).setPreferenceKey(Prefs.SUBTITLE_SIZE).hasNext(true).setValue(getSubtitleSize()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return Integer.toString((Integer) item.getValue());
                }
            }).build();
        case Prefs.SUBTITLE_STROKE_COLOR:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_subtitle_stroke_color).setTitleResource(R.string.subtitle_stroke_color).setPreferenceKey(Prefs.SUBTITLE_STROKE_COLOR).hasNext(true).setValue(getSubtitleStrokeColor()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return String.format("#%06X", 0xFFFFFF & ((Integer) item.getValue()));
                }
            }).build();
        case Prefs.SUBTITLE_STROKE_WIDTH:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_subtitle_stroke_width).setTitleResource(R.string.subtitle_stroke_width).setPreferenceKey(Prefs.SUBTITLE_STROKE_WIDTH).hasNext(true).setValue(getSubtitleStrokeWidth()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return Integer.toString(((Integer) item.getValue()));
                }
            }).build();
        case Prefs.SUBTITLE_DEFAULT_LANGUAGE:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_subtitle_lang).setTitleResource(R.string.default_subtitle_language).setPreferenceKey(Prefs.SUBTITLE_DEFAULT_LANGUAGE).hasNext(true).setValue(getSubtitleDefaultLanguage()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    String langCode = (String) item.getValue();
                    if (langCode == null) {
                        return resources.getString(R.string.no_default_set);
                    } else {
                        Locale locale = LocaleUtils.toLocale(langCode);
                        return locale.getDisplayName(locale);
                    }
                }
            }).build();
        case Prefs.LIBTORRENT_CONNECTION_LIMIT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_connections).setTitleResource(R.string.max_connections).setPreferenceKey(Prefs.LIBTORRENT_CONNECTION_LIMIT).hasNext(true).setValue(getTorrentConnectionLimit()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return item.getValue() + " connections";
                }
            }).build();
        case Prefs.LIBTORRENT_DOWNLOAD_LIMIT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_download_limit).setTitleResource(R.string.download_speed).setPreferenceKey(Prefs.LIBTORRENT_DOWNLOAD_LIMIT).hasNext(true).setValue(getTorrentDownloadLimit()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    int limit = (int) item.getValue();
                    if (limit == 0) {
                        return resources.getString(R.string.unlimited);
                    } else {
                        return (limit / 1000) + " kB/s";
                    }
                }
            }).build();
        case Prefs.LIBTORRENT_UPLOAD_LIMIT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_upload_limit).setTitleResource(R.string.upload_speed).setPreferenceKey(Prefs.LIBTORRENT_UPLOAD_LIMIT).hasNext(true).setValue(getTorrentUploadLimit()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    int limit = (int) item.getValue();
                    if (limit == 0) {
                        return resources.getString(R.string.unlimited);
                    } else {
                        return (limit / 1000) + " kB/s";
                    }
                }
            }).build();
        case Prefs.STORAGE_LOCATION:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_storage_location).setTitleResource(R.string.storage_location).setPreferenceKey(Prefs.STORAGE_LOCATION).hasNext(true).setValue(getStorageLocation()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return ((String) item.getValue());
                }
            }).build();
        case Prefs.REMOVE_CACHE:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_remove_cache).setTitleResource(R.string.remove_cache).setPreferenceKey(Prefs.REMOVE_CACHE).setValue(removeCache()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return ((Boolean) item.getValue()) ? resources.getString(R.string.enabled) : resources.getString(R.string.disabled);
                }
            }).build();
        case Prefs.LIBTORRENT_AUTOMATIC_PORT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_random).setTitleResource(R.string.automatic_port).setPreferenceKey(Prefs.LIBTORRENT_AUTOMATIC_PORT).hasNext(true).setValue(torrentAutomaticPort()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return ((Boolean) item.getValue()) ? resources.getString(R.string.enabled) : resources.getString(R.string.disabled);
                }
            }).build();
        case Prefs.LIBTORRENT_LISTENING_PORT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_router).setTitleResource(R.string.listening_port).setPreferenceKey(Prefs.LIBTORRENT_LISTENING_PORT).hasNext(true).setClickable(!torrentAutomaticPort()).setValue(getTorrentListeningPort()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    int port = (int) item.getValue();
                    if (port == -1 || torrentAutomaticPort()) {
                        return "Listening on random port";
                    } else {
                        return "Listening on port " + port;
                    }
                }
            }).build();
        case Prefs.HW_ACCELERATION:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_hw_accel).setTitleResource(R.string.hw_acceleration).setPreferenceKey(Prefs.HW_ACCELERATION).hasNext(true).setValue(getHwAcceleration()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    int value = ((Integer) item.getValue());
                    switch(value) {
                        case VLCMediaOptions.HW_ACCELERATION_DECODING:
                            return resources.getString(R.string.hw_decoding);
                        case VLCMediaOptions.HW_ACCELERATION_DISABLED:
                            return resources.getString(R.string.disabled);
                        case VLCMediaOptions.HW_ACCELERATION_FULL:
                            return resources.getString(R.string.hw_full);
                        default:
                        case VLCMediaOptions.HW_ACCELERATION_AUTOMATIC:
                            return resources.getString(R.string.hw_automatic);
                    }
                }
            }).build();
        case Prefs.PIXEL_FORMAT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_pixel_format).setTitleResource(R.string.pixel_format).setPreferenceKey(Prefs.PIXEL_FORMAT).hasNext(true).setValue(getPixelFormat()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    String value = (String) item.getValue();
                    if ("YV12".equals(value)) {
                        return resources.getString(R.string.yuv);
                    } else if ("RV16".equals(value)) {
                        return resources.getString(R.string.rgb16);
                    } else {
                        return resources.getString(R.string.rgb32);
                    }
                }
            }).build();
        case Prefs.SHOW_VPN:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_nav_vpn).setTitleResource(R.string.show_vpn).setPreferenceKey(Prefs.SHOW_VPN).setValue(showVpn()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return ((Boolean) item.getValue()) ? resources.getString(R.string.enabled) : resources.getString(R.string.disabled);
                }
            }).build();
        case Prefs.AUTOMATIC_UPDATES:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_auto_update).setTitleResource(R.string.auto_updates).setPreferenceKey(Prefs.AUTOMATIC_UPDATES).setValue(automaticUpdates()).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return ((Boolean) item.getValue()) ? resources.getString(R.string.enabled) : resources.getString(R.string.disabled);
                }
            }).build();
        case Prefs.CHECK_UPDATE:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_check_update).setTitleResource(R.string.check_for_updates).setPreferenceKey(Prefs.CHECK_UPDATE).setValue(prefManager.get(ButterUpdateManager.LAST_UPDATE_CHECK, 1L)).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    long timeStamp = (long) item.getValue();
                    Calendar cal = Calendar.getInstance(Locale.getDefault());
                    cal.setTimeInMillis(timeStamp);
                    String time = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, Locale.getDefault()).format(timeStamp);
                    String date = DateFormat.format("dd-MM-yyy", cal).toString();
                    return resources.getString(R.string.last_check) + ": " + date + " " + time;
                }
            }).build();
        case Prefs.REPORT_BUG:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_report_bug).setTitleResource(R.string.report_a_bug).setPreferenceKey(Prefs.REPORT_BUG).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return resources.getString(R.string.tap_to_open);
                }
            }).build();
        case Prefs.CHANGE_LOG:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_changelog).setTitleResource(R.string.changelog).setPreferenceKey(Prefs.CHANGE_LOG).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return resources.getString(R.string.tap_to_open);
                }
            }).build();
        case Prefs.NOTICE:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_open_source).setTitleResource(R.string.open_source_licenses).setPreferenceKey(Prefs.NOTICE).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return resources.getString(R.string.tap_to_open);
                }
            }).build();
        case Prefs.VERSION:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_version).setTitleResource(R.string.version).setPreferenceKey(Prefs.VERSION).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    try {
                        PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                        return packageInfo.versionName + " - " + Build.CPU_ABI;
                    } catch (NameNotFoundException e) {
                        e.printStackTrace();
                    }
                    return "?.? (?) - ?";
                }
            }).build();
        case Prefs.ABOUT:
            return PrefItem.newBuilder().setIconResource(R.drawable.ic_prefs_about).setTitleResource(R.string.about_app).setPreferenceKey(Prefs.ABOUT).setSubtitleGenerator(new SubtitleGenerator() {

                @Override
                public String get(PrefItem item) {
                    return resources.getString(R.string.tap_to_open);
                }
            }).build();
        case Prefs.TITLE_GENERAL:
            return buildTitlePrefItem(R.string.general);
        case Prefs.TITLE_SUBTITLES:
            return buildTitlePrefItem(R.string.subtitles);
        case Prefs.TITLE_TORRENTS:
            return buildTitlePrefItem(R.string.torrents);
        case Prefs.TITLE_NETWORKING:
            return buildTitlePrefItem(R.string.networking);
        case Prefs.TITLE_ADVANCED:
            return buildTitlePrefItem(R.string.advanced);
        case Prefs.TITLE_UPDATES:
            return buildTitlePrefItem(R.string.updates);
        case Prefs.TITLE_ABOUT:
            return buildTitlePrefItem(R.string.about_app);
        default:
            throw new IllegalArgumentException("Unknown preference key:" + key);
    }
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Context(android.content.Context) SubtitleGenerator(butter.droid.base.content.preferences.PrefItem.SubtitleGenerator) SimpleDateFormat(java.text.SimpleDateFormat) StringRes(android.support.annotation.StringRes) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull) PackageInfo(android.content.pm.PackageInfo) R(butter.droid.base.R) ArrayList(java.util.ArrayList) Format(butter.droid.provider.base.model.Format) Inject(javax.inject.Inject) Calendar(java.util.Calendar) ButterApplication(butter.droid.base.ButterApplication) PrefManager(butter.droid.base.manager.prefs.PrefManager) Locale(java.util.Locale) Map(java.util.Map) Build(android.os.Build) DEFAULT_PROVIDER(butter.droid.base.content.preferences.Prefs.DEFAULT_PROVIDER) LocaleUtils(butter.droid.base.utils.LocaleUtils) Reusable(dagger.Reusable) VLCMediaOptions(butter.droid.base.manager.internal.vlc.VLCMediaOptions) Color(android.graphics.Color) ColorInt(android.support.annotation.ColorInt) DateFormat(android.text.format.DateFormat) List(java.util.List) StorageUtils(butter.droid.base.utils.StorageUtils) Constants(butter.droid.base.Constants) Nullable(android.support.annotation.Nullable) ButterUpdateManager(butter.droid.base.manager.internal.updater.ButterUpdateManager) PrefKey(butter.droid.base.content.preferences.Prefs.PrefKey) Resources(android.content.res.Resources) Locale(java.util.Locale) SubtitleGenerator(butter.droid.base.content.preferences.PrefItem.SubtitleGenerator) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo) Calendar(java.util.Calendar) NonNull(android.support.annotation.NonNull)

Aggregations

Format (butter.droid.provider.base.model.Format)3 NonNull (android.support.annotation.NonNull)2 Nullable (android.support.annotation.Nullable)2 Episode (butter.droid.provider.base.model.Episode)2 Torrent (butter.droid.provider.base.model.Torrent)2 Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 PackageInfo (android.content.pm.PackageInfo)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Resources (android.content.res.Resources)1 Color (android.graphics.Color)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 ColorInt (android.support.annotation.ColorInt)1 StringRes (android.support.annotation.StringRes)1 TextUtils (android.text.TextUtils)1 DateFormat (android.text.format.DateFormat)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1