Search in sources :

Example 6 with Fragment

use of androidx.fragment.app.Fragment in project k-9 by k9mail.

the class CryptoInfoDialog method onCreateDialog.

// inflating without root element is fine for creating a dialog
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Builder b = new AlertDialog.Builder(getActivity());
    View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.message_crypto_info_dialog, null);
    statusIcon = dialogView.findViewById(R.id.crypto_info_top_icon_1);
    titleText = dialogView.findViewById(R.id.crypto_info_title);
    descriptionText = dialogView.findViewById(R.id.crypto_info_text);
    MessageCryptoDisplayStatus displayStatus = MessageCryptoDisplayStatus.valueOf(getArguments().getString(ARG_DISPLAY_STATUS));
    setMessageForDisplayStatus(displayStatus);
    b.setView(dialogView);
    b.setPositiveButton(R.string.crypto_info_ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dismiss();
        }
    });
    boolean hasSecurityWarning = getArguments().getBoolean(ARG_HAS_SECURITY_WARNING);
    if (hasSecurityWarning) {
        b.setNeutralButton(R.string.crypto_info_view_security_warning, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Fragment frag = getTargetFragment();
                if (!(frag instanceof OnClickShowCryptoKeyListener)) {
                    throw new AssertionError("Displaying activity must implement OnClickShowCryptoKeyListener!");
                }
                ((OnClickShowCryptoKeyListener) frag).onClickShowSecurityWarning();
            }
        });
    } else if (displayStatus.isUnknownKey()) {
        b.setNeutralButton(R.string.crypto_info_search_key, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Fragment frag = getTargetFragment();
                if (!(frag instanceof OnClickShowCryptoKeyListener)) {
                    throw new AssertionError("Displaying activity must implement OnClickShowCryptoKeyListener!");
                }
                ((OnClickShowCryptoKeyListener) frag).onClickSearchKey();
            }
        });
    } else if (displayStatus.hasAssociatedKey()) {
        int buttonLabel = displayStatus.isUnencryptedSigned() ? R.string.crypto_info_view_signer : R.string.crypto_info_view_sender;
        b.setNeutralButton(buttonLabel, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Fragment frag = getTargetFragment();
                if (!(frag instanceof OnClickShowCryptoKeyListener)) {
                    throw new AssertionError("Displaying activity must implement OnClickShowCryptoKeyListener!");
                }
                ((OnClickShowCryptoKeyListener) frag).onClickShowCryptoKey();
            }
        });
    }
    return b.create();
}
Also used : DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) MessageCryptoDisplayStatus(com.fsck.k9.view.MessageCryptoDisplayStatus) OnClickListener(android.content.DialogInterface.OnClickListener) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Fragment(androidx.fragment.app.Fragment) DialogFragment(androidx.fragment.app.DialogFragment) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 7 with Fragment

use of androidx.fragment.app.Fragment in project Parse-SDK-Android by ParsePlatform.

the class ParseFacebookUtilsTest method doLinkWith.

private void doLinkWith(Activity activity, Fragment fragment, Collection<String> permissions, FacebookController.LoginAuthorizationType type) {
    assertFalse("Cannot run test with both Activity and Fragment", activity != null && fragment != null);
    Map<String, String> authData = new HashMap<>();
    when(controller.authenticateAsync(nullable(Activity.class), nullable(Fragment.class), any(FacebookController.LoginAuthorizationType.class), anyList())).thenReturn(Task.forResult(authData));
    ParseFacebookUtils.isInitialized = true;
    ParseUser user = mock(ParseUser.class);
    when(user.linkWithInBackground(anyString(), anyMap())).thenReturn(Task.forResult(null));
    Task<Void> task;
    if (FacebookController.LoginAuthorizationType.PUBLISH.equals(type)) {
        if (activity != null) {
            task = ParseFacebookUtils.linkWithPublishPermissionsInBackground(user, activity, permissions);
        } else {
            task = ParseFacebookUtils.linkWithPublishPermissionsInBackground(user, fragment, permissions);
        }
    } else {
        if (activity != null) {
            task = ParseFacebookUtils.linkWithReadPermissionsInBackground(user, activity, permissions);
        } else {
            task = ParseFacebookUtils.linkWithReadPermissionsInBackground(user, fragment, permissions);
        }
    }
    verify(controller).authenticateAsync(activity, fragment, type, permissions);
    verify(user).linkWithInBackground("facebook", authData);
    assertTrue(task.isCompleted());
}
Also used : HashMap(java.util.HashMap) Activity(android.app.Activity) Matchers.anyString(org.mockito.Matchers.anyString) Fragment(androidx.fragment.app.Fragment) ParseUser(com.parse.ParseUser)

Example 8 with Fragment

use of androidx.fragment.app.Fragment in project Timber by naman14.

the class PlaylistFragment method initPager.

private void initPager() {
    pager.setVisibility(View.VISIBLE);
    recyclerView.setVisibility(View.GONE);
    recyclerView.setAdapter(null);
    adapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {

        @Override
        public int getCount() {
            return playlistcount;
        }

        @Override
        public Fragment getItem(int position) {
            return PlaylistPagerFragment.newInstance(position);
        }
    };
    pager.setAdapter(adapter);
    pager.setOffscreenPageLimit(3);
}
Also used : FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) Fragment(androidx.fragment.app.Fragment) PlaylistPagerFragment(com.naman14.timber.subfragments.PlaylistPagerFragment)

Example 9 with Fragment

use of androidx.fragment.app.Fragment in project Timber by naman14.

the class NowPlayingActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nowplaying);
    SharedPreferences prefs = getSharedPreferences(Constants.FRAGMENT_ID, Context.MODE_PRIVATE);
    String fragmentID = prefs.getString(Constants.NOWPLAYING_FRAGMENT_ID, Constants.TIMBER3);
    Fragment fragment = NavigationUtils.getFragmentForNowplayingID(fragmentID);
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) SharedPreferences(android.content.SharedPreferences) Fragment(androidx.fragment.app.Fragment)

Example 10 with Fragment

use of androidx.fragment.app.Fragment in project Timber by naman14.

the class NavigationUtils method navigateToArtist.

@TargetApi(21)
public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) {
    FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
    Fragment fragment;
    transaction.setCustomAnimations(R.anim.activity_fade_in, R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out);
    fragment = ArtistDetailFragment.newInstance(artistID, false, null);
    transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
    transaction.add(R.id.fragment_container, fragment);
    transaction.addToBackStack(null).commit();
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) ArtistDetailFragment(com.naman14.timber.fragments.ArtistDetailFragment) Fragment(androidx.fragment.app.Fragment) AlbumDetailFragment(com.naman14.timber.fragments.AlbumDetailFragment) TargetApi(android.annotation.TargetApi)

Aggregations

Fragment (androidx.fragment.app.Fragment)262 FragmentTransaction (androidx.fragment.app.FragmentTransaction)57 Bundle (android.os.Bundle)49 FragmentManager (androidx.fragment.app.FragmentManager)42 DialogFragment (androidx.fragment.app.DialogFragment)24 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 Intent (android.content.Intent)22 View (android.view.View)22 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 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