// Replace the contents of a view (invoked by the layout manager) @Override public void onBindViewHolder(ViewHolder holder, final int position) { final Refuge refuge = mDataset.get(position); Random rand = new Random(); int n = rand.nextInt(1000) + 1; holder.meter.setText(n + " m"); try { holder.name.setText(refuge.getName()); holder.location.setText(refuge.getLocation()); holder.contact.setText(refuge.getContact()); Bitmap image = loadBitmap(refuge.getImageUrl()); holder.image.setImageBitmap(image); } catch (IOException e) { e.printStackTrace(); } holder.layout.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mContext, RefugeLocationActivity.class); i.putExtra("Name", refuge.getName()); i.putExtra("Location", refuge.getLocation()); i.putExtra("Contact", refuge.getContact()); i.putExtra("ImageURL", refuge.getImageUrl()); mContext.startActivity(i); } }); }
public void filterDataSet(String query) { List<Refuge> newDataset = new ArrayList<>(); for (Refuge location : mDatasetFull) { if (location.getName().toLowerCase().contains(query.toLowerCase()) || location.getDescription().toLowerCase().contains(query.toLowerCase())) { newDataset.add(location); } } mDataset = newDataset; }