Firebase does not work properly

2019-02-21 01:36发布

问题:

I have an online quiz app in Firebase.

If my phone is in English, the app works fine, but when it change into Turkish, Piccaso does not load image.Please help me I can not find a solution for over a week In this case my phone is in English

In this cas my phone is in Turkish

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());
                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);
    }

View Holder

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;
    }

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

Catgeory Model.java

    public class Category {
    private String Name;
    private String Image;
    private String Button;

    public Category() {
    }

    public Category(String name, String image, String button) {
        this.Name = name;
        this.Image = image;
        this.Button = button;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getImage() {
        return Image;
    }

    public void setImage(String image) {
        Image = image;
    }

    public String getButton() {
        return Button;
    }

    public void setButton(String button) {
        Button = button;
    }
}

I find solution.I changed catgegory model and firabse json file.Maybe in category model Name And İmage translated into Turkish when changed phone language.

you model should be the same firebase json file. I changed model and jason file then app works fine.

Json File

"Category" : {
    "01" : {
      "ad" : "Azərbaycan",
      "sekil" : "https://avatanplus.com/files/resources/mid/5969ff2ae80a415d460cbfc6.jpg"
    },
    "02" : {
      "ad" : "Türkiyə",
      "sekil" : "https://img00.deviantart.net/6f00/i/2012/238/9/0/turkey_flag_grunge_hd_2_0_by_syndikata_np-d5che5q.jpg"
    },
    "03" : {
      "ad" : "Viner",
      "sekil" : "https://img.milli.az/2017/12/08/606172.jpg"
    }

Category Model

public class Category {
    private String ad;
    private String sekil;
    private String Button;

    public Category() {
    }

    public Category(String ad, String sekil, String button) {
        this.ad = ad;
        this.sekil = sekil;
        Button = button;
    }

    public String getAd() {
        return ad;
    }

    public void setAd(String ad) {
        this.ad = ad;
    }

    public String getSekil() {
        return sekil;
    }

    public void setSekil(String sekil) {
        this.sekil = sekil;
    }



    public String getButton() {
        return Button;
    }

    public void setButton(String button) {
        Button = button;
    }
}

回答1:

I find solution.I changed catgegory model and firabse json file.Maybe in category model Name And İmage translated into Turkish when changed phone language.