Commit 245991fc authored by cyberta's avatar cyberta

use lambdas in NavigationDrawerFragment

parent 33f811f6
Pipeline #21786 passed with stages
in 21 minutes and 35 seconds
...@@ -47,7 +47,6 @@ import android.view.View; ...@@ -47,7 +47,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ListView; import android.widget.ListView;
import se.leap.bitmaskclient.DrawerSettingsAdapter; import se.leap.bitmaskclient.DrawerSettingsAdapter;
...@@ -201,12 +200,7 @@ public class NavigationDrawerFragment extends Fragment { ...@@ -201,12 +200,7 @@ public class NavigationDrawerFragment extends Fragment {
} }
// Defer code dependent on restoration of previous instance state. // Defer code dependent on restoration of previous instance state.
this.drawerLayout.post(new Runnable() { this.drawerLayout.post(() -> drawerToggle.syncState());
@Override
public void run() {
drawerToggle.syncState();
}
});
this.drawerLayout.addDrawerListener(drawerToggle); this.drawerLayout.addDrawerListener(drawerToggle);
} }
...@@ -261,12 +255,7 @@ public class NavigationDrawerFragment extends Fragment { ...@@ -261,12 +255,7 @@ public class NavigationDrawerFragment extends Fragment {
private void setupSettingsListView() { private void setupSettingsListView() {
ListView drawerSettingsListView = drawerView.findViewById(R.id.settingsList); ListView drawerSettingsListView = drawerView.findViewById(R.id.settingsList);
drawerSettingsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { drawerSettingsListView.setOnItemClickListener((parent, view, position, id) -> selectItem(parent, position));
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(parent, position);
}
});
drawerSettingsListView.setAdapter(settingsListAdapter); drawerSettingsListView.setAdapter(settingsListAdapter);
} }
...@@ -276,12 +265,7 @@ public class NavigationDrawerFragment extends Fragment { ...@@ -276,12 +265,7 @@ public class NavigationDrawerFragment extends Fragment {
settingsListAdapter.addItem(getSwitchInstance(getString(R.string.save_battery), settingsListAdapter.addItem(getSwitchInstance(getString(R.string.save_battery),
getSaveBattery(getContext()), getSaveBattery(getContext()),
BATTERY_SAVER, BATTERY_SAVER,
new CompoundButton.OnCheckedChangeListener() { (buttonView, newStateIsChecked) -> onSwitchItemSelected(BATTERY_SAVER, newStateIsChecked)));
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean newStateIsChecked) {
onSwitchItemSelected(BATTERY_SAVER, newStateIsChecked);
}
}));
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
settingsListAdapter.addItem(getSimpleTextInstance(getString(R.string.always_on_vpn), ALWAYS_ON)); settingsListAdapter.addItem(getSimpleTextInstance(getString(R.string.always_on_vpn), ALWAYS_ON));
...@@ -318,31 +302,25 @@ public class NavigationDrawerFragment extends Fragment { ...@@ -318,31 +302,25 @@ public class NavigationDrawerFragment extends Fragment {
private void showDottedIconWithDelay() { private void showDottedIconWithDelay() {
final Handler navigationDrawerHandler = new Handler(); final Handler navigationDrawerHandler = new Handler();
navigationDrawerHandler.postDelayed(new Runnable() { navigationDrawerHandler.postDelayed(() -> {
@Override if (!wasPaused) {
public void run() { toolbar.setNavigationIcon(R.drawable.ic_menu_color_point);
if (!wasPaused) { toolbar.playSoundEffect(android.view.SoundEffectConstants.CLICK);
toolbar.setNavigationIcon(R.drawable.ic_menu_color_point);
toolbar.playSoundEffect(android.view.SoundEffectConstants.CLICK);
}
} }
}, THREE_SECONDS); }, THREE_SECONDS);
} }
@NonNull @NonNull
private void closeDrawerWithDelay() { private void closeDrawerWithDelay() {
final Handler navigationDrawerHandler = new Handler(); final Handler navigationDrawerHandler = new Handler();
navigationDrawerHandler.postDelayed(new Runnable() { navigationDrawerHandler.postDelayed(() -> {
@Override if (!wasPaused) {
public void run() { drawerLayout.closeDrawer(fragmentContainerView, true);
if (!wasPaused) { } else {
drawerLayout.closeDrawer(fragmentContainerView, true); shouldCloseOnResume = true;
} else {
shouldCloseOnResume = true;
}
} }
}, TWO_SECONDS); }, TWO_SECONDS);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment