@Test public void testUiInit() { final View container = mCurrentGuidanceSpeedView.findViewById(R.id.guidance_current_speed_container); final TextView speedValueView = mCurrentGuidanceSpeedView.findViewById(R.id.guidance_current_speed_value); final TextView speedUnitView = mCurrentGuidanceSpeedView.findViewById(R.id.guidance_current_speed_unit); assertThat(container.getVisibility(), is(View.VISIBLE)); assertThat(speedValueView.getText().toString(), is(getString(R.string.msdkui_value_not_available))); assertThat(speedUnitView.getText().toString(), is("")); GuidanceSpeedData data = new GuidanceSpeedData(VELOCITY, SPEED_LIMIT); mCurrentGuidanceSpeedView.setCurrentSpeedData(data); assertThat(speedValueView.getText().toString(), is(String.valueOf(SpeedFormatterUtil.format(VELOCITY, UnitSystem.METRIC)))); }
public void setCurrentSpeedData(@Nullable GuidanceSpeedData data) { populateUi(data); if (data == null || !data.isValid()) { mGuidanceSpeedData = data; return; } boolean refreshBackground = false; if (mGuidanceSpeedData == null || !mGuidanceSpeedData.isValid() || data.isSpeeding() != mGuidanceSpeedData.isSpeeding()) { refreshBackground = true; } mGuidanceSpeedData = data; if (refreshBackground) { post(this::refreshDrawableState); } }
GuidanceSpeedView extends BaseView { public void setCurrentSpeedData(@Nullable GuidanceSpeedData data) { populateUi(data); if (data == null || !data.isValid()) { mGuidanceSpeedData = data; return; } boolean refreshBackground = false; if (mGuidanceSpeedData == null || !mGuidanceSpeedData.isValid() || data.isSpeeding() != mGuidanceSpeedData.isSpeeding()) { refreshBackground = true; } mGuidanceSpeedData = data; if (refreshBackground) { post(this::refreshDrawableState); } } }
GuidanceSpeedView extends BaseView { public void setCurrentSpeedData(@Nullable GuidanceSpeedData data) { populateUi(data); if (data == null || !data.isValid()) { mGuidanceSpeedData = data; return; } boolean refreshBackground = false; if (mGuidanceSpeedData == null || !mGuidanceSpeedData.isValid() || data.isSpeeding() != mGuidanceSpeedData.isSpeeding()) { refreshBackground = true; } mGuidanceSpeedData = data; if (refreshBackground) { post(this::refreshDrawableState); } } GuidanceSpeedView(Context context);  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs);  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); }
GuidanceSpeedView extends BaseView { public void setCurrentSpeedData(@Nullable GuidanceSpeedData data) { populateUi(data); if (data == null || !data.isValid()) { mGuidanceSpeedData = data; return; } boolean refreshBackground = false; if (mGuidanceSpeedData == null || !mGuidanceSpeedData.isValid() || data.isSpeeding() != mGuidanceSpeedData.isSpeeding()) { refreshBackground = true; } mGuidanceSpeedData = data; if (refreshBackground) { post(this::refreshDrawableState); } } GuidanceSpeedView(Context context);  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs);  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); void setValueTextColor(int color); void setUnitTextColor(int color); void setCurrentSpeedData(@Nullable GuidanceSpeedData data); @NonNull GuidanceSpeedData getCurrentSpeedData(); int getValueTextColor(); int getUnitTextColor(); @Override void onRestoreInstanceState(Parcelable state); }
GuidanceSpeedView extends BaseView { public void setCurrentSpeedData(@Nullable GuidanceSpeedData data) { populateUi(data); if (data == null || !data.isValid()) { mGuidanceSpeedData = data; return; } boolean refreshBackground = false; if (mGuidanceSpeedData == null || !mGuidanceSpeedData.isValid() || data.isSpeeding() != mGuidanceSpeedData.isSpeeding()) { refreshBackground = true; } mGuidanceSpeedData = data; if (refreshBackground) { post(this::refreshDrawableState); } } GuidanceSpeedView(Context context);  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs);  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  GuidanceSpeedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); void setValueTextColor(int color); void setUnitTextColor(int color); void setCurrentSpeedData(@Nullable GuidanceSpeedData data); @NonNull GuidanceSpeedData getCurrentSpeedData(); int getValueTextColor(); int getUnitTextColor(); @Override void onRestoreInstanceState(Parcelable state);  }