From c26603e0ca094aae4518ecb5cea8380154bb6b96 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sun, 17 Sep 2023 10:49:13 +0300 Subject: [PATCH] Crash fixes --- .../ComposeAutocompleteViewController.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java index 1f8dacef1..922cc2a8d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java @@ -96,6 +96,24 @@ public class ComposeAutocompleteViewController{ outRect.right=V.dp(8); } }); + // Set empty adapter to prevent NPEs + list.setAdapter(new RecyclerView.Adapter<>(){ + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ + throw new UnsupportedOperationException(); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position){ + + } + + @Override + public int getItemCount(){ + return 0; + } + }); contentView.addView(list, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); emptyButton=new FilterChipView(activity); @@ -227,6 +245,8 @@ public class ComposeAutocompleteViewController{ @Override public void onSuccess(SearchResults result){ currentRequest=null; + if(mode!=Mode.USERS) + return; List oldList=users; users=result.accounts.stream().map(a->new AccountViewModel(a, accountID)).collect(Collectors.toList()); if(isLoading){