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
adapter = new RealmRecyclerViewAdapter<Dog, DogViewHolder>(getContext(), | |
realm.where(Dog.class).contains(currentName).findAllAsync(), true) { // query definition + true == automatic updates | |
@Override | |
public DogViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
return new DogViewHolder(LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.view_dog_item, parent, false)); | |
} | |
@Override | |
public void onBindViewHolder(DogViewHolder holder, int position) { |
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
catService.getCats() | |
.subscribeOn(Schedulers.io()) | |
.retry() | |
.subscribe(catsBO -> { | |
try(Realm realm = Realm.getDefaultInstance()) { | |
Cat defaultCat = new Cat(); | |
long rank; | |
if(realm.where(Cat.class).count() > 0) { | |
rank = realm.where(Cat.class).max(CatFields.RANK).longValue(); | |
} else { |
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
private Subscription queryDogsByInput() { | |
return RxTextView.textChanges(editText) | |
.switchMap(charSequence -> realm.where(Dog.class) | |
.contains(DogFields.NAME, charSequence.toString()) | |
.findAllSortedAsync(DogFields.NAME) | |
.asObservable() | |
).filter(RealmResults::isLoaded) // filter async results while not loaded | |
.subscribe(dogs -> adapter.updateData(dogs)); | |
} |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
repositories { | |
jcenter() | |
mavenCentral() | |
maven {url "https://clojars.org/repo/"} | |
maven { url "https://jitpack.io" } | |
} | |
dependencies { |
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
apply plugin: 'com.android.application' | |
//apply plugin: 'com.neenbedankt.android-apt' | |
//apply plugin: 'me.tatarka.retrolambda' | |
apply plugin: 'realm-android' // <-- added this line |
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
#realm | |
-keepnames public class * extends io.realm.RealmObject | |
-keep @io.realm.annotations.RealmModule class * | |
-keep class io.realm.** { *; } | |
-dontwarn javax.** | |
-dontwarn io.realm.** | |
#realm 0.84.1+ | |
-keep class io.realm.annotations.RealmModule | |
-keep @io.realm.annotations.RealmModule class * |
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
adapter = new RealmRecyclerViewAdapter<NewsPost, NewsPostViewHolder>(getContext(), | |
realm.where(NewsPost.class).findAllSortedAsync(NewsPostFields.MODIFIED, Sort.DESCENDING), true) { // query definition + true == automatic updates | |
@Override | |
public NewsPostViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
return new NewsPostViewHolder(LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.view_news_post_item, parent, false)); | |
} | |
@Override | |
public void onBindViewHolder(NewsPostViewHolder holder, int position) { |
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 GetNewsPostAsyncTask | |
extends AsyncTask<Void, Void, Void> { | |
private Retrofit retrofit; | |
private ApiService apiService; | |
private long postId; | |
public GetNewsPostAsyncTask(Retrofit retrofit, ApiService apiService, long postId) { | |
this.retrofit = retrofit; | |
this.apiService = apiService; |
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 NewsActivity extends AppCompatActivity { | |
// ... | |
private RealmChangeListener<RealmResults<NewsPost>> realmChangeListener; | |
private RealmResults<NewsPost> listenerSet; | |
private long postId; | |
private Realm realm; | |
@Override | |
protected void onCreate(Bundle bundle) { |
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
apply plugin: 'com.android.application' | |
//apply plugin: 'com.neenbedankt.android-apt' | |
//apply plugin: 'me.tatarka.retrolambda' | |
apply plugin: 'realm-android' | |
android { | |
compileSdkVersion 24 | |
buildToolsVersion "24.0.2" | |
//compileOptions { |
OlderNewer