use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.
the class StreamableDetailPresenterImpl method subtitleSelected.
@Override
public void subtitleSelected(UiSubItem item) {
UiSubItem selectedSub = this.selectedSub;
if (selectedSub != null) {
selectedSub.setSelected(false);
}
this.selectedSub = item;
item.setSelected(true);
String language = item.getLanguage();
parentPresenter.selectSubtitle(new SubtitleWrapper(item.getSubtitle()));
if (language == null) {
view.setSubtitleText(R.string.no_subs);
} else {
view.setSubtitleText(item.getName());
}
view.hideDialog();
}
use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.
the class BaseStreamLoadingFragmentPresenterImpl method loadSubtitles.
/**
* Downloads the subs file
*/
private void loadSubtitles() {
MediaWrapper media = streamInfo.getMedia();
SubsProvider subsProvider = providerManager.getSubsProvider(media.getProviderId());
SubtitleWrapper subtitle = streamInfo.getSubtitle();
// TODO dispose
subtitleManager.downloadSubtitle(subsProvider, media.getMedia(), subtitle).observeOn(AndroidSchedulers.mainThread()).subscribe(new MaybeObserver<SubtitleWrapper>() {
@Override
public void onSubscribe(final Disposable d) {
subtitleDisposable = d;
}
@Override
public void onSuccess(final SubtitleWrapper wrapper) {
subtitleDisposable = null;
startPlayer();
}
@Override
public void onError(final Throwable e) {
subtitleDisposable = null;
startPlayer();
}
@Override
public void onComplete() {
subtitleDisposable = null;
startPlayer();
}
});
}
use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.
the class TVStreamableDetailsFragment method startMovie.
@Override
public void startMovie(final MediaWrapper item, final Torrent torrent, final String quality) {
// Default subtitles will be loaded
StreamInfo info = new StreamInfo(torrent, item, null, new SubtitleWrapper());
TVStreamLoadingActivity.startActivity(getActivity(), info);
}
use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.
the class StreamableDetailPresenterImpl method displaySubtitles.
private void displaySubtitles() {
if (providerManager.hasSubsProvider(mediaWrapper.getProviderId())) {
view.setSubtitleText(R.string.loading_subs);
view.setSubtitleEnabled(false);
providerManager.getSubsProvider(mediaWrapper.getProviderId()).list(mediaWrapper.getMedia()).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.getLanguage().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) {
subtitlesRequest = d;
}
@Override
public void onSuccess(final List<UiSubItem> subs) {
if (subs.isEmpty()) {
view.setSubtitleText(R.string.no_subs_available);
subtitleList = null;
} else {
view.setSubtitleEnabled(true);
subtitleList = subs;
UiSubItem selectedItem = null;
for (final UiSubItem sub : subs) {
if (sub.isSelected()) {
selectedItem = sub;
String name = sub.getName();
if (TextUtils.isEmpty(name)) {
view.setSubtitleText(R.string.no_subs);
} else {
view.setSubtitleText(name);
}
break;
}
}
if (selectedItem == null) {
selectedItem = subs.get(0);
}
selectedSub = selectedItem;
if (selectedItem.getLanguage() == null) {
parentPresenter.selectSubtitle(new SubtitleWrapper());
} else {
parentPresenter.selectSubtitle(new SubtitleWrapper(selectedItem.getSubtitle()));
}
}
}
@Override
public void onError(final Throwable e) {
subtitleList = null;
view.setSubtitleText(R.string.no_subs_available);
view.setSubtitleEnabled(false);
}
});
} else {
view.setSubtitleText(R.string.no_subs_available);
view.setSubtitleEnabled(false);
}
}
Aggregations