tunjid / android-extensions Goto Github PK
View Code? Open in Web Editor NEWAn Android library with modules to quickly bootstrap an Android application.
License: MIT License
An Android library with modules to quickly bootstrap an Android application.
License: MIT License
Check the video that's attached:
In this file, you had declared two times the kotlin-gradle-plugin.
https://github.com/tunjid/Android-Extensions/blob/develop/build.gradle
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
This typo is nothing. But, Your code is fantastic. I am following step by step to grab some good practices. Then, I saw these two lines that distracted me a little
The declaration of the multiStackNavigator is interesting. Is this a propery delegation? It took me a while till I understood the connection to the extension function declared in the MultiStackNavigator.kt
Hi @tunjid,
actually I discovered an issue while implementing shared element transitions between activities by using StackNavigator.
The issue is that the back transition of the shared element transition is not working because every fragment is added to the back stack. Every means that also the initial one is added to the back stack.
The issues lies within
StackNavigator.push(fragment:Fragment, tag:String)
to be more precise
fragmentManager.commit {
transactionModifier?.invoke(this, fragment)
replace(containerId, fragmentToShow, tag)
addToBackStack(tag.toEntry)
}
Is there a way to circumvent "addToBackStack(tag.toEntry)?
If I do not use StackNavigator and simple use a transaction where I do not add the initial fragment to the back stack then the back transition of the shared element transition is working fine.
Do you need an example project?
Regards
wMan
Hi,
very nice library!
Currently I am asking myself how to implement MaterialFadeThrough-Transition during a stack-change?
I was able to implement a Cross-Fade Transition by using stackTransactionModifier of MultiStackNavigator like this
this.stackTransactionModifier = { setCustomAnimations( R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out ) }
But how to do this by using a MaterialFadeThrough Transition?
I'm not sure how to use the speed dial components without all the complex UI driver stuff. These are the steps I followed:
private var _fabExtended = true
private lateinit var _fabExtensionAnimator: FabExtensionAnimator
private lateinit var _fabClickListener: SpeedDialClickListener
private var _fabTransitionOptions: SpringAnimation.() -> Unit = {}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val speedDialItems = createSpeedDialItems()
_fabExtensionAnimator = FabExtensionAnimator(expandable_fab).apply {
speedDialItems[1].run { updateGlyphs(first, second) }
}
_fabClickListener = SpeedDialClickListener(
tint = view.context.themeColorAt(R.attr.colorAccent),
items = speedDialItems,
runGuard = this@MainFragment::fabExtensionGuard,
dismissListener = {
when (it) {
null -> Unit
0 -> {
_fabExtended = true
_fabExtensionAnimator.configureSpring(_fabTransitionOptions)
}
else -> speedDialItems[it].run {
_fabExtensionAnimator.updateGlyphs(first, second)
}
}
}
)
expandable_fab.setOnClickListener {
_fabExtensionAnimator.isExtended = !_fabExtensionAnimator.isExtended
}
}
private fun fabExtensionGuard(view: View): Boolean {
if (!_fabExtended) return true
_fabExtended = false
_fabExtensionAnimator.configureSpring(_fabTransitionOptions)
_fabTransitionOptions = { speedDialRecall(view) }
return false
}
private fun SpringAnimation.speedDialRecall(view: View) = withOneShotEndListener {
if (_fabExtended) return@withOneShotEndListener
_fabClickListener.invoke(view)
}
private fun createSpeedDialItems() = requireActivity().run {
listOf(
"Item 1" to getDrawable(R.drawable.ic_folder)!!,
"Item 2" to getDrawable(R.drawable.ic_folder_special)!!
)
}
When I run the app, the button shows the text and icon for the first speed dial item, but I expected it to show the unfold icon. Clicking the button expands the button and shows the label next to the icon but doesn't show the speed dial items.
Needless to say, I don't really understand what all this code does. I get really confused when I look into the GlobalUiDriver class, so I'd rather not have to add all of that.
Hi @tunjid,
I just checked out version 1.2.1. Thanks for the changes.
I discovered that something is not working correctly with BackstackType Unlimited or Restricted. Its working fine with uniqueEntries. I ONLY changed the type to Unlimited/Restricted.
Back press navigation within a tab with several fragments seems to work fine as well as switching then to the previous tab, but if the next previous tab just has only a root fragment I have to press twice the back button.
It seems that it only occurs if I just navigate back between tabs with only root fragment added to it.
Hi,
would it be possible to add the Instagram-like navigation example from https://proandroiddev.com/simplifying-the-fragmentmanager-api-multiple-fragment-backstacks-on-android-9b64ddb0d654 also seen in the following gif
https://miro.medium.com/max/648/1*Rj7f7D3XfwUuXFlBnBSQ1A.gif
to the sample app?
I'm asking because I need exactly that but I don't really understand how to transfer the knowledge from the sample app to my app, where I pretty much need exactly what one can see in the gif.
In particular, I'm wondering how the fragments in the main activity are created since the root function in the sample app appears to create a new fragment each time it is called. Also, I was wondering how the inner fragments should be added in such a way that their state is preserved.
Please let me know if you need more information since the explanation I gave here is rather brief.
Hey @tunjid,
with version 1.2.1 I'll get an error:
Unresolved reference: MultiStackNavigator
with version 1.2.0 it works ...
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1689)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1729)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:321)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:286)
at com.emaar.shopndrop.navigation.MultiStackNavigator.showInternal(MultiStackNavigator.kt:320)
at com.emaar.shopndrop.navigation.MultiStackNavigator.show(MultiStackNavigator.kt:119)
at com.emaar.shopndrop.activities.MainActivity$fetchRequestDetail$1.onNext(MainActivity.kt:193)
at com.emaar.shopndrop.activities.MainActivity$fetchRequestDetail$1.onNext(MainActivity.kt:178)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
@tunjid I'm getting this error. What I'm trying is after launching MainActivity hitting the web API and launching fragment.
Hi @tunjid,
its me again! :)
If I start you example project and click myself through the tabs in the following order
Nav, Lists, Comms, Misc, Comms, Lists, Nav (From left to right and back to left)
I would expect that while I am pressing the back button I would go through
Lists, Comms, Misc, Comms, Lists, Nav and finally app is moved to background
but instead the order is
Lists, Comms, Misc and finally app is moved to background
is that the right behavior?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.