使用毕加索从Firebase提取图像问题 [英] Fetching Image Issue from firebase using Picasso

查看:49
本文介绍了使用毕加索从Firebase提取图像问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从数据库中提取了文本feteching,在使用毕加索从数据库中获取图像时,buit图像未加载手机,并且logcat显示错误:

I have done with the text feteching from the database, buit while fetching image from the database using picasso the images are not loading the phone and the logcat is displaying the error :

com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.

textviews很容易从firebase获取.但是在ImageView的情况下,无法正确加载.

The textviews are easily getting fetching from the firebase. But in case of ImageView its not loading properly.

QuoteList.java

public class QuoteList extends AppCompatActivity {

    private StorageReference storageRef;

    RecyclerView  mRecyclerView;
    FirebaseDatabase mFirebaseDatabase;
    DatabaseReference mReference;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_quote_list);

        //ActionBar actionBar = getSupportActionBar();
        //getSupportActionBar().setTitle("Quotes");
        //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        //getSupportActionBar().setHomeButtonEnabled(true);

        final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView = findViewById(R.id.quotes_list);
        mRecyclerView.setLayoutManager(layoutManager);


        mFirebaseDatabase = FirebaseDatabase.getInstance();
        mReference = mFirebaseDatabase.getReference("Quotes");
    }





    @Override
    protected void onStart() {
        super.onStart();

        FirebaseRecyclerAdapter<Quote, QuoteViewHolder> firebaseRecyclerAdapter =
                new FirebaseRecyclerAdapter<Quote, QuoteViewHolder>(
                        Quote.class,
                        R.layout.quote_row,
                        QuoteViewHolder.class,
                        mReference
                ) {

                    @Override
                    protected void populateViewHolder(QuoteViewHolder viewHolder , Quote model , int position) {

                     //   viewHolder.setDetails(getApplicationContext(), model.getQuotes(), model.getQuote_Author(), model.getImages());
                            viewHolder.setQuotes(model.getQuotes());
                            viewHolder.setQuoteAuthor(model.getQuote_Author());
                            viewHolder.setImage(getApplicationContext(),model.getImages());


                    }
                };

        mRecyclerView.setAdapter(firebaseRecyclerAdapter);

    }

    public static class QuoteViewHolder extends RecyclerView.ViewHolder{

        View mView;

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

            mView = itemView;
        }

        public void setQuotes(String Quote){
            TextView post_quote = (TextView) mView.findViewById(R.id.post_quote);
            post_quote.setText(Quote);
        }

        public void setQuoteAuthor(String QuoteAuthor){
            TextView post_quoteAuthor = (TextView) mView.findViewById(R.id.post_author);
            post_quoteAuthor.setText(QuoteAuthor);
        }

        public void setImage(Context ctx, String image){
            ImageView post_image = (ImageView) mView.findViewById(R.id.post_image);
            Picasso.get().load(image).into(post_image);

        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        getMenuInflater().inflate(R.menu.main_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }
}

我还附上了logcat错误报告.请仔细检查.

I am also attaching the logcat error report. Please go through it.

    11-04 16:16:37.413 6688-7596/com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
11-04 16:16:39.547 6688-7596/com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
11-04 16:16:40.567 6688-7596/com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
11-04 16:16:41.948 6688-7596/com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
11-04 16:16:44.661 6688-7596/com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
11-04 16:16:48.528 6688-7603/com.example.lenovo.skanda E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
11-04 16:24:46.716 6688-6698/com.example.lenovo.skanda E/System: Uncaught exception thrown by finalizer
11-04 16:24:46.717 6688-6698/com.example.lenovo.skanda E/System: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.org.conscrypt.SslWrapper.isClosed()' on a null object reference
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.free(ConscryptFileDescriptorSocket.java:986)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.finalize(ConscryptFileDescriptorSocket.java:1014)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:252)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:239)
        at java.lang.Daemons$Daemon.run(Daemons.java:105)
        at java.lang.Thread.run(Thread.java:764)
    Uncaught exception thrown by finalizer
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.org.conscrypt.SslWrapper.isClosed()' on a null object reference
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.free(ConscryptFileDescriptorSocket.java:986)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.finalize(ConscryptFileDescriptorSocket.java:1014)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:252)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:239)
        at java.lang.Daemons$Daemon.run(Daemons.java:105)
        at java.lang.Thread.run(Thread.java:764)
    Uncaught exception thrown by finalizer
11-04 16:24:46.718 6688-6698/com.example.lenovo.skanda E/System: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.org.conscrypt.SslWrapper.isClosed()' on a null object reference
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.free(ConscryptFileDescriptorSocket.java:986)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.finalize(ConscryptFileDescriptorSocket.java:1014)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:252)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:239)
        at java.lang.Daemons$Daemon.run(Daemons.java:105)
        at java.lang.Thread.run(Thread.java:764)
    Uncaught exception thrown by finalizer
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.org.conscrypt.SslWrapper.isClosed()' on a null object reference
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.free(ConscryptFileDescriptorSocket.java:986)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.finalize(ConscryptFileDescriptorSocket.java:1014)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:252)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:239)
        at java.lang.Daemons$Daemon.run(Daemons.java:105)
        at java.lang.Thread.run(Thread.java:764)

请帮帮我.先感谢您.

Please help me out. Thank you in advance.

推荐答案

出现以下错误:

java.util.concurrent.ExecutionException:com.google.firebase.internal.api.FirebaseNoSignedInUserException:请先登录,然后再尝试获取令牌.

java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.

由于默认情况下,您的安全规则要求对用户进行身份验证.

Because by default, your are security rules require your user to be authenticated.

allow read, write: if request.auth != null;

要解决此问题,您可以在尝试播放图像之前先确保您的用户已通过身份验证,或将安全规则更改为:

To solve this, you can either make sure your user is authenticated before trying to diplay the image or change the security rules to:

allow read, write;

但是我建议您仅将这些规则用于测试目的.不要一直保持这样的规则.保护您的Firebase实时数据库以及Firebase存储.

But I recommend you to use these rules only for testing purposes. Don't keep this rules always like this. Secure your Firebase realtime database, as well as Firebase Storage.

这篇关于使用毕加索从Firebase提取图像问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆