nicoqueijo / android-currency-converter Goto Github PK
View Code? Open in Web Editor NEWCurrency conversion tool using real-time exchange rates.
License: Apache License 2.0
Currency conversion tool using real-time exchange rates.
License: Apache License 2.0
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.
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.
Create this tag and release when all pending major features are completed.
This naming makes more sense. This should be a simple rename/refactor throughout the project.
Add BillingProcessor to dependency graph.
Flow:
BillingProcessor
checks if user has purchased remove_ads
product.
Remove Ads
menu item is hidden and ad views are not initialized.Remove Ads
menu item is shown and ad views are initilized.Remove Ads
and goes through with purchase, disable the ad views.Disable interstitial ads on the SelectorFragment
if user purchased the remove_ads
product.
Title is self-explanatory.
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.
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.
Going to put this issue aside for now because it's not clear what approach to take since the app won't build without some API keys that are not being tracked by git. This stackoverflow thread describes the issue: https://stackoverflow.com/questions/60993450/how-to-replace-a-api-key-with-a-secret-in-code-during-github-actions-job
This is a library issue that is being tracked here.
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.
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.
because Google said so
Helpful links:
https://developer.android.com/training/dependency-injection
https://developer.android.com/training/dependency-injection/hilt-android
https://dagger.dev/hilt/
https://medium.com/androiddevelopers/dependency-injection-on-android-with-hilt-67b6031e62d
https://levelup.gitconnected.com/hilt-the-future-of-dependency-injection-in-android-e9a919c0993d
from where can i get the api key
and RowSelectableCurrencyBinding could not be found
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 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.
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)
A couple of the images show layout elements that are in English. Take new screenshots without English elements to cater to all locales.
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 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.
Options:
-Unit tests
-Integration tests
-UI tests
Issue branch: https://github.com/nicoqueijo/Android-Currency-Converter/tree/tests
-Migrate to Google Truth for better assertions.
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.