@Test public void shouldShowCompletedInventory() { RnRFormViewModel viewModel = new RnRFormViewModel(new Period(new DateTime()), "MMIA", RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED); viewHolder = getViewHolderByType(RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED); viewHolder.populate(viewModel); assertThat(viewHolder.tvPeriod.getText().toString(), is(viewModel.getTitle())); assertThat(viewHolder.tvMessage.getText().toString(), is(getStringResource(R.string.label_completed_mmia_physical_inventory_message, viewModel.getName()))); assertThat(((ColorDrawable) viewHolder.tvPeriod.getBackground()).getColor(), is(getColorResource(R.color.color_draft_title))); assertThat(viewHolder.btnView.getText().toString(), is(getStringResource(R.string.btn_view_completed_physical_inventory, viewModel.getName()))); assertThat(viewHolder.ivDelete.getVisibility(), is(View.GONE)); }
@SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } RnRFormViewHolder(View inflate, RnRFormItemClickListener itemClickListener); }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } RnRFormViewHolder(View inflate, RnRFormItemClickListener itemClickListener); @SuppressLint("StringFormatMatches") void populate(final RnRFormViewModel model); }
RnRFormViewHolder extends BaseViewHolder { @SuppressLint("StringFormatMatches") public void populate(final RnRFormViewModel model) { switch (model.getType()) { case RnRFormViewModel.TYPE_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_previous_period_missing)), R.drawable.ic_description, R.color.color_draft_title, color_white); break; case RnRFormViewModel.TYPE_FIRST_MISSED_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_missed_period)), R.drawable.ic_description, R.color.color_select_title, color_white); setupButton(model, context.getString(R.string.btn_select_close_period)); setupButtonColor(); break; case RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY: showCannotDoMonthlyInventory(model); break; case RnRFormViewModel.TYPE_UNCOMPLETE_INVENTORY_IN_CURRENT_PERIOD: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_uncompleted_physical_inventory_message, model.getName(), model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_uncompleted_physical_inventory)); break; case RnRFormViewModel.TYPE_INVENTORY_DONE: case RnRFormViewModel.TYPE_CLOSE_OF_PERIOD_SELECTED: populateRnrFormNotBeCreatedView(model); break; case RnRFormViewModel.TYPE_CREATED_BUT_UNCOMPLETED: configHolder(model.getTitle(), Html.fromHtml(context.getString(R.string.label_incomplete_requisition, model.getName())), R.drawable.ic_description, R.color.color_draft_title, color_white); setupButton(model, context.getString(R.string.btn_view_incomplete_requisition, model.getName())); break; case RnRFormViewModel.TYPE_UNSYNCED_HISTORICAL: populateRnrFormUnsyncedMessage(model); break; case RnRFormViewModel.TYPE_SYNCED_HISTORICAL: populateSyncedHistorical(model); break; case RnRFormViewModel.TYPE_INACTIVE: populateRnrFormInActiveCreatedView(model); break; } } RnRFormViewHolder(View inflate, RnRFormItemClickListener itemClickListener); @SuppressLint("StringFormatMatches") void populate(final RnRFormViewModel model);  }