本文整理汇总了Java中android.support.v4.app.Fragment.onResume方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.onResume方法的具体用法?Java Fragment.onResume怎么用?Java Fragment.onResume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.onResume方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBind
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void testBind(Fragment fragment) {
fragment.onAttach(null);
fragment.onCreate(null);
//before view created null
assertTrue(this.presenter.view == null);
fragment.onCreateView(null, null, null);
fragment.onViewCreated(null, null);
//after view created, the view has been bound automatically
assertTrue(this.presenter.view != null);
fragment.onStart();
fragment.onResume();
fragment.onPause();
fragment.onStop();
fragment.onDestroy();
//after on destroy the view has been released automatically
assertTrue(this.presenter.view == null);
}
示例2: testBindUntilEvent
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {
Fragment fragment = (Fragment) provider;
startFragment(fragment);
TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();
fragment.onAttach(null);
testObserver.assertNotComplete();
fragment.onCreate(null);
testObserver.assertNotComplete();
fragment.onViewCreated(null, null);
testObserver.assertNotComplete();
fragment.onStart();
testObserver.assertNotComplete();
fragment.onResume();
testObserver.assertNotComplete();
fragment.onPause();
testObserver.assertNotComplete();
fragment.onStop();
testObserver.assertComplete();
}
示例3: onBackPressed
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
super.onBackPressed();
Fragment fragment = fragmentManager.findFragmentById(R.id.contain_main);
if (fragment != null)
fragment.onResume();
else
finish();
}
示例4: showTab
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public void showTab(int idx) {
for (int i = 0; i < fragments.size(); i++) {
if (idx == i) {
Fragment fragment = fragments.get(i);
FragmentTransaction ft = null;
if(!isInit&&idx==0){
ft=obtainFragmentTransaction(idx,NO_ANIMATION);
isInit=true;
}else{
ft=obtainFragmentTransaction(idx,1);
}
if(getCurrentFragment()!=null&&getCurrentFragment().isVisible()){
getCurrentFragment().onPause();
ft.hide(getCurrentFragment());
}
currentTab = idx;
if(fragment.isAdded()){
fragment.onResume();
}else{
ft.add(fragmentContentId, fragment);
}
ft.show(fragment);
try {
ft.commit();
} catch (Exception e) {
// Log.d("commitError"," -->"+e.toString());
}
return;
}
}
}
示例5: onResume
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
Fragment fragment = null;
if (null!=mAdapter) {
fragment = mAdapter.getItem(mCurrentPosition);
}
if (null!=fragment) {
fragment.onResume();
}
}
示例6: onResume
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
if (null!=mPlayerPresenter) {
mPlayerPresenter.requestMusicInfo();
mPlayerPresenter.syncPlayerInfo();
Fragment fragment = adapter.getItem(mCurrentPosition);
if (null!=fragment) {
fragment.onResume();
}
}
}
示例7: onPageSelected
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onPageSelected(int position) {
mCurrentPosition = position;
mRadioGroup.check(position == 0 ? R.id.action_music : R.id.action_list);
Fragment fragment = adapter.getItem(mCurrentPosition);
if (null!=fragment) {
fragment.onResume();
}
}
示例8: onCheckedChanged
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
for (int i = 0; i < radioGroup.getChildCount(); i++) {
if (radioGroup.getChildAt(i).getId() == checkId) {
// 即将要展示的Fragment
Fragment target = mFragmentList.get(i);
Fragment currentFragment = getCurrentFragment();
currentFragment.onPause();
FragmentTransaction fragmentTransaction = getFragmentTransaction();
if (target.isAdded()) {
target.onResume();
fragmentTransaction.show(target).hide(currentFragment);
} else {
fragmentTransaction.add(mContentId, target).show(target).hide(currentFragment);
}
fragmentTransaction.commit();
currentTab = i;
if (mFragmentToogleListener != null) {
mFragmentToogleListener.onToogleChange(target, currentTab);
}
}
}
}
示例9: testLifecycle
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
Fragment fragment = (Fragment) provider;
startFragment(fragment);
TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();
fragment.onAttach(null);
fragment.onCreate(null);
fragment.onViewCreated(null, null);
fragment.onStart();
fragment.onResume();
fragment.onPause();
fragment.onStop();
fragment.onDestroyView();
fragment.onDestroy();
fragment.onDetach();
testObserver.assertValues(
FragmentEvent.ATTACH,
FragmentEvent.CREATE,
FragmentEvent.CREATE_VIEW,
FragmentEvent.START,
FragmentEvent.RESUME,
FragmentEvent.PAUSE,
FragmentEvent.STOP,
FragmentEvent.DESTROY_VIEW,
FragmentEvent.DESTROY,
FragmentEvent.DETACH
);
}
示例10: onCheckedChanged
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
for (int i = 0; i < rgs.getChildCount(); i++) {
if (rgs.getChildAt(i).getId() == checkedId) {
Fragment fragment = fragments.get(i);
FragmentTransaction ft = obtainFragmentTransaction(i);
//暂停现在Fragment
getCurrentFragment().onPause();
//如果该Fragment对象被添加到了它的Activity中,那么它返回true,否则返回false。
if (fragment.isAdded()) {
fragment.onResume();
} else {
ft.add(fragmentContentId, fragment);
}
//显示被选中的Frag
showTab(i);
//执行
ft.commit();
if (null != onRgsExtraCheckedChangedListener) {
onRgsExtraCheckedChangedListener.OnRgsExtraCheckedChanged(
radioGroup, checkedId, i);
}
}
}
}
示例11: testBindToLifecycle
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void testBindToLifecycle(LifecycleProvider<FragmentEvent> provider) {
Fragment fragment = (Fragment) provider;
startFragment(fragment);
fragment.onAttach(null);
TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onCreate(null);
attachObserver.assertNotComplete();
TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onViewCreated(null, null);
attachObserver.assertNotComplete();
createObserver.assertNotComplete();
TestObserver<Object> createViewObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onStart();
attachObserver.assertNotComplete();
createObserver.assertNotComplete();
createViewObserver.assertNotComplete();
TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onResume();
attachObserver.assertNotComplete();
createObserver.assertNotComplete();
createViewObserver.assertNotComplete();
startObserver.assertNotComplete();
TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onPause();
attachObserver.assertNotComplete();
createObserver.assertNotComplete();
createViewObserver.assertNotComplete();
startObserver.assertNotComplete();
resumeObserver.assertComplete();
TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onStop();
attachObserver.assertNotComplete();
createObserver.assertNotComplete();
createViewObserver.assertNotComplete();
startObserver.assertComplete();
pauseObserver.assertComplete();
TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onDestroyView();
attachObserver.assertNotComplete();
createObserver.assertNotComplete();
createViewObserver.assertComplete();
stopObserver.assertComplete();
TestObserver<Object> destroyViewObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onDestroy();
attachObserver.assertNotComplete();
createObserver.assertComplete();
destroyViewObserver.assertComplete();
TestObserver<Object> destroyObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onDetach();
attachObserver.assertComplete();
destroyObserver.assertComplete();
}