小编Leo*_*ela的帖子

样式化 OssLicensesMenuActivity

我使用的是谷歌库调用播放服务,插件,以包括开源通知我的应用程序。

我可以毫无问题地实施它,但我不知道如何设计显示许可证的活动。

在我的代码中,我通过调用开始活动 startActivity(Intent(this, OssLicensesMenuActivity::class.java))

由于OssLicensesMenuActivity是一个 Activity 类,我设法设置如下样式:


styles.xml:

<style name="LicensesTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimaryDark</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)


AndroidManifest.xml:

<activity
    android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
    android:theme="@style/LicensesTheme" />
Run Code Online (Sandbox Code Playgroud)


这就像一个魅力,但此活动仅显示我正在使用的所有库。还有第二个活动显示许可证,这是我无法弄清楚如何设计样式的活动。我面临的问题是代码OssLicensesMenuActivity被混淆了,我找不到我想要设置样式的活动类的名称和包。

有谁知道我该如何解决这个问题?

为了更容易检查,混淆的代码OssLicensesMenuActivity如下:

package com.google.android.gms.oss.licenses;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.content.res.Resources.NotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AppCompatActivity;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader;
import …
Run Code Online (Sandbox Code Playgroud)

android android-theme google-play-services android-studio android-styles

7
推荐指数
1
解决办法
939
查看次数

葡萄牙语(巴西)的区域设置错误

我正在尝试获取葡萄牙语(巴西)的系统区域设置,但它给出的小数分隔符为.而不是,任何人都可以帮忙吗?我正在使用 Java 8。

下面是我正在使用的代码:

public static void main(String[] args) 
{
    final Locale locale = new Locale(System.getProperty("user.country.format"));
    
    final NumberFormat nf = NumberFormat.getNumberInstance(locale);
     
    DecimalFormatSymbols decSymbols = new DecimalFormatSymbols(locale);
    System.out.println("Decimal Symbol"+ decSymbols.getDecimalSeparator() + "");
}
Run Code Online (Sandbox Code Playgroud)

获取小数点分隔符而.不是,.

java decimalformat

6
推荐指数
1
解决办法
3212
查看次数

Room - 不确定如何将 Cursor 转换为该方法的返回类型 (java.lang.Object)

我正在使用 Room 创建一个项目,并且有以下代码:

对于我的实体类:

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity("matches")
data class MatchEntity(
    @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") val id: Int,
    @ColumnInfo(name = "name") val name: String,
    @ColumnInfo(name = "city") val city: String,
    @ColumnInfo(name = "distance") val distance: Int,
    @ColumnInfo(name = "description") val description: String,
    @ColumnInfo(name = "score") val score: Int,
    @ColumnInfo(name = "age") val age: Int,
    @ColumnInfo(name = "body_type") val bodyType: BodyType,
    @ColumnInfo(name = "height") val height: Float,
    @ColumnInfo(name = "diet") val diet: DietType,
    @ColumnInfo(name = "zodiac_sign") …
Run Code Online (Sandbox Code Playgroud)

sqlite android kotlin android-room

6
推荐指数
1
解决办法
2095
查看次数

Kotlin - 无法创建两个具有不同列表类型参数的构造函数

我试图创建以下类:

class MyClass {

    var foos: List<Foo> = listOf()

    constructor(foos: List<Foo>) {
        this.foos = foos
    }

    constructor(bars: List<Bar>) : super() {
        this.foos = bars.map { bar ->
            Foo(bar)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)


但是,我收到一条错误消息:

平台声明冲突:以下声明具有相同的 JVM 签名( (Ljava/util/List;)V):


我知道它们都是 List 对象,但它们是用泛型键入的,所以我确信这不会有问题。

java generics jvm kotlin

5
推荐指数
1
解决办法
686
查看次数

Kotlin - 仅替换字符串中最后给定的字符串

我想用另一个字符串替换字符串,但只替换最后找到的字符串。例如:

"ONE, TWO, THREE, FOUR".replaceLast(",", " &") // Outputs: "ONE, TWO, THREE & FOUR"
Run Code Online (Sandbox Code Playgroud)

java kotlin

4
推荐指数
1
解决办法
166
查看次数

Retrofit2 - 如何仅缓存某些 API 调用

我只想缓存某些呼叫而不是全部。这是我现在拥有的代码,但它将影响所有改造调用:

int cacheSize = 10 * 1024 * 1024; // 10 MB  
Cache cache = new Cache(getCacheDir(), cacheSize);

OkHttpClient okHttpClient = new OkHttpClient.Builder()
    .cache(cache)
    .build();

Retrofit.Builder builder = new Retrofit.Builder()  
    .baseUrl("http://10.0.2.2:3000/")
    .client(okHttpClient)
    .addConverterFactory(GsonConverterFactory.create());

Retrofit retrofit = builder.build(); 
Run Code Online (Sandbox Code Playgroud)

当我只想为该调用进行缓存时,是否可以在标头中放入一些内容?

例如:

// 我想我足以在标题中添加一些内容。我只想缓存客户端(android)端的调用。所以我想改造可以记住响应并缓存它以供下一次调用,但我不希望它用于我的所有调用,只需要我想要的那些,也许1或2。其余的可以一直连接到服务器。这是如何实现的?

@Headers("Cache-Control:????XXXXX) //is it possible this way ?, how ?
@GET("getBusiness.action")// Store information 
Call<RestaurantInfoModel> getRestaurantInfo(@Query("userId") String userId,@Query("businessId") String businessId);
Run Code Online (Sandbox Code Playgroud)

更新

这是我现在尝试过的:

这是我构建 okhttpclient 的方法:

final OkHttpClient.Builder builder = new OkHttpClient.Builder();
int cacheSize = 10 * 1024 * 1024; // …
Run Code Online (Sandbox Code Playgroud)

android caching http-headers retrofit2

3
推荐指数
1
解决办法
8370
查看次数