Search in sources :

Example 51 with Fragment

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();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment) Test(org.junit.Test)

Example 52 with Fragment

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());
}
Also used : Fragment(androidx.fragment.app.Fragment) EfficientCacheView(com.skocken.efficientadapter.lib.util.EfficientCacheView) View(android.view.View) Test(org.junit.Test)

Example 53 with Fragment

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);
    }
}
Also used : Fragment(androidx.fragment.app.Fragment) ImageView(android.widget.ImageView) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Example 54 with Fragment

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");
                }
            }
        }
    }
}
Also used : UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) Fragment(androidx.fragment.app.Fragment) ImageView(android.widget.ImageView) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Example 55 with Fragment

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();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Fragment(androidx.fragment.app.Fragment) ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment)

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