什么是Jetifier?例如,要使用androidx打包的依赖项创建一个新项目,这个新项目需要将以下行添加到gradle.properties文件中:
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
那是什么意思 - "启用jetifier"?
如何确定用户是否有资格免费试用计费库?换句话说,如何知道用户之前没有使用过免费试用呢?我没有找到任何 API 可以帮助确定这一点。并且此信息与应用程序帐户无关,而是与用户的 Google Play 帐户相关。用户可以在应用程序中创建一个新帐户,但如果他已经参加了免费试用,即他之前使用当前的 Google 帐户(在 Google Play 中)购买了免费试用订阅,他将在弹出窗口中看到一条消息来自 Google“您已经参加了免费试用”。用户还可以随时更改其在 Google Play 中的 Google 帐户。因此,将用户已购买订阅的信息存储在服务器上是没有帮助的。我需要在应用程序用户界面上显示这些信息。
如何搭配androidx.recyclerview.widget.RecyclerView使用tools:listitem?我有这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerViewActors"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/list_item_actor"
tools:itemCount="5"
tools:orientation="horizontal"
tools:scrollbars="horizontal"
tools:spanCount="2"/>
Run Code Online (Sandbox Code Playgroud)
但“ 设计”选项卡不显示预览:
而且,如果我androidx.recyclerview.widget.RecyclerView将此布局更改为ListView,则预览工作正常:
android preview android-recyclerview android-tools-namespace androidx
我有以下方法来更新我的地图:
private void setCamera() {
if (currentLocation != null) {
String[] coords = currentLocation.split(",", 2);
CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(Double.parseDouble(coords[0]), Double.parseDouble(coords[1])));
CameraUpdate zoom = CameraUpdateFactory.zoomTo(5);
mMap.moveCamera(center);
mMap.animateCamera(zoom);
}
}
Run Code Online (Sandbox Code Playgroud)
我第一次在打开应用程序后立即调用此方法,并且此方法正常工作.但之后我转到另一个片段然后再到第一个片段.在这种情况下,方法被调用,currentLocation不等于null,center得到正确的LatLng对象,但我的地图视图没有改变,缩放小于5.有什么问题?
我可以通过查询获得没有毫秒的近似时间
SELECT UNIX_TIMESTAMP(NOW());
Run Code Online (Sandbox Code Playgroud)
但如何获得精确的当前时间戳(以毫秒为单位)?例如,执行上述查询后我得到了1352717640值,但我想得到1352717640xxx值。
UPD
SO 的其他答案(像这样)提供了像这样的解决方案
SELECT UNIX_TIMESTAMP(NOW(3))*1000;
Run Code Online (Sandbox Code Playgroud)
但此查询仅用“000”填充毫秒位置,但我想获得精确的毫秒值,例如1352717640937.
在 SQLyog 中:
并在 mysql 控制台中:
MySQL 5.1是否可以实现?
import kotlinx.coroutines.*
fun main() {
GlobalScope.launch {
delay(1000L)
println("${Thread.currentThread().name}: World")
}
println("${Thread.currentThread().name}: Hello")
Thread.sleep(2000L)
println("${Thread.currentThread().name}: Finish!")
}
Run Code Online (Sandbox Code Playgroud)
我的build.gradle文件如下所示:
buildscript {
// Consider moving these values to `gradle.properties`
ext.kotlin_version = '1.3.0-rc-146'
ext.kotlin_gradle_plugin_version = '1.3.0-rc-198'
ext.kotlinx_coroutines = '1.0.0-RC1'
repositories {
maven { url "https://kotlin.bintray.com/kotlin-eap" }
mavenCentral()
jcenter()
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51"
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version "1.1.51"
}
apply plugin: 'idea'
apply plugin: 'application'
group 'by.kotlin'
version '1.0-SNAPSHOT'
mainClassName = 'MainKt' …Run Code Online (Sandbox Code Playgroud) 我在带三引号的字符串内部使用带三引号的字符串:
fun main(args: Array<String>) {
val firstStr = """
OLOLO
""".trimIndent()
val secondStr = """
$firstStr
new added text
""".trimIndent()
println("The firstStr is $firstStr")
println("The secondStr is $secondStr")
}
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
The firstStr is
OLOLO
The secondStr is
OLOLO
new added text
Run Code Online (Sandbox Code Playgroud)
我很困惑为什么缩进保留在最后一行(" new added text")...因为我预计该trimIndent()方法必须修剪所有缩进(正如文档注释所说,该方法
检测所有输入行的公共最小缩进,将其从每一行中删除,如果第一行和最后一行为空白,则还删除它们(注意空白与空的区别)。
同时我可以使用带有默认参数(“|”)的trimMargin()来剪切这个缩进:
fun main(args: Array<String>) {
val firstStr = """
OLOLO
""".trimIndent()
val secondStr = """
$firstStr
|new added text
""".trimMargin()
println("The firstStr is $firstStr")
println("The secondStr is $secondStr")
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我得到以下输出: …
如何理解死锁的原因——即如何找出哪些事务捕获了哪些锁?
我有带有以下死锁的engine.log文件:
------------------------
LATEST DETECTED DEADLOCK
------------------------
170327 11:09:53
*** (1) TRANSACTION:
TRANSACTION 4 2719072253, ACTIVE 5 sec, OS thread id 26215 starting index read
...
INSERT INTO... (the first transaction)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 36025889 n bits 96 index `PRIMARY` of table `mydb`.`mytable` trx id 4 2719072253 lock mode S locks rec but not gap waiting
...
*** (2) TRANSACTION:
TRANSACTION 4 2719072205, ACTIVE 35 …Run Code Online (Sandbox Code Playgroud) 我想向不同的收件人发送几封电子邮件,但这些字母的文字可能会有所不同.我还希望授权用户并代表他发送邮件,Intent以及内置的邮件客户端应用程序.有没有办法通过单击按钮来执行此操作,而不是为每个字母调用新的电子邮件窗口(活动)并强制用户确认每封信件的发送?
有没有办法不为每个字母调用新的电子邮件窗口,以便用户确认发送每个字母,只需按一下按钮即可完成此操作?
为此可能有任何第三方图书馆或免费邮件服务?
我知道以下方法也是如此,但哪种变体更好,为什么?
public boolean method() {
if (condition) {
return otherMethod();
} else {
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
要么
public boolean method() {
if (condition) {
return otherMethod();
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
或许这是更好的变种?
public boolean method() {
return condition ? otherMethod() : true;
}
Run Code Online (Sandbox Code Playgroud) 有没有什么好方法来获取第一个非null String数组元素的索引?是的,你可以写
int index;
for (int i = 0; i < arr.length; i++) {
if (arr[i] != null) {
index = i;
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但也许有可能以更美丽的方式做到这一点?例如,您可以使用ObjectUtils.firstNonNull方法来获取数组的第一个非null元素,也许有类似于获取索引的东西?
我有RecyclerView、ItemTouchHelper和ItemTouchHelper.Callback实例可以一起工作,并且在向左滑动时应删除应删除的所选项目(通过本教程)。移除动画有效,但只是部分有效。首先,在滑动后,该项目似乎被删除,但之后它又重新出现,并且列表保持不变:
为什么会发生呢?
android ×7
androidx ×2
java ×2
kotlin ×2
mysql ×2
arrays ×1
deadlock ×1
email ×1
google-maps ×1
google-play ×1
gradle ×1
preview ×1
string ×1
subscription ×1
timestamp ×1