Skip to content

Commit

Permalink
Merge pull request #551 from OpenSRP/images-and-text-label-view
Browse files Browse the repository at this point in the history
Cleaned up recycler view bug in DynamicLabelAdapter
  • Loading branch information
qaziabubakar-vd authored Feb 9, 2021
2 parents 65472f8 + f7c0ada commit 52ce126
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<DynamicLabelInfo>()));
}

@Test
public void testOnCreateViewHolder() {
LinearLayout linearLayout = new LinearLayout(RuntimeEnvironment.application);
RecyclerView.ViewHolder itemView = multiSelectListAdapter.onCreateViewHolder(linearLayout, 0);
assertNotNull(itemView);
assertTrue(itemView instanceof DynamicLabelAdapter.RecyclerViewHolder);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 52ce126

Please sign in to comment.