use of androidx.fragment.app.Fragment in project zype-android by zype.
the class VideoDetailActivity method createContentUriObserver.
private Observer<String> createContentUriObserver() {
return new Observer<String>() {
@Override
public void onChanged(@Nullable String url) {
Logger.d("getContentUri(): onChanged(): url=" + url);
if (!TextUtils.isEmpty(url)) {
if (playerViewModel.isTrailer().getValue()) {
Logger.d("getContentUri(): onChanged(): playing trailer");
mType = PlayerFragment.TYPE_VIDEO_TRAILER;
Fragment fragment = PlayerFragment.newInstance(mType, url, null);
// showFragment(fragment);
} else {
switch(playerViewModel.getPlayerMode().getValue()) {
case AUDIO:
if (playerViewModel.isAudioDownloaded()) {
mType = PlayerFragment.TYPE_AUDIO_LOCAL;
} else {
mType = PlayerFragment.TYPE_AUDIO_WEB;
}
break;
case VIDEO:
if (playerViewModel.isVideoDownloaded()) {
mType = PlayerFragment.TYPE_VIDEO_LOCAL;
} else {
mType = PlayerFragment.TYPE_VIDEO_WEB;
}
break;
}
hideProgress();
changeFragment(isChromecastConntected());
}
} else {
showThumbnailView(videoDetailViewModel.getVideo().getValue());
}
}
};
}
use of androidx.fragment.app.Fragment in project zype-android by zype.
the class VideoDetailActivity method showSections.
private void showSections(String videoId) {
pagerSections = findViewById(R.id.pagerSections);
tabs = findViewById(R.id.tabs);
layoutSummary = findViewById(R.id.layoutSummary);
if (hasOptions(videoId)) {
pagerSections.setAdapter(new VideoDetailPagerAdapter(this, getSupportFragmentManager(), videoId));
tabs.setupWithViewPager(pagerSections);
pagerSections.setVisibility(View.VISIBLE);
tabs.setVisibility(View.VISIBLE);
layoutSummary.setVisibility(GONE);
} else {
pagerSections.setVisibility(GONE);
tabs.setVisibility(GONE);
layoutSummary.setVisibility(View.VISIBLE);
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = SummaryFragment.newInstance();
fm.beginTransaction().replace(R.id.layoutSummary, fragment, SummaryFragment.TAG).commit();
}
}
use of androidx.fragment.app.Fragment in project IITB-App by wncc.
the class Utils method changeTheme.
public static void changeTheme(SettingsFragment fragment, boolean darkTheme) {
isDarkTheme = darkTheme;
FragmentActivity fragmentActivity = fragment.getActivity();
fragmentActivity.setTheme(darkTheme ? R.style.AppThemeDark : R.style.AppTheme);
// Set background color of activity
fragmentActivity.findViewById(R.id.drawer_layout).setBackgroundColor(getAttrColor(fragmentActivity, R.attr.themeColor));
// Put in a new settings fragment
Fragment newFragment = new SettingsFragment();
newFragment.setArguments(fragment.getArguments());
FragmentManager fm = fragmentActivity.getSupportFragmentManager();
fm.popBackStack();
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(getTag(fragment));
ft.replace(R.id.framelayout_for_fragment, newFragment, getTag(fragment)).commit();
}
use of androidx.fragment.app.Fragment in project IITB-App by wncc.
the class NotificationsAdapter method onClick.
@Override
public void onClick(Notification notification, FragmentActivity fragmentActivity) {
/* Mark notification read */
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
String sessId = Utils.getSessionIDHeader();
retrofitInterface.markNotificationRead(sessId, notification.getNotificationId().toString()).enqueue(new EmptyCallback<Void>());
ShortcutBadger.applyCount(fragmentActivity.getApplicationContext(), NotificationId.decrementAndGetCurrentCount());
/* Close the bottom sheet */
notificationsFragment.dismiss();
Gson gson = Utils.gson;
/* Open event */
if (notification.isEvent()) {
Event event = gson.fromJson(gson.toJson(notification.getNotificationActor()), Event.class);
Utils.openEventFragment(event, fragmentActivity);
} else if (notification.isNews()) {
NewsFragment newsFragment = new NewsFragment();
NewsArticle newsArticle = gson.fromJson(gson.toJson(notification.getNotificationActor()), NewsArticle.class);
newsFragment.withId(newsArticle.getId());
Utils.updateFragment(newsFragment, fragmentActivity);
} else if (notification.isBlogPost()) {
PlacementBlogPost post = gson.fromJson(gson.toJson(notification.getNotificationActor()), PlacementBlogPost.class);
Fragment fragment;
if (post.getLink().contains("training")) {
fragment = (new TrainingBlogFragment()).withId(post.getId());
} else {
fragment = (new PlacementBlogFragment()).withId(post.getId());
}
Utils.updateFragment(fragment, fragmentActivity);
}
}
use of androidx.fragment.app.Fragment in project zype-android by zype.
the class VideoCastControllerActivity method showTracksChooserDialog.
private void showTracksChooserDialog() throws TransientNetworkDisconnectionException, NoConnectionException {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag(DIALOG_TAG);
if (prev != null) {
transaction.remove(prev);
}
transaction.addToBackStack(null);
// Create and show the dialog.
TracksChooserDialog dialogFragment = TracksChooserDialog.newInstance(mCastManager.getRemoteMediaInformation());
dialogFragment.show(transaction, DIALOG_TAG);
}
Aggregations