mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 06:08:51 +00:00
Replace listeners and runnables with lambdas.
This commit is contained in:
parent
d08464cb7f
commit
34b1104020
35 changed files with 803 additions and 1340 deletions
|
@ -190,29 +190,25 @@ public class MyActionBar extends LinearLayout {
|
|||
public void startProgress() {
|
||||
if (progressCount++ == 0) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
handler.post(() -> {
|
||||
progressView.setVisibility(View.VISIBLE);
|
||||
if (progressAnimation == null) {
|
||||
progressAnimation = AnimationUtils.loadAnimation(context, R.anim.rotate);
|
||||
progressImage.startAnimation(progressAnimation);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void stopProgress() {
|
||||
if (--progressCount <= 0) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
handler.postDelayed(() -> {
|
||||
if (progressAnimation != null) {
|
||||
progressImage.clearAnimation();
|
||||
progressAnimation = null;
|
||||
}
|
||||
if (!progressAlwaysVisible)
|
||||
progressView.setVisibility(View.GONE);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
@ -224,13 +220,11 @@ public class MyActionBar extends LinearLayout {
|
|||
public void overflow(final int menuResId, final PopupMenu.OnMenuItemClickListener menuItemClickListener) {
|
||||
final View overflowButton = findViewById(R.id.action_bar_overflow_button);
|
||||
overflowButton.setVisibility(View.VISIBLE);
|
||||
overflowButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
overflowButton.setOnClickListener(v -> {
|
||||
final PopupMenu overflowMenu = new PopupMenu(context, v);
|
||||
overflowMenu.inflate(menuResId);
|
||||
overflowMenu.setOnMenuItemClickListener(menuItemClickListener);
|
||||
overflowMenu.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,12 +187,10 @@ public abstract class OeffiMainActivity extends OeffiActivity {
|
|||
final MyActionBar actionBar = getMyActionBar();
|
||||
|
||||
final NavigationMenuAdapter menuAdapter = new NavigationMenuAdapter(this,
|
||||
new MenuItem.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
item -> {
|
||||
onOptionsItemSelected(item);
|
||||
navigationDrawerLayout.closeDrawers();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
final Menu menu = menuAdapter.getMenu();
|
||||
onCreateOptionsMenu(menu);
|
||||
|
@ -206,11 +204,7 @@ public abstract class OeffiMainActivity extends OeffiActivity {
|
|||
navigationDrawerLayout.setDrawerShadow(R.drawable.view_shadow_right, Gravity.LEFT);
|
||||
navigationDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
|
||||
public void onDrawerOpened(final View drawerView) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
heartbeat.start();
|
||||
}
|
||||
}, 2000);
|
||||
handler.postDelayed(() -> heartbeat.start(), 2000);
|
||||
}
|
||||
|
||||
public void onDrawerClosed(final View drawerView) {
|
||||
|
@ -223,18 +217,12 @@ public abstract class OeffiMainActivity extends OeffiActivity {
|
|||
}
|
||||
});
|
||||
|
||||
navigationDrawerFooterView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
navigationDrawerFooterView.setOnClickListener(v -> {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
heartbeat.start();
|
||||
}
|
||||
});
|
||||
|
||||
actionBar.setDrawer(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
toggleNavigation();
|
||||
}
|
||||
});
|
||||
actionBar.setDrawer(v -> toggleNavigation());
|
||||
|
||||
updateNavigation();
|
||||
}
|
||||
|
@ -581,8 +569,7 @@ public abstract class OeffiMainActivity extends OeffiActivity {
|
|||
}
|
||||
}
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
if (isFinishing())
|
||||
return;
|
||||
|
||||
|
@ -592,7 +579,6 @@ public abstract class OeffiMainActivity extends OeffiActivity {
|
|||
messagesPrefs.edit().putLong(id, now).commit();
|
||||
if ("info".equals(action))
|
||||
prefs.edit().putLong(Constants.PREFS_KEY_LAST_INFO_AT, now).commit();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log.info("Got '{}: {}' when fetching message from: '{}'", response.code(),
|
||||
|
|
|
@ -495,17 +495,13 @@ public class OeffiMapView extends MapView {
|
|||
|
||||
public void setZoomControls(final ZoomControls zoomControls) {
|
||||
this.zoomControls = zoomControls;
|
||||
zoomControls.setOnZoomInClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
zoomControls.setOnZoomInClickListener(v -> {
|
||||
showZoomControls();
|
||||
getController().zoomIn();
|
||||
}
|
||||
});
|
||||
zoomControls.setOnZoomOutClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
zoomControls.setOnZoomOutClickListener(v -> {
|
||||
showZoomControls();
|
||||
getController().zoomOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -272,31 +272,20 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
final MyActionBar actionBar = getMyActionBar();
|
||||
setPrimaryColor(R.color.action_bar_background_directions);
|
||||
actionBar.setPrimaryTitle(R.string.directions_activity_title);
|
||||
actionBar.setTitlesOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
NetworkPickerActivity.start(DirectionsActivity.this);
|
||||
}
|
||||
});
|
||||
actionBar.setTitlesOnClickListener(v -> NetworkPickerActivity.start(DirectionsActivity.this));
|
||||
buttonExpand = actionBar.addToggleButton(R.drawable.ic_expand_white_24dp,
|
||||
R.string.directions_action_expand_title);
|
||||
buttonExpand.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(final ToggleImageButton buttonView, final boolean isChecked) {
|
||||
buttonExpand.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked)
|
||||
expandForm();
|
||||
else
|
||||
collapseForm();
|
||||
|
||||
updateMap();
|
||||
}
|
||||
});
|
||||
actionBar.addButton(R.drawable.ic_shuffle_white_24dp, R.string.directions_action_return_trip_title)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
viewToLocation.exchangeWith(viewFromLocation);
|
||||
}
|
||||
});
|
||||
actionBar.overflow(R.menu.directions_options, new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
.setOnClickListener(v -> viewToLocation.exchangeWith(viewFromLocation));
|
||||
actionBar.overflow(R.menu.directions_options, item -> {
|
||||
if (item.getItemId() == R.id.directions_options_clear_history) {
|
||||
if (network != null)
|
||||
showDialog(DIALOG_CLEAR_HISTORY);
|
||||
|
@ -304,29 +293,22 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
initNavigation();
|
||||
|
||||
((Button) findViewById(R.id.directions_network_missing_capability_button))
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
NetworkPickerActivity.start(DirectionsActivity.this);
|
||||
}
|
||||
});
|
||||
.setOnClickListener((OnClickListener) v -> NetworkPickerActivity.start(DirectionsActivity.this));
|
||||
connectivityWarningView = (TextView) findViewById(R.id.directions_connectivity_warning_box);
|
||||
|
||||
initLayoutTransitions();
|
||||
|
||||
final AutoCompleteLocationAdapter autoCompleteAdapter = new AutoCompleteLocationAdapter();
|
||||
|
||||
final LocationView.Listener locationChangeListener = new LocationView.Listener() {
|
||||
public void changed() {
|
||||
final LocationView.Listener locationChangeListener = () -> {
|
||||
updateMap();
|
||||
queryHistoryListAdapter.clearSelectedEntry();
|
||||
requestFocusFirst();
|
||||
}
|
||||
};
|
||||
|
||||
viewFromLocation = (LocationView) findViewById(R.id.directions_from);
|
||||
|
@ -344,8 +326,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
viewToLocation = (LocationView) findViewById(R.id.directions_to);
|
||||
viewToLocation.setAdapter(autoCompleteAdapter);
|
||||
viewToLocation.setListener(locationChangeListener);
|
||||
viewToLocation.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
|
||||
viewToLocation.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_GO) {
|
||||
viewGo.performClick();
|
||||
return true;
|
||||
|
@ -355,7 +336,6 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
viewToLocation.setContextMenuItemClickListener(new LocationContextMenuItemClickListener(viewToLocation,
|
||||
REQUEST_CODE_LOCATION_PERMISSION_TO, REQUEST_CODE_PICK_CONTACT_TO, REQUEST_CODE_PICK_STATION_TO));
|
||||
|
@ -372,12 +352,10 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
viewProductToggles.add((ToggleImageButton) findViewById(R.id.directions_products_c));
|
||||
initProductToggles();
|
||||
|
||||
final OnLongClickListener productLongClickListener = new OnLongClickListener() {
|
||||
public boolean onLongClick(final View v) {
|
||||
final OnLongClickListener productLongClickListener = v -> {
|
||||
final DialogBuilder builder = DialogBuilder.get(DirectionsActivity.this);
|
||||
builder.setTitle(R.string.directions_products_prompt);
|
||||
builder.setItems(R.array.directions_products, new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setItems(R.array.directions_products, (dialog, which) -> {
|
||||
for (final ToggleImageButton view : viewProductToggles) {
|
||||
if (which == 0)
|
||||
view.setChecked(view.equals(v));
|
||||
|
@ -388,11 +366,9 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
if (which == 3)
|
||||
view.setChecked("SUTBP".contains((String) view.getTag()));
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
for (final View view : viewProductToggles)
|
||||
view.setOnLongClickListener(productLongClickListener);
|
||||
|
@ -400,12 +376,10 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
viewBike = (CheckBox) findViewById(R.id.directions_option_bike);
|
||||
|
||||
viewTimeDepArr = (Button) findViewById(R.id.directions_time_dep_arr);
|
||||
viewTimeDepArr.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
viewTimeDepArr.setOnClickListener(v -> {
|
||||
final DialogBuilder builder = DialogBuilder.get(DirectionsActivity.this);
|
||||
builder.setTitle(R.string.directions_set_time_prompt);
|
||||
builder.setItems(R.array.directions_set_time, new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setItems(R.array.directions_set_time, (dialog, which) -> {
|
||||
final String[] parts = getResources().getStringArray(R.array.directions_set_time_values)[which]
|
||||
.split("_");
|
||||
final DepArr depArr = DepArr.valueOf(parts[0]);
|
||||
|
@ -423,21 +397,15 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
throw new IllegalStateException(parts[1]);
|
||||
}
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
});
|
||||
|
||||
viewTime1 = (Button) findViewById(R.id.directions_time_1);
|
||||
viewTime2 = (Button) findViewById(R.id.directions_time_2);
|
||||
|
||||
viewGo = (Button) findViewById(R.id.directions_go);
|
||||
viewGo.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
handleGo();
|
||||
}
|
||||
});
|
||||
viewGo.setOnClickListener(v -> handleGo());
|
||||
|
||||
viewQueryHistoryList = (RecyclerView) findViewById(android.R.id.list);
|
||||
viewQueryHistoryList.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
@ -453,10 +421,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
quickReturnView.getLayoutParams().width, quickReturnView.getLayoutParams().height);
|
||||
layoutParams.setBehavior(new QuickReturnBehavior());
|
||||
quickReturnView.setLayoutParams(layoutParams);
|
||||
quickReturnView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(final View v, final int left, final int top, final int right, final int bottom,
|
||||
final int oldLeft, final int oldTop, final int oldRight, final int oldBottom) {
|
||||
quickReturnView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
final int height = bottom - top;
|
||||
viewQueryHistoryList.setPadding(viewQueryHistoryList.getPaddingLeft(), height,
|
||||
viewQueryHistoryList.getPaddingRight(), viewQueryHistoryList.getPaddingBottom());
|
||||
|
@ -464,7 +429,6 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
viewQueryHistoryEmpty.getPaddingRight(), viewQueryHistoryEmpty.getPaddingBottom());
|
||||
viewQueryMissingCapability.setPadding(viewQueryMissingCapability.getPaddingLeft(), height,
|
||||
viewQueryMissingCapability.getPaddingRight(), viewQueryMissingCapability.getPaddingBottom());
|
||||
}
|
||||
});
|
||||
|
||||
mapView = (OeffiMapView) findViewById(R.id.directions_map);
|
||||
|
@ -493,17 +457,13 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
final LocationTextView locationView = (LocationTextView) view
|
||||
.findViewById(R.id.directions_map_pin_location);
|
||||
final View buttonGroup = view.findViewById(R.id.directions_map_pin_buttons);
|
||||
buttonGroup.findViewById(R.id.directions_map_pin_button_from).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
buttonGroup.findViewById(R.id.directions_map_pin_button_from).setOnClickListener(v -> {
|
||||
viewFromLocation.setLocation(pinLocation);
|
||||
mapView.removeAllViews();
|
||||
}
|
||||
});
|
||||
buttonGroup.findViewById(R.id.directions_map_pin_button_to).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
buttonGroup.findViewById(R.id.directions_map_pin_button_to).setOnClickListener(v -> {
|
||||
viewToLocation.setLocation(pinLocation);
|
||||
mapView.removeAllViews();
|
||||
}
|
||||
});
|
||||
locationView.setLocation(pinLocation);
|
||||
locationView.setShowLocationType(false);
|
||||
|
@ -744,49 +704,37 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
}
|
||||
}
|
||||
|
||||
private final OnClickListener dateClickListener = new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
private final OnClickListener dateClickListener = v -> {
|
||||
final Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTimeInMillis(((TimeSpec.Absolute) time).timeMs);
|
||||
final int year = calendar.get(Calendar.YEAR);
|
||||
final int month = calendar.get(Calendar.MONTH);
|
||||
final int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
new DatePickerDialog(DirectionsActivity.this, Constants.ALERT_DIALOG_THEME, new OnDateSetListener() {
|
||||
public void onDateSet(final DatePicker view, final int year, final int month, final int day) {
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.set(Calendar.MONTH, month);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||||
new DatePickerDialog(DirectionsActivity.this, Constants.ALERT_DIALOG_THEME, (view, year1, month1, day1) -> {
|
||||
calendar.set(Calendar.YEAR, year1);
|
||||
calendar.set(Calendar.MONTH, month1);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, day1);
|
||||
time = new TimeSpec.Absolute(time.depArr, calendar.getTimeInMillis());
|
||||
updateGUI();
|
||||
}
|
||||
}, year, month, day).show();
|
||||
}
|
||||
};
|
||||
|
||||
private final OnClickListener timeClickListener = new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
private final OnClickListener timeClickListener = v -> {
|
||||
final Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTimeInMillis(((TimeSpec.Absolute) time).timeMs);
|
||||
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
final int minute = calendar.get(Calendar.MINUTE);
|
||||
|
||||
new TimePickerDialog(DirectionsActivity.this, Constants.ALERT_DIALOG_THEME, new OnTimeSetListener() {
|
||||
public void onTimeSet(final TimePicker view, final int hour, final int minute) {
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hour);
|
||||
calendar.set(Calendar.MINUTE, minute);
|
||||
new TimePickerDialog(DirectionsActivity.this, Constants.ALERT_DIALOG_THEME, (view, hour1, minute1) -> {
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hour1);
|
||||
calendar.set(Calendar.MINUTE, minute1);
|
||||
time = new TimeSpec.Absolute(time.depArr, calendar.getTimeInMillis());
|
||||
updateGUI();
|
||||
}
|
||||
}, hour, minute, DateFormat.is24HourFormat(DirectionsActivity.this)).show();
|
||||
}
|
||||
};
|
||||
|
||||
private final OnClickListener diffClickListener = new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
handleDiffClick();
|
||||
}
|
||||
};
|
||||
private final OnClickListener diffClickListener = v -> handleDiffClick();
|
||||
|
||||
private void handleDiffClick() {
|
||||
final int[] relativeTimeValues = getResources().getIntArray(R.array.directions_set_time_relative);
|
||||
|
@ -801,8 +749,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
}
|
||||
final DialogBuilder builder = DialogBuilder.get(this);
|
||||
builder.setTitle(R.string.directions_set_time_relative_prompt);
|
||||
builder.setItems(relativeTimeStrings, new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setItems(relativeTimeStrings, (dialog, which) -> {
|
||||
if (which < relativeTimeValues.length) {
|
||||
final int mins = relativeTimeValues[which];
|
||||
time = new TimeSpec.Relative(mins * DateUtils.MINUTE_IN_MILLIS);
|
||||
|
@ -810,7 +757,6 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
time = new TimeSpec.Absolute(DepArr.DEPART, time.timeInMillis());
|
||||
}
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
@ -1009,11 +955,9 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
}
|
||||
|
||||
final ProgressDialog progressDialog = ProgressDialog.show(DirectionsActivity.this, null,
|
||||
getString(R.string.directions_query_progress), true, true, new DialogInterface.OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
getString(R.string.directions_query_progress), true, true, dialog -> {
|
||||
if (queryTripsRunnable != null)
|
||||
queryTripsRunnable.cancel();
|
||||
}
|
||||
});
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
|
||||
|
@ -1070,14 +1014,12 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
final DialogBuilder builder = DialogBuilder.get(DirectionsActivity.this);
|
||||
builder.setTitle(getString(R.string.ambiguous_address_title));
|
||||
builder.setAdapter(new AmbiguousLocationAdapter(DirectionsActivity.this, autocompletes),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
(dialog, which) -> {
|
||||
final LocationView locationView = result.ambiguousFrom != null
|
||||
? viewFromLocation
|
||||
: (result.ambiguousVia != null ? viewViaLocation : viewToLocation);
|
||||
locationView.setLocation(autocompletes.get(which));
|
||||
viewGo.performClick();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
} else {
|
||||
|
@ -1092,11 +1034,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
R.string.directions_alert_redirect_title);
|
||||
builder.setMessage(getString(R.string.directions_alert_redirect_message, url.host()));
|
||||
builder.setPositiveButton(R.string.directions_alert_redirect_button_follow,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString())));
|
||||
}
|
||||
});
|
||||
(dialog, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString()))));
|
||||
builder.setNegativeButton(R.string.directions_alert_redirect_button_dismiss, null);
|
||||
builder.show();
|
||||
}
|
||||
|
@ -1107,11 +1045,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
R.string.directions_alert_blocked_title);
|
||||
builder.setMessage(getString(R.string.directions_alert_blocked_message, url.host()));
|
||||
builder.setPositiveButton(R.string.directions_alert_blocked_button_retry,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
viewGo.performClick();
|
||||
}
|
||||
});
|
||||
(dialog, which) -> viewGo.performClick());
|
||||
builder.setNegativeButton(R.string.directions_alert_blocked_button_dismiss, null);
|
||||
builder.show();
|
||||
}
|
||||
|
@ -1122,11 +1056,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
R.string.directions_alert_internal_error_title);
|
||||
builder.setMessage(getString(R.string.directions_alert_internal_error_message, url.host()));
|
||||
builder.setPositiveButton(R.string.directions_alert_internal_error_button_retry,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
viewGo.performClick();
|
||||
}
|
||||
});
|
||||
(dialog, which) -> viewGo.performClick());
|
||||
builder.setNegativeButton(R.string.directions_alert_internal_error_button_dismiss, null);
|
||||
builder.show();
|
||||
}
|
||||
|
@ -1145,17 +1075,11 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
final DialogBuilder builder = DialogBuilder.warn(DirectionsActivity.this,
|
||||
R.string.alert_network_problem_title);
|
||||
builder.setMessage(R.string.alert_network_problem_message);
|
||||
builder.setPositiveButton(R.string.alert_network_problem_retry, new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setPositiveButton(R.string.alert_network_problem_retry, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
viewGo.performClick();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(dialog -> dialog.dismiss());
|
||||
builder.show();
|
||||
}
|
||||
};
|
||||
|
@ -1172,13 +1096,11 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
final DialogBuilder builder = DialogBuilder.get(this);
|
||||
builder.setMessage(R.string.directions_query_history_clear_confirm_message);
|
||||
builder.setPositiveButton(R.string.directions_query_history_clear_confirm_button_clear,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
(dialog, which) -> {
|
||||
queryHistoryListAdapter.removeAllEntries();
|
||||
viewFromLocation.reset();
|
||||
viewViaLocation.reset();
|
||||
viewToLocation.reset();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.directions_query_history_clear_confirm_button_dismiss, null);
|
||||
return builder.create();
|
||||
|
|
|
@ -143,15 +143,13 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
|
||||
public void onLocationStart(final String provider) {
|
||||
progressDialog = ProgressDialog.show(DirectionsShortcutActivity.this, null,
|
||||
getString(R.string.acquire_location_start, provider), true, true, new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
getString(R.string.acquire_location_start, provider), true, true, dialog -> {
|
||||
locationHelper.stop();
|
||||
|
||||
if (queryTripsRunnable != null)
|
||||
queryTripsRunnable.cancel();
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
|
@ -264,23 +262,13 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
R.string.directions_alert_redirect_title);
|
||||
builder.setMessage(getString(R.string.directions_alert_redirect_message, url.host()));
|
||||
builder.setPositiveButton(R.string.directions_alert_redirect_button_follow,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
(dialog, which) -> {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString())));
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.directions_alert_redirect_button_dismiss,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
(dialog, which) -> finish());
|
||||
builder.setOnCancelListener(dialog -> finish());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
|
@ -290,16 +278,8 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
R.string.directions_alert_blocked_title);
|
||||
builder.setMessage(getString(R.string.directions_alert_blocked_message, url.host()));
|
||||
builder.setNeutralButton(R.string.directions_alert_blocked_button_dismiss,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
(dialog, which) -> finish());
|
||||
builder.setOnCancelListener(dialog -> finish());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
|
@ -309,16 +289,8 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
R.string.directions_alert_internal_error_title);
|
||||
builder.setMessage(getString(R.string.directions_alert_internal_error_message, url.host()));
|
||||
builder.setNeutralButton(R.string.directions_alert_internal_error_button_dismiss,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
(dialog, which) -> finish());
|
||||
builder.setOnCancelListener(dialog -> finish());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
|
@ -329,16 +301,8 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
builder.setMessage(getString(R.string.directions_alert_ssl_exception_message,
|
||||
Throwables.getRootCause(x).toString()));
|
||||
builder.setNeutralButton(R.string.directions_alert_ssl_exception_button_dismiss,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
(dialog, which) -> finish());
|
||||
builder.setOnCancelListener(dialog -> finish());
|
||||
builder.show();
|
||||
}
|
||||
};
|
||||
|
@ -351,16 +315,8 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
|||
private void errorDialog(final int resId) {
|
||||
final DialogBuilder builder = DialogBuilder.warn(this, R.string.directions_shortcut_error_title);
|
||||
builder.setMessage(resId);
|
||||
builder.setPositiveButton("Ok", new OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("Ok", (dialog, which) -> finish());
|
||||
builder.setOnCancelListener(dialog -> finish());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -144,11 +144,7 @@ public class LocationView extends FrameLayout implements LocationHelper.Callback
|
|||
|
||||
@Override
|
||||
protected void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
chooseView.requestLayout();
|
||||
}
|
||||
});
|
||||
handler.post(() -> chooseView.requestLayout());
|
||||
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
}
|
||||
|
@ -164,8 +160,7 @@ public class LocationView extends FrameLayout implements LocationHelper.Callback
|
|||
final int paddingCram = res.getDimensionPixelSize(R.dimen.list_entry_padding_horizontal_cram);
|
||||
final int paddingLax = res.getDimensionPixelSize(R.dimen.list_entry_padding_horizontal_lax);
|
||||
textView.setPadding(paddingLax, paddingCram, paddingLax, paddingCram);
|
||||
textView.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
|
||||
textView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
// workaround for NPE
|
||||
if (parent == null)
|
||||
return;
|
||||
|
@ -180,7 +175,6 @@ public class LocationView extends FrameLayout implements LocationHelper.Callback
|
|||
|
||||
afterLocationViewInput();
|
||||
fireChanged();
|
||||
}
|
||||
});
|
||||
|
||||
leftDrawable = new MultiDrawable(context);
|
||||
|
|
|
@ -157,8 +157,7 @@ public abstract class QueryTripsRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnPreExecute() {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
handler.post(() -> {
|
||||
final boolean hasOptimize = options.optimize != null;
|
||||
final boolean hasWalkSpeed = options.walkSpeed != null && options.walkSpeed != WalkSpeed.NORMAL;
|
||||
final boolean hasAccessibility = options.accessibility != null
|
||||
|
@ -204,7 +203,6 @@ public abstract class QueryTripsRunnable implements Runnable {
|
|||
dialog.setMessage(progressMessage);
|
||||
|
||||
onPreExecute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -212,65 +210,41 @@ public abstract class QueryTripsRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnPostExecute() {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onPostExecute();
|
||||
}
|
||||
});
|
||||
handler.post(() -> onPostExecute());
|
||||
}
|
||||
|
||||
protected void onPostExecute() {
|
||||
}
|
||||
|
||||
private void postOnResult(final QueryTripsResult result) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onResult(result);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onResult(result));
|
||||
}
|
||||
|
||||
protected abstract void onResult(QueryTripsResult result);
|
||||
|
||||
private void postOnRedirect(final HttpUrl url) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onRedirect(url);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onRedirect(url));
|
||||
}
|
||||
|
||||
protected void onRedirect(final HttpUrl url) {
|
||||
}
|
||||
|
||||
private void postOnBlocked(final HttpUrl url) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onBlocked(url);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onBlocked(url));
|
||||
}
|
||||
|
||||
protected void onBlocked(final HttpUrl url) {
|
||||
}
|
||||
|
||||
private void postOnInternalError(final HttpUrl url) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onInternalError(url);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onInternalError(url));
|
||||
}
|
||||
|
||||
protected void onInternalError(final HttpUrl url) {
|
||||
}
|
||||
|
||||
private void postOnSSLException(final SSLException x) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onSSLException(x);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onSSLException(x));
|
||||
}
|
||||
|
||||
protected void onSSLException(final SSLException x) {
|
||||
|
@ -279,11 +253,7 @@ public abstract class QueryTripsRunnable implements Runnable {
|
|||
public void cancel() {
|
||||
cancelled.set(true);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onCancelled();
|
||||
}
|
||||
});
|
||||
handler.post(() -> onCancelled());
|
||||
}
|
||||
|
||||
protected void onCancelled() {
|
||||
|
|
|
@ -198,11 +198,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
final MyActionBar actionBar = getMyActionBar();
|
||||
setPrimaryColor(R.color.action_bar_background_directions);
|
||||
actionBar.setPrimaryTitle(getTitle());
|
||||
actionBar.setBack(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
actionBar.setBack(v -> finish());
|
||||
|
||||
// action bar secondary title
|
||||
final StringBuilder secondaryTitle = new StringBuilder();
|
||||
|
@ -223,8 +219,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
trackButton = actionBar.addToggleButton(R.drawable.ic_location_white_24dp,
|
||||
R.string.directions_trip_details_action_track_title);
|
||||
trackButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(final ToggleImageButton buttonView, final boolean isChecked) {
|
||||
trackButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked) {
|
||||
final String provider = requestLocationUpdates();
|
||||
if (provider != null) {
|
||||
|
@ -246,16 +241,13 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
|
||||
mapView.zoomToAll();
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
actionBar.addButton(R.drawable.ic_share_white_24dp, R.string.directions_trip_details_action_share_title)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
.setOnClickListener(v -> {
|
||||
final PopupMenu popupMenu = new PopupMenu(TripDetailsActivity.this, v);
|
||||
popupMenu.inflate(R.menu.directions_trip_details_action_share);
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.directions_trip_details_action_share_short) {
|
||||
shareTripShort();
|
||||
return true;
|
||||
|
@ -265,18 +257,12 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
popupMenu.show();
|
||||
}
|
||||
});
|
||||
if (getPackageManager().resolveActivity(scheduleTripIntent, 0) != null) {
|
||||
actionBar.addButton(R.drawable.ic_today_white_24dp, R.string.directions_trip_details_action_calendar_title)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
startActivity(scheduleTripIntent);
|
||||
}
|
||||
});
|
||||
.setOnClickListener(v -> startActivity(scheduleTripIntent));
|
||||
}
|
||||
|
||||
legsGroup = (ViewGroup) findViewById(R.id.directions_trip_details_legs_group);
|
||||
|
@ -626,11 +612,9 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
expandButton
|
||||
.setVisibility(intermediateStops != null && !intermediateStops.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
expandButton.setChecked(checked != null ? checked : false);
|
||||
expandButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(final ToggleImageButton buttonView, final boolean isChecked) {
|
||||
expandButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
legExpandStates.put(leg, isChecked);
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
|
||||
final TableLayout stopsView = (TableLayout) row.findViewById(R.id.directions_trip_details_public_entry_stops);
|
||||
|
@ -664,11 +648,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
final View collapsedIntermediateStopsRow = collapsedIntermediateStopsRow(numIntermediateStops,
|
||||
leg.line.style);
|
||||
stopsView.addView(collapsedIntermediateStopsRow);
|
||||
collapsedIntermediateStopsRow.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
expandButton.setChecked(true);
|
||||
}
|
||||
});
|
||||
collapsedIntermediateStopsRow.setOnClickListener(v -> expandButton.setChecked(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -898,15 +878,13 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
public void onClick(final View v) {
|
||||
final PopupMenu contextMenu = new StationContextMenu(TripDetailsActivity.this, v, network, location, null,
|
||||
false, false, true, false, false);
|
||||
contextMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
contextMenu.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.station_context_details) {
|
||||
StationDetailsActivity.start(TripDetailsActivity.this, network, location);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
contextMenu.show();
|
||||
}
|
||||
|
@ -922,8 +900,7 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
public void onClick(final View v) {
|
||||
final PopupMenu contextMenu = new StationContextMenu(TripDetailsActivity.this, v, network, stop.location,
|
||||
null, false, false, true, true, false);
|
||||
contextMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
contextMenu.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.station_context_details) {
|
||||
StationDetailsActivity.start(TripDetailsActivity.this, network, stop.location);
|
||||
return true;
|
||||
|
@ -944,7 +921,6 @@ public class TripDetailsActivity extends OeffiActivity implements LocationListen
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
contextMenu.show();
|
||||
}
|
||||
|
|
|
@ -101,8 +101,7 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
|
||||
private @Nullable QueryTripsContext context;
|
||||
private TripsGallery barView;
|
||||
private final NavigableSet<Trip> trips = new TreeSet<>(new Comparator<Trip>() {
|
||||
public int compare(final Trip trip1, final Trip trip2) {
|
||||
private final NavigableSet<Trip> trips = new TreeSet<>((trip1, trip2) -> {
|
||||
if (trip1.equals(trip2))
|
||||
return 0;
|
||||
else
|
||||
|
@ -111,7 +110,6 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
.compare(trip1.getLastArrivalTime(), trip2.getLastArrivalTime()) //
|
||||
.compare(trip1.numChanges, trip2.numChanges, Ordering.natural().nullsLast()) //
|
||||
.result();
|
||||
}
|
||||
});
|
||||
private boolean queryMoreTripsRunning = false;
|
||||
|
||||
|
@ -142,21 +140,12 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
setContentView(R.layout.directions_trip_overview_content);
|
||||
final MyActionBar actionBar = getMyActionBar();
|
||||
setPrimaryColor(R.color.action_bar_background_directions_dark);
|
||||
actionBar.setBack(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
actionBar.setBack(v -> finish());
|
||||
actionBar.setCustomTitles(R.layout.directions_trip_overview_custom_title);
|
||||
actionBar.addProgressButton().setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
handler.post(checkMoreRunnable);
|
||||
}
|
||||
});
|
||||
actionBar.addProgressButton().setOnClickListener(v -> handler.post(checkMoreRunnable));
|
||||
|
||||
barView = (TripsGallery) findViewById(R.id.trips_bar_view);
|
||||
barView.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(final AdapterView<?> parent, final View v, final int position, final long id) {
|
||||
barView.setOnItemClickListener((parent, v, position, id) -> {
|
||||
final Trip trip = (Trip) barView.getAdapter().getItem(position);
|
||||
|
||||
if (trip != null && trip.legs != null) {
|
||||
|
@ -174,13 +163,8 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
getContentResolver().update(historyUri, values, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
barView.setOnScrollListener(new OnScrollListener() {
|
||||
public void onScroll() {
|
||||
handler.post(checkMoreRunnable);
|
||||
}
|
||||
});
|
||||
barView.setOnScrollListener(() -> handler.post(checkMoreRunnable));
|
||||
|
||||
processResult(result, dep);
|
||||
}
|
||||
|
@ -259,21 +243,15 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
}
|
||||
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
actionBar.startProgress();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> actionBar.startProgress());
|
||||
|
||||
try {
|
||||
doRequest();
|
||||
} finally {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
queryMoreTripsRunning = false;
|
||||
|
||||
actionBar.stopProgress();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -288,8 +266,7 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
final NetworkProvider networkProvider = NetworkProviderFactory.provider(network);
|
||||
final QueryTripsResult result = networkProvider.queryMoreTrips(context, later);
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
log.debug("Got {} ({})", result.toShortString(), later ? "later" : "earlier");
|
||||
if (result.status == QueryTripsResult.Status.OK) {
|
||||
processResult(result, later);
|
||||
|
@ -301,21 +278,12 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
} else {
|
||||
new Toast(TripsOverviewActivity.this).toast(R.string.toast_network_problem);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (final SessionExpiredException | NotFoundException x) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(TripsOverviewActivity.this).longToast(R.string.toast_session_expired);
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> new Toast(TripsOverviewActivity.this).longToast(R.string.toast_session_expired));
|
||||
} catch (final InvalidDataException x) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(TripsOverviewActivity.this).longToast(R.string.toast_invalid_data,
|
||||
x.getMessage());
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> new Toast(TripsOverviewActivity.this).longToast(R.string.toast_invalid_data,
|
||||
x.getMessage()));
|
||||
} catch (final IOException x) {
|
||||
final String message = "IO problem while processing " + context + " on " + network + " (try "
|
||||
+ tries + ")";
|
||||
|
@ -323,18 +291,10 @@ public class TripsOverviewActivity extends OeffiActivity {
|
|||
if (tries >= Constants.MAX_TRIES_ON_IO_PROBLEM) {
|
||||
if (x instanceof SocketTimeoutException || x instanceof UnknownHostException
|
||||
|| x instanceof SocketException || x instanceof SSLException) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(TripsOverviewActivity.this).toast(R.string.toast_network_problem);
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> new Toast(TripsOverviewActivity.this).toast(R.string.toast_network_problem));
|
||||
} else if (x instanceof InternalErrorException) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(TripsOverviewActivity.this).toast(R.string.toast_internal_error,
|
||||
((InternalErrorException) x).getUrl().host());
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> new Toast(TripsOverviewActivity.this).toast(R.string.toast_internal_error,
|
||||
((InternalErrorException) x).getUrl().host()));
|
||||
} else {
|
||||
throw new RuntimeException(message, x);
|
||||
}
|
||||
|
|
|
@ -65,12 +65,10 @@ public class QueryHistoryViewHolder extends RecyclerView.ViewHolder {
|
|||
final QueryHistoryContextMenuItemListener contextMenuItemListener) {
|
||||
final boolean selected = rowId == selectedRowId;
|
||||
itemView.setActivated(selected);
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
final int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
clickListener.onEntryClick(position, from, to);
|
||||
}
|
||||
});
|
||||
|
||||
fromView.setLocation(from);
|
||||
|
@ -84,20 +82,17 @@ public class QueryHistoryViewHolder extends RecyclerView.ViewHolder {
|
|||
final long now = System.currentTimeMillis();
|
||||
tripView.setText(Formats.formatDate(context, now, savedTripDepartureTime) + "\n"
|
||||
+ Formats.formatTime(context, savedTripDepartureTime));
|
||||
tripView.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
tripView.setOnClickListener(v -> {
|
||||
final int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
clickListener.onSavedTripClick(position, serializedSavedTrip);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tripView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
contextButton.setVisibility(selected ? View.VISIBLE : View.GONE);
|
||||
contextButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
contextButton.setOnClickListener(v -> {
|
||||
final PopupMenu contextMenu = new PopupMenu(context, v);
|
||||
final MenuInflater inflater = contextMenu.getMenuInflater();
|
||||
final Menu menu = contextMenu.getMenu();
|
||||
|
@ -136,8 +131,7 @@ public class QueryHistoryViewHolder extends RecyclerView.ViewHolder {
|
|||
} else {
|
||||
toMenu = null;
|
||||
}
|
||||
contextMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
contextMenu.setOnMenuItemClickListener(item -> {
|
||||
final int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION) {
|
||||
if (fromMenu != null && item == fromMenu.findItem(item.getItemId()))
|
||||
|
@ -152,10 +146,8 @@ public class QueryHistoryViewHolder extends RecyclerView.ViewHolder {
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
contextMenu.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,11 +86,7 @@ public abstract class GetAreaRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnResult(final Point[] area) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onResult(area);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onResult(area));
|
||||
}
|
||||
|
||||
protected abstract void onResult(final Point[] area);
|
||||
|
|
|
@ -144,11 +144,7 @@ public class NetworkPickerActivity extends Activity implements ActivityCompat.On
|
|||
((FrameLayout) findViewById(R.id.network_picker_firsttime_message_shadow)).setForeground(null);
|
||||
} else {
|
||||
findViewById(R.id.network_picker_firsttime_message).setVisibility(View.GONE);
|
||||
actionBar.setBack(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
actionBar.setBack(v -> finish());
|
||||
final NetworkId networkId = prefsGetNetworkId();
|
||||
if (networkId != null) {
|
||||
backgroundHandler.post(new GetAreaRunnable(NetworkProviderFactory.provider(networkId), handler) {
|
||||
|
|
|
@ -68,11 +68,7 @@ public class NetworkViewHolder extends RecyclerView.ViewHolder {
|
|||
@Nullable final NetworkContextMenuItemListener contextMenuItemListener) {
|
||||
itemView.setFocusable(isEnabled);
|
||||
if (clickListener != null) {
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
clickListener.onNetworkClick(entry);
|
||||
}
|
||||
});
|
||||
itemView.setOnClickListener(v -> clickListener.onNetworkClick(entry));
|
||||
} else {
|
||||
itemView.setOnClickListener(null);
|
||||
}
|
||||
|
@ -114,17 +110,11 @@ public class NetworkViewHolder extends RecyclerView.ViewHolder {
|
|||
if (contextMenuItemListener != null) {
|
||||
contextButton.setVisibility(View.VISIBLE);
|
||||
contextButtonSpace.setVisibility(View.VISIBLE);
|
||||
contextButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
contextButton.setOnClickListener(v -> {
|
||||
final PopupMenu contextMenu = new PopupMenu(context, v);
|
||||
contextMenu.inflate(R.menu.network_picker_context);
|
||||
contextMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
return contextMenuItemListener.onNetworkContextMenuItemClick(entry, item.getItemId());
|
||||
}
|
||||
});
|
||||
contextMenu.setOnMenuItemClickListener(item -> contextMenuItemListener.onNetworkContextMenuItemClick(entry, item.getItemId()));
|
||||
contextMenu.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
contextButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -137,35 +137,29 @@ public class PlanActivity extends Activity {
|
|||
viewAnimator = (ViewAnimator) findViewById(R.id.plans_layout);
|
||||
|
||||
plan = (ScrollImageView) findViewById(R.id.plans_plan);
|
||||
plan.setOnMoveListener(new OnMoveListener() {
|
||||
public void onMove() {
|
||||
plan.setOnMoveListener(() -> {
|
||||
updateBubble();
|
||||
updateScale();
|
||||
|
||||
zoom.clearAnimation();
|
||||
zoom.startAnimation(zoomControlsAnimation);
|
||||
}
|
||||
});
|
||||
|
||||
bubble = findViewById(R.id.plans_bubble);
|
||||
bubble.setVisibility(View.GONE);
|
||||
bubble.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
bubble.setOnClickListener(v -> {
|
||||
final Station selection = checkNotNull(PlanActivity.this.selection);
|
||||
final PopupMenu contextMenu = new StationContextMenu(PlanActivity.this, v, selection.network,
|
||||
selection.location, null, false, false, false, false, false);
|
||||
contextMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
contextMenu.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.station_context_details) {
|
||||
StationDetailsActivity.start(PlanActivity.this, selection.network, selection.location);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
contextMenu.show();
|
||||
}
|
||||
});
|
||||
|
||||
bubbleName = (TextView) findViewById(R.id.plans_bubble_name);
|
||||
|
@ -173,17 +167,13 @@ public class PlanActivity extends Activity {
|
|||
bubbleLinesView = (LineView) findViewById(R.id.plans_bubble_lines);
|
||||
|
||||
zoom = (ZoomControls) findViewById(R.id.plans_zoom);
|
||||
zoom.setOnZoomInClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
zoom.setOnZoomInClickListener(v -> {
|
||||
plan.animateScaleStepIn();
|
||||
updateScale();
|
||||
}
|
||||
});
|
||||
zoom.setOnZoomOutClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
zoom.setOnZoomOutClickListener(v -> {
|
||||
plan.animateScaleStepOut();
|
||||
updateScale();
|
||||
}
|
||||
});
|
||||
|
||||
final String planId = checkNotNull(getIntent().getExtras().getString(INTENT_EXTRA_PLAN_ID),
|
||||
|
@ -408,11 +398,7 @@ public class PlanActivity extends Activity {
|
|||
for (final Station station : stations) {
|
||||
if (selectedId.equals(station.location.id)) {
|
||||
// delay until after layout finished
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
selectStation(station);
|
||||
}
|
||||
}, 500);
|
||||
handler.postDelayed(() -> selectStation(station), 500);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -113,11 +113,7 @@ public class PlansPickerActivity extends OeffiMainActivity implements ActivityCo
|
|||
setPrimaryColor(R.color.action_bar_background);
|
||||
actionBar.setPrimaryTitle(R.string.plans_activity_title);
|
||||
actionBar.addButton(R.drawable.ic_search_white_24dp, R.string.plans_picker_action_search_title)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
onSearchRequested();
|
||||
}
|
||||
});
|
||||
.setOnClickListener(v -> onSearchRequested());
|
||||
|
||||
initNavigation();
|
||||
|
||||
|
@ -132,11 +128,7 @@ public class PlansPickerActivity extends OeffiMainActivity implements ActivityCo
|
|||
connectivityWarningView = (TextView) findViewById(R.id.plans_picker_connectivity_warning_box);
|
||||
filterBox = findViewById(R.id.plans_picker_filter_box);
|
||||
|
||||
findViewById(R.id.plans_picker_filter_clear).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
clearListFilter();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.plans_picker_filter_clear).setOnClickListener(v -> clearListFilter());
|
||||
|
||||
connectivityReceiver = new ConnectivityBroadcastReceiver(connectivityManager) {
|
||||
@Override
|
||||
|
@ -308,10 +300,7 @@ public class PlansPickerActivity extends OeffiMainActivity implements ActivityCo
|
|||
final HttpUrl remoteUrl = plan.url != null ? plan.url
|
||||
: Constants.PLANS_BASE_URL.newBuilder().addEncodedPathSegment(planFilename).build();
|
||||
final ListenableFuture<Integer> download = downloader.download(remoteUrl, planFile, false,
|
||||
new Downloader.ProgressCallback() {
|
||||
public void progress(final long contentRead, final long contentLength) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
(contentRead, contentLength) -> runOnUiThread(() -> {
|
||||
final RecyclerView.ViewHolder holder = listView.findViewHolderForItemId(plan.rowId);
|
||||
if (holder != null) {
|
||||
final int position = holder.getAdapterPosition();
|
||||
|
@ -319,10 +308,7 @@ public class PlansPickerActivity extends OeffiMainActivity implements ActivityCo
|
|||
listAdapter.setProgressPermille(position,
|
||||
(int) (contentRead * 1000 / contentLength));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
actionBar.startProgress();
|
||||
Futures.addCallback(download, new FutureCallback<Integer>() {
|
||||
public void onSuccess(final @Nullable Integer status) {
|
||||
|
|
|
@ -71,11 +71,7 @@ public class PlanViewHolder extends RecyclerView.ViewHolder {
|
|||
|
||||
public void bind(final PlansAdapter.Plan plan, final PlanClickListener clickListener,
|
||||
final PlanContextMenuItemListener contextMenuItemListener) {
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
clickListener.onPlanClick(plan);
|
||||
}
|
||||
});
|
||||
itemView.setOnClickListener(v -> clickListener.onPlanClick(plan));
|
||||
|
||||
thumbView.setImageDrawable(null);
|
||||
|
||||
|
@ -101,18 +97,13 @@ public class PlanViewHolder extends RecyclerView.ViewHolder {
|
|||
networkLogoView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
contextButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
contextButton.setOnClickListener(v -> {
|
||||
final PopupMenu contextMenu = new PopupMenu(context, v);
|
||||
contextMenu.inflate(R.menu.plans_picker_context);
|
||||
contextMenu.getMenu().findItem(R.id.plans_picker_context_remove).setVisible(plan.localFile.exists());
|
||||
contextMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
return contextMenuItemListener.onPlanContextMenuItemClick(plan, item.getItemId());
|
||||
}
|
||||
});
|
||||
contextMenu.setOnMenuItemClickListener(item -> contextMenuItemListener.onPlanContextMenuItemClick(plan,
|
||||
item.getItemId()));
|
||||
contextMenu.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -154,24 +154,18 @@ public class PlansAdapter extends RecyclerView.Adapter<PlanViewHolder> {
|
|||
else
|
||||
thumb = res.getDrawable(R.drawable.ic_oeffi_plans_grey300_72dp).mutate();
|
||||
if (!call.isCanceled()) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
handler.post(() -> {
|
||||
holder.setCall(null);
|
||||
final int position = holder.getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
notifyItemChanged(position, thumb);
|
||||
}
|
||||
final int position1 = holder.getAdapterPosition();
|
||||
if (position1 != RecyclerView.NO_POSITION)
|
||||
notifyItemChanged(position1, thumb);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onFailure(final Call call, final IOException e) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
holder.setCall(null);
|
||||
}
|
||||
});
|
||||
handler.post(() -> holder.setCall(null));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -53,13 +53,10 @@ public class AboutFragment extends PreferenceFragment {
|
|||
final Uri marketUri = Uri.parse(String.format(Constants.MARKET_APP_URL, application.getPackageName()));
|
||||
findPreference(KEY_ABOUT_MARKET_APP).setSummary(marketUri.toString());
|
||||
findPreference(KEY_ABOUT_MARKET_APP).setIntent(new Intent(Intent.ACTION_VIEW, marketUri));
|
||||
findPreference(KEY_ABOUT_CHANGELOG).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
findPreference(KEY_ABOUT_CHANGELOG).setOnPreferenceClickListener(preference -> {
|
||||
ChangelogDialogBuilder.get(activity, Application.versionCode(application), null,
|
||||
Application.versionFlavor(application), 0, null).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,9 @@ public class DonateFragment extends PreferenceFragment {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
addPreferencesFromResource(R.xml.preference_donate);
|
||||
findPreference(KEY_ABOUT_DONATE_BITCOIN).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
findPreference(KEY_ABOUT_DONATE_BITCOIN).setOnPreferenceClickListener(preference -> {
|
||||
BitcoinIntegration.request(getActivity(), Constants.BITCOIN_ADDRESS);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,11 +61,7 @@ public class DecodeForeignActivity extends Activity {
|
|||
final Matcher m = Pattern.compile("/t/d(\\d+)").matcher(path);
|
||||
if (m.matches()) {
|
||||
final ProgressDialog progressDialog = ProgressDialog.show(DecodeForeignActivity.this, null,
|
||||
getString(R.string.stations_decode_foreign_progress), true, true, new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
getString(R.string.stations_decode_foreign_progress), true, true, dialog -> finish());
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
|
||||
final Request.Builder request = new Request.Builder();
|
||||
|
@ -79,8 +75,7 @@ public class DecodeForeignActivity extends Activity {
|
|||
if (mRefresh.find()) {
|
||||
final Uri refreshUri = Uri.parse(mRefresh.group(1));
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
progressDialog.dismiss();
|
||||
if ("mobil.rmv.de".equals(refreshUri.getHost())
|
||||
&& "/mobile".equals(refreshUri.getPath())) {
|
||||
|
@ -91,7 +86,6 @@ public class DecodeForeignActivity extends Activity {
|
|||
} else {
|
||||
errorDialog(R.string.stations_decode_foreign_failed);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
onFail();
|
||||
|
@ -107,11 +101,9 @@ public class DecodeForeignActivity extends Activity {
|
|||
}
|
||||
|
||||
private void onFail() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
progressDialog.dismiss();
|
||||
errorDialog(R.string.stations_decode_foreign_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -127,16 +119,8 @@ public class DecodeForeignActivity extends Activity {
|
|||
private void errorDialog(final int resId) {
|
||||
final DialogBuilder builder = DialogBuilder.warn(this, 0);
|
||||
builder.setMessage(resId);
|
||||
builder.setPositiveButton("Ok", new OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("Ok", (dialog, which) -> finish());
|
||||
builder.setOnCancelListener(dialog -> finish());
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,11 +77,7 @@ public class FavoriteStationsActivity extends OeffiActivity
|
|||
final MyActionBar actionBar = getMyActionBar();
|
||||
setPrimaryColor(R.color.action_bar_background_stations);
|
||||
actionBar.setPrimaryTitle(getTitle());
|
||||
actionBar.setBack(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
actionBar.setBack(v -> finish());
|
||||
|
||||
viewAnimator = (ViewAnimator) findViewById(R.id.favorites_layout);
|
||||
|
||||
|
|
|
@ -121,11 +121,7 @@ public class LineView extends TextView {
|
|||
|
||||
// sort by count
|
||||
final List<Entry<Product, Integer>> sortedEntries = new ArrayList<>(productCounts.entrySet());
|
||||
Collections.sort(sortedEntries, new Comparator<Entry<Product, Integer>>() {
|
||||
public int compare(final Entry<Product, Integer> entry1, final Entry<Product, Integer> entry2) {
|
||||
return entry2.getValue().compareTo(entry1.getValue());
|
||||
}
|
||||
});
|
||||
Collections.sort(sortedEntries, (entry1, entry2) -> entry2.getValue().compareTo(entry1.getValue()));
|
||||
|
||||
// condense
|
||||
for (final Map.Entry<Product, Integer> entry : sortedEntries) {
|
||||
|
|
|
@ -122,43 +122,27 @@ public abstract class QueryDeparturesRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnPreExecute() {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onPreExecute();
|
||||
}
|
||||
});
|
||||
handler.post(() -> onPreExecute());
|
||||
}
|
||||
|
||||
protected void onPreExecute() {
|
||||
}
|
||||
|
||||
private void postOnPostExecute() {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onPostExecute();
|
||||
}
|
||||
});
|
||||
handler.post(() -> onPostExecute());
|
||||
}
|
||||
|
||||
protected void onPostExecute() {
|
||||
}
|
||||
|
||||
private void postOnResult(final QueryDeparturesResult result) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onResult(result);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onResult(result));
|
||||
}
|
||||
|
||||
protected abstract void onResult(QueryDeparturesResult result);
|
||||
|
||||
private void postOnRedirect(final HttpUrl url) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onRedirect(url);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onRedirect(url));
|
||||
}
|
||||
|
||||
protected void onRedirect(final HttpUrl url) {
|
||||
|
@ -166,11 +150,7 @@ public abstract class QueryDeparturesRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnBlocked(final HttpUrl url) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onBlocked(url);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onBlocked(url));
|
||||
}
|
||||
|
||||
protected void onBlocked(final HttpUrl url) {
|
||||
|
@ -178,11 +158,7 @@ public abstract class QueryDeparturesRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnInternalError(final HttpUrl url) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onInternalError(url);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onInternalError(url));
|
||||
}
|
||||
|
||||
protected void onInternalError(final HttpUrl url) {
|
||||
|
@ -190,11 +166,7 @@ public abstract class QueryDeparturesRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnParserException(final String message) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onParserException(message);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onParserException(message));
|
||||
}
|
||||
|
||||
protected void onParserException(final String message) {
|
||||
|
@ -202,11 +174,7 @@ public abstract class QueryDeparturesRunnable implements Runnable {
|
|||
}
|
||||
|
||||
private void postOnInputOutputError(final IOException x) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
onInputOutputError(x);
|
||||
}
|
||||
});
|
||||
handler.post(() -> onInputOutputError(x));
|
||||
}
|
||||
|
||||
protected void onInputOutputError(final IOException x) {
|
||||
|
|
|
@ -85,8 +85,7 @@ public class StationContextMenu extends PopupMenu {
|
|||
builder.setTitle(R.string.station_context_launcher_shortcut_title);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.create_launcher_shortcut_dialog_button_ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
final EditText nameView = (EditText) view
|
||||
.findViewById(R.id.create_launcher_shortcut_dialog_name);
|
||||
final String shortcutName = nameView.getText().toString();
|
||||
|
@ -117,7 +116,6 @@ public class StationContextMenu extends PopupMenu {
|
|||
R.mipmap.ic_oeffi_directions_color_48dp))
|
||||
.setIntent(shortcutIntent).build(),
|
||||
null);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.button_cancel, null);
|
||||
return builder.create();
|
||||
|
@ -189,11 +187,9 @@ public class StationContextMenu extends PopupMenu {
|
|||
final String planName = plansCursor
|
||||
.getString(plansCursor.getColumnIndexOrThrow(PlanContentProvider.KEY_PLAN_NAME));
|
||||
plansCursor.close();
|
||||
menu.add(planName).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
menu.add(planName).setOnMenuItemClickListener(item -> {
|
||||
PlanActivity.start(context, planId, location.id);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
stationsCursor.close();
|
||||
|
@ -203,11 +199,9 @@ public class StationContextMenu extends PopupMenu {
|
|||
private static void prepareMapMenuItem(final Context context, final MenuItem item, final Intent intent) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
item.setVisible(pm.resolveActivity(intent, 0) != null);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
item.setOnMenuItemClickListener(item1 -> {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,21 +152,12 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
|
|||
setContentView(R.layout.stations_station_details_content);
|
||||
actionBar = getMyActionBar();
|
||||
setPrimaryColor(R.color.action_bar_background_stations);
|
||||
actionBar.setBack(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
actionBar.setBack(v -> finish());
|
||||
actionBar.swapTitles();
|
||||
actionBar.addProgressButton().setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
load();
|
||||
}
|
||||
});
|
||||
actionBar.addProgressButton().setOnClickListener(v -> load());
|
||||
favoriteButton = actionBar.addToggleButton(R.drawable.ic_star_24dp,
|
||||
R.string.stations_station_details_action_favorite_title);
|
||||
favoriteButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(final ToggleImageButton buttonView, final boolean isChecked) {
|
||||
favoriteButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked) {
|
||||
final Uri rowUri = FavoriteUtils.persist(getContentResolver(),
|
||||
FavoriteStationsProvider.TYPE_FAVORITE, selectedNetwork, selectedStation);
|
||||
|
@ -181,7 +172,6 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
|
|||
FavoriteUtils.notifyFavoritesChanged(StationDetailsActivity.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
viewAnimator = (ViewAnimator) findViewById(R.id.stations_station_details_list_layout);
|
||||
|
@ -800,11 +790,7 @@ public class StationDetailsActivity extends OeffiActivity implements StationsAwa
|
|||
final Location destination = departure.destination;
|
||||
if (destination != null) {
|
||||
destinationView.setText(Constants.DESTINATION_ARROW_PREFIX + destination.uniqueShortName());
|
||||
itemView.setOnClickListener(destination.id != null ? new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
start(context, network, destination);
|
||||
}
|
||||
} : null);
|
||||
itemView.setOnClickListener(destination.id != null ? (OnClickListener) v -> start(context, network, destination) : null);
|
||||
} else {
|
||||
destinationView.setText(null);
|
||||
itemView.setOnClickListener(null);
|
||||
|
|
|
@ -195,30 +195,18 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
actionBar = getMyActionBar();
|
||||
setPrimaryColor(R.color.action_bar_background_stations);
|
||||
actionBar.setPrimaryTitle(R.string.stations_activity_title);
|
||||
actionBar.setTitlesOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
NetworkPickerActivity.start(StationsActivity.this);
|
||||
}
|
||||
});
|
||||
actionBar.addProgressButton().setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
actionBar.setTitlesOnClickListener(v -> NetworkPickerActivity.start(StationsActivity.this));
|
||||
actionBar.addProgressButton().setOnClickListener(v -> {
|
||||
for (final Station station : stations)
|
||||
station.requestedAt = null;
|
||||
handler.post(initStationsRunnable);
|
||||
}
|
||||
});
|
||||
actionBar.addButton(R.drawable.ic_search_white_24dp, R.string.stations_action_search_title)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
onSearchRequested();
|
||||
}
|
||||
});
|
||||
.setOnClickListener(v -> onSearchRequested());
|
||||
filterActionButton = actionBar.addButton(R.drawable.ic_filter_list_24dp, R.string.stations_filter_title);
|
||||
filterActionButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
filterActionButton.setOnClickListener(v -> {
|
||||
final StationsFilterPopup popup = new StationsFilterPopup(StationsActivity.this, products,
|
||||
new StationsFilterPopup.Listener() {
|
||||
public void filterChanged(final Set<Product> filter) {
|
||||
filter -> {
|
||||
final Set<Product> added = new HashSet<>(filter);
|
||||
added.removeAll(products);
|
||||
|
||||
|
@ -246,20 +234,16 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
}
|
||||
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
popup.showAsDropDown(v);
|
||||
}
|
||||
});
|
||||
actionBar.overflow(R.menu.stations_options, new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
actionBar.overflow(R.menu.stations_options, item -> {
|
||||
if (item.getItemId() == R.id.stations_options_favorites) {
|
||||
FavoriteStationsActivity.start(StationsActivity.this);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
initNavigation();
|
||||
|
@ -268,26 +252,14 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
|
||||
final Button locationPermissionRequestButton = (Button) findViewById(
|
||||
R.id.stations_location_permission_request_button);
|
||||
locationPermissionRequestButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
ActivityCompat.requestPermissions(StationsActivity.this,
|
||||
locationPermissionRequestButton.setOnClickListener(v -> ActivityCompat.requestPermissions(StationsActivity.this,
|
||||
new String[] { Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION }, 0);
|
||||
}
|
||||
});
|
||||
Manifest.permission.ACCESS_BACKGROUND_LOCATION }, 0));
|
||||
|
||||
final Button locationSettingsButton = (Button) findViewById(R.id.stations_list_location_settings);
|
||||
locationSettingsButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||
}
|
||||
});
|
||||
locationSettingsButton.setOnClickListener(v -> startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)));
|
||||
|
||||
final OnClickListener selectNetworkListener = new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
NetworkPickerActivity.start(StationsActivity.this);
|
||||
}
|
||||
};
|
||||
final OnClickListener selectNetworkListener = v -> NetworkPickerActivity.start(StationsActivity.this);
|
||||
final Button networkSettingsButton = (Button) findViewById(R.id.stations_list_empty_network_settings);
|
||||
networkSettingsButton.setOnClickListener(selectNetworkListener);
|
||||
final Button missingCapabilityButton = (Button) findViewById(R.id.stations_network_missing_capability_button);
|
||||
|
@ -597,8 +569,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
if (fixedLocation != null && fixedLocation.hasCoord())
|
||||
mapView.animateToLocation(fixedLocation.getLatAsDouble(), fixedLocation.getLonAsDouble());
|
||||
|
||||
findViewById(R.id.stations_location_clear).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
findViewById(R.id.stations_location_clear).setOnClickListener(v -> {
|
||||
fixedLocation = null;
|
||||
|
||||
if (deviceLocation != null) {
|
||||
|
@ -626,7 +597,6 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
|
||||
handler.post(initStationsRunnable);
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
|
||||
handler.post(initStationsRunnable);
|
||||
|
@ -652,11 +622,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
private void setListFilter(final String filter) {
|
||||
searchQuery = filter;
|
||||
|
||||
findViewById(R.id.stations_search_clear).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
clearListFilter();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.stations_search_clear).setOnClickListener(v -> clearListFilter());
|
||||
|
||||
stations.clear();
|
||||
stationsMap.clear();
|
||||
|
@ -777,17 +743,11 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
final DialogBuilder builder = DialogBuilder.warn(this, R.string.stations_nearby_stations_error_title);
|
||||
builder.setMessage(getString(R.string.stations_nearby_stations_error_message));
|
||||
builder.setPositiveButton(getString(R.string.stations_nearby_stations_error_continue),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
(dialog, _id) -> dialog.dismiss());
|
||||
builder.setNegativeButton(getString(R.string.stations_nearby_stations_error_exit),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
(dialog, _id) -> {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
@ -825,14 +785,11 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
if (favoriteIds.length() != 0)
|
||||
favoriteIds.setLength(favoriteIds.length() - 1);
|
||||
|
||||
backgroundHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
backgroundHandler.post(() -> {
|
||||
runOnUiThread(() -> {
|
||||
actionBar.startProgress();
|
||||
loading = true;
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
|
||||
final Builder uriBuilder = NetworkContentProvider.CONTENT_URI.buildUpon();
|
||||
|
@ -883,7 +840,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
products = Product.fromCodes(cursor.getString(productsColumnIndex).toCharArray());
|
||||
else
|
||||
products = null;
|
||||
final Station station = new Station(network, new de.schildbach.pte.dto.Location(
|
||||
final Station station = new Station(network, new Location(
|
||||
LocationType.STATION, id, coord, place, name, products), lineDestinations);
|
||||
if (deviceLocation != null) {
|
||||
android.location.Location.distanceBetween(referenceLocation.getLatAsDouble(),
|
||||
|
@ -896,21 +853,14 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
|
||||
cursor.close();
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mergeIntoStations(freshStations, true);
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> mergeIntoStations(freshStations, true));
|
||||
}
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
actionBar.stopProgress();
|
||||
loading = false;
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1032,11 +982,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
}
|
||||
|
||||
if (added) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
mapView.zoomToStations(stations);
|
||||
}
|
||||
}, 500);
|
||||
handler.postDelayed(() -> mapView.zoomToStations(stations), 500);
|
||||
}
|
||||
|
||||
updateGUI();
|
||||
|
@ -1065,8 +1011,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
}
|
||||
|
||||
private static void sortStations(final List<Station> stations) {
|
||||
Collections.sort(stations, new Comparator<Station>() {
|
||||
public int compare(final Station station1, final Station station2) {
|
||||
Collections.sort(stations, (station1, station2) -> {
|
||||
ComparisonChain chain = ComparisonChain.start();
|
||||
|
||||
// order by distance
|
||||
|
@ -1091,7 +1036,6 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
}
|
||||
|
||||
return chain.result();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1183,58 +1127,40 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
protected void onRedirect(final HttpUrl url) {
|
||||
log.info("Redirect while querying departures on {}", requestedStationId);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(StationsActivity.this).toast(R.string.toast_network_problem);
|
||||
}
|
||||
});
|
||||
handler.post(() -> new Toast(StationsActivity.this).toast(R.string.toast_network_problem));
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onBlocked(final HttpUrl url) {
|
||||
log.info("Blocked querying departures on {}", requestedStationId);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(StationsActivity.this).toast(R.string.toast_network_blocked,
|
||||
url.host());
|
||||
}
|
||||
});
|
||||
handler.post(() -> new Toast(StationsActivity.this).toast(R.string.toast_network_blocked,
|
||||
url.host()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInternalError(final HttpUrl url) {
|
||||
log.info("Internal error querying departures on {}", requestedStationId);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(StationsActivity.this).toast(R.string.toast_internal_error,
|
||||
url.host());
|
||||
}
|
||||
});
|
||||
handler.post(() -> new Toast(StationsActivity.this).toast(R.string.toast_internal_error,
|
||||
url.host()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onParserException(final String message) {
|
||||
log.info("Cannot parse departures on {}: {}", requestedStationId, message);
|
||||
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
handler.post(() -> {
|
||||
final String limitedMessage = message != null
|
||||
? message.substring(0, Math.min(100, message.length())) : null;
|
||||
new Toast(StationsActivity.this).toast(R.string.toast_invalid_data,
|
||||
limitedMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInputOutputError(final IOException x) {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
new Toast(StationsActivity.this).toast(R.string.toast_network_problem);
|
||||
}
|
||||
});
|
||||
handler.post(() -> new Toast(StationsActivity.this).toast(R.string.toast_network_problem));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1571,8 +1497,7 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
|
||||
lastTime = System.currentTimeMillis();
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
runOnUiThread(() -> {
|
||||
deviceBearing = azimuth;
|
||||
stationListAdapter.setDeviceBearing(azimuth, faceDown);
|
||||
|
||||
|
@ -1584,7 +1509,6 @@ public class StationsActivity extends OeffiMainActivity implements StationsAware
|
|||
if (bearingView != null)
|
||||
bearingView.invalidate();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -60,12 +60,10 @@ public class FavoriteStationViewHolder extends RecyclerView.ViewHolder {
|
|||
final long selectedRowId) {
|
||||
final boolean selected = rowId == selectedRowId;
|
||||
itemView.setActivated(selected);
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
final int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
clickListener.onStationClick(position, network, station);
|
||||
}
|
||||
});
|
||||
|
||||
if (showNetwork) {
|
||||
|
@ -84,22 +82,18 @@ public class FavoriteStationViewHolder extends RecyclerView.ViewHolder {
|
|||
|
||||
if (contextMenuItemListener != null) {
|
||||
contextButton.setVisibility(View.VISIBLE);
|
||||
contextButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
contextButton.setOnClickListener(v -> {
|
||||
final PopupMenu contextMenu = new StationContextMenu(context, v, network, station,
|
||||
FavoriteStationsProvider.TYPE_FAVORITE, true, false, true, false, false);
|
||||
contextMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
contextMenu.setOnMenuItemClickListener(item -> {
|
||||
final int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
return contextMenuItemListener.onStationContextMenuItemClick(position, network, station,
|
||||
null, item.getItemId());
|
||||
else
|
||||
return false;
|
||||
}
|
||||
});
|
||||
contextMenu.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
contextButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -185,22 +185,18 @@ public class StationViewHolder extends RecyclerView.ViewHolder {
|
|||
// context button
|
||||
contextButton.setVisibility(itemView.isActivated() ? View.VISIBLE : View.GONE);
|
||||
contextButtonSpace.setVisibility(itemView.isActivated() ? View.VISIBLE : View.GONE);
|
||||
contextButton.setOnClickListener(itemView.isActivated() ? new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
contextButton.setOnClickListener(itemView.isActivated() ? (View.OnClickListener) v -> {
|
||||
final PopupMenu contextMenu = new StationContextMenu(context, v, station.network, station.location,
|
||||
favState, true, true, true, true, true);
|
||||
contextMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
contextMenu.setOnMenuItemClickListener(item -> {
|
||||
final int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
return contextMenuItemListener.onStationContextMenuItemClick(position, station.network,
|
||||
station.location, station.departures, item.getItemId());
|
||||
else
|
||||
return false;
|
||||
}
|
||||
});
|
||||
contextMenu.show();
|
||||
}
|
||||
} : null);
|
||||
|
||||
// departures
|
||||
|
|
|
@ -104,12 +104,9 @@ public class StationsAdapter extends RecyclerView.Adapter<StationViewHolder> imp
|
|||
|
||||
// select stations
|
||||
holder.itemView.setActivated(stationsAware.isSelectedStation(station.location.id));
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
final boolean isSelected = stationsAware.isSelectedStation(station.location.id);
|
||||
stationsAware.selectStation(isSelected ? null : station);
|
||||
}
|
||||
});
|
||||
|
||||
// populate view
|
||||
|
|
|
@ -77,10 +77,6 @@ public class ChangelogDialogBuilder extends AlertDialog.Builder {
|
|||
: "") + context.getString(R.string.changelog_dialog_title));
|
||||
setView(view);
|
||||
setPositiveButton(context.getString(R.string.changelog_dialog_button_dismiss),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
(dialog, id) -> dialog.dismiss());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,7 @@ public class CheatSheet {
|
|||
* The view to add a cheat sheet for.
|
||||
*/
|
||||
public static void setup(View view) {
|
||||
view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
return showCheatSheet(view, view.getContentDescription());
|
||||
}
|
||||
});
|
||||
view.setOnLongClickListener(v -> showCheatSheet(v, v.getContentDescription()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,12 +64,7 @@ public class CheatSheet {
|
|||
* The string resource containing the text to show on long-press.
|
||||
*/
|
||||
public static void setup(View view, final int textResId) {
|
||||
view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
return showCheatSheet(view, view.getContext().getString(textResId));
|
||||
}
|
||||
});
|
||||
view.setOnLongClickListener(v -> showCheatSheet(v, v.getContext().getString(textResId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,12 +78,7 @@ public class CheatSheet {
|
|||
* The text to show on long-press.
|
||||
*/
|
||||
public static void setup(View view, final CharSequence text) {
|
||||
view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
return showCheatSheet(view, text);
|
||||
}
|
||||
});
|
||||
view.setOnLongClickListener(v -> showCheatSheet(v, text));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -356,11 +356,7 @@ public class ErrorReporter implements Thread.UncaughtExceptionHandler {
|
|||
}
|
||||
|
||||
private void callback(final String newVersion) {
|
||||
callbackHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
dialog(context, newVersion);
|
||||
}
|
||||
});
|
||||
callbackHandler.post(() -> dialog(context, newVersion));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -369,39 +365,25 @@ public class ErrorReporter implements Thread.UncaughtExceptionHandler {
|
|||
final DialogBuilder builder = DialogBuilder.warn(context, R.string.alert_crash_report_title);
|
||||
builder.setMessage(newVersion != null ? context.getString(R.string.alert_crash_report_new_version, newVersion)
|
||||
: context.getString(R.string.alert_crash_report_message));
|
||||
builder.setNegativeButton(R.string.alert_crash_report_negative, new OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
stackTraceFile.delete();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.alert_crash_report_negative, (dialog, which) -> stackTraceFile.delete());
|
||||
if (newVersion != null) {
|
||||
builder.setNeutralButton(R.string.alert_crash_report_update, new OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setNeutralButton(R.string.alert_crash_report_update, (dialog, which) -> {
|
||||
stackTraceFile.delete();
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id=" + context.getPackageName())));
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(R.string.alert_crash_report_download, new OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setPositiveButton(R.string.alert_crash_report_download, (dialog, which) -> {
|
||||
stackTraceFile.delete();
|
||||
context.startActivity(
|
||||
new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.OEFFI_BASE_URL + "download.html")));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.setPositiveButton(R.string.alert_crash_report_positive, new OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
builder.setPositiveButton(R.string.alert_crash_report_positive, (dialog, which) -> {
|
||||
sendError(context);
|
||||
stackTraceFile.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
builder.setOnCancelListener(new OnCancelListener() {
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
stackTraceFile.delete();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(dialog -> stackTraceFile.delete());
|
||||
|
||||
try {
|
||||
builder.show();
|
||||
|
|
|
@ -98,21 +98,13 @@ public class GeocoderThread extends Thread {
|
|||
private void onResult(final Address address) {
|
||||
log.info("Geocoder took {} ms, returned {}", System.currentTimeMillis() - startTime, address);
|
||||
|
||||
callbackHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
callback.onGeocoderResult(address);
|
||||
}
|
||||
});
|
||||
callbackHandler.post(() -> callback.onGeocoderResult(address));
|
||||
}
|
||||
|
||||
private void onFail(final Exception exception) {
|
||||
log.info("Geocoder failed: {}", exception.getMessage());
|
||||
|
||||
callbackHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
callback.onGeocoderFail(exception);
|
||||
}
|
||||
});
|
||||
callbackHandler.post(() -> callback.onGeocoderFail(exception));
|
||||
}
|
||||
|
||||
public static Location addressToLocation(final Address address) {
|
||||
|
|
|
@ -105,11 +105,9 @@ public final class LocationHelper {
|
|||
manager.requestLocationUpdates(provider, 0, 0, listener);
|
||||
|
||||
if (timeout > 0) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
handler.postDelayed(() -> {
|
||||
log.info("LocationHelper timed out");
|
||||
stop(true);
|
||||
}
|
||||
}, timeout);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -114,11 +114,7 @@ public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAd
|
|||
itemView.setActivated(item.isChecked());
|
||||
itemView.setFocusable(item.isEnabled());
|
||||
if (item.isEnabled()) {
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
menuClickListener.onMenuItemClick(item);
|
||||
}
|
||||
});
|
||||
itemView.setOnClickListener(v -> menuClickListener.onMenuItemClick(item));
|
||||
}
|
||||
|
||||
final boolean primaryItem = item.getTitleCondensed() != null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue