Force update custom action view

This commit is contained in:
M66B 2015-11-04 09:57:38 +01:00
parent dcdbe2e7fd
commit b7e6000393
1 changed files with 5 additions and 1 deletions

View File

@ -87,6 +87,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
private static final String TAG = "NetGuard.Main"; private static final String TAG = "NetGuard.Main";
private boolean running = false; private boolean running = false;
private View actionView;
private ImageView ivInteractive; private ImageView ivInteractive;
private ImageView ivWifi; private ImageView ivWifi;
private ImageView ivOther; private ImageView ivOther;
@ -125,7 +126,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
boolean enabled = prefs.getBoolean("enabled", false); boolean enabled = prefs.getBoolean("enabled", false);
// Action bar // Action bar
View actionView = getLayoutInflater().inflate(R.layout.action, null); actionView = getLayoutInflater().inflate(R.layout.action, null);
SwitchCompat swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); SwitchCompat swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled);
ivInteractive = (ImageView) actionView.findViewById(R.id.ivInteractive); ivInteractive = (ImageView) actionView.findViewById(R.id.ivInteractive);
ivWifi = (ImageView) actionView.findViewById(R.id.ivWifi); ivWifi = (ImageView) actionView.findViewById(R.id.ivWifi);
@ -311,6 +312,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
Util.logExtras(TAG, intent); Util.logExtras(TAG, intent);
ivInteractive.setVisibility(Intent.ACTION_SCREEN_ON.equals(intent.getAction()) ? View.VISIBLE : View.INVISIBLE); ivInteractive.setVisibility(Intent.ACTION_SCREEN_ON.equals(intent.getAction()) ? View.VISIBLE : View.INVISIBLE);
actionView.postInvalidate();
} }
}; };
@ -330,6 +332,8 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
ivRoaming.setVisibility(View.VISIBLE); ivRoaming.setVisibility(View.VISIBLE);
else else
ivOther.setVisibility(View.VISIBLE); ivOther.setVisibility(View.VISIBLE);
actionView.postInvalidate();
} }
}; };