use of androidx.fragment.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsActivityTest method onActivityResult_shouldDelegateToListener.
@Test
public void onActivityResult_shouldDelegateToListener() {
final List<Fragment> fragments = new ArrayList<>();
fragments.add(new Fragment());
fragments.add(new ListenerFragment());
final FragmentManager manager = mock(FragmentManager.class);
when(mActivity.getSupportFragmentManager()).thenReturn(manager);
when(manager.getFragments()).thenReturn(fragments);
mActivity.onActivityResult(0, 0, new Intent());
assertThat(((ListenerFragment) fragments.get(1)).mOnActivityResultCalled).isTrue();
}
use of androidx.fragment.app.Fragment in project Presentation by StanKocken.
the class BaseViewProxyTest method testConstructorFragmentShouldGetView.
@Test
public void testConstructorFragmentShouldGetView() {
Fragment fragment = Mockito.mock(Fragment.class);
View rootView = Mockito.mock(View.class);
when(fragment.getView()).thenReturn(rootView);
BaseViewProxy baseViewProxy = new BaseViewProxy(fragment) {
};
assertEquals("The view is not properly get from the Activity", rootView, baseViewProxy.getRootView());
}
use of androidx.fragment.app.Fragment in project UltimateRecyclerView by cymcsg.
the class ViewPagerTabFragmentParentFragment method onUpOrCancelMotionEvent.
@Override
public void onUpOrCancelMotionEvent(final ObservableScrollState scrollState) {
if (!mScrolled) {
// This event can be used only when TouchInterceptionFrameLayout
// doesn't handle the consecutive events.
// toolbarAdjustment(scrollState);
mBaseTranslationY = 0;
final Fragment fragment = getCurrentFragment();
if (fragment == null) {
return;
}
View view = fragment.getView();
if (view == null) {
return;
}
// toolbarAdjustment(mLastScrollState, view);
}
}
use of androidx.fragment.app.Fragment in project UltimateRecyclerView by cymcsg.
the class ViewPagerTabFragmentParentFragment method propagateToolbarState.
private void propagateToolbarState(boolean isShown) {
final int toolbarHeight = headerBanner.getHeight();
// Set scrollY for the fragments that are not created yet
mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight);
// Set scrollY for the active fragments
for (int i = 0; i < mPagerAdapter.getCount(); i++) {
// Skip current item
if (i == mPager.getCurrentItem()) {
continue;
}
// Skip destroyed or not created item
Fragment f = mPagerAdapter.getItemAt(i);
if (f == null) {
continue;
}
View view = f.getView();
if (view == null) {
continue;
}
if (view.findViewById(R.id.scroll) instanceof UltimateRecyclerView) {
UltimateRecyclerView listView = (UltimateRecyclerView) viewscrollable(view);
if (isShown) {
// Scroll up
if (0 < listView.getCurrentScrollY()) {
// listView.setSelection(0);
Log.d(FRAGMENT_TAG, "up");
}
} else {
// Scroll down (to hide padding)
if (listView.getCurrentScrollY() < toolbarHeight) {
// listView.setSelection(1);
Log.d(FRAGMENT_TAG, "down");
}
}
}
}
}
use of androidx.fragment.app.Fragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsHomepageActivity method showFragment.
private void showFragment(Fragment fragment, int id) {
final FragmentManager fragmentManager = getSupportFragmentManager();
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
final Fragment showFragment = fragmentManager.findFragmentById(id);
if (showFragment == null) {
fragmentTransaction.add(id, fragment);
} else {
fragmentTransaction.show(showFragment);
}
fragmentTransaction.commit();
}
Aggregations