Move possible NPE

This commit is contained in:
Stephen Paul Weber 2024-06-30 21:07:58 +02:00 committed by Arne
parent 8828cf5f5a
commit 5070d565b9

View file

@ -3131,7 +3131,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
mTitle = title;
mNode = node;
this.xmppConnectionService = xmppConnectionService;
if (mPager != null) setupLayoutManager();
if (mPager != null) setupLayoutManager(mPager.getContext());
actionsAdapter = new ActionsAdapter(xmppConnectionService);
actionsAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
@ -3210,7 +3210,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
if ("result".equals(el.getAttribute("type")) || "form".equals(el.getAttribute("type"))) {
this.responseElement = el;
setupReported(el.findChild("reported", "jabber:x:data"));
if (mBinding != null) mBinding.form.setLayoutManager(setupLayoutManager());
if (mBinding != null) mBinding.form.setLayoutManager(setupLayoutManager(mBinding.getRoot().getContext()));
}
eu.siacs.conversations.xmpp.forms.Field actionList = form.getFieldByName("http://jabber.org/protocol/commands#actions");
@ -3641,10 +3641,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} catch (final IllegalStateException e) { }
}
protected GridLayoutManager setupLayoutManager() {
protected GridLayoutManager setupLayoutManager(final Context ctx) {
int spanCount = 1;
Context ctx = mPager == null ? getView().getContext() : mPager.getContext();
if (reported != null) {
float screenWidth = ctx.getResources().getDisplayMetrics().widthPixels;
TextPaint paint = ((TextView) LayoutInflater.from(mPager.getContext()).inflate(R.layout.command_result_cell, null)).getPaint();
@ -3708,7 +3707,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) { }
});
mBinding.form.setLayoutManager(setupLayoutManager());
mBinding.form.setLayoutManager(setupLayoutManager(mBinding.getRoot().getContext()));
mBinding.form.setAdapter(this);
mBinding.actions.setAdapter(actionsAdapter);
mBinding.actions.setOnItemClickListener((parent, v, pos, id) -> {
@ -3820,7 +3819,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
this.responseElement = form;
setupReported(form.findChild("reported", "jabber:x:data"));
if (mBinding != null) mBinding.form.setLayoutManager(setupLayoutManager());
if (mBinding != null) mBinding.form.setLayoutManager(setupLayoutManager(mBinding.getRoot().getContext()));
if (actionsAdapter.countExceptCancel() < 1) {
actionsAdapter.add(Pair.create("save", "Save"));