Skip to content

Commit

Permalink
📝 update doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYeoh committed Aug 3, 2018
1 parent b9ef6d8 commit debd0d8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* [转场动画](https://github.com/JustKiddingBaby/FragmentRigger/wiki/转场动画)
* [onBackPressed拦截](https://github.com/JustKiddingBaby/FragmentRigger/wiki/onBackPressed拦截)
* [startFragmentForResult方法](https://github.com/JustKiddingBaby/FragmentRigger/wiki/startFragmentForResult方法)
* 滑动退出Activity/Fragment
* [滑动退出Activity/Fragment](https://github.com/JustKiddingBaby/FragmentRigger/wiki/滑动边缘退出)
* [如何在library module中使用](https://github.com/JustKiddingBaby/FragmentRigger/wiki/如何在library-module中使用)
#### 信息
* [gradle错误](https://github.com/JustKiddingBaby/FragmentRigger/wiki/gradle%E4%BE%9D%E8%B5%96%E9%97%AE%E9%A2%98)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ You can use this `FragmentRigger` with one line annotation.
* [Transition animations](https://github.com/JustKiddingBaby/FragmentRigger/wiki/Transition-animations)
* [Intercept onBackPressed](https://github.com/JustKiddingBaby/FragmentRigger/wiki/Intercept-onBackPressed)
* [startFragmentForResult](https://github.com/JustKiddingBaby/FragmentRigger/wiki/startFragmentForResult)
* Swipe edge to exit Activity/Fragment
* [Swipe edge to exit Activity/Fragment](https://github.com/JustKiddingBaby/FragmentRigger/wiki/Swipe-edge-to-exit)
* [How to use in library module](https://github.com/JustKiddingBaby/FragmentRigger/wiki/How-to-use-in-library-module)
#### Information
* [Errors in gradle](https://github.com/JustKiddingBaby/FragmentRigger/wiki/Errors-in-gradle)
Expand Down
74 changes: 38 additions & 36 deletions app/src/main/java/com/yj/app/base/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -15,45 +16,46 @@
* Base fragment.
*
* @author JingYeoh
* <a href="mailto:[email protected]">Email me</a>
* <a href="https://github.com/justkiddingbaby">Github</a>
* <a href="http://blog.justkiddingbaby.com">Blog</a>
* <a href="mailto:[email protected]">Email me</a>
* <a href="https://github.com/justkiddingbaby">Github</a>
* <a href="http://blog.justkiddingbaby.com">Blog</a>
* @since Nov 22,2017
*/
@Puppet
public abstract class BaseFragment extends Fragment {

protected static final String BUNDLE_KEY = "/bundle/key";
protected View mContentView;
protected Context mContext;

@Override
public void onAttach(Context context) {
super.onAttach(context);
mContext = context;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mContentView = inflater.inflate(getContentView(), container, false);
return mContentView;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
init(savedInstanceState);
}

@LayoutRes
protected abstract int getContentView();

protected abstract void init(Bundle savedInstanceState);

protected View findViewById(@IdRes int id) {
return mContentView.findViewById(id);
}
protected static final String BUNDLE_KEY = "/bundle/key";
protected View mContentView;
protected Context mContext;

@Override
public void onAttach(Context context) {
super.onAttach(context);
mContext = context;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mContentView = inflater.inflate(getContentView(), container, false);
mContentView.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white));
return mContentView;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
init(savedInstanceState);
}

@LayoutRes
protected abstract int getContentView();

protected abstract void init(Bundle savedInstanceState);

protected View findViewById(@IdRes int id) {
return mContentView.findViewById(id);
}
}
4 changes: 2 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ext {
]

rigger = [
publishCode : 8,
publishVersion: "1.3.0",
publishCode : 9,
publishVersion: "1.4.0",
userOrg : 'jkb',
groupId : 'com.justkiddingbaby',
artifactId : 'fragment-rigger',
Expand Down

0 comments on commit debd0d8

Please sign in to comment.