Example usage for android.support.v4.app Fragment equals

List of usage examples for android.support.v4.app Fragment equals

Introduction

In this page you can find the example usage for android.support.v4.app Fragment equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.github.riotopsys.malforandroid2.adapter.DynamicPagerAdapter.java

@Override
public int getItemPosition(Object object) {
    Fragment f = (Fragment) object;//from w  ww  .j a v  a  2s.c om
    for (int i = 0; i < getCount(); i++) {

        Fragment item = (Fragment) getItem(i);
        if (item.equals(f)) {
            return i;
        }
    }
    return POSITION_NONE;
}

From source file:org.kesar.lazy.primary.android.activity.BaseActivity.java

/**
 * ?Fragment//from   w  w w . jav  a2 s  . c  om
 *
 * @param resView
 * @param targetFragment
 */
public void changeFragment(int resView, Fragment targetFragment) {
    if (targetFragment.equals(mCurrentFragment)) {
        return;
    }
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    if (!targetFragment.isAdded()) {
        transaction.add(resView, targetFragment, targetFragment.getClass().getName());
    }
    if (targetFragment.isHidden()) {
        transaction.show(targetFragment);
    }
    if (mCurrentFragment != null && mCurrentFragment.isVisible()) {
        transaction.hide(mCurrentFragment);
    }
    mCurrentFragment = targetFragment;
    transaction.commit();
}

From source file:eu.trentorise.smartcampus.jp.custom.TabListener.java

public void onTabSelected(Tab tab, FragmentTransaction ft) {
    Fragment preInitializedFragment = mActivity.getSupportFragmentManager().findFragmentByTag(mTag);
    if (preInitializedFragment != null && !preInitializedFragment.equals(mFragment)) {
        ft.remove(preInitializedFragment);
    }/*  w ww.  ja  v a2 s . c  om*/

    if (mFragment == null) {
        // If not, instantiate and add it to the activity
        mFragment = Fragment.instantiate(mActivity, mClass.getName(),
                tab.getTag() != null ? (Bundle) tab.getTag() : null);
        ft.add(android.R.id.content, mFragment, mTag);
        //         ft.replace(android.R.id.content, mFragment);

    } else {
        // If it exists, simply attach it in order to show it
        ft.attach(mFragment);
    }

    // SherlockFragment preInitializedFragment = (SherlockFragment)
    // mActivity.getSupportFragmentManager()
    // .findFragmentByTag(mTag);
    //
    // if (mFragment == null && preInitializedFragment == null) {
    // mFragment = (SherlockFragment)
    // SherlockFragment.instantiate(mActivity, mClass.getName());
    // ft.add(mViewGroup, mFragment, mTag);
    // } else if (mFragment != null) {
    // // If it exists, simply attach it in order to show it
    // ft.attach(mFragment);
    // } else if (preInitializedFragment != null) {
    // mFragment = preInitializedFragment;
    // ft.attach(mFragment);
    //
    // }
    // // Check if the fragment is already initialized
    // if (mFragment == null) {
    // // If not, instantiate and add it to the activity
    // mFragment = Fragment.instantiate(mActivity, mClass.getName());
    // ft.add(mViewGroup, mFragment, mTag);
    // } else {
    // // If it exists, simply attach it in order to show it
    // ft.attach(mFragment);
    // }

}

From source file:net.illusor.swipeplayer.activities.SwipePagerAdapter.java

@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    final Fragment fragment = (Fragment) object;
    if (!fragment.equals(this.primaryFragment)) {
        if (this.primaryFragment != null)
            activateFragment(this.primaryFragment, false);

        //here we implement the feature of removing folder-browser fragments, if we swipe the ViewPager Left-To-Right
        //(but we never remove the playlistFragment)
        if (primaryFragment != this.playlistFragment) {
            //detect Left-To-Right swipe
            //if detected, remove folder-browser fragment, which got moved to the right of the screen
            int index = this.browserFragments.indexOf(primaryFragment);
            if (index > position)
                removeFolder(index);/* ww w.j  ava2s  .  c  o  m*/
        }

        this.activateFragment(fragment, true);
        this.primaryFragment = fragment;
    }
}

From source file:com.activiti.android.app.fragments.process.ProcessDetailsFragment.java

@Override
public void onStart() {
    Fragment fr = getFragmentManager().findFragmentById(R.id.right_drawer);
    if (fr == null || (fr != null && !(fr.equals(commentFragment)))) {
        if (fr != null) {
            FragmentDisplayer.with(getActivity()).back(false).animate(null).remove(fr);
        }//from   ww  w  .j a  v  a  2  s  .  c om
    }
    setLockRightMenu(false);

    super.onStart();
}

From source file:ch.citux.td.ui.fragments.ChannelFragment.java

private void setFragment(Fragment fragment, boolean backstack) {
    if (fragment != null) {
        FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
        if (fragmentManager != null) {
            FragmentTransaction transaction = fragmentManager.beginTransaction();

            if (backstack) {
                transaction.addToBackStack(null);
            }//from ww  w .j av  a  2s  .com

            Fragment currentFragment = fragmentManager.findFragmentById(R.id.container);
            if (currentFragment == null) {
                transaction.add(R.id.container, fragment);
            } else {
                if (!currentFragment.equals(fragment)) {
                    transaction.replace(R.id.container, fragment);
                } else {
                    ((TDBase) fragment).loadData();
                }
            }
            transaction.commit();
        }
    }
}

From source file:com.binomed.showtime.android.util.activity.AbstractSimpleCineShowTimeActivity.java

@Override
protected void initContentView() {
    Fragment fragmentRecycle = getSupportFragmentManager().findFragmentById(R.id.root_container);
    fragment = getFragment(fragmentRecycle);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    if (fragmentRecycle == null) {
        transaction.add(R.id.root_container, fragment);
    } else if ((fragment != null) && !fragmentRecycle.equals(fragment)) {
        transaction.replace(R.id.root_container, fragment);
    }// w w  w  .j a v a2s .  c  om
    transaction.commit();

}

From source file:com.ruesga.rview.TabFragmentActivity.java

@Override
@SuppressWarnings("unchecked")
public <T> void onRefreshEnd(Fragment from, T result) {
    super.onRefreshEnd(from, result);
    if (result == null) {
        return;//from   w w w  . ja va 2s  .  c o  m
    }

    if (mIsTwoPane && result instanceof List) {
        Fragment current = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_LIST);
        if (current instanceof PageableFragment) {
            current = ((PageableFragment) current).getCurrentFragment();
            if (!current.equals(from)) {
                // This is not the visible fragment. ignore its results
                return;
            }
        } else {
            if (!current.equals(from)) {
                // This is not the visible fragment. ignore its results
                return;
            }
        }

        List<ChangeInfo> changes = (List<ChangeInfo>) result;
        if (!changes.isEmpty() && mSelectedChangeId == INVALID_ITEM) {
            onChangeItemPressed(changes.get(0));
        }
    } else if (result instanceof ChangeInfo) {
        mSelectedChangeId = ((ChangeInfo) result).legacyChangeId;
    }
}

From source file:org.videolan.vlc.gui.AudioPlayerContainerActivity.java

public void updateLib() {
    FragmentManager fm = getSupportFragmentManager();
    Fragment current = fm.findFragmentById(R.id.fragment_placeholder);
    if (current != null && current instanceof IRefreshable) {
        ((IRefreshable) current).refresh();
    } else/*from w  w w.  j a v a  2s .c o  m*/
        MediaLibrary.getInstance().loadMediaItems();
    Fragment fragment = fm.findFragmentByTag(SidebarAdapter.SidebarEntry.ID_AUDIO);
    if (fragment != null && !fragment.equals(current)) {
        ((MediaBrowserFragment) fragment).clear();
    }
    fragment = fm.findFragmentByTag(SidebarAdapter.SidebarEntry.ID_VIDEO);
    if (fragment != null && !fragment.equals(current)) {
        ((MediaBrowserFragment) fragment).clear();
    }
}

From source file:net.reichholf.dreamdroid.fragment.helper.HttpFragmentHelper.java

public void bindToFragment(Fragment fragment) {
    if (!(fragment instanceof IHttpBase) && !(fragment instanceof ScreenShotFragment))
        throw new IllegalStateException(
                getClass().getSimpleName() + " must be attached to a HttpBaseFragment.");
    if (!fragment.equals(mFragment)) {
        mFragment = fragment;/* w  w w. j a  v  a 2  s.  co m*/
    }
    mSwipeRefreshLayout = null;
}