Skip to content

Commit 669a6a6

Browse files
author
A.Badakhshan
committed
0.4.7
1 parent f731e25 commit 669a6a6

File tree

5 files changed

+17
-129
lines changed

5 files changed

+17
-129
lines changed

app/src/main/java/com/alirezabdn/whygoogle/MainFragment.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.alirezabdn.whygoogle
22

3+
import android.util.Log
34
import android.view.LayoutInflater
45
import android.view.ViewGroup
56
import androidx.fragment.app.Fragment
@@ -27,6 +28,11 @@ class MainFragment : WhyGoogleFragment<MainFragmentBinding>() {
2728
}
2829
}
2930

31+
override fun onBackToFragment() {
32+
super.onBackToFragment()
33+
Log.d("WhG", "backtofrag")
34+
}
35+
3036
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> MainFragmentBinding
3137
get() = MainFragmentBinding::inflate
3238
}

whygoogle/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
minSdkVersion 17
1212
targetSdkVersion 30
1313
versionCode 1
14-
versionName "0.4.6"
14+
versionName "0.4.7"
1515
}
1616
buildFeatures {
1717
viewBinding true

whygoogle/src/main/java/ir/ayantech/whygoogle/activity/SwipableWhyGoogleActivity.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,22 @@ abstract class SwipableWhyGoogleActivity<T : ViewBinding> : AppCompatActivity(),
4545
override fun onCreate(savedInstanceState: Bundle?) {
4646
super.onCreate(savedInstanceState)
4747
setContentView(binding.root)
48-
fragmentHost.registerOnPageChangeCallback(object : NonFinalViewPager2.OnPageChangeCallback() {
48+
fragmentHost.registerOnPageChangeCallback(object :
49+
NonFinalViewPager2.OnPageChangeCallback() {
4950
override fun onPageScrollStateChanged(state: Int) {
5051
super.onPageScrollStateChanged(state)
5152
if (state == ViewPager2.SCROLL_STATE_IDLE) {
5253
val previousCount = getFragmentCount()
5354
while (fragmentHost.currentItem <= getFragmentCount() - 2) {
5455
fragmentStack.removeLast()
5556
}
56-
if (previousCount >= fragmentHost.currentItem + 2)
57+
if (previousCount >= fragmentHost.currentItem + 2) {
5758
whyGoogleFragmentAdapter.notifyItemRangeRemoved(
5859
fragmentHost.currentItem + 1,
5960
previousCount - fragmentHost.currentItem - 1
6061
)
62+
fragmentStack.lastOrNull()?.onBackToFragment()
63+
}
6164
onTopFragmentChanged(fragmentStack.last())
6265
fragmentStack.last().onFragmentVisible()
6366
}
@@ -173,7 +176,9 @@ abstract class SwipableWhyGoogleActivity<T : ViewBinding> : AppCompatActivity(),
173176
when {
174177
fragmentStack.lastOrNull()?.onBackPressed() == true -> {
175178
}
176-
getFragmentCount() > 1 -> trying { pop() }
179+
getFragmentCount() > 1 -> trying {
180+
pop()
181+
}
177182
else -> ActivityCompat.finishAfterTransition(this)
178183
}
179184
}

whygoogle/src/main/java/ir/ayantech/whygoogle/fragment/WhyGoogleFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,6 @@ abstract class WhyGoogleFragment<T : ViewBinding> : Fragment() {
173173
fun popAll() {
174174
(activity as? WhyGoogleInterface)?.popAll()
175175
}
176+
177+
open fun onBackToFragment() {}
176178
}

whygoogle/src/main/java/ir/ayantech/whygoogle/helper/NestedScrollableHost.kt

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)