-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigate from supervised feature to supervisor
- Loading branch information
Showing
13 changed files
with
278 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
library/inspector/src/main/java/io/mehow/laboratory/inspector/FeatureCoordinates.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.mehow.laboratory.inspector | ||
|
||
internal data class FeatureCoordinates( | ||
val sectionIndex: Int, | ||
val featureIndex: Int, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
library/inspector/src/main/java/io/mehow/laboratory/inspector/GroupAdapter.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
library/inspector/src/main/java/io/mehow/laboratory/inspector/SectionAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.mehow.laboratory.inspector | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
import kotlinx.coroutines.delay | ||
import java.lang.ref.WeakReference | ||
|
||
internal class SectionAdapter( | ||
activity: FragmentActivity, | ||
private val sectionNames: List<String>, | ||
) : FragmentStateAdapter(activity) { | ||
private val pages = mutableMapOf<String, WeakReference<SectionFragment>>() | ||
|
||
override fun getItemCount() = sectionNames.size | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
val sectionName = sectionNames[position] | ||
return SectionFragment.create(sectionName).also { | ||
pages[sectionName] = WeakReference(it) | ||
} | ||
} | ||
|
||
suspend fun awaitSectionFragment(sectionName: String): SectionFragment = pages[sectionName]?.get() ?: run { | ||
delay(100) // ¯\_(ツ)_/¯ | ||
awaitSectionFragment(sectionName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...spector/src/main/java/io/mehow/laboratory/inspector/SmoothScrollingLinearLayoutManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.mehow.laboratory.inspector | ||
|
||
import android.content.Context | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.LinearSmoothScroller | ||
|
||
internal class SmoothScrollingLinearLayoutManager( | ||
context: Context, | ||
) : LinearLayoutManager(context) { | ||
private val scroller = object : LinearSmoothScroller(context) { | ||
override fun getVerticalSnapPreference() = SNAP_TO_START | ||
|
||
override fun getHorizontalSnapPreference() = SNAP_TO_START | ||
} | ||
|
||
fun smoothScrollTo(index: Int) { | ||
scroller.targetPosition = index | ||
startSmoothScroll(scroller) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
library/inspector/src/main/res/layout/io_mehow_laboratory_feature_group.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.