mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 04:46:51 +01:00
no not refresh whole activity when deciding whether fab should be shown or not
This commit is contained in:
parent
4641e51715
commit
e491a8c21d
@ -74,6 +74,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
private GBDeviceAdapterv2 mGBDeviceAdapter;
|
||||
private RecyclerView deviceListView;
|
||||
private FloatingActionButton fab;
|
||||
|
||||
private boolean isLanguageInvalid = false;
|
||||
|
||||
@ -128,8 +129,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
deviceListView.setAdapter(this.mGBDeviceAdapter);
|
||||
|
||||
//we need deviceList so fab logic moved to here
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -137,15 +137,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
}
|
||||
});
|
||||
|
||||
if (GBApplication.getPrefs().getBoolean("display_add_device_fab", true)) {
|
||||
fab.show();
|
||||
} else {
|
||||
if (deviceList.isEmpty()) {
|
||||
fab.show();
|
||||
} else {
|
||||
fab.hide();
|
||||
}
|
||||
}
|
||||
showFabIfNeccessary();
|
||||
|
||||
/* uncomment to enable fixed-swipe to reveal more actions
|
||||
|
||||
@ -249,7 +241,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == MENU_REFRESH_CODE) {
|
||||
this.recreate();
|
||||
showFabIfNeccessary();
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +295,9 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
+ "color: " + AndroidUtils.getTextColorHex(getBaseContext()) + "; "
|
||||
+ "background-color: " + AndroidUtils.getBackgroundColorHex(getBaseContext()) + ";" +
|
||||
"}";
|
||||
return new ChangeLog(this, css);}
|
||||
return new ChangeLog(this, css);
|
||||
}
|
||||
|
||||
private void launchDiscoveryActivity() {
|
||||
startActivity(new Intent(this, DiscoveryActivity.class));
|
||||
}
|
||||
@ -312,6 +306,18 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
mGBDeviceAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void showFabIfNeccessary() {
|
||||
if (GBApplication.getPrefs().getBoolean("display_add_device_fab", true)) {
|
||||
fab.show();
|
||||
} else {
|
||||
if (deviceListView.getChildCount() < 1) {
|
||||
fab.show();
|
||||
} else {
|
||||
fab.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
private void checkAndRequestPermissions() {
|
||||
List<String> wantedPermissions = new ArrayList<>();
|
||||
@ -347,7 +353,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
}
|
||||
|
||||
if (!wantedPermissions.isEmpty())
|
||||
ActivityCompat.requestPermissions(this, wantedPermissions.toArray(new String[wantedPermissions.size()]), 0);
|
||||
ActivityCompat.requestPermissions(this, wantedPermissions.toArray(new String[0]), 0);
|
||||
}
|
||||
|
||||
public void setLanguage(Locale language, boolean invalidateLanguage) {
|
||||
|
Loading…
Reference in New Issue
Block a user