FirebaseDatabase Piccasso无法正常工作

时间:2018-07-31 19:28:02

标签: android firebase firebase-realtime-database firebaseui

我在Firebase中有一个在线测验应用程序。

如果我的手机是英语手机,则该应用程序可以正常工作,但是当将其更改为土耳其语时,Piccaso无法加载图片,并且该应用程序会崩溃。

private void loadCategories() {
        adapter = new FirebaseRecyclerAdapter<Category, CategoryViewHolder>(Category.class,
                R.layout.category_layout,
                CategoryViewHolder.class,
                categories) {
            @Override
            protected void populateViewHolder(CategoryViewHolder viewHolder, final Category model, int position) {
                viewHolder.category_name.setText(model.getName());
                viewHolder.setImage(model.getImage());
                //Picasso.get().load(model.getImage()).into(viewHolder.category_image);
                viewHolder.setItemClickListener(new ItemClickListener() {
                    @Override
                    public void onClick(View view, final int position, boolean isLongClick) {
                        {
                            Intent play = new Intent(getActivity(), StartActivity.class);
                            Common.categoryId = adapter.getRef(position).getKey();
                            Common.categoryName = model.getName();
                            startActivity(play);
                        }
                    }
                });
            }
        };
        adapter.notifyDataSetChanged();
        listCategory.setAdapter(adapter);
    }

ViewHolder

public class CategoryViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

    View mV;

    public TextView category_name;
    public ImageView category_image,gradient2;
    public Button btnPlay;

    private ItemClickListener itemClickListener;

    public CategoryViewHolder(View itemView) {
        super(itemView);

        mV = itemView;

        category_image = (ImageView)itemView.findViewById(R.id.category_image);
        category_name = (TextView)itemView.findViewById(R.id.category_name);
        gradient2 = (ImageView)itemView.findViewById(R.id.gradient2);
        btnPlay = (Button)itemView.findViewById(R.id.btn_play);
        btnPlay.setTag(R.id.btn_play,itemView);
        btnPlay.setOnClickListener(this);
        itemView.setOnClickListener(this);
    }

    public void setItemClickListener(ItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }
    public void setImage(String image){
        ImageView category_image = (ImageView)mV.findViewById(R.id.category_image);
        Picasso.get().load(image).into(category_image);
    }

    @Override
    public void onClick(View v) {
        itemClickListener.onClick(v,getAdapterPosition(),false);
    }
}

0 个答案:

没有答案