小编Art*_*RiT的帖子

RecyclerView快速滚动后显示错误图像

在我的应用程序中,我正在使用RecyclerView.Adapter自定义Holder类。每个项目都由几个TextView和一个ImageView(图标)组成。问题是RecyclerView快速滚动后显示错误的图像。

例:

真相

不真实

因此,我的持有人是:

public class CafeHolder extends RecyclerView.ViewHolder implements OnClickListener {
TextView itemName, itemType, itemMarksCount, itemCommentsCount, itemRating;
ImageView imgCafe;
ImageLoader imgLoader;
private Context context;
private int cafeId;

public CafeHolder(View view, Context context){
    super(view);
    this.context = context;
    itemName = (TextView) view.findViewById(R.id.tvCafeName);
    imgCafe = (ImageView) view.findViewById(R.id.imgCafe);
    itemType = (TextView) view.findViewById(R.id.tvCafeType);
    itemMarksCount = (TextView) view.findViewById(R.id.tvMarksCount);
    itemCommentsCount = (TextView) view.findViewById(R.id.tvCommentsCount);
    itemRating = (TextView) view.findViewById(R.id.tvRatingCount);
    imgLoader = new ImageLoader(context);
    view.setOnClickListener(this);
}

@Override
public …
Run Code Online (Sandbox Code Playgroud)

android imageview android-recyclerview

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

拦截刷新令牌 GRPC 的调用

我在项目中使用带有 proto 的 GRPC,并且有 KEY 和 AUTHORITY 令牌来访问服务器 API。所以,我需要使用我的权限更新密钥。我正在像这样建立频道:

OkHttpChannelBuilder.forAddress(host, port)
        .usePlaintext()
        .intercept(auth, logger)
        .build()
Run Code Online (Sandbox Code Playgroud)

我的拦截器看起来像:

class AuthClientInterceptor(
    private val prefs: Preferences,
    private val keyApi: KeyApi) : ClientInterceptor {

    companion object {
        private const val ACCESS_TOKEN = "authorization"
    }

    override fun <ReqT : Any?, RespT : Any?> interceptCall(method: MethodDescriptor<ReqT, RespT>?,
                                                       callOptions: CallOptions?,
                                                       next: Channel): ClientCall<ReqT, RespT> {

        val call = next.newCall(method, callOptions)

        val callForwarding = object : ClientInterceptors.CheckedForwardingClientCall<ReqT, RespT>(call) {
            override fun checkedStart(responseListener: Listener<RespT>?, headers: Metadata) {

            synchronized(this@AuthClientInterceptor) {
                val …
Run Code Online (Sandbox Code Playgroud)

android interceptor kotlin grpc

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