From 720a988d954e6fd990ebe39ddc617f0bde0a8bc3 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Tue, 9 Feb 2021 11:23:05 +0500 Subject: [PATCH 1/2] Cleaned up recycler view bug in DynamicLabelAdapter --- .../com/vijay/jsonwizard/adapter/DynamicLabelAdapter.java | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapter.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapter.java index ccc4b61eb..cccc4ead2 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapter.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapter.java @@ -41,12 +41,16 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi if (StringUtils.isNotBlank(dynamicLabelTitle)) { recyclerViewHolder.tileTextView.setText(dynamicLabelTitle); recyclerViewHolder.tileTextView.setVisibility(View.VISIBLE); + } else { + recyclerViewHolder.tileTextView.setVisibility(View.GONE); } String dynamicLabelText = dynamicLabelInfoList.get(position).getDynamicLabelText(); if (StringUtils.isNotBlank(dynamicLabelText)) { recyclerViewHolder.descriptionTextView.setText(dynamicLabelText); recyclerViewHolder.descriptionTextView.setVisibility(View.VISIBLE); + } else { + recyclerViewHolder.descriptionTextView.setVisibility(View.GONE); } String dynamicLabelImageSrc = dynamicLabelInfoList.get(position).getDynamicLabelImageSrc(); @@ -56,7 +60,10 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi recyclerViewHolder.imageViewLabel.setVisibility(View.VISIBLE); } catch (IOException e) { e.printStackTrace(); + recyclerViewHolder.imageViewLabel.setVisibility(View.GONE); } + } else { + recyclerViewHolder.imageViewLabel.setVisibility(View.GONE); } } diff --git a/gradle.properties b/gradle.properties index ca772a411..c01aaa168 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.3-SNAPSHOT +VERSION_NAME=2.0.4-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard From f2a92a1453c322373d21b045b0b28c59d8c87392 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Tue, 9 Feb 2021 11:47:12 +0500 Subject: [PATCH 2/2] Added new test class for DynamicLabelAdapter --- .../adapter/DynamicLabelAdapterTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 android-json-form-wizard/src/test/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapterTest.java diff --git a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapterTest.java b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapterTest.java new file mode 100644 index 000000000..85db3ec76 --- /dev/null +++ b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/adapter/DynamicLabelAdapterTest.java @@ -0,0 +1,35 @@ +package com.vijay.jsonwizard.adapter; + +import android.support.v7.widget.RecyclerView; +import android.widget.LinearLayout; + +import com.vijay.jsonwizard.BaseTest; +import com.vijay.jsonwizard.model.DynamicLabelInfo; + +import org.junit.Before; +import org.junit.Test; +import org.robolectric.RuntimeEnvironment; + +import java.util.ArrayList; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.spy; + +public class DynamicLabelAdapterTest extends BaseTest { + + private DynamicLabelAdapter multiSelectListAdapter; + + @Before + public void setUp() { + multiSelectListAdapter = spy(new DynamicLabelAdapter(RuntimeEnvironment.application, new ArrayList())); + } + + @Test + public void testOnCreateViewHolder() { + LinearLayout linearLayout = new LinearLayout(RuntimeEnvironment.application); + RecyclerView.ViewHolder itemView = multiSelectListAdapter.onCreateViewHolder(linearLayout, 0); + assertNotNull(itemView); + assertTrue(itemView instanceof DynamicLabelAdapter.RecyclerViewHolder); + } +} \ No newline at end of file