kotlin-android-extensions

How to Rebind the Module at secound time called in kodein?

旧时模样 提交于 2019-12-24 20:54:41
问题 I have an android app, its developed in kotlin, also we use kodein dependence for binding the data.When the binding the data first time it will bind correctly but it does not bind at second time call. inner class CallmyClass() : MultiDexApplication(), KodeinAware { val diModel = Kodein.Module { bind<ExchangeRateProvider>() with singleton { CryptoCompareExchangeProvider(this@App, instance()) } bind<SyncProgressProvider>() with singleton { SyncProgressProvider() } bind<WallethKeyStore>() with

How to add +/- functionality to a butting in kotlin android

无人久伴 提交于 2019-12-24 12:19:44
问题 I need to add new button with functionality of +/-. If user clicks the button for the first time the value should return -> "-" (ex => -123), if the user clicks again value "-" should be removed (ex => 123). The functionality is similar as +/- button in the calculator. Here is my code Activity.kt file package com.tripbegins.calculator import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.Button import com.tripbegins.calculator

Android local VPN Service: can't get response

眉间皱痕 提交于 2019-12-24 09:46:33
问题 I'm quite new to Android and its services. I'm trying to implement a local VPN service in my app (with Kotlin and Java). QUESTION My VPN service taken from ToyVpn Google example, combined with examples from 1, 2, 3 to use it locally (without connection to remote server) is NOT working. MY APP PRINCIPE I saw this and this SO questions, but the answers there aren't very insightful and I can't find the solution for my issue. So the app is pretty simple : it should forward all of the packets when

NoClassDefFoundError after migrating to Android API 28

≡放荡痞女 提交于 2019-12-24 01:42:14
问题 I know, similar questions have been asked, but I think, my situation is different. Please don't delete. I've started getting NoClassDefFoundError error after migrating to API 28, just like many other folks. I've seen others experienced this issue because Google has deprecated org.apache classes, which required changing manifest, but I don't use apache classes in my project. What makes investigation difficult is that there is no custom classes in the stack trace below, and it's not even clear

How to disable the generating of synthetic view properties by the Kotlin Android extensions plugin

↘锁芯ラ 提交于 2019-12-23 08:47:16
问题 The Kotlin Android Extensions plugin generates static properties for each view with an ID from my app layout files, as it is described in the documentation. I would like to disable this feature, because we use DataBinding instead of the Kotlin synthetic view properties, and sometimes I import them by accident; also it adds extra build overhead for something we don't use. Disabling the Android extensions plugin is not possible, because we use the Parcelize feature which is done by the same

kotlin connect to self-signed https server

我是研究僧i 提交于 2019-12-22 11:23:17
问题 I have the following kotlin code: val urlPath = "https://10.0.2.2:8080" var data: String try { data = URL(urlPath).readText() } catch (e: Exception) { Log.e("doInBackground", "Exception caught: ${e.localizedMessage}") error = when (e) { is MalformedURLException -> "Invalid URL" is IOException -> "Network Error" else -> { "Network error: ${e.localizedMessage}" } } } If I use the above code to connect to a http server, the above code works. However when I try to connect to a https server with a

kotlin connect to self-signed https server

霸气de小男生 提交于 2019-12-22 11:20:25
问题 I have the following kotlin code: val urlPath = "https://10.0.2.2:8080" var data: String try { data = URL(urlPath).readText() } catch (e: Exception) { Log.e("doInBackground", "Exception caught: ${e.localizedMessage}") error = when (e) { is MalformedURLException -> "Invalid URL" is IOException -> "Network Error" else -> { "Network error: ${e.localizedMessage}" } } } If I use the above code to connect to a http server, the above code works. However when I try to connect to a https server with a

How can i access a char in string in at specific number? [closed]

你说的曾经没有我的故事 提交于 2019-12-22 08:19:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I tried this code but it is giving me errors. So how can i access a character in a string in kotlin. in java it can be done by charAt() method. private fun abc(x: String) { var i: Int = 0 while (x[i].toString() != "+") { var y: Char = x[i] i++ } } 回答1: The equivalent of Javas String.charAt() in Kotlin is String

Kotlin synthetic and custom layout in DialogFragment

╄→尐↘猪︶ㄣ 提交于 2019-12-22 01:33:15
问题 Let's say I have this layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageButton android:id="@+id/add_dep_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_marginEnd="5dp" android:layout

The difference between !! and ? in Kotlin

 ̄綄美尐妖づ 提交于 2019-12-20 08:32:49
问题 I am new to Kotlin . I want to know the difference between this two !! and ? in below code. I am having below two snippet first having use of !! for mCurrentDataset and another having ? for same variable. if(!mCurrentDataset!!.load(mDataSetString.get(mCurrentDataSelectionIndex), STORAGE_TYPE.STORAGE_APPRESOURCE)) { Log.d("MyActivity","Failed to load data.") return false } if(!mCurrentDataset?.load(mDataSetString.get(mCurrentDataSelectionIndex), STORAGE_TYPE.STORAGE_APPRESOURCE)!!) { Log.d(