use of im.tny.segvault.subway.Network in project underlx by underlx.
the class StationLobbyFragment 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;
// Lobbies
final int[] lobbyColors = Util.lobbyColors.clone();
if (station.getLobbies().size() == 1) {
lobbyColors[0] = Color.BLACK;
}
int curLobbyColorIdx = 0;
for (Lobby lobby : station.getLobbies()) {
LobbyView v = new LobbyView(getContext(), lobby, lobbyColors[curLobbyColorIdx]);
v.setInteractionListener(new LobbyView.OnViewInteractionListener() {
@Override
public void onExitClicked(Lobby.Exit exit) {
if (googleMap == null || !mapLayoutReady) {
return;
}
Marker marker = markers.get(exit);
if (marker != null) {
marker.showInfoWindow();
}
lobbyScrollView.fullScroll(NestedScrollView.FOCUS_UP);
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.fromLatLngZoom(marker.getPosition(), googleMap.getCameraPosition().zoom)));
}
});
lobbiesLayout.addView(v);
curLobbyColorIdx = (curLobbyColorIdx + 1) % lobbyColors.length;
}
final int preselExit = mListener.getPreselectedExitId();
final ViewTreeObserver vto = mapView.getViewTreeObserver();
if (vto.isAlive()) {
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
mapLayoutReady = true;
trySetupMap(station, lobbyColors, preselExit);
// remove the listener... or we'll be doing this a lot.
ViewTreeObserver obs = mapView.getViewTreeObserver();
obs.removeGlobalOnLayoutListener(this);
}
});
}
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap mMap) {
googleMap = mMap;
trySetupMap(station, lobbyColors, preselExit);
}
});
}
use of im.tny.segvault.subway.Network in project underlx by underlx.
the class AboutFragment method refreshDatasetInfo.
private void refreshDatasetInfo() {
if (mListener != null) {
networksLayout.removeAllViews();
for (Network n : mListener.getNetworks()) {
DatasetInfoView d = new DatasetInfoView(getContext(), n, this);
networksLayout.addView(d);
}
}
}
use of im.tny.segvault.subway.Network in project underlx by underlx.
the class StationTriviaFragment 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;
Station station = net.getStation(stationId);
if (station == null)
return;
ExtraContentCache.getTrivia(getContext(), new ExtraContentCache.OnTriviaReadyListener() {
@Override
public void onSuccess(List<String> trivia) {
if (isAdded()) {
triviaView.setHtml(trivia.get(0));
}
}
@Override
public void onProgress(int current) {
}
@Override
public void onFailure() {
if (isAdded()) {
triviaView.setHtml(getString(R.string.frag_station_info_unavailable));
}
}
}, station);
}
use of im.tny.segvault.subway.Network in project underlx by underlx.
the class NotifPreferenceFragment method updateLinesPreference.
private void updateLinesPreference() {
MultiSelectListPreference linesPreference;
linesPreference = (MultiSelectListPreference) findPreference(PreferenceNames.NotifsLines);
List<CharSequence> lineNames = new ArrayList<>();
List<CharSequence> lineIDs = new ArrayList<>();
List<Line> lines = new LinkedList<>();
if (mListener != null && mListener.getMainService() != null) {
for (Network n : mListener.getMainService().getNetworks()) {
lines.addAll(n.getLines());
}
Collections.sort(lines, new Comparator<Line>() {
@Override
public int compare(Line line, Line t1) {
return Integer.valueOf(line.getOrder()).compareTo(t1.getOrder());
}
});
for (Line l : lines) {
lineNames.add(Util.getLineNames(getContext(), l)[0]);
lineIDs.add(l.getId());
}
}
linesPreference.setEntries(lineNames.toArray(new CharSequence[lineNames.size()]));
linesPreference.setEntryValues(lineIDs.toArray(new CharSequence[lineIDs.size()]));
updateLinesPreferenceSummary(linesPreference, linesPreference.getValues());
linesPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
MultiSelectListPreference multilistPreference = (MultiSelectListPreference) preference;
@SuppressWarnings("unchecked") Set<String> values = (Set<String>) newValue;
updateLinesPreferenceSummary(multilistPreference, values);
return true;
}
});
}
use of im.tny.segvault.subway.Network in project underlx by underlx.
the class DisturbancesIntroSlide method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_intro_disturbances, container, false);
((Button) view.findViewById(R.id.select_lines_button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<Line> lines = new LinkedList<>();
if (mListener != null && mListener.getMainService() != null) {
for (Network n : mListener.getMainService().getNetworks()) {
lines.addAll(n.getLines());
}
Collections.sort(lines, new Comparator<Line>() {
@Override
public int compare(Line line, Line t1) {
return Integer.valueOf(line.getOrder()).compareTo(t1.getOrder());
}
});
}
if (lines.size() == 0) {
if (Connectivity.isConnected(getContext())) {
Snackbar.make(view, R.string.intro_disturbances_misc_error, Snackbar.LENGTH_LONG).show();
} else {
Snackbar.make(view, R.string.intro_disturbances_connection_error, Snackbar.LENGTH_LONG).show();
}
return;
}
view.findViewById(R.id.description_layout).setVisibility(View.GONE);
view.findViewById(R.id.select_lines_button).setVisibility(View.GONE);
LinearLayout checkboxLayout = (LinearLayout) view.findViewById(R.id.checkbox_layout);
SharedPreferences sharedPref = getContext().getSharedPreferences("notifsettings", Context.MODE_PRIVATE);
Set<String> linePref = sharedPref.getStringSet(PreferenceNames.NotifsLines, null);
for (final Line l : lines) {
AppCompatCheckBox checkBox = new AppCompatCheckBox(view.getContext());
checkBox.setText(Util.getLineNames(getContext(), l)[0]);
checkBox.setTextColor(Color.WHITE);
ColorStateList colorStateList = new ColorStateList(new int[][] { // unchecked
new int[] { -android.R.attr.state_checked }, // checked
new int[] { android.R.attr.state_checked } }, new int[] { l.getColor(), l.getColor() });
CompoundButtonCompat.setButtonTintList(checkBox, colorStateList);
checkBox.setChecked(linePref == null || linePref.contains(l.getId()));
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateShowLineNotifs(l.getId(), isChecked);
}
});
checkboxLayout.addView(checkBox);
}
view.findViewById(R.id.lines_layout).setVisibility(View.VISIBLE);
}
});
return view;
}
Aggregations