diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 73d054549d..43a5179d9b 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -776,25 +776,36 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); if (mapInfoLayer != null) { recordControl = new TextInfoWidget(activity) { + + private Integer cachedAction; + private Boolean cachedRecording; + @Override public boolean updateInfo(DrawSettings drawSettings) { + boolean recording = isRecording(); Integer action = AV_DEFAULT_ACTION.get(); - boolean isVideoAction = action.equals(AV_DEFAULT_ACTION_VIDEO); - boolean isTakePictureAction = action.equals(AV_DEFAULT_ACTION_TAKEPICTURE); - boolean isAudioAction = action.equals(AV_DEFAULT_ACTION_AUDIO); - if (isRecording()) { - setText(app.getString(R.string.shared_string_control_stop), null); - setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); - } else { - setText(app.getString(R.string.shared_string_control_start), null); - if (isVideoAction) { - setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night); - } else if (isTakePictureAction) { - setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night); - } else if (isAudioAction) { - setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night); + if (!Algorithms.objectEquals(recording, cachedAction) || !Algorithms.objectEquals(action, cachedRecording)) { + cachedAction = action; + cachedRecording = recording; + if (recording) { + setText(app.getString(R.string.shared_string_control_stop), null); + setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night); } else { - setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night); + setText(app.getString(R.string.shared_string_control_start), null); + switch (action) { + case AV_DEFAULT_ACTION_VIDEO: + setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night); + break; + case AV_DEFAULT_ACTION_TAKEPICTURE: + setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night); + break; + case AV_DEFAULT_ACTION_AUDIO: + setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night); + break; + default: + setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night); + break; + } } } return false;