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