Skip to content

Instantly share code, notes, and snippets.

View iammert's full-sized avatar
🎧
Focusing

Mert Şimşek iammert

🎧
Focusing
View GitHub Profile
@BindingAdapter({"bind:font"})
public static void setFont(TextView textView, String fontName) {
textView.setTypeface(Typeface.createFromAsset(textView.getContext().getAssets(), "fonts/" + fontName));
}
map.setInfoWindowAdapter(markerAdapter);
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);
}
class InfoWindowRefresher implements Callback {
Marker marker;
public InfoWindowRefresher(Marker marker) {
this.marker = marker;
}
@Override
public void onSuccess() {
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);
map.addMarker(new MarkerOptions().position(new LatLng(lat, long)));
@iammert
iammert / LatLngBounds.java
Created August 24, 2016 08:05
LatLngBounds.java
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);
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);
public void updateList(ArrayList<Person> newList) {
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new MyDiffCallback(this.persons, newList));
diffResult.dispatchUpdatesTo(this);
}
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;
}