使用毕加索从Firebase获取图像

时间:2018-11-04 10:09:49

标签: java android firebase firebase-storage picasso

我已经用完数据库中的feteching文本,当使用毕加索从数据库中获取图像时,buit图像未加载电话,并且logcat显示错误:

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,则无法正确加载。

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错误报告。请仔细检查。

    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)

请帮帮我。先感谢您。

0 个答案:

没有答案