Skip to content

Commit

Permalink
测试pushTo 导致的生命周期回调问题
Browse files Browse the repository at this point in the history
  • Loading branch information
paul feng committed Oct 28, 2021
1 parent ac155d1 commit ee8e229
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.github.fragivity.applySlideInOut
import com.github.fragivity.example.communicate.CommFragment
import com.github.fragivity.navigator
import com.github.fragivity.push
import kotlinx.coroutines.delay
Expand All @@ -33,7 +34,11 @@ class SplashFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
lifecycleScope.launchWhenResumed {
delay(500)
navigator.push(HomeFragment::class) {
// navigator.push(HomeFragment::class) {
// popSelf = true
// applySlideInOut()
// }
navigator.push(CommFragment::class) {
popSelf = true
applySlideInOut()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.github.fragivity.example.AbsBaseFragment
import com.github.fragivity.example.HomeFragment
import com.github.fragivity.example.R
import com.github.fragivity.example.databinding.FragmentCommBinding
import com.github.fragivity.example.viewbinding.viewBinding
import com.github.fragivity.navigator
import com.github.fragivity.push
import com.github.fragivity.pushTo


class CommFragment : AbsBaseFragment() {
Expand Down Expand Up @@ -38,6 +40,9 @@ class CommFragment : AbsBaseFragment() {
binding.btnCallback.setOnClickListener {
navigator.push(com.github.fragivity.example.communicate.callback.CheckListFragment::class)
}
binding.btnGoHome.setOnClickListener {
navigator.pushTo(HomeFragment::class)
}
}

override val titleName: String
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/fragment_comm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@
android:layout_height="wrap_content"
android:text="Callback"/>

<Button
android:id="@+id/btn_goHome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="goHome"/>

</LinearLayout>

0 comments on commit ee8e229

Please sign in to comment.