Firebase无法正常运行

时间:2018-08-01 11:13:55

标签: android firebase firebase-realtime-database picasso firebaseui

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

如果我的手机是英语手机,则该应用程序可以正常工作,但是当它变成土耳其语时,Piccasso无法加载图片。请帮我一个多星期都找不到解决方案 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);
    }

视图架

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

我找到了解决方案。我更改了类别模型和firabse json文件。也许在类别模型“名称”和“İmage”中,更改了电话语言后翻译为土耳其语。

您的模型应该是相同的firebase json文件。我更改了模型和杰森文件,然后应用程序正常运行。

Json文件

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

类别模型

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 个答案:

答案 0 :(得分:0)

我找到了解决方案。我更改了类别模型和firabse json文件。也许在类别模型“名称”和“İmage”中,更改了电话语言后翻译为土耳其语。