我在新游戏中实现了Facebook登录,可以挑战朋友。
除了任何可靠的上传用户个人资料图像的方法都很慢之外,一切都可以完美地工作。
我尝试了不同的方法,但最后我离开了受信任的毕加索,但问题仍然存在。
我注意到该问题与以下事实完全相关:我通过了图像链接的“图形”,该图像在加载时比常规图像链接花费了我更多的时间。
也许问题可能也与适配器的类型有关,我使用BaseAdapter加载了朋友列表或分数列表:
public class ScoreAdapter extends BaseAdapter {
private Context context;
private ArrayList<Punteggio> ListPunteggi;
int count;
View row = null;
ScoreAdapter adapter = this;
// Constructor de dos par?metros
public ScoreAdapter(Context context, ArrayList<Punteggio> ListPunteggi) {
super();
this.context = context;
this.ListPunteggi = ListPunteggi;
}
// Obetenemos la cantidad de im?genes
@Override
public int getCount() {
return ListPunteggi.size();
}
// Obtenemos el objeto a partir de su posici?n
@Override
public Object getItem(int position) {
return ListPunteggi.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
// Generamos la vista
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final GridHolder holder;
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = layoutInflater.inflate(R.layout.item_score, parent, false);
holder = new GridHolder(row);
holder.link_img = (ImageView) row.findViewById(R.id.link_img);
holder.nickname = (TextView) row.findViewById(R.id.nickname);
holder.posizione = (TextView) row.findViewById(R.id.posizione);
holder.punti = (TextView) row.findViewById(R.id.punti);
holder.livello = (TextView) row.findViewById(R.id.livello);
holder.nickname.setTypeface(null, Typeface.BOLD);
holder.nickname.setTextColor(Color.BLACK);
holder.nickname.setShadowLayer(20, 0, 0, Color.WHITE);
holder.nickname.setPadding(0,10,0,0);
holder.posizione.setTypeface(null, Typeface.BOLD);
holder.posizione.setTextColor(Color.BLACK);
holder.posizione.setShadowLayer(20, 0, 0, Color.WHITE);
holder.posizione.setPadding(0,10,0,0);
holder.punti.setTypeface(null, Typeface.BOLD);
holder.punti.setTextColor(Color.BLACK);
holder.punti.setShadowLayer(20, 0, 0, Color.WHITE);
holder.punti.setPadding(0,10,0,0);
holder.livello.setTypeface(null, Typeface.BOLD);
holder.livello.setTextColor(Color.BLACK);
holder.livello.setShadowLayer(20, 0, 0, Color.WHITE);
holder.livello.setPadding(0,10,0,0);
row.setTag(holder);
} else {
row = convertView;
holder = (GridHolder) row.getTag();
holder.progressBar = (ProgressBar) row
.findViewById(R.id.progressBar1);
holder.progressBar.setVisibility(View.VISIBLE);
}
adapter.notifyDataSetChanged();
// Setto le TextView
holder.nickname.setText((ListPunteggi.get(position).getNome()));
holder.livello.setText("Livello :"+ListPunteggi.get(position).getLivello());
holder.posizione.setText(ListPunteggi.get(position).getPosizione());
holder.punti.setText(ListPunteggi.get(position).getPunti()+" punti");
Picasso.with(context)
.load((ListPunteggi.get(position).getUrl()))
.placeholder(R.drawable.user)
.error(R.drawable.user)
.centerCrop()
// .fit()
.resize(150, 150)
.noFade()
.transform(new CircleTransform())
.into(holder.link_img, new Home.ImageLoadedCallback(holder.progressBar) {
@Override
public void onSuccess() {
if (this.progressBar != null) {
this.progressBar.setVisibility(View.GONE);
}
}
});
return row;
}
private class GridHolder {
public TextView punti;
public TextView posizione;
public TextView livello;
public ImageView link_img;
public TextView nickname;
public ProgressBar progressBar;
public GridHolder(View itemView) {
link_img = (ImageView) itemView.findViewById(R.id.link_img);
// link_img = (ImageView) itemView.findViewById(R.id.link_img);
nickname = (TextView) itemView.findViewById(R.id.nickname);
posizione = (TextView) itemView.findViewById(R.id.posizione);
punti = (TextView) itemView.findViewById(R.id.punti);
livello = (TextView) itemView.findViewById(R.id.livello);
progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar1);
}
}
@Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
class ImageLoadedCallback implements Callback {
ProgressBar progressBar;
public ImageLoadedCallback(ProgressBar progBar) {
progressBar = progBar;
}
@Override
public void onSuccess() {
}
@Override
public void onError() {
}
}
}