Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
weikaiyun committed Sep 10, 2020
1 parent 3788f81 commit ae5ab11
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ kapt {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

//implementation project(':fragmentation')
implementation 'com.github.weikaiyun:EasyFragmentation:1.0.5'
implementation project(':fragmentation')
//implementation 'com.github.weikaiyun:EasyFragmentation:1.0.5'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlinx_coroutines}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import androidx.lifecycle.lifecycleScope
import com.common.weikaiyun.R
import com.common.weikaiyun.demo.db.User
import com.common.weikaiyun.demo.viewmodel.UserViewModel
import com.weikaiyun.fragmentation.SupportActivity
import com.weikaiyun.fragmentation.BaseActivity

class DemoActivity : SupportActivity() {
class DemoActivity : BaseActivity() {

override fun getContentViewID(): Int = R.layout.activity_demo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.util.trigger
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.BaseFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment1 : SupportFragment() {
class DemoFragment1 : BaseFragment() {
private var param1: Int by argument()
private var param2: String by argument()
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.util.trigger
import com.weikaiyun.fragmentation.BaseFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment2: com.weikaiyun.fragmentation.SupportFragment() {
class DemoFragment2: BaseFragment() {
private var param1: Int by argument()
private var param2: String by argument()
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.util.trigger
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.BaseFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment3: SupportFragment() {
class DemoFragment3: BaseFragment() {
private var param1: Int by argument()
private var param2: String by argument()
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.util.trigger
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.BaseFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo4.*

class DemoFragment4: SupportFragment() {
class DemoFragment4: BaseFragment() {
private var param1: Int by argument()
private var param2: String by argument()
private var param3: String by argument()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.common.weikaiyun.demo.ui
import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.BaseFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment5: SupportFragment() {
class DemoFragment5: BaseFragment() {
private var param1: Int by argument()
private var param2: String by argument()
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* {@link ISupportActivity} and
* {@link AppCompatActivity} APIs.
*/
abstract public class SupportActivity extends AppCompatActivity implements ISupportActivity {
abstract public class BaseActivity extends AppCompatActivity implements ISupportActivity {
final SupportActivityDelegate mDelegate = new SupportActivityDelegate(this);

private boolean isLoaded;
Expand Down Expand Up @@ -147,14 +147,14 @@ public void showHideFragment(ISupportFragment showFragment, ISupportFragment hid
}

/**
* It is recommended to use {@link SupportFragment#start(ISupportFragment)}.
* It is recommended to use {@link BaseFragment#start(ISupportFragment)}.
*/
public void start(ISupportFragment toFragment) {
mDelegate.start(toFragment);
}

/**
* It is recommended to use {@link SupportFragment#start(ISupportFragment, int)}.
* It is recommended to use {@link BaseFragment#start(ISupportFragment, int)}.
*
* @param launchMode Similar to Activity's LaunchMode.
*/
Expand All @@ -163,23 +163,23 @@ public void start(ISupportFragment toFragment, @ISupportFragment.LaunchMode int
}

/**
* It is recommended to use {@link SupportFragment#startForResult(ISupportFragment, int)}.
* It is recommended to use {@link BaseFragment#startForResult(ISupportFragment, int)}.
* Launch an fragment for which you would like a result when it popped.
*/
public void startForResult(ISupportFragment toFragment, int requestCode) {
mDelegate.startForResult(toFragment, requestCode);
}

/**
* It is recommended to use {@link SupportFragment#startWithPop(ISupportFragment)}.
* It is recommended to use {@link BaseFragment#startWithPop(ISupportFragment)}.
* Start the target Fragment and pop itself
*/
public void startWithPop(ISupportFragment toFragment) {
mDelegate.startWithPop(toFragment);
}

/**
* It is recommended to use {@link SupportFragment#startWithPopTo(ISupportFragment, Class, boolean)}.
* It is recommended to use {@link BaseFragment#startWithPopTo(ISupportFragment, Class, boolean)}.
*
* @see #popTo(Class, boolean)
* +
Expand All @@ -192,7 +192,7 @@ public void startWithPopTo(ISupportFragment toFragment, Class<?> targetFragmentC
}

/**
* It is recommended to use {@link SupportFragment#replaceFragment(ISupportFragment)}.
* It is recommended to use {@link BaseFragment#replaceFragment(ISupportFragment)}.
*/
public void replaceFragment(ISupportFragment toFragment) {
mDelegate.replaceFragment(toFragment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* {@link ISupportFragment} and
* {@link Fragment} APIs.
*/
abstract public class SupportFragment extends Fragment implements ISupportFragment {
abstract public class BaseFragment extends Fragment implements ISupportFragment {
final SupportFragmentDelegate mDelegate = new SupportFragmentDelegate(this);
protected SupportActivity _mActivity;
protected BaseActivity _mActivity;

private boolean isLoaded;

Expand All @@ -44,7 +44,7 @@ public ExtraTransaction extraTransaction() {
public void onAttach(Context context) {
super.onAttach(context);
mDelegate.onAttach(context);
_mActivity = (SupportActivity) mDelegate.getActivity();
_mActivity = (BaseActivity) mDelegate.getActivity();
}

@Override
Expand Down

0 comments on commit ae5ab11

Please sign in to comment.