@Test public void shouldDisplayYellowIconAndTimeUnitIsDay() throws Exception { when(sharedPreferenceMgr.getRnrLastSyncTime()).thenReturn(nowDateTime.minusDays(1).getMillis()); when(sharedPreferenceMgr.getStockLastSyncTime()).thenReturn(nowDateTime.minusDays(2).getMillis()); syncTimeView.showLastSyncTime(); assertThat(sharedPreferenceMgr.getStockLastSyncTime(), is(nowDateTime.minusDays(2).getMillis())); assertThat(sharedPreferenceMgr.getRnrLastSyncTime(), is(nowDateTime.minusDays(1).getMillis())); assertThat(syncTimeView.txSyncTime.getText().toString(), is("1 day since last sync")); assertThat(shadowOf(syncTimeView.ivSyncTimeIcon.getDrawable()).getCreatedFromResId(), is(R.drawable.icon_circle_yellow)); }
public void showLastSyncTime() { hideSyncProgressBarAndShowIcon(); rnrLastSyncTime = sharedPreferenceMgr.getRnrLastSyncTime(); stockLastSyncTime = sharedPreferenceMgr.getStockLastSyncTime(); if (isNeverSyncSuccessful()) { if (hasSyncFailed()) { txSyncTime.setText(LMISApp.getContext().getString(R.string.initial_sync_failed)); } return; } txSyncTime.setText(updateSyncTimeViewUI()); if (sharedPreferenceMgr.isStockCardLastYearSyncError()) { setSyncStockCardLastYearError(); } }
SyncTimeView extends LinearLayout implements View.OnClickListener { public void showLastSyncTime() { hideSyncProgressBarAndShowIcon(); rnrLastSyncTime = sharedPreferenceMgr.getRnrLastSyncTime(); stockLastSyncTime = sharedPreferenceMgr.getStockLastSyncTime(); if (isNeverSyncSuccessful()) { if (hasSyncFailed()) { txSyncTime.setText(LMISApp.getContext().getString(R.string.initial_sync_failed)); } return; } txSyncTime.setText(updateSyncTimeViewUI()); if (sharedPreferenceMgr.isStockCardLastYearSyncError()) { setSyncStockCardLastYearError(); } } }
SyncTimeView extends LinearLayout implements View.OnClickListener { public void showLastSyncTime() { hideSyncProgressBarAndShowIcon(); rnrLastSyncTime = sharedPreferenceMgr.getRnrLastSyncTime(); stockLastSyncTime = sharedPreferenceMgr.getStockLastSyncTime(); if (isNeverSyncSuccessful()) { if (hasSyncFailed()) { txSyncTime.setText(LMISApp.getContext().getString(R.string.initial_sync_failed)); } return; } txSyncTime.setText(updateSyncTimeViewUI()); if (sharedPreferenceMgr.isStockCardLastYearSyncError()) { setSyncStockCardLastYearError(); } } SyncTimeView(Context context);  SyncTimeView(Context context, AttributeSet attrs); }
SyncTimeView extends LinearLayout implements View.OnClickListener { public void showLastSyncTime() { hideSyncProgressBarAndShowIcon(); rnrLastSyncTime = sharedPreferenceMgr.getRnrLastSyncTime(); stockLastSyncTime = sharedPreferenceMgr.getStockLastSyncTime(); if (isNeverSyncSuccessful()) { if (hasSyncFailed()) { txSyncTime.setText(LMISApp.getContext().getString(R.string.initial_sync_failed)); } return; } txSyncTime.setText(updateSyncTimeViewUI()); if (sharedPreferenceMgr.isStockCardLastYearSyncError()) { setSyncStockCardLastYearError(); } } SyncTimeView(Context context);  SyncTimeView(Context context, AttributeSet attrs); void showLastSyncTime(); @Override void onClick(View v); void showSyncProgressBarAndHideIcon(); void setSyncStockCardLastYearText(); void setSyncStockCardLastYearError(); void setSyncedMovementError(String error); }
SyncTimeView extends LinearLayout implements View.OnClickListener { public void showLastSyncTime() { hideSyncProgressBarAndShowIcon(); rnrLastSyncTime = sharedPreferenceMgr.getRnrLastSyncTime(); stockLastSyncTime = sharedPreferenceMgr.getStockLastSyncTime(); if (isNeverSyncSuccessful()) { if (hasSyncFailed()) { txSyncTime.setText(LMISApp.getContext().getString(R.string.initial_sync_failed)); } return; } txSyncTime.setText(updateSyncTimeViewUI()); if (sharedPreferenceMgr.isStockCardLastYearSyncError()) { setSyncStockCardLastYearError(); } } SyncTimeView(Context context);  SyncTimeView(Context context, AttributeSet attrs); void showLastSyncTime(); @Override void onClick(View v); void showSyncProgressBarAndHideIcon(); void setSyncStockCardLastYearText(); void setSyncStockCardLastYearError(); void setSyncedMovementError(String error);  }