fun getClient(token: String, userId: Long, language: String = "en", maxTry: Int = 2): Retrofit {
val okHttpClient = OkHttpClient.Builder()
okHttpClient.readTimeout(30, TimeUnit.SECONDS)
okHttpClient.connectTimeout(30, TimeUnit.SECONDS)
okHttpClient.writeTimeout(90, TimeUnit.SECONDS)
var tryCount = 0
okHttpClient.addInterceptor { chain ->
val original = chain.request()
val request = original.newBuilder()
.addHeader("Content-Type", "application/json")
.addHeader("secToken", token)
.addHeader("userId", userId.toString()).build()
var response = chain.proceed(request)
while (!response.isSuccessful && tryCount < maxTry) {
Log.d("intercept", "Request is not successful - $tryCount")
tryCount++
response = chain.proceed(request)
}
response
}
val builder = GsonBuilder()
builder.registerTypeAdapter(TransModel::class.java, NotificationTypeAdapter(language))
val gson …Run Code Online (Sandbox Code Playgroud) 我有两个标签的活动.两个选项卡使用不同的片段 当某个特定事件发生时,如用户点击项目,我将在同一活动中打开另一个片段.
我知道如何动态添加片段,我也知道如何动画它.
在这里,我如何frameLayout在我的活动中添加片段:
transaction.setCustomAnimations(R.animator.object_slide_in_up, R.animator.activity_hold)
transaction.add(R.id.flSellerHome, fragment)
transaction.commit()
Run Code Online (Sandbox Code Playgroud)
在模拟器和新手机中一切正常.我已经使用api 25进行了模拟器测试,它现在可以正常闪烁发生,当我用真实设备测试它时,api 23闪烁一点,所以它没有影响,之后当我用api 19测试它时,它闪烁太多了.
所以我的问题是做动画的最佳实践.
我动态添加的第三个片段包含recylerview,其中包含来自本地db的大约20个项目,我还在后台线程中完成了db fatching.
主线程没有负载.recyclerview也很简单,有一个Image和三个文本.
图像也使用Glide加载,我也有滑动的覆盖功能**
任何帮助表示赞赏..
在更新android studio 3.0.1之前一切正常,但在更新android studio之后我感到困惑
配置'compile'已经过时,已被'implementation'取代.它将在2018年底删除无法解决:滑动打开文件夹/ home/lalit/repositories/android/WaveDist/app/build/generated/source/kaptKotlin/debug文件夹/ home/lalit/repositories/android/WaveDist/app/build/generated/source/kaptKotlin/release第三方Gradle插件可能是原因
我的依赖
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.theartofdev.edmodo:android-image-cropper:2.2.+'
implementation 'com.github.wrdlbrnft:sorted-list-adapter:0.2.0.1'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.google.firebase:firebase-core:12.0.0'
implementation 'com.google.firebase:firebase-messaging:12.0.0'
implementation 'com.google.android.gms:play-services-analytics:12.0.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.android.support:support-vector-drawable:27.1.0'
implementation 'com.android.support:support-core-utils:27.1.0'
testImplementation 'junit:junit:4.12'
implementation 'android.arch.lifecycle:common-java8:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:reactivestreams:1.1.1'
implementation 'android.arch.persistence.room:runtime:1.0.0'
kapt "android.arch.persistence.room:compiler:1.0.0"
implementation 'com.google.firebase:firebase-auth:12.0.0'
implementation 'com.google.android.gms:play-services-maps:12.0.0'
implementation 'com.google.firebase:firebase-database:12.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.google.android.gms:play-services-location:12.0.0'
implementation 'com.google.android.gms:play-services-places:12.0.0'
implementation 'com.google.android.gms:play-services-base:12.0.0'
}
Run Code Online (Sandbox Code Playgroud)
应用级别gradle: …