use of im.tny.segvault.disturbances.MainService in project underlx by underlx.
the class HomeFragment method refreshCurrentTrip.
private void refreshCurrentTrip() {
if (mListener == null)
return;
final MainService m = mListener.getMainService();
if (m == null)
return;
S2LS loc = m.getS2LS(MainService.PRIMARY_NETWORK_ID);
if (loc == null || loc.getCurrentTrip() == null) {
ongoingTripCard.setVisibility(View.GONE);
} else {
final Station station = loc.getCurrentTrip().getCurrentStop().getStation();
curStationNameView.setText(station.getName());
Stop direction = loc.getCurrentTrip().getDirection();
Stop next = loc.getCurrentTrip().getNextStop();
if (direction != null && next != null) {
directionView.setText(String.format(getString(R.string.frag_home_trip_direction), direction.getStation().getName()));
nextStationView.setText(String.format(getString(R.string.frag_home_trip_next_station), next.getStation().getName()));
Stop likelyExit = m.getLikelyNextExit(loc.getCurrentTrip().getEdgeList(), 1);
int resId = android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Small;
if (next == likelyExit) {
resId = android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Medium;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
nextStationView.setTextAppearance(resId);
} else {
nextStationView.setTextAppearance(getContext(), resId);
}
directionView.setVisibility(View.VISIBLE);
nextStationView.setVisibility(View.VISIBLE);
} else {
directionView.setVisibility(View.GONE);
nextStationView.setVisibility(View.GONE);
}
redrawCurrentStationLineIcons(station);
curStationLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getContext(), StationActivity.class);
intent.putExtra(StationActivity.EXTRA_STATION_ID, station.getId());
intent.putExtra(StationActivity.EXTRA_NETWORK_ID, MainService.PRIMARY_NETWORK_ID);
startActivity(intent);
}
});
curTripIncorrectLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new FeedbackUtil.IncorrectLocation(getContext(), m, station).showReportWizard();
}
});
if (loc.canRequestEndOfTrip()) {
curTripEndButton.setVisibility(View.VISIBLE);
curTripIncorrectLocationButton.setVisibility(View.GONE);
} else {
curTripEndButton.setVisibility(View.GONE);
curTripIncorrectLocationButton.setVisibility(View.VISIBLE);
}
ongoingTripCard.setVisibility(View.VISIBLE);
}
}
use of im.tny.segvault.disturbances.MainService in project underlx by underlx.
the class HomeFragment method refresh.
private void refresh(boolean requestOnlineUpdate) {
Realm realm = Application.getDefaultRealmInstance(getContext());
boolean hasTripsToConfirm = Trip.getMissingConfirmTrips(realm).size() > 0;
realm.close();
if (hasTripsToConfirm) {
if (unconfirmedTripsCard.getVisibility() == View.GONE) {
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
Fragment newFragment = UnconfirmedTripsFragment.newInstance(1);
transaction.replace(R.id.unconfirmed_trips_card, newFragment);
transaction.commitAllowingStateLoss();
unconfirmedTripsCard.setVisibility(View.VISIBLE);
}
} else {
unconfirmedTripsCard.setVisibility(View.GONE);
}
if (mListener == null)
return;
MainService m = mListener.getMainService();
if (m == null)
return;
if (requestOnlineUpdate) {
m.getLineStatusCache().updateLineStatus();
m.getStatsCache().updateStats();
}
Network net = m.getNetwork(MainService.PRIMARY_NETWORK_ID);
if (net == null) {
networkClosedCard.setVisibility(View.GONE);
unconfirmedTripsCard.setVisibility(View.GONE);
m.checkForTopologyUpdates();
} else if (net.isOpen()) {
networkClosedCard.setVisibility(View.GONE);
} else {
Formatter f = new Formatter();
DateUtils.formatDateRange(getContext(), f, net.getNextOpenTime(), net.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, net.getTimezone().getID());
networkClosedView.setText(String.format(getString(R.string.warning_network_closed), f.toString()));
networkClosedCard.setVisibility(View.VISIBLE);
}
recomputeShortcutVisibility();
}
use of im.tny.segvault.disturbances.MainService in project underlx by underlx.
the class TripFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_trip, container, false);
layoutRoute = (LinearLayout) view.findViewById(R.id.layout_route);
stationNamesView = (TextView) view.findViewById(R.id.station_names_view);
dateView = (TextView) view.findViewById(R.id.date_view);
correctButton = (Button) view.findViewById(R.id.correct_button);
deleteButton = (Button) view.findViewById(R.id.delete_button);
statsLayout = (LinearLayout) view.findViewById(R.id.layout_stats);
statsView = (TextView) view.findViewById(R.id.stats_view);
if (mListener == null)
return view;
MainService service = mListener.getMainService();
if (service == null)
return view;
network = service.getNetwork(networkId);
correctButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), TripCorrectionActivity.class);
intent.putExtra(TripCorrectionActivity.EXTRA_NETWORK_ID, networkId);
intent.putExtra(TripCorrectionActivity.EXTRA_TRIP_ID, tripId);
startActivity(intent);
}
});
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.frag_trip_delete_confirm_title).setMessage(R.string.frag_trip_delete_confirm_desc).setPositiveButton(R.string.frag_trip_delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
deleteTrip();
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
}).show();
}
});
this.inflater = inflater;
refreshUI();
return view;
}
use of im.tny.segvault.disturbances.MainService in project underlx by underlx.
the class StationGeneralFragment method update.
private void update() {
if (mListener == null)
return;
MainService service = mListener.getMainService();
if (service == null)
return;
Network net = service.getNetwork(networkId);
if (net == null)
return;
final Station station = net.getStation(stationId);
if (station == null)
return;
if (station.isAlwaysClosed()) {
LinearLayout closedLayout = (LinearLayout) view.findViewById(R.id.closed_info_layout);
closedLayout.setVisibility(View.VISIBLE);
} else if (station.isExceptionallyClosed(net, new Date())) {
TextView closedView = (TextView) view.findViewById(R.id.closed_info_view);
Formatter f = new Formatter();
DateUtils.formatDateRange(getContext(), f, station.getNextOpenTime(net), station.getNextOpenTime(net), DateUtils.FORMAT_SHOW_TIME, net.getTimezone().getID());
closedView.setText(String.format(getString(R.string.frag_station_closed_schedule), f.toString()));
LinearLayout closedLayout = (LinearLayout) view.findViewById(R.id.closed_info_layout);
closedLayout.setVisibility(View.VISIBLE);
}
// Connections
TextView connectionsTitleView = (TextView) view.findViewById(R.id.connections_title_view);
// buttons
Button busButton = (Button) view.findViewById(R.id.connections_bus_button);
if (station.hasConnectionUrl(Station.CONNECTION_TYPE_BUS)) {
busButton.setVisibility(View.VISIBLE);
busButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ExtraContentCache.getConnectionInfo(getContext(), new ConnectionInfoReadyListener(), Station.CONNECTION_TYPE_BUS, station);
}
});
connectionsTitleView.setVisibility(View.VISIBLE);
}
Button boatButton = (Button) view.findViewById(R.id.connections_boat_button);
if (station.hasConnectionUrl(Station.CONNECTION_TYPE_BOAT)) {
boatButton.setVisibility(View.VISIBLE);
boatButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ExtraContentCache.getConnectionInfo(getContext(), new ConnectionInfoReadyListener(), Station.CONNECTION_TYPE_BOAT, station);
}
});
connectionsTitleView.setVisibility(View.VISIBLE);
}
Button trainButton = (Button) view.findViewById(R.id.connections_train_button);
if (station.hasConnectionUrl(Station.CONNECTION_TYPE_TRAIN)) {
trainButton.setVisibility(View.VISIBLE);
trainButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ExtraContentCache.getConnectionInfo(getContext(), new ConnectionInfoReadyListener(), Station.CONNECTION_TYPE_TRAIN, station);
}
});
connectionsTitleView.setVisibility(View.VISIBLE);
}
// icons
LinearLayout busLayout = (LinearLayout) view.findViewById(R.id.feature_bus_layout);
if (station.getFeatures().bus) {
busLayout.setVisibility(View.VISIBLE);
connectionsTitleView.setVisibility(View.VISIBLE);
}
LinearLayout boatLayout = (LinearLayout) view.findViewById(R.id.feature_boat_layout);
if (station.getFeatures().boat) {
boatLayout.setVisibility(View.VISIBLE);
connectionsTitleView.setVisibility(View.VISIBLE);
}
LinearLayout trainLayout = (LinearLayout) view.findViewById(R.id.feature_train_layout);
if (station.getFeatures().train) {
trainLayout.setVisibility(View.VISIBLE);
connectionsTitleView.setVisibility(View.VISIBLE);
}
LinearLayout airportLayout = (LinearLayout) view.findViewById(R.id.feature_airport_layout);
if (station.getFeatures().airport) {
airportLayout.setVisibility(View.VISIBLE);
connectionsTitleView.setVisibility(View.VISIBLE);
}
// Accessibility
TextView accessibilityTitleView = (TextView) view.findViewById(R.id.accessibility_title_view);
LinearLayout liftLayout = (LinearLayout) view.findViewById(R.id.feature_lift_layout);
if (station.getFeatures().lift) {
liftLayout.setVisibility(View.VISIBLE);
accessibilityTitleView.setVisibility(View.VISIBLE);
}
// Services
TextView servicesTitleView = (TextView) view.findViewById(R.id.services_title_view);
Button parkButton = (Button) view.findViewById(R.id.connections_park_button);
if (station.hasConnectionUrl(Station.CONNECTION_TYPE_PARK)) {
parkButton.setVisibility(View.VISIBLE);
parkButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ExtraContentCache.getConnectionInfo(getContext(), new ConnectionInfoReadyListener(), Station.CONNECTION_TYPE_PARK, station);
}
});
servicesTitleView.setVisibility(View.VISIBLE);
}
Button bikeButton = (Button) view.findViewById(R.id.connections_bike_button);
if (station.hasConnectionUrl(Station.CONNECTION_TYPE_BIKE)) {
bikeButton.setVisibility(View.VISIBLE);
bikeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ExtraContentCache.getConnectionInfo(getContext(), new ConnectionInfoReadyListener(), Station.CONNECTION_TYPE_BIKE, station);
}
});
servicesTitleView.setVisibility(View.VISIBLE);
}
LinearLayout wifiLayout = (LinearLayout) view.findViewById(R.id.service_wifi_layout);
if (station.getFeatures().wifi) {
wifiLayout.setVisibility(View.VISIBLE);
servicesTitleView.setVisibility(View.VISIBLE);
}
LinearLayout parkLayout = (LinearLayout) view.findViewById(R.id.service_park_layout);
if (station.getFeatures().parking) {
parkLayout.setVisibility(View.VISIBLE);
servicesTitleView.setVisibility(View.VISIBLE);
}
LinearLayout bikeLayout = (LinearLayout) view.findViewById(R.id.service_bike_layout);
if (station.getFeatures().bike) {
bikeLayout.setVisibility(View.VISIBLE);
servicesTitleView.setVisibility(View.VISIBLE);
}
// Statistics
Realm realm = Application.getDefaultRealmInstance(getContext());
TextView statsEntryCountView = (TextView) view.findViewById(R.id.station_entry_count_view);
long entryCount = realm.where(StationUse.class).equalTo("station.id", station.getId()).equalTo("type", StationUse.UseType.NETWORK_ENTRY.name()).count();
statsEntryCountView.setText(String.format(getString(R.string.frag_station_stats_entry), entryCount));
TextView statsExitCountView = (TextView) view.findViewById(R.id.station_exit_count_view);
long exitCount = realm.where(StationUse.class).equalTo("station.id", station.getId()).equalTo("type", StationUse.UseType.NETWORK_EXIT.name()).count();
statsExitCountView.setText(String.format(getString(R.string.frag_station_stats_exit), exitCount));
TextView statsGoneThroughCountView = (TextView) view.findViewById(R.id.station_gone_through_count_view);
long goneThroughCount = realm.where(StationUse.class).equalTo("station.id", station.getId()).equalTo("type", StationUse.UseType.GONE_THROUGH.name()).count();
statsGoneThroughCountView.setText(String.format(getString(R.string.frag_station_stats_gone_through), goneThroughCount));
TextView statsTransferCountView = (TextView) view.findViewById(R.id.station_transfer_count_view);
if (station.getLines().size() > 1) {
long transferCount = realm.where(StationUse.class).equalTo("station.id", station.getId()).equalTo("type", StationUse.UseType.INTERCHANGE.name()).count();
statsTransferCountView.setText(String.format(getString(R.string.frag_station_stats_transfer), transferCount));
statsTransferCountView.setVisibility(View.VISIBLE);
} else {
statsTransferCountView.setVisibility(View.GONE);
}
realm.close();
}
use of im.tny.segvault.disturbances.MainService in project underlx by underlx.
the class FinishIntroSlide method refresh.
private void refresh() {
if (mListener == null || mListener.getMainService() == null) {
return;
}
final MainService m = mListener.getMainService();
if (m.getNetworks().size() == 0) {
title.setText(R.string.intro_finish_wait_title);
if (!Connectivity.isConnected(getContext())) {
image.setImageResource(R.drawable.ic_frowning_intro);
description.setText(R.string.intro_finish_connect_desc);
button.setText(R.string.intro_finish_try_again);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
m.updateTopology();
}
});
button.setVisibility(View.VISIBLE);
} else {
image.setImageResource(R.drawable.ic_hourglass_flowing_sand_intro);
description.setText(String.format(getString(R.string.intro_finish_downloading), lastKnownPercentage));
button.setVisibility(View.GONE);
}
canLeave = false;
} else {
title.setText(R.string.intro_finish_done_title);
image.setImageResource(R.drawable.ic_ok_hand_intro);
description.setText(R.string.intro_finish_done_desc);
button.setText(R.string.intro_finish_get_started);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onDonePressed(FinishIntroSlide.this);
}
});
button.setVisibility(View.VISIBLE);
canLeave = true;
}
}
Aggregations