Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/adapters/StopRecyclerAdapter.java
Show All 11 Lines | BusTO - Adapter components | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.adapters; | package it.reyboz.bustorino.adapters; | ||||
import android.util.Log; | |||||
import android.view.ContextMenu; | import android.view.ContextMenu; | ||||
import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
import android.view.MenuInflater; | import android.view.MenuInflater; | ||||
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 androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||
import java.util.List; | import java.util.List; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.backend.Stop; | import it.reyboz.bustorino.backend.Stop; | ||||
public class StopRecyclerAdapter extends RecyclerView.Adapter<StopRecyclerAdapter.ViewHolder> { | public class StopRecyclerAdapter extends RecyclerView.Adapter<StopRecyclerAdapter.ViewHolder> { | ||||
private List<Stop> stops; | private List<Stop> stops; | ||||
private static final int ITEM_LAYOUT_FAVORITES = R.layout.entry_bus_stop; | private static final int ITEM_LAYOUT_FAVORITES = R.layout.entry_bus_stop; | ||||
private static final int ITEM_LAYOUT_LINES = R.layout.bus_stop_line_elmt; | private static final int ITEM_LAYOUT_LINES = R.layout.stop_line_element; | ||||
private static final int busIcon = R.drawable.bus; | private static final int busIcon = R.drawable.bus; | ||||
private static final int trainIcon = R.drawable.subway; | private static final int trainIcon = R.drawable.subway; | ||||
private static final int tramIcon = R.drawable.tram; | private static final int tramIcon = R.drawable.tram; | ||||
private static final int cityIcon = R.drawable.city; | private static final int cityIcon = R.drawable.city; | ||||
private NameCapitalize capitalizeLocation = NameCapitalize.DO_NOTHING; | private NameCapitalize capitalizeLocation = NameCapitalize.DO_NOTHING; | ||||
private final Use usedFor; | private final Use usedFor; | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | public void onBindViewHolder(@NonNull StopRecyclerAdapter.ViewHolder vh, int position) { | ||||
return false; | return false; | ||||
}); | }); | ||||
if(this.usedFor == Use.LINES){ | if(this.usedFor == Use.LINES){ | ||||
//vh.menuResID; | //vh.menuResID; | ||||
vh.bottomStub.setVisibility(View.VISIBLE); | vh.bottomStub.setVisibility(View.VISIBLE); | ||||
vh.topStub.setVisibility(View.VISIBLE); | vh.topStub.setVisibility(View.VISIBLE); | ||||
if(position == 0) { | if(position == 0) { | ||||
vh.topStub.setVisibility(View.GONE); | vh.topStub.setVisibility(View.INVISIBLE); | ||||
} | } | ||||
else if (position == stops.size()-1) { | else if (position == stops.size()-1) { | ||||
vh.bottomStub.setVisibility(View.GONE); | vh.bottomStub.setVisibility(View.GONE); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public int getItemCount() { | public int getItemCount() { | ||||
return stops.size(); | return stops.size(); | ||||
} | } | ||||
public enum Use{ | public enum Use{ | ||||
FAVORITES, LINES | FAVORITES, 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