From a9f48ad4da2a26bb2c8ee7f526e2b3f936f6dc8a Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 11 Dec 2018 13:17:01 +0100 Subject: [PATCH] Fix code review Signed-off-by: Mario Danic --- .../ConversationInfoController.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java index 493828772..8501069cf 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java @@ -20,6 +20,7 @@ package com.nextcloud.talk.controllers; +import android.app.Activity; import android.os.Bundle; import android.text.TextUtils; import android.view.LayoutInflater; @@ -161,16 +162,20 @@ public class ConversationInfoController extends BaseController { } private void setupAdapter() { - if (adapter == null && getActivity() != null) { - adapter = new FlexibleAdapter<>(recyclerViewItems, getActivity(), true); - } + Activity activity; - if (recyclerView != null && getActivity() != null) { - SmoothScrollLinearLayoutManager layoutManager = - new SmoothScrollLinearLayoutManager(getActivity()); - recyclerView.setLayoutManager(layoutManager); - recyclerView.setHasFixedSize(true); - recyclerView.setAdapter(adapter); + if ((activity = getActivity()) != null) { + if (adapter == null) { + adapter = new FlexibleAdapter<>(recyclerViewItems, activity, true); + } + + if (recyclerView != null) { + SmoothScrollLinearLayoutManager layoutManager = + new SmoothScrollLinearLayoutManager(activity); + recyclerView.setLayoutManager(layoutManager); + recyclerView.setHasFixedSize(true); + recyclerView.setAdapter(adapter); + } } }