Giter Club home page Giter Club logo

android-extensions's Introduction

Hi there ๐Ÿ‘‹๐Ÿฟ

I love to build things, like bad puns, and enjoy football.

I'm also on the Media Foundations Team at Airbnb.

I identify as a functional reactive programming and immutable state zealot.

Pinned are a few of my favorite things.

For more experimental / avant garde / Kotlin multiplatform stuff you may wanna checkout:

โœจ Me: An experimental Kotlin multiplatform WYSIWYG blog editor for the desktop and Android

โœจ Tiler: An experimental Kotlin multiplatform pagination library

โœจ Mutator: Yet another Kotlin multiplatform redux like library

โœจ TreeNav: An experiment in Kotlin multiplatform for representing app navigation with tree like data structures

android-extensions's People

Contributors

dependabot[bot] avatar lolaodelola avatar petergelsomino avatar tunjid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-extensions's Issues

Can't perform this action after onSaveInstanceState

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.

BackStackType Unlimited/Restricted in version 1.2.1 not working correctly

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.

Minimal steps needed to implement speed dial

I'm not sure how to use the speed dial components without all the complex UI driver stuff. These are the steps I followed:

  1. I added a dependency on com.tunjid.androidx:material:1.0.0-rc06 to my app's build.gradle
  2. I copied the SpeedDialClickListener class into my project (aside: it would be nice if this was provided by a lib), along with the missing resources it used (R.drawable.ic_unfold_less_24dp and R.drawable.ic_unfold_more_24dp)
  3. I added a MaterialButton to my fragment layout
  4. I added the following code to my fragment:
    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.

How to use MaterialFadeThrough Transition as StackTransactionModifier?

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?

Example of Instagram-Like Navigation

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.

Wrong order of selected tabs during back press?

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?

StackNavigator shared element transition between activities

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.