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();
}
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());
}
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);
}
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();
}
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();
}
Aggregations