本文整理了Java中androidx.fragment.app.Fragment.onAttach()
方法的一些代码示例,展示了Fragment.onAttach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fragment.onAttach()
方法的具体详情如下:
包路径:androidx.fragment.app.Fragment
类名称:Fragment
方法名:onAttach
暂无
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context = context;
}
代码示例来源:origin: ankidroid/Anki-Android
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mListener = (StudyOptionsListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString() + " must implement StudyOptionsListener");
}
}
代码示例来源:origin: trello/RxLifecycle
@Override
public void onAttach(android.app.Activity activity) {
super.onAttach(activity);
lifecycleSubject.onNext(FragmentEvent.ATTACH);
}
代码示例来源:origin: ArthurHub/Android-Image-Cropper
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mDemoPreset = CropDemoPreset.valueOf(getArguments().getString("DEMO_PRESET"));
((MainActivity) activity).setCurrentFragment(this);
}
代码示例来源:origin: westnordost/StreetComplete
@Override public void onAttach(Context context)
{
super.onAttach(context);
listener = (Listener) context;
}
代码示例来源:origin: westnordost/StreetComplete
@Override public void onAttach(Context context)
{
super.onAttach(context);
compass.onCreate(
(SensorManager) context.getSystemService(SENSOR_SERVICE),
((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay());
lostApiClient = new LostApiClient.Builder(context).addConnectionCallbacks(this).build();
listener = (Listener) context;
}
代码示例来源:origin: trello/RxLifecycle
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
);
}
代码示例来源:origin: trello/RxLifecycle
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
);
}
代码示例来源:origin: trello/RxLifecycle
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();
}
代码示例来源:origin: trello/RxLifecycle
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();
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity)
activity = (AppCompatActivity)context;
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity) {
activity = (AppCompatActivity)context;
if (context instanceof DetailTorrentFragment.Callback)
callback = (DetailTorrentFragment.Callback)context;
}
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity)
activity = (AppCompatActivity)context;
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity) {
activity = (AppCompatActivity)context;
if (context instanceof DetailTorrentFragment.Callback)
callback = (DetailTorrentFragment.Callback)context;
}
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity)
activity = (AppCompatActivity)context;
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity)
this.activity = (AppCompatActivity)context;
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (context instanceof AppCompatActivity) {
activity = (AppCompatActivity)context;
callback = (Callback)context;
}
}
代码示例来源:origin: esafirm/android-image-picker
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof ImagePickerInteractionListener) {
interactionListener = (ImagePickerInteractionListener) context;
}
}
代码示例来源:origin: trello/RxLifecycle
startFragment(fragment);
fragment.onAttach(null);
TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();
代码示例来源:origin: trello/RxLifecycle
startFragment(fragment);
fragment.onAttach(null);
TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();
内容来源于网络,如有侵权,请联系作者删除!