Skip to content

Instantly share code, notes, and snippets.

interface PlacesService {
@GET("places/{id}")
Observable<Place> getPlaceById(@Path("id") int placeId);
}
interface UsersService {
@GET("users")
Observable<List<User>> listUsers();
}
interface PlacesService {
@GET("places/{id}")
Call<Place> getPlaceById(@Path("id") int placeId);
}
interface UsersService {
@GET("users")
Call<List<User>> listUsers();
}
Observable<Car> carsObservable = getBestSellingCarsObservable();
carsObservable.subscribeOn(Schedulers.io())
.filter(car -> car.type == Car.Type.ALL_ELECTRIC)
.filter(car -> car.price < 90000)
.map(car -> car.year + " " + car.make + " " + car.model)
.distinct()
.take(5)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::updateUi);
getPerson(person => {
getPlanet(person, (planet) => {
getGalaxy(planet, (galaxy) => {
console.log(galaxy);
});
});
});
package com.example.pkg.myimageview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import com.example.pkg.myimageviewlibrary.MyImageViewBasic;
public class MainActivity extends AppCompatActivity {
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.example.pkg.myimageviewlibrary.MyImageViewBasic
android:id="@+id/blackAndWhiteImage"
package com.example.pkg.myimageviewlibrary;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyImageViewBasic">
<attr name="imageSrc" format="reference"/>
<attr name="imagePlaceholder" format="reference"/>
<attr name="imageError" format="reference"/>
<attr name="isBlackAndWhite" format="boolean"/>
</declare-styleable>
</resources>
package com.example.pkg.myimageviewlibrary;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
public class MyImageViewBasic extends RelativeLayout {
public MyImageViewBasic(Context context) {
super(context);
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/my_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />