kotlin

androidx.navigation.fragment.NavHostFragment is not accessible from xml file

人走茶凉 提交于 2020-07-09 13:28:47
问题 I am trying to use androidx navigation with bottom navigation view.So when i put fragment with android:name = "androidx.navigation.fragment.NavHostFragment" in xml file it gives me an error. I guess that xml doesn't see this library or this Fragment Here is xml file : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout

How do we detect the Orientation of Image captured using CameraX if Application's default orientation is set to Portrait Mode

有些话、适合烂在心里 提交于 2020-07-09 13:01:04
问题 Basically, My camera app is set to Portrait Mode. However, user can take photos in Potrait or landscape by rotating the phone accordingly (The app doesnt rotate). So my question is, how can we find the captured image orientation? I tried using DisplayManager.DisplayListener , however, it works only when orientation of app happens. Since I have blocked the orientation of app to portrait mode, it doesnt get any callbacks here. I even tried using ExifInterface , however, it always gives 6 as

Codec not found for requested operation: [map<varchar, int> <-> java.util.Map]; issue Apache Cassandra

浪尽此生 提交于 2020-07-09 05:30:23
问题 I have a table with the fields CREATE TABLE app_category_agg ( category text, app_count int, sp_count int, subscriber_count int, window_revenue bigint, top_apps frozen <list<map<text,int>>>, PRIMARY KEY (category) ); when I try to map it to kotlin model @Table("app_category_agg") class AppCategoryAggData { @PrimaryKeyColumn(name = "category", ordinal = 0, type = PrimaryKeyType.PARTITIONED) lateinit var category: String @Column("app_count") var appCount: Int = 0 @Column("sp_count") var spCount

Download Large File with MediaStore Android 10

放肆的年华 提交于 2020-07-09 03:14:12
问题 I am trying to download a file to download the directory in Android 10 and above. I did as following. val resolver = contentResolver val contentValues = ContentValues().apply { put(MediaStore.MediaColumns.DISPLAY_NAME, "CuteKitten001") put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg") put(MediaStore.MediaColumns.RELATIVE_PATH, "Download/PerracoLabs") } val uri = resolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues) val outputStream: OutputStream? = if (uri == null) null

Clear database before testcase espresso

余生长醉 提交于 2020-07-08 11:39:18
问题 im using espresso to clear database in my app Im setting activity like this @Rule @JvmField val activity = ActivityTestRule<PhotoPrinterActivity>(PhotoPrinterActivity::class.java,false,false) And this is my before function @Before open fun setup() { clearDatabase() activity.launchActivity(null) // Waiting for start app success fully } And this is my clear database code fun clearDatabase() { val databaseList = InstrumentationRegistry.getInstrumentation().targetContext.databaseList() for

Update UI async call with coroutines

江枫思渺然 提交于 2020-07-08 09:32:55
问题 I've got to update the UI with an async call to the Room Database, but when I do I've got this error : android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. // FavoritesPresenter.kt GlobalScope.launch { favoritesView.showFavorites(ProductProvider.getAllProducts() as ArrayList<Product>) } // ProductProvider.kt fun getAllProducts() : MutableList<Product> { return dao.getAllProducts() } // ProductDao.kt @Query(

Annotate interface function that must call super

▼魔方 西西 提交于 2020-07-08 04:17:38
问题 I'm creating interface and some function in it has a body. It's required, that class that implements this interface must call super in overriding function before executing other code. How can I do this? interface Watcher { fun funWithoutBody() fun startWatching() { //do some important stuff which must be called } } 回答1: I've accidentally found, what I was looking for. It's a @CallSuper annotation available in android.support.annotation package. Docs Use the @CallSuper annotation to validate

Cannot create instance of viewmodel after using Hilt in Android

南笙酒味 提交于 2020-07-07 10:32:40
问题 Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewModel() { } Here is PdfItemRepository class. @Singleton class PdfItemRepository @Inject constructor(private val pdfItemDao: PdfItemDao){ } For pdfItemDao . I created a module named DatabaseModule . Below is the code - @Module @InstallIn(ApplicationComponent::class) object DatabaseModule { @Provides fun provideDatabase(@ApplicationContext

Cannot create instance of viewmodel after using Hilt in Android

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-07 10:32:32
问题 Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewModel() { } Here is PdfItemRepository class. @Singleton class PdfItemRepository @Inject constructor(private val pdfItemDao: PdfItemDao){ } For pdfItemDao . I created a module named DatabaseModule . Below is the code - @Module @InstallIn(ApplicationComponent::class) object DatabaseModule { @Provides fun provideDatabase(@ApplicationContext

Unresolved Dependency on package in subproject

…衆ロ難τιáo~ 提交于 2020-07-07 04:28:24
问题 In my Kotlin spring boot project, I am using Kotlin DSL Gradle, with three subprojects. Two of which are security which depends on database . In IntelliJ, the application runs successfully and performs as expected (when run as a Spring Boot application run config). However, when I try to build the project with Gradle ./gradlew clean build I get e: /security/src/main/kotlin/com/path/security/jwt/JwtRealm.kt: (3, 26): Unresolved reference: database e: /security/src/main/kotlin/com/path/security