Search in sources :

Example 66 with Fragment

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());
            }
        }
    };
}
Also used : Observer(androidx.lifecycle.Observer) Fragment(androidx.fragment.app.Fragment) PlayerFragment(com.zype.android.ui.player.PlayerFragment) Nullable(androidx.annotation.Nullable)

Example 67 with Fragment

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();
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) VideoDetailPagerAdapter(com.zype.android.ui.video_details.VideoDetailPagerAdapter) Fragment(androidx.fragment.app.Fragment) ThumbnailFragment(com.zype.android.ui.player.ThumbnailFragment) SummaryFragment(com.zype.android.ui.video_details.fragments.summary.SummaryFragment) PlayerFragment(com.zype.android.ui.player.v2.PlayerFragment)

Example 68 with Fragment

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();
}
Also used : SettingsFragment(app.insti.fragment.SettingsFragment) FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) FragmentTransaction(androidx.fragment.app.FragmentTransaction) TransitionTargetFragment(app.insti.fragment.TransitionTargetFragment) Fragment(androidx.fragment.app.Fragment) EventFragment(app.insti.fragment.EventFragment) SettingsFragment(app.insti.fragment.SettingsFragment) BodyFragment(app.insti.fragment.BodyFragment) UserFragment(app.insti.fragment.UserFragment)

Example 69 with Fragment

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);
    }
}
Also used : NewsArticle(app.insti.api.model.NewsArticle) PlacementBlogPost(app.insti.api.model.PlacementBlogPost) PlacementBlogFragment(app.insti.fragment.PlacementBlogFragment) Gson(com.google.gson.Gson) Event(app.insti.api.model.Event) NewsFragment(app.insti.fragment.NewsFragment) NotificationsFragment(app.insti.fragment.NotificationsFragment) NewsFragment(app.insti.fragment.NewsFragment) TrainingBlogFragment(app.insti.fragment.TrainingBlogFragment) Fragment(androidx.fragment.app.Fragment) PlacementBlogFragment(app.insti.fragment.PlacementBlogFragment) TrainingBlogFragment(app.insti.fragment.TrainingBlogFragment) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 70 with Fragment

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);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) TracksChooserDialog(com.google.android.libraries.cast.companionlibrary.cast.tracks.ui.TracksChooserDialog) Fragment(androidx.fragment.app.Fragment)

Aggregations

Fragment (androidx.fragment.app.Fragment)239 FragmentTransaction (androidx.fragment.app.FragmentTransaction)54 Bundle (android.os.Bundle)46 FragmentManager (androidx.fragment.app.FragmentManager)38 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 DialogFragment (androidx.fragment.app.DialogFragment)22 View (android.view.View)21 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 Intent (android.content.Intent)19 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18