Example usage for android.view ViewGroup getId

List of usage examples for android.view ViewGroup getId

Introduction

In this page you can find the example usage for android.view ViewGroup getId.

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:de.aw.awlib.fragments.AWFragment.java

/**
 * Handelt es sich um einen Dialog, wird null zurueckgegeben. Ansoonsten wird die View erstellt
 * und zurueckgegeben./*from  ww  w . jav  a2  s.c  om*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container != null) {
        this.containerID = container.getId();
    }
    if (!getShowsDialog()) {
        return layout == NOLAYOUT ? null : inflater.inflate(layout, container, false);
    }
    return null;
}

From source file:am.util.viewpager.adapter.FragmentRemovePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }/*from w w w. j  ava 2  s . co m*/

    final long itemId = getItemId(position);

    // Do we already have this fragment?
    String name = makeFragmentName(container.getId(), itemId);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
        if (DEBUG)
            Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
        mCurTransaction.attach(fragment);
    } else {
        fragment = getItem(position);
        if (DEBUG)
            Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
        if (mSavedState.size() > position) {
            Fragment.SavedState fss = mSavedState.get(position);
            if (fss != null) {
                fragment.setInitialSavedState(fss);
            }
        }
        mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:am.project.x.widget.FragmentRemovePagerAdapter.java

@SuppressLint("CommitTransaction")
@NonNull//from  w  w  w  .jav a2  s.  c om
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    final long itemId = getItemId(position);

    // Do we already have this fragment?
    String name = makeFragmentName(container.getId(), itemId);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
        if (DEBUG)
            Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
        mCurTransaction.attach(fragment);
    } else {
        fragment = getItem(position);
        if (DEBUG)
            Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
        if (mSavedState.size() > position) {
            Fragment.SavedState fss = mSavedState.get(position);
            if (fss != null) {
                fragment.setInitialSavedState(fss);
            }
        }
        mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:net.thetranquilpsychonaut.hashtagger.cwacpager.ArrayPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (currTransaction == null) {
        currTransaction = fm.beginTransaction();
    }/*from w w  w.j  a v  a  2 s.com*/
    Fragment fragment = getExistingFragment(position);
    if (fragment != null) {
        if (fragment.getId() == container.getId()) {
            retentionStrategy.attach(fragment, currTransaction);
        } else {
            fm.beginTransaction().remove(fragment).commit();
            fm.executePendingTransactions();
            currTransaction.add(container.getId(), fragment, getFragmentTag(position));
        }
    } else {
        fragment = createFragment(entries.get(position).getDescriptor());
        currTransaction.add(container.getId(), fragment, getFragmentTag(position));
    }
    if (fragment != currPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }
    return fragment;
}

From source file:com.commonsware.cwac.pager.v4.ArrayPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (currTransaction == null) {
        currTransaction = fm.beginTransaction();
    }//from  w ww . ja v  a  2 s  . c  o m

    Fragment fragment = getExistingFragment(position);

    if (fragment != null) {
        if (fragment.getId() == container.getId()) {
            retentionStrategy.attach(fragment, currTransaction);
        } else {
            fm.beginTransaction().remove(fragment).commit();
            fm.executePendingTransactions();

            currTransaction.add(container.getId(), fragment, getFragmentTag(position));
        }
    } else {
        fragment = createFragment(entries.get(position).getDescriptor());
        currTransaction.add(container.getId(), fragment, getFragmentTag(position));
    }

    if (fragment != currPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:li.barter.fragments.AbstractBarterLiFragment.java

/**
 * Call this method in the onCreateView() of any subclasses
 *
 * @param container          The container passed into onCreateView()
 * @param savedInstanceState The Instance state bundle passed into the onCreateView() method
 *///w  ww  . jav a 2s  .co  m
protected void init(final ViewGroup container, final Bundle savedInstanceState) {
    mContainerViewId = container.getId();
    long lastScreenTime = 0l;
    if (savedInstanceState != null) {
        mAddUserInfoDialogFragment = (AddUserInfoDialogFragment) getFragmentManager()
                .findFragmentByTag(FragmentTags.DIALOG_ADD_NAME);
        lastScreenTime = savedInstanceState.getLong(Keys.LAST_SCREEN_TIME);
    }

    if (Utils.shouldReportScreenHit(lastScreenTime)) {
        mShouldReportScreenHit = true;
    } else {
        mShouldReportScreenHit = false;
    }
}

From source file:free.yhc.netmbuddy.FragmentPagerAdapterEx.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null)
        mCurTransaction = mFragmentManager.beginTransaction();

    // Do we already have this fragment?
    String name = getFragmentName(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null)
        mCurTransaction.attach(fragment);
    else {//from w ww  .  j  a  v a 2  s. c o m
        fragment = getItem(position);
        mCurTransaction.add(container.getId(), fragment, getFragmentName(position));
    }

    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:free.yhc.feeder.FragmentPagerAdapterEx.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null)
        mCurTransaction = mFragmentManager.beginTransaction();

    // Do we already have this fragment?
    String name = getFragmentName(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
        mCurTransaction.attach(fragment);
    } else {//  w ww  . j  av  a 2  s. c  om
        fragment = getItem(position);
        mCurTransaction.add(container.getId(), fragment, getFragmentName(position));
    }

    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:com.inovex.zabbixmobile.adapters.BaseServicePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mFragmentManager == null)
        return null;
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }//  ww  w .java  2s .  c om

    final Long itemId = getItemId(position);
    if (itemId == null)
        return null;

    // Do we already have this fragment?
    String name = makeFragmentName(container.getId(), itemId);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null && !mRefresh) {
        if (DEBUG)
            Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
        mCurTransaction.attach(fragment);
    } else {
        fragment = getItem(position);
        if (DEBUG)
            Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
        mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:com.androidinspain.deskclock.FragmentTabPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurrentTransaction == null) {
        mCurrentTransaction = mFragmentManager.beginTransaction();
    }//w  w  w  .j  a va 2 s. c  om

    // Use the fragment located in the fragment manager if one exists.
    final UiDataModel.Tab tab = UiDataModel.getUiDataModel().getTabAt(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(tab.name());
    if (fragment != null) {
        mCurrentTransaction.attach(fragment);
    } else {
        fragment = getDeskClockFragment(position);
        mCurrentTransaction.add(container.getId(), fragment, tab.name());
    }

    if (fragment != mCurrentPrimaryItem) {
        FragmentCompat.setMenuVisibility(fragment, false);
        FragmentCompat.setUserVisibleHint(fragment, false);
    }

    return fragment;
}