android-jetpack

how to remove default animation transition when using navigation component in Android?

孤街醉人 提交于 2020-01-15 09:14:33
问题 I am using Navigation component, and I have a bottom navigation view in the main activity. when I tap the tab in that bottom navigation view, it seems that there is a fade in animation when the fragment appear. I don't think I manually set the animation, it seems that the animation will be there by default. I want to remove that animation. here is the code I use in my Main Activity. class MainActivity : AppCompatActivity(), NavController.OnDestinationChangedListener { private lateinit var

Calling custom SQLite functions in Room

前提是你 提交于 2020-01-13 18:06:57
问题 I include a custom build of sqlite in my app. I have several custom functions in that library, and I would like to call them from @Query in my Room DAOs. However I get an error that Room couldn't find those functions. Is there a way to tell Room that they exist WITHOUT using a @RawQuery? 回答1: From Google: Room can't verify queries with custom functions, please annotate your method with @SkipQueryVerification . Room verifies your Dao queries using sqlite-jdbc which uses a vanilla prebuilt

Calling custom SQLite functions in Room

心不动则不痛 提交于 2020-01-13 18:04:03
问题 I include a custom build of sqlite in my app. I have several custom functions in that library, and I would like to call them from @Query in my Room DAOs. However I get an error that Room couldn't find those functions. Is there a way to tell Room that they exist WITHOUT using a @RawQuery? 回答1: From Google: Room can't verify queries with custom functions, please annotate your method with @SkipQueryVerification . Room verifies your Dao queries using sqlite-jdbc which uses a vanilla prebuilt

How to pass Complex Types of Objects to WorkManager in android. i.e lists, maps, POJO

懵懂的女人 提交于 2020-01-13 05:19:06
问题 WorkManager is a library used to enqueue work that is guaranteed to execute after its constraints are met. WorkManager allows observation of work status and the ability to create complex chains of work. Valid types supported are only: Boolean, Integer, Long, Double, String, and array versions of each of those types. // Define the Worker class: public class MathWorker extends Worker { // Define the parameter keys: public static final String KEY_X_ARG = "X"; public static final String KEY_Y_ARG

Paging library DataSource.Factory for multiple data sources

放肆的年华 提交于 2020-01-13 02:45:14
问题 The new paging library allows us to specify a custom data source to use with data pagination. Paging library documentation and sample code on github show us how to create your custom data source instances by creating a subclass of DataSource.Factory like so: class ConcertTimeDataSourceFactory(private val concertStartTime: Date) : DataSource.Factory<Date, Concert>() { val sourceLiveData = MutableLiveData<ConcertTimeDataSource>() override fun create(): DataSource<Date, Concert> { val source =

Display back button on toolbar on first screen of navigation graph

牧云@^-^@ 提交于 2020-01-12 09:50:47
问题 I'm trying out androidx navigation component and have setup my activity with a toolbar a container. I'm doing this in one of the intermittent screens of my app which has a lot of internal navigation/steps and I thought I could navigation arch component a try with this. Since this is an intermittent screen, I want to display a back button on the toolbar from the first screen itself. I've already setup the toolbar with the below code in the onCreate() method of my host activity,

Navigation destination unknown to this NavController after an activity result

本小妞迷上赌 提交于 2020-01-12 03:36:07
问题 i'm using nav controller 1.0.0alpha05 and it is working great, but i'm struggling with this dreaded error when i execute a navigation action after an activity result. I have a single activity/multiple fragments structure, in particular a fragment with a list of items and another one with the form for adding a new one. When i add another one without any picture it is working and returning to the previous one with the list of items, but when i take some photos i get the exception during the

WorkManager OneTimeWorkRequest InitialDelay works after twise the time set

微笑、不失礼 提交于 2020-01-11 07:19:14
问题 UPDATE (21-nov-2019) WorkManager.getInstance(activity).enqueueUniquePeriodicWork("test_work", ExistingPeriodicWorkPolicy.KEEP, PeriodicWorkRequest.Builder(MyWorker::class.java, 15, TimeUnit.MINUTES) .build()) Now I'm using PeriodicWork and now doWork() called twice even I cancelled uniquettask at first attempt.I'm getting Notification twice and Checked in Log also It's called twice . Note: It's happen only first time and sometime second time also but not getting third time twice. override fun

How to implement Dagger for worker classes?

女生的网名这么多〃 提交于 2020-01-10 03:34:04
问题 Since the Worker class is created by the framework ( WorkerManager ), how can we use @Inject fields into the Worker ? 回答1: You have to provide class using @Provides annotation in the module to inject. First create a component containing a module which will provide the class. @Component(modules = {Module.class}) public interface Component1{ void inject(SyncWorker syncWorker); } Module Class @Module public class Module{ @Provides public ISettingRepository getSettingRepo(){ return new

Scoping a viewmodel to multiple fragments (not activity) using the navigation component

自古美人都是妖i 提交于 2020-01-09 11:15:50
问题 I'm using the navigation component, I want a view model to be shared between a few fragments but they should be cleared when I leave the fragments (hence not scoping them to the activity) I'm trying to take the one activity many fragments approach. I have managed to achieve this using multiple nav hosts and scoping the fragments to it using getParentFragment but this just leads to more issues having to wrap fragments in other parent fragments, losing the back button working seamlessly and