Example usage for android.app Fragment getView

List of usage examples for android.app Fragment getView

Introduction

In this page you can find the example usage for android.app Fragment getView.

Prototype

@Nullable
public View getView() 

Source Link

Document

Get the root view for the fragment's layout (the one returned by #onCreateView ), if provided.

Usage

From source file:com.breadwallet.tools.animation.BRAnimator.java

public static void animateSlideToRight(final MainActivity context) {
    try {/*w w w  . j  av a2  s  . c o  m*/
        if (!checkTheHorizontalSlideAvailability())
            return;
        final Fragment tmp = previous.pop();
        level--;
        if (level < 1)
            context.setBurgerButtonImage(BRConstants.BURGER);
        if (level == 1)
            context.setBurgerButtonImage(BRConstants.CLOSE);
        FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.main_layout, tmp, tmp.getClass().getName());
        fragmentTransaction.commit();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                TranslateAnimation trans = new TranslateAnimation(-MainActivity.screenParametersPoint.x, 0, 0,
                        0);
                trans.setDuration(horizontalSlideDuration);
                trans.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f));
                View view = tmp.getView();
                if (view != null)
                    view.startAnimation(trans);
            }
        }, 1);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:de.sourcestream.movieDB.controller.MovieSlideTab.java

private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }/*www  . java 2 s. c o  m*/
    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);
    }
}

From source file:de.sourcestream.movieDB.controller.TVSlideTab.java

private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }//  ww w .  j  ava 2  s  . com
    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);
    }
}

From source file:com.breadwallet.tools.animation.BRAnimator.java

/**
 * Animates the fragment transition on button_regular_blue "Settings" pressed
 *//*  www  .j  a  v  a2s. c o m*/
public static void animateSlideToLeft(final MainActivity context, final Fragment to,
        Fragment previousFragment) {
    try {
        if (!checkTheHorizontalSlideAvailability())
            return;
        level++;
        if (level > 1)
            context.setBurgerButtonImage(BRConstants.BACK);
        FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.main_layout, to, to.getClass().getName());
        if (previousFragment != null)
            previous.add(previousFragment);
        fragmentTransaction.commit();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                TranslateAnimation trans = new TranslateAnimation(MainActivity.screenParametersPoint.x, 0, 0,
                        0);
                trans.setDuration(horizontalSlideDuration);
                trans.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f));
                View view = to.getView();
                if (view != null)
                    view.startAnimation(trans);
            }
        }, 1);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.github.paradam.infinitepager.InfiniteFragmentStatePagerAdapter.java

/**
 * Create the page for the given position.  The adapter is responsible for adding the view to
 * the container given here, although it only must ensure this is done by the time it returns
 * from {@link #finishUpdate(android.view.ViewGroup)}.
 *
 * @param container The containing View in which the page will be shown.
 * @param position  The page position to be instantiated.
 * @return Returns an Object representing the new page.  This does not need to be a View, but
 * can be some other container of the page.
 *//*from w ww. j  av a2s.  c om*/
public Object instantiateRelativeItem(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.
    Fragment f;
    if (mFragments.size() > position) {
        f = mFragments.get(position);
        if (f != null) {
            return f;
        }
    }

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

    if (f.getView() != null) {
        mCurTransaction.remove(f);
    }

    if (mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null && !f.isAdded()) {
            f.setInitialSavedState(fss);
        } else if (f.isAdded()) {
            Log.e(TAG, "Error when instantiating Fragment: " + f + ", FragmentSavedState: " + fss
                    + ", fragment already added: " + f.isAdded());
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }

    FragmentCompat.setMenuVisibility(f, false);
    FragmentCompat.setUserVisibleHint(f, false);
    mFragments.set(position, f);
    mCurTransaction.add(container.getId(), f);

    return f;
}

From source file:com.breadwallet.presenter.activities.IntroActivity.java

private void animateSlide(final Fragment from, final Fragment to, int direction) {
    if (to instanceof IntroRecoverWalletFragment) {
        if (Utils.isUsingCustomInputMethod(to.getActivity()))
            ((IntroRecoverWalletFragment) to).disableEditText();
    }/*  w  w w  .j a  v  a  2  s  .  c o  m*/
    int screenWidth = screenParametersPoint.x;
    int screenHeigth = screenParametersPoint.y;

    showHideFragments(from, to);
    TranslateAnimation transFrom = direction == RIGHT ? new TranslateAnimation(0, -screenWidth, 0, 0)
            : new TranslateAnimation(0, screenWidth, 0, 0);
    transFrom.setDuration(BRAnimator.horizontalSlideDuration);
    transFrom.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f));
    View fromView = from.getView();
    if (fromView != null)
        fromView.startAnimation(transFrom);
    TranslateAnimation transTo = direction == RIGHT ? new TranslateAnimation(screenWidth, 0, 0, 0)
            : new TranslateAnimation(-screenWidth, 0, 0, 0);
    transTo.setDuration(BRAnimator.horizontalSlideDuration);
    transTo.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f));
    transTo.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            showHideFragments(to);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    View toView = to.getView();
    if (toView != null)
        toView.startAnimation(transTo);
}

From source file:com.android.settings.HWSettings.java

@Override
public void invalidateHeaders() {
    super.invalidateHeaders();

    int index = mActionBar.getSelectedTab().getPosition();
    if (index == TAB_INDEX_SYSTEM) {
        Fragment fragment = getFragment(index);
        if (fragment != null && fragment.getView() != null) {
            ((BasePreferenceFragment) fragment).updateHeaders();
        }/*  w  w  w.  jav a 2s  . c  o  m*/
    }
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }//w  ww. ja v a2s  .  c  o m
    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);
    }
}

From source file:de.sourcestream.movieDB.controller.TVDetails.java

private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }//from w  w  w .jav  a2  s .  c  om
    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);
    }
}

From source file:de.sourcestream.movieDB.controller.MovieDetails.java

private Scrollable getCurrentScrollable() {
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return null;
    }//w  w w  . j a v a2s  . c  o m
    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);
    }
}