In a Fragment
I have a list of items construct with RecyclerView
(adapter and viewholder).
Each item of the list is linked with a estimote beacon.
So i want to highlight the item view (setAlpha or add a imageView) when the beacon is detected.
The beacon detection is in the fragment file :
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
if (!list.isEmpty()) {
Beacon nearestBeacon = list.get(0);
replaceIconBeaconCard(nearestBeacon);
Log.d("Airport", "Nearest places: " + nearestBeacon);
}
}
});
Actually, I display a beacon icon on the item view. But the purpose is to highlight the detected item and put a alpha on the others items.
private void replaceIconBeaconCard(Beacon beacon){
for(SItem item: items) {
if (!item.getMajor().equals("")) {
int i = item.getId().intValue();
SCard card = listCards.get(i-1);
if (Integer.parseInt(item.getMajor()) == beacon.getMajor()) {
rv.getLayoutManager().scrollToPosition(i);
int resID = getResources().getIdentifier("beacon_ice", "drawable", getActivity().getPackageName());
card.setField_1(resID);
} else {
card.setField_1(Color.TRANSPARENT);
}
}
}
mAdapter.notifyDataSetChanged();
}
I don't know how I can access to item layout and change the alpha.