use of androidx.fragment.app.Fragment in project android by nextcloud.
the class PreviewImagePagerAdapter method getItem.
@NonNull
public Fragment getItem(int i) {
OCFile file = getFileAt(i);
Fragment fragment;
if (file == null) {
fragment = PreviewImageErrorFragment.newInstance();
} else if (file.isDown()) {
fragment = PreviewImageFragment.newInstance(file, mObsoletePositions.contains(i), false);
} else {
if (mDownloadErrors.remove(i)) {
fragment = FileDownloadFragment.newInstance(file, user, true);
((FileDownloadFragment) fragment).setError(true);
} else {
if (file.isEncrypted()) {
fragment = FileDownloadFragment.newInstance(file, user, mObsoletePositions.contains(i));
} else {
fragment = PreviewImageFragment.newInstance(file, mObsoletePositions.contains(i), true);
}
}
}
mObsoletePositions.remove(i);
return fragment;
}
use of androidx.fragment.app.Fragment in project EhViewer by seven332.
the class StageActivity method getTopSceneClass.
@Nullable
public Class<?> getTopSceneClass() {
int index = mSceneTagList.size() - 1;
if (index < 0) {
return null;
}
String tag = mSceneTagList.get(index);
Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
if (null == fragment) {
return null;
}
return fragment.getClass();
}
use of androidx.fragment.app.Fragment in project EhViewer by seven332.
the class StageActivity method onBackPressed.
@Override
public void onBackPressed() {
int size = mSceneTagList.size();
String tag = mSceneTagList.get(size - 1);
SceneFragment scene;
Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
if (fragment == null) {
Log.e(TAG, "onBackPressed: Can't find scene by tag: " + tag);
return;
}
if (!(fragment instanceof SceneFragment)) {
Log.e(TAG, "onBackPressed: The fragment is not SceneFragment");
return;
}
scene = (SceneFragment) fragment;
scene.onBackPressed();
}
use of androidx.fragment.app.Fragment in project BaseProject by fly803.
the class FragmentUtils method operate.
private static void operate(final int type, final FragmentManager fm, final FragmentTransaction ft, final Fragment src, final Fragment... dest) {
if (src != null && src.isRemoving()) {
Log.e("FragmentUtils", src.getClass().getName() + " is isRemoving");
return;
}
String name;
Bundle args;
switch(type) {
case TYPE_ADD_FRAGMENT:
for (Fragment fragment : dest) {
name = fragment.getClass().getName();
args = fragment.getArguments();
Fragment fragmentByTag = fm.findFragmentByTag(name);
if (fragmentByTag != null && fragmentByTag.isAdded()) {
ft.remove(fragmentByTag);
}
ft.add(args.getInt(ARGS_ID), fragment, name);
if (args.getBoolean(ARGS_IS_HIDE))
ft.hide(fragment);
if (args.getBoolean(ARGS_IS_ADD_STACK))
ft.addToBackStack(name);
}
break;
case TYPE_HIDE_FRAGMENT:
for (Fragment fragment : dest) {
ft.hide(fragment);
}
break;
case TYPE_SHOW_FRAGMENT:
for (Fragment fragment : dest) {
ft.show(fragment);
}
break;
case TYPE_SHOW_HIDE_FRAGMENT:
ft.show(src);
for (Fragment fragment : dest) {
if (fragment != src) {
ft.hide(fragment);
}
}
break;
case TYPE_REPLACE_FRAGMENT:
name = dest[0].getClass().getName();
args = dest[0].getArguments();
ft.replace(args.getInt(ARGS_ID), dest[0], name);
if (args.getBoolean(ARGS_IS_ADD_STACK))
ft.addToBackStack(name);
break;
case TYPE_REMOVE_FRAGMENT:
for (Fragment fragment : dest) {
if (fragment != src) {
ft.remove(fragment);
}
}
break;
case TYPE_REMOVE_TO_FRAGMENT:
for (int i = dest.length - 1; i >= 0; --i) {
Fragment fragment = dest[i];
if (fragment == dest[0]) {
if (src != null)
ft.remove(fragment);
break;
}
ft.remove(fragment);
}
break;
}
ft.commitAllowingStateLoss();
}
use of androidx.fragment.app.Fragment in project BaseProject by fly803.
the class FragmentUtils method show.
/**
* Show fragment.
*
* @param fm The manager of fragment.
*/
public static void show(@NonNull final FragmentManager fm) {
List<Fragment> fragments = getFragments(fm);
for (Fragment show : fragments) {
putArgs(show, false);
}
operateNoAnim(fm, TYPE_SHOW_FRAGMENT, null, fragments.toArray(new Fragment[fragments.size()]));
}
Aggregations