Java Code Examples for android.app.Fragment#getView()

The following examples show how to use android.app.Fragment#getView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TVDetails.java    From moviedb-android with Apache License 2.0 6 votes vote down vote up
private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }
    View view = fragment.getView();
    if (view == null) {
        return null;
    }
    switch (mViewPager.getCurrentItem()) {
        case 0:
            return (Scrollable) view.findViewById(R.id.tvdetailsinfo);
        case 1:
            return (Scrollable) view.findViewById(R.id.castList);
        case 2:
            return (Scrollable) view.findViewById(R.id.tvdetailsoverview);
        default:
            return (Scrollable) view.findViewById(R.id.tvdetailsinfo);
    }
}
 
Example 2
Source File: MovieSlideTab.java    From moviedb-android with Apache License 2.0 6 votes vote down vote up
private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }
    View view = fragment.getView();
    if (view == null) {
        return null;
    }
    switch (mViewPager.getCurrentItem()) {
        case 0:
            return (Scrollable) view.findViewById(R.id.movieslist);
        case 1:
            return (Scrollable) view.findViewById(R.id.nowplaying);
        case 2:
            return (Scrollable) view.findViewById(R.id.popular);
        case 3:
            return (Scrollable) view.findViewById(R.id.toprated);
        default:
            return (Scrollable) view.findViewById(R.id.movieslist);
    }
}
 
Example 3
Source File: CastDetails.java    From moviedb-android with Apache License 2.0 6 votes vote down vote up
private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }
    View view = fragment.getView();
    if (view == null) {
        return null;
    }
    switch (mViewPager.getCurrentItem()) {
        case 0:
            return (Scrollable) view.findViewById(R.id.castdetailsinfo);
        case 1:
            return (Scrollable) view.findViewById(R.id.castdetailscredits);
        case 2:
            return (Scrollable) view.findViewById(R.id.castdetailsbiography);
        default:
            return (Scrollable) view.findViewById(R.id.castdetailsinfo);
    }
}
 
Example 4
Source File: TVSlideTab.java    From moviedb-android with Apache License 2.0 6 votes vote down vote up
private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }
    View view = fragment.getView();
    if (view == null) {
        return null;
    }
    switch (mViewPager.getCurrentItem()) {
        case 0:
            return (Scrollable) view.findViewById(R.id.TVOnTheAirList);
        case 1:
            return (Scrollable) view.findViewById(R.id.TVAiringTodayList);
        case 2:
            return (Scrollable) view.findViewById(R.id.TVPopularList);
        case 3:
            return (Scrollable) view.findViewById(R.id.TVTopRatedList);
        default:
            return (Scrollable) view.findViewById(R.id.TVOnTheAirList);
    }
}
 
Example 5
Source File: MovieDetails.java    From moviedb-android with Apache License 2.0 6 votes vote down vote up
private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }
    View view = fragment.getView();
    if (view == null) {
        return null;
    }
    switch (mViewPager.getCurrentItem()) {
        case 0:
            return (Scrollable) view.findViewById(R.id.moviedetailsinfo);
        case 1:
            return (Scrollable) view.findViewById(R.id.castList);
        case 2:
            return (Scrollable) view.findViewById(R.id.moviedetailsoverview);
        default:
            return (Scrollable) view.findViewById(R.id.moviedetailsinfo);
    }
}
 
Example 6
Source File: AndroidOFragmentRefWatcher.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
@Override
public void onFragmentViewDestroyed(FragmentManager fm, Fragment fragment) {
  View view = fragment.getView();
  if (view != null) {
    refWatcher.watch(view);
  }
}
 
Example 7
Source File: Preferences.java    From delion with Apache License 2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 8
Source File: SoftKeyboardHelper.java    From Snake with Apache License 2.0 5 votes vote down vote up
public static boolean hideKeyboard(@NonNull Fragment fragment) {
    if(fragment.isDetached() || fragment.isRemoving() || null == fragment.getActivity()) return true;

    InputMethodManager inputMethodManager = (InputMethodManager) fragment.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    View rootView = fragment.getView();
    if(rootView instanceof ViewGroup) {
        View focusedChild = ((ViewGroup)rootView).getFocusedChild();
        if(null != focusedChild) {
            return inputMethodManager.hideSoftInputFromWindow(focusedChild.getWindowToken(), 0);
        }
    }

    return true;
}
 
Example 9
Source File: Preferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 10
Source File: Preferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 11
Source File: MirrorActivity.java    From mirror with Apache License 2.0 4 votes vote down vote up
private int getParentId(final Fragment fragment) {
    if (fragment.getView() != null && fragment.getView().getParent() != null) {
        return ((View) fragment.getView().getParent()).getId();
    }
    return 0;
}
 
Example 12
Source File: FragmentCompatFramework.java    From weex with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View getView(Fragment fragment) {
  return fragment.getView();
}
 
Example 13
Source File: FragmentCompatFramework.java    From stetho with MIT License 4 votes vote down vote up
@Nullable
@Override
public View getView(Fragment fragment) {
  return fragment.getView();
}
 
Example 14
Source File: TapchatFragmentStatePagerAdapter.java    From tapchat-android with Apache License 2.0 4 votes vote down vote up
@Override public Object instantiateItem(ViewGroup container, int position) {
    // If we already have this item instantiated, there is nothing
    // to do.  This can happen when we are restoring the entire pager
    // from its saved state, where the fragment manager has already
    // taken care of restoring the fragments we previously had instantiated.
    if (mFragments.size() > position) {
        Fragment f = mFragments.get(position);
        if (f != null) {
            int newPos = getItemPosition(f);
            if (position == newPos) {
                if (f.getView() != null && f.getView().getParent() != container) {
                    ((ViewGroup) f.getView().getParent()).removeView(f.getView());
                    container.addView(f.getView());
                }
                return f;
            } else {
                mFragments.remove(position);
                mFragments.ensureCapacity(newPos + 1);
                for (int i = mFragments.size(); i < (newPos +1); i++) {
                    mFragments.add(null);
                }
                mFragments.set(newPos, f);
            }
        }
    }

    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    Fragment fragment = getItem(position);
    if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    if (mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }
    fragment.setMenuVisibility(false);
    mFragments.set(position, fragment);
    mCurTransaction.add(container.getId(), fragment, getTag(position));

    return fragment;
}