我正在我的项目中一起工作kotlin
,我有一个如下所示的java
课程:kotlin
class AuthenticationPresenter @Inject constructor(
private val navigator: AuthenticationNavigator,
private val getCurrentServerInteractor: GetCurrentServerInteractor,
private val getAccountInteractor: GetAccountInteractor,
private val settingsRepository: SettingsRepository,
private val localRepository: LocalRepository,
private val tokenRepository: TokenRepository
) {
suspend fun loadCredentials(newServer: Boolean, callback: (authenticated: Boolean) -> Unit) {
val currentServer = getCurrentServerInteractor.get()
val serverToken = currentServer?.let { tokenRepository.get(currentServer) }
val settings = currentServer?.let { settingsRepository.get(currentServer) }
val account = currentServer?.let { getAccountInteractor.get(currentServer) }
account?.let {
localRepository.save(LocalRepository.CURRENT_USERNAME_KEY, account.userName)
}
if (newServer || currentServer …
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用OneSignal,如下:
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString()
def isPlay = !(taskRequests.contains("Foss") || taskRequests.contains("foss"))
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
if (isPlay) {
apply plugin: 'io.fabric'
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "com.github.ben-manes.versions"
android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools
defaultConfig {
manifestPlaceholders = [onesignal_app_id : “111”,
// Project number pulled from dashboard, …
Run Code Online (Sandbox Code Playgroud) 我需要附加两个list
,但它告诉我:
type mismatch required collection found list
Run Code Online (Sandbox Code Playgroud)
就像下面这样:
val list: List<Cohort> = ArrayList()
private fun fillFromDao() {
val notesObserver: Observer<ArrayList<Cohort?>?>? =
Observer { cohort: ArrayList<Cohort?>? ->
list.toMutableList().addAll(cohort)
}
if (notesObserver != null) {
otherDialogFragmentViewModel.fetchIsFree()?.observe(this, notesObserver)
otherDialogFragmentViewModel.fetchHasCertificate()?.observe(this, notesObserver)
}
}
Run Code Online (Sandbox Code Playgroud) 我有吼叫xml
:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbarMainActivity"
style="@style/CustomToolbar"
android:background="@color/biscay"
app:layout_scrollFlags="scroll|enterAlways">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/icon_drawer_imagebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@null"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_drawer" />
<RelativeLayout
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/icon_drawer_imagebutton">
<ImageButton
android:id="@+id/icon_logo_imagebutton"
android:layout_width="@dimen/size_logo"
android:layout_height="@dimen/size_logo"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:background="@null"
android:scaleType="fitXY"
app:srcCompat="@drawable/ic_logo_white" />
<TextView
android:id="@+id/nameUniversity_textview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="18sp"
android:layout_toLeftOf="@+id/icon_logo_imagebutton"
android:gravity="center_vertical"
android:text="@string/nameUniversity"
android:textColor="@color/colorTextLight"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabsMainActivity"
style="@style/CustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud) 我使用下面的方法class
进行swipe
检测recyclerView
:
open class OnSwipeTouchListener(context: Context) : View.OnTouchListener {
var context: Context? = context
private val gestureDetector = GestureDetector(context, GestureListener())
fun onTouchs(event: MotionEvent): Boolean {
return gestureDetector.onTouchEvent(event)
}
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
private val SWIPE_THRESHOLD = 100
private val SWIPE_VELOCITY_THRESHOLD = 100
override fun onDown(e: MotionEvent): Boolean {
return true
}
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
onTouchs(e)
return true
}
override fun onFling(@NonNull e1: MotionEvent,
@NonNull e2: MotionEvent,
@NonNull velocityX: Float, …
Run Code Online (Sandbox Code Playgroud) 什么是波纹管警告:
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)