提交 a63135ec 编写于 作者: J jessyan

Improve FragmentDelegate

上级 f8a77795
......@@ -73,7 +73,7 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return initView(inflater, container, savedInstanceState);
}
......
......@@ -17,6 +17,8 @@ package com.jess.arms.base.delegate;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;
......@@ -36,11 +38,11 @@ public interface FragmentDelegate {
void onAttach(Context context);
void onCreate(Bundle savedInstanceState);
void onCreate(@Nullable Bundle savedInstanceState);
void onCreateView(View view, Bundle savedInstanceState);
void onCreateView(@Nullable View view, @Nullable Bundle savedInstanceState);
void onActivityCreate(Bundle savedInstanceState);
void onActivityCreate(@Nullable Bundle savedInstanceState);
void onStart();
......@@ -50,7 +52,7 @@ public interface FragmentDelegate {
void onStop();
void onSaveInstanceState(Bundle outState);
void onSaveInstanceState(@NonNull Bundle outState);
void onDestroyView();
......
......@@ -17,6 +17,8 @@ package com.jess.arms.base.delegate;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.jess.arms.utils.ArmsUtils;
......@@ -55,21 +57,21 @@ public class FragmentDelegateImpl implements FragmentDelegate {
}
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState) {
if (iFragment.useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().register(mFragment);//注册到事件主线
iFragment.setupFragmentComponent(ArmsUtils.obtainAppComponentFromContext(mFragment.getActivity()));
}
@Override
public void onCreateView(View view, Bundle savedInstanceState) {
public void onCreateView(@Nullable View view, @Nullable Bundle savedInstanceState) {
//绑定到butterknife
if (view != null)
mUnbinder = ButterKnife.bind(mFragment, view);
}
@Override
public void onActivityCreate(Bundle savedInstanceState) {
public void onActivityCreate(@Nullable Bundle savedInstanceState) {
iFragment.initData(savedInstanceState);
}
......@@ -94,13 +96,13 @@ public class FragmentDelegateImpl implements FragmentDelegate {
}
@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
}
@Override
public void onDestroyView() {
if (mUnbinder != null && mUnbinder != mUnbinder.EMPTY) {
if (mUnbinder != null && mUnbinder != Unbinder.EMPTY) {
try {
mUnbinder.unbind();
} catch (IllegalStateException e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册