Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/adapters/SquareStopAdapter.java
Show All 22 Lines | |||||
import android.util.Log; | import android.util.Log; | ||||
import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
import android.view.View; | import android.view.View; | ||||
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.backend.Stop; | import it.reyboz.bustorino.backend.Stop; | ||||
import it.reyboz.bustorino.util.StopSorterByDistance; | import it.reyboz.bustorino.util.StopSorterByDistance; | ||||
import it.reyboz.bustorino.fragments.FragmentListener; | import it.reyboz.bustorino.fragments.FragmentListenerMain; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
public class SquareStopAdapter extends RecyclerView.Adapter<SquareStopAdapter.SquareViewHolder> { | public class SquareStopAdapter extends RecyclerView.Adapter<SquareStopAdapter.SquareViewHolder> { | ||||
private final static int layoutRes = R.layout.stop_card; | private final static int layoutRes = R.layout.stop_card; | ||||
//private List<Stop> stops; | //private List<Stop> stops; | ||||
private @Nullable Location userPosition; | private @Nullable Location userPosition; | ||||
private FragmentListener listener; | private FragmentListenerMain listener; | ||||
private List<Stop> stops; | private List<Stop> stops; | ||||
public SquareStopAdapter(@Nullable List<Stop> stopList, FragmentListener fragmentListener, @Nullable Location pos) { | public SquareStopAdapter(@Nullable List<Stop> stopList, FragmentListenerMain fragmentListener, @Nullable Location pos) { | ||||
listener = fragmentListener; | listener = fragmentListener; | ||||
userPosition = pos; | userPosition = pos; | ||||
stops = stopList; | stops = stopList; | ||||
} | } | ||||
@Override | @Override | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | class SquareViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { | ||||
stopIDView = (TextView) holdView.findViewById(R.id.stop_numberText); | stopIDView = (TextView) holdView.findViewById(R.id.stop_numberText); | ||||
stopNameView = (TextView) holdView.findViewById(R.id.stop_nameText); | stopNameView = (TextView) holdView.findViewById(R.id.stop_nameText); | ||||
routesView = (TextView) holdView.findViewById(R.id.stop_linesText); | routesView = (TextView) holdView.findViewById(R.id.stop_linesText); | ||||
distancetextView = (TextView) holdView.findViewById(R.id.stop_distanceTextView); | distancetextView = (TextView) holdView.findViewById(R.id.stop_distanceTextView); | ||||
} | } | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
listener.createFragmentForStop(stopID); | listener.requestArrivalsForStopID(stopID); | ||||
} | } | ||||
} | } | ||||
public void setStops(List<Stop> stops) { | public void setStops(List<Stop> stops) { | ||||
this.stops = stops; | this.stops = stops; | ||||
} | } | ||||
Show All 10 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register