Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created Dec 28, 2017
Embed
What would you like to do?
class RouteViewHolder extends RecyclerView.ViewHolder {
TextView busTextView = null;
TextView leaveTextView = null;
TextView onTheSpotTextView = null;
TextView transferTextView = null;
RouteViewHolder(View itemView) {
super(itemView);
busTextView = itemView.findViewById(R.id.bus_tv);
leaveTextView = itemView.findViewById(R.id.leave_tv);
onTheSpotTextView = itemView.findViewById(R.id.on_the_spot_tv);
transferTextView = itemView.findViewById(R.id.transfer_tv);
}
void bind(int listIndex) {
try {
JSONObject routeObject = (JSONObject) mItems.get(listIndex);
busTextView.setText(routeObject.getJSONArray("bus").join(" | ").replaceAll("\"", ""));
leaveTextView.setText(routeObject.get("leave").toString());
onTheSpotTextView.setText(routeObject.get("on_the_spot").toString());
if (routeObject.has("transfer")) {
transferTextView.setText(routeObject.get("transfer").toString());
} else {
transferTextView.setText("");
}
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment