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
@BindingAdapter({"bind:font"}) | |
public static void setFont(TextView textView, String fontName) { | |
textView.setTypeface(Typeface.createFromAsset(textView.getContext().getAssets(), "fonts/" + fontName)); | |
} |
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
map.setInfoWindowAdapter(markerAdapter); |
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
RequestCreator requestCreator = Picasso.with(context).load(hotel.imageURL); | |
if (imageStatusMap.get(hotel.id)) | |
requestCreator.into(imageView); | |
else{ | |
imageStatusMap.put(hotel.id, true); | |
requestCreator.into(imageView), new InfoWindowRefresher(marker); | |
} |
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
class InfoWindowRefresher implements Callback { | |
Marker marker; | |
public InfoWindowRefresher(Marker marker) { | |
this.marker = marker; | |
} | |
@Override | |
public void onSuccess() { |
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 CustomInfoView implements GoogleMap.InfoWindowAdapter{ | |
private LayoutInflater inflater; | |
private Context context; | |
private WeakHashMap<Marker, Hotel> hashMap; | |
public CustomInfoView(Context context, WeakHashMap<Marker, Hotel> hashMap) { | |
this.context = context; | |
this.hashMap = hashMap; | |
inflater = LayoutInflater.from(context); |
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
map.addMarker(new MarkerOptions().position(new LatLng(lat, long))); |
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
LatLngBounds.Builder builder = new LatLngBounds.Builder(); | |
for (Marker marker : markers) | |
builder.include(marker.getPosition()); | |
LatLngBounds bounds = builder.build(); | |
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 0); | |
map.animateCamera(cameraUpdate); |
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
LatLngBounds.Builder builder = new LatLngBounds.Builder(); | |
for (Marker marker : markers) | |
builder.include(marker.getPosition()); | |
LatLngBounds bounds = builder.build(); | |
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 0); | |
map.animateCamera(cameraUpdate); |
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 void updateList(ArrayList<Person> newList) { | |
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new MyDiffCallback(this.persons, newList)); | |
diffResult.dispatchUpdatesTo(this); | |
} |
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 DataProvider { | |
public static List<Person> getOldPersonList(){ | |
List<Person> persons = new ArrayList<>(); | |
persons.add(new Person(1, 20, "John")); | |
persons.add(new Person(2, 12, "Jack")); | |
persons.add(new Person(3, 8, "Michael")); | |
persons.add(new Person(4, 19, "Rafael")); | |
return persons; | |
} |