gpt4 book ai didi

java - 用 Glide 加载图像很慢

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:01:48 24 4
gpt4 key购买 nike

我有应用程序与服务器连接,当图片加载时看起来很慢,当上下滚动时似乎滑动想要再次阅读图像!这是我的 Glide 适配器:

数据适配器:

public class DataAdapter extends RecyclerView.Adapter<DataAdapter.ViewHolder> {
private Context context;
private ArrayList<AndroidVersion> android;


public DataAdapter(Context context,ArrayList<AndroidVersion> android) {
this.context = context;
this.android = android;
}


@Override
public DataAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_row, viewGroup, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(DataAdapter.ViewHolder viewHolder, int i) {

viewHolder.tv_name.setText(android.get(i).getName());
viewHolder.tv_version.setText(android.get(i).getVer());
viewHolder.tv_api_level.setText(android.get(i).getApi());

// load image into imageview using glide
Glide.with(context).load("http://memaraneha.ir/Erfan/images/"+android.get(i).getPic())
.placeholder(R.drawable.truiton)
.error(R.drawable.truiton)
.into(viewHolder.tv_image);
}

@Override
public int getItemCount() {
return android.size();
}

public class ViewHolder extends RecyclerView.ViewHolder{
private TextView tv_name,tv_version,tv_api_level;
public ImageView tv_image;
public ViewHolder(View view) {
super(view);

tv_name = (TextView)view.findViewById(R.id.tv_name);
tv_version = (TextView)view.findViewById(R.id.tv_version);
tv_api_level = (TextView)view.findViewById(R.id.tv_api_level);
tv_image= (ImageView) view.findViewById(R.id.img);

}
}

}

如果有人可以提供帮助,请提供帮助!

最佳答案

我使用了 dontTransform() 方法,它几乎节省了我一秒钟。图像首先加载到列表中。

关于java - 用 Glide 加载图像很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39674227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com