-
-
Save jezinka/4ed262246161be9b44d0097650a757a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RoutesAdapter extends RecyclerView.Adapter<RoutesAdapter.RouteViewHolder> { | |
private static final String TAG = RoutesAdapter.class.getSimpleName(); | |
private JSONArray mItems; | |
RoutesAdapter(JSONArray routes) { | |
mItems = routes; | |
} | |
@Override | |
public RouteViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { | |
Context context = viewGroup.getContext(); | |
int layoutIdForListItem = R.layout.route_list_item; | |
LayoutInflater inflater = LayoutInflater.from(context); | |
View view = inflater.inflate(layoutIdForListItem, viewGroup, false); | |
return new RouteViewHolder(view); | |
} | |
@Override | |
public void onBindViewHolder(RouteViewHolder holder, int position) { | |
holder.bind(position); | |
} | |
@Override | |
public int getItemCount() { | |
return mItems.length(); | |
} | |
class RouteViewHolder extends RecyclerView.ViewHolder { | |
(...) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment