Я создал ListView, который покажет мои дочерние базы данных. Если я щелкну по нему, у меня будет AlertDialog, который спросит, хочу ли я удалить изображение.
После того, как я удалю изображение, я попытаюсь go к действию, которое показывает ListView, с которым происходит сбой журнал:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.alphaver, PID: 5739
java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:496)
at android.net.Uri$StringUri.<init>(Uri.java:486)
at android.net.Uri.parse(Uri.java:458)
at com.example.alphaver.ImagesActivity$1.populateView(ImagesActivity.java:61)
at com.firebase.ui.database.FirebaseListAdapter.getView(FirebaseListAdapter.java:121)
at android.widget.AbsListView.obtainView(AbsListView.java:2405)
at android.widget.ListView.makeAndAddView(ListView.java:2071)
at android.widget.ListView.fillDown(ListView.java:797)
at android.widget.ListView.fillFromTop(ListView.java:859)
at android.widget.ListView.layoutChildren(ListView.java:1814)
at android.widget.AbsListView.onLayout(AbsListView.java:2202)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:446)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:779)
at android.view.View.layout(View.java:21912)
at android.view.ViewGroup.layout(ViewGroup.java:6260)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3080)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Это мой код ListView, который вызывает крэ sh, но я не знаю почему:
lv = (ListView)findViewById(R.id.lv);
Query query = FirebaseDatabase.getInstance().getReference().child("Uploads");
FirebaseListOptions<Upload> options = new FirebaseListOptions.Builder<Upload>()
.setLayout(R.layout.information)
.setLifecycleOwner(ImagesActivity.this)
.setQuery(query, Upload.class)
.build();
adapter = new FirebaseListAdapter(options) {
@Override
protected void populateView(@NonNull View v, @NonNull Object model, int position) {
TextView name = v.findViewById(R.id.name_tv);
ImageView imageView = v.findViewById(R.id.imageViewTV);
Upload std = (Upload) model;
name.setText(std.getName());
if(Uri.parse(std.getmImageUrl()) != null){
Picasso.get().load(Uri.parse(std.getmImageUrl())).into(imageView);
}
}
};
Я ищу, чтобы решить проблему и сделать ListView ничего не показывает, когда не отображается значение mImageUrl.