Giter Site home page Giter Site logo

nicoqueijo / android-currency-converter Goto Github PK

View Code? Open in Web Editor NEW
42.0 42.0 22.0 81.42 MB

Currency conversion tool using real-time exchange rates.

License: Apache License 2.0

Kotlin 100.00%
android android-app currency-conversion exchange-rates finance kotlin

android-currency-converter's People

Contributors

nicoqueijo 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

Watchers

 avatar  avatar  avatar

android-currency-converter's Issues

Weird behavior when undoing swipes.

Undoing a swipe sometimes draws the wrong currency code and flag (the currency below it) although that ViewHolder is holding the correct underlying data. I suspect this might be a race condition between letting Room know the data has changed and the adapter redrawing the cached data before room is able to emit new values.

ezgif-3-66bca99af2d3

Swiping a currency that has the focus sometimes crashes on the call to notifyItemChange()

Swiping a currency that has the focus sometimes crashes on the call to notifyItemChange(). This call is necessary to redraw the newly focused currency with its proper styling.

Possible solutions:

  • Make the adapterActiveCurrencies a MediatorLiveData so it can update the UI when volatile fields change? Since it references a LiveData, when the non-volatile fields change (db) it gets updated about them.

  • Non-volatile fields change -> db changes its list -> activeCurrencies is changed -> setCurrencies() called -> adapterActiveCurrencies receives changes -> submitList() called -> DiffUtil takes care of notifying adapter.

  • Volatile fields change -> adapterActiveCurrencies -> UI changes without calls to notifyItemChanged() ?

  • If above doesn’t work, try the FastAdapter library (this might be require a big refactor).

I suspect the root of this issue is two different threads trying to manipulate the same adapter position. One is from DiffUtil callbacks and the other is from manual calls to notifyItemChange(). Article on this here.

It might be impossible to migrate to only using DiffUtil and maintain the focused currency’s text with the exact same text the user has input.

Another option is to move away from a RecyclerView entirely as the binding management is overkill for a list that will realistically be small.

Submit v1.2 release

Create this tag and release when all pending major features are completed.

Add feature to remove ads

Add BillingProcessor to dependency graph.

Flow:

  • User launches app.
  • BillingProcessor checks if user has purchased remove_ads product.
    • If so, Remove Ads menu item is hidden and ad views are not initialized.
    • Else, Remove Ads menu item is shown and ad views are initilized.
  • If user clicks Remove Ads and goes through with purchase, disable the ad views.

Disable interstitial ads on the SelectorFragment if user purchased the remove_ads product.

Retain state on process death

Retain the ViewModel’s state/data if it is destroyed due to process death. This should be the focused currency and its conversion value. The conversion values for all other currencies can be calculated on the fly from the focused currency’s conversion value.

  • Article
  • Remember: we want to get the app back to its previous state, saving the least amount of data as possible.

Incorrect decimal and grouping separators used on Locale change

When the user changes locale, the app restarts due to a configuration change. Since the ViewModel (who survives config changes) stores the decimal and grouping separators that it acquires on the app launch, those could’ve been swapped if the old locale uses periods as a decimal separator and the new locale uses commas. This introduces bugs in the input validation logic stored in the ViewModel and can cause a crash on when converting currencies on an unexpected format.

State of selected currencies is lost when process is killed.

When the OS kills the process (due to low memory, for instance), the state of the selected currencies is lost and this allows duplicates to be added to the list of active currencies as the information of whether this currency is selected or not is gone.

Currency 'selected' state might be getting overwritten when stale data is refreshed from network

This is an unconfirmed issue.

When local data becomes stale (over 24 hours has passed since an API call was made) an API call is made to update the exchange rate values. When this happens all the currency values from the local database are replaced with the json values from the API call. This possibly overwrites the 'isSelected' state of each currency in the database with a 'false' value since the json only contains values for the currency code and the exchange rate.

Api key

from where can i get the api key

and RowSelectableCurrencyBinding could not be found

Introduce dependency injection

Don’t create the Dao or web service inside the Repository, but instead provide it via dependency injection.

Dependency injection use case: Currency depends on a currency code and an exchange rate. Fragments depend on ViewModels; ViewModels depend on Repositories. Anything that involves composition can be a candidate for dependency injection (?).

Resource: Dagger YouTube videos; Dagger codelab.

Assure that shared dependencies point to the same object (produce same hash code).

Can't add multiple currencies at same time

Can't select multiple currencies at the same time when adding new currency.
Should be able to scroll through the list and check multiple, as opposed to having to add individually.

Crash when trying to navigate after app was restarted (manually or via process death)

Example error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.nicoqueijo.android.currencyconverter, PID: 16732
    java.lang.IllegalArgumentException: navigation destination com.nicoqueijo.android.currencyconverter:id/action_watchlistFragment_to_selectorFragment is unknown to this NavController
        at androidx.navigation.NavController.navigate(NavController.java:914)
        at com.nicoqueijo.android.currencyconverter.kotlin.view.WatchlistFragment$initFloatingActionButton$$inlined$apply$lambda$1.onClick(WatchlistFragment.kt:141)
        at android.view.View.performClick(View.java:7869)
        at android.view.View.performClickInternal(View.java:7838)
        at android.view.View.access$3600(View.java:886)
        at android.view.View$PerformClick.run(View.java:29362)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8016)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

Facing Issue While Running The Application

I have Upgrade Gradle Veriosn of this project to 7.2 and facing this issue
java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @1dd3925a

Try to 'add' Fragments instead of 'replace' when using Jetpack's Navigation

Try to see if I could ‘add’ instead of ‘replace’ the SelectorFragment when I click on the FloatingActionButton so that WatchlistFragment stays in memory.

The default behavior when using Jetpack’s Navigation is to 'replace' and that is why I always have to redraw the DragLinearLayout when we return from SelectorFragment.

If I could do an ‘add’ instead of a ‘replace’ then this would provide a much better UX as there would be no overhead cost when returning from selecting a Currency.

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.