@Override public boolean isViewFromObject(View view, Object object) { return ((Fragment) object).getView() == view; }
@Nullable @Override public View getView(Fragment fragment) { return fragment.getView(); }
@Override public void onFragmentViewDestroyed(FragmentManager fm, Fragment fragment) { View view = fragment.getView(); if (view != null) { refWatcher.watch(view); } }
@Override public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { return ((Fragment) object).getView() == view; }
@SuppressWarnings("deprecation") @Deprecated @TargetApi(Build.VERSION_CODES.O) private void findAllFragmentsWithViews( @NonNull android.app.FragmentManager fragmentManager, @NonNull ArrayMap<View, android.app.Fragment> result) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { for (android.app.Fragment fragment : fragmentManager.getFragments()) { if (fragment.getView() != null) { result.put(fragment.getView(), fragment); findAllFragmentsWithViews(fragment.getChildFragmentManager(), result); } } } else { findAllFragmentsWithViewsPreO(fragmentManager, result); } }
@SuppressWarnings("deprecation") @Deprecated private void findAllFragmentsWithViewsPreO( @NonNull android.app.FragmentManager fragmentManager, @NonNull ArrayMap<View, android.app.Fragment> result) { int index = 0; while (true) { tempBundle.putInt(FRAGMENT_INDEX_KEY, index++); android.app.Fragment fragment = null; try { fragment = fragmentManager.getFragment(tempBundle, FRAGMENT_INDEX_KEY); } catch (Exception e) { // This generates log spam from FragmentManager anyway. } if (fragment == null) { break; } if (fragment.getView() != null) { result.put(fragment.getView(), fragment); if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { findAllFragmentsWithViews(fragment.getChildFragmentManager(), result); } } } }
@SuppressLint("CommitTransaction") @Override public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } if (DEBUG) Log.v(TAG, "Detaching item #" + getItemId(position) + ": f=" + object + " v=" + ((Fragment) object).getView()); mCurTransaction.detach((Fragment) object); }
/** */ @Override public boolean isViewFromObject(View view, Object object) { return ((Fragment) object).getView() == view; }
/** */ @Override public boolean isViewFromObject(View view, Object object) { return ((Fragment) object).getView() == view; }
/** */ @Override public boolean isViewFromObject(View view, Object object) { return ((Fragment) object).getView() == view; }
/** */ @Override public boolean isViewFromObject(View view, Object object) { return ((Fragment) object).getView() == view; }
@Override public boolean isViewFromObject(View view, Object object) { return ((Fragment) object).getView() == view; }
private static void addAliveFragment(Object obj) { View view = null; if (obj instanceof Fragment) { view = ((Fragment) obj).getView(); } else if (obj instanceof android.support.v4.app.Fragment) { view = ((android.support.v4.app.Fragment) obj).getView(); } if (null != view) { int viewCode = view.hashCode(); sAliveFragMap.put(obj.hashCode(), new Pair<>(viewCode, obj.getClass().getSimpleName())); } }
@Nullable private static View getView(Object object, int value) { View viewById = null; if (object instanceof Activity) { viewById = ((Activity) object).getWindow().findViewById(value); } else if (object instanceof View) { viewById = ((View) object).findViewById(value); } else if (object instanceof Fragment) { viewById = ((Fragment) object).getView().findViewById(value); } return viewById; }
public static LoadingLayout wrap(Fragment fragment) { return wrap(fragment.getView()); } public static LoadingLayout wrap(View view) {
public FragmentItemBinding(final Fragment fragment, final int layoutResourceId){ super(fragment.getActivity().getApplicationContext(), fragment.getView().findViewById(layoutResourceId), new HashSet<Binding>()); }
public FragmentAdapterBinding(final Fragment fragment, int resourceId, final ViewModelColumn viewModelColumn, List<AdapterItemBinding> adapterItemBindings) { super(fragment.getActivity().getApplicationContext(), (AdapterView) fragment.getView().findViewById(resourceId), viewModelColumn, adapterItemBindings); } }
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Fragment fragment = getFragmentManager().findFragmentById(android.R.id.content); if (fragment instanceof PreferenceFragment && fragment.getView() != null) { // Set list view padding to 0 so dividers are the full width of the screen. fragment.getView().findViewById(android.R.id.list).setPadding(0, 0, 0, 0); } } }
public static void apply(@NonNull android.app.Fragment fragment, @Nullable String key) { if (fragment.getActivity() == null) throw new IllegalStateException("Fragment is not attached to an Activity yet."); else if (fragment.getView() == null) throw new IllegalStateException("Fragment does not have a View yet."); apply(fragment.getActivity(), (ViewGroup) fragment.getView(), key); if (fragment.getActivity() instanceof AppCompatActivity) apply(fragment.getActivity(), key); }
@Override public void onTabFragmentViewCreated(Fragment fragment) { mStaggeredLayoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL); mRecyclerView = (CollectionRecyclerView) fragment.getView().findViewById(R.id.list); mRecyclerView.setLayoutManager(mStaggeredLayoutManager); mRecyclerView.setHasFixedSize(true); mAdapter = new CategoryTabFragment.TabAdapter(this); mRecyclerView.setAdapter(mAdapter); mAdapter.setOnItemClickListener(onItemClickListener); enableActionBarAutoHide(mRecyclerView); }