Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Commit

Permalink
Update to Realm 89.1
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbenprimke committed Apr 26, 2016
1 parent c20b30b commit 67a4557
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'

classpath "io.realm:realm-gradle-plugin:0.88.2"
classpath "io.realm:realm-gradle-plugin:0.89.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ protected Void doInBackground(Void... params) {
instance.where(QuoteModel.class).equalTo("id", id).findFirst();
if (quoteModel != null) {
instance.beginTransaction();
quoteModel.removeFromRealm();
quoteModel.deleteFromRealm();
instance.commitTransaction();
}
instance.close();
Expand Down
4 changes: 2 additions & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha5'
classpath 'com.android.tools.build:gradle:2.1.0-rc1'

classpath "io.realm:realm-gradle-plugin:0.88.2"
classpath "io.realm:realm-gradle-plugin:0.89.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
25 changes: 15 additions & 10 deletions library/src/main/java/io/realm/RealmBasedRecyclerViewAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import difflib.Delta;
import difflib.DiffUtils;
import difflib.Patch;
import io.realm.internal.RealmObjectProxy;
import io.realm.internal.Row;
import io.realm.internal.TableOrView;

/**
Expand Down Expand Up @@ -334,13 +336,13 @@ public void close() {
public void updateRealmResults(RealmResults<T> queryResults) {
if (listener != null) {
if (realmResults != null) {
realmResults.realm.removeChangeListener(listener);
realmResults.removeChangeListener(listener);
}
}

realmResults = queryResults;
if (realmResults != null) {
realmResults.realm.addChangeListener(listener);
realmResults.addChangeListener(listener);
}

updateRowWrappers();
Expand Down Expand Up @@ -384,10 +386,13 @@ private List getIdsOfRealmResults() {

private Object getRealmRowId(int realmIndex) {
Object rowPrimaryId;
RealmObjectProxy proxy = (RealmObjectProxy) realmResults.get(realmIndex);
Row row = proxy.realmGet$proxyState().getRow$realm();

if (animatePrimaryIdType == RealmFieldType.INTEGER) {
rowPrimaryId = realmResults.get(realmIndex).row.getLong(animatePrimaryColumnIndex);
rowPrimaryId = row.getLong(animatePrimaryColumnIndex);
} else if (animatePrimaryIdType == RealmFieldType.STRING) {
rowPrimaryId = realmResults.get(realmIndex).row.getString(animatePrimaryColumnIndex);
rowPrimaryId = row.getString(animatePrimaryColumnIndex);
} else {
throw new IllegalStateException("Unknown animatedIdType");
}
Expand All @@ -396,11 +401,9 @@ private Object getRealmRowId(int realmIndex) {
String rowPrimaryIdStr = (rowPrimaryId instanceof String)
? (String) rowPrimaryId : String.valueOf(rowPrimaryId);
if (animateExtraIdType == RealmFieldType.INTEGER) {
return rowPrimaryIdStr + String.valueOf(
realmResults.get(realmIndex).row.getLong(animateExtraColumnIndex));
return rowPrimaryIdStr + String.valueOf(row.getLong(animateExtraColumnIndex));
} else if (animateExtraIdType == RealmFieldType.STRING) {
return rowPrimaryIdStr +
realmResults.get(realmIndex).row.getString(animateExtraColumnIndex);
return rowPrimaryIdStr + row.getString(animateExtraColumnIndex);
} else {
throw new IllegalStateException("Unknown animateExtraIdType");
}
Expand All @@ -422,7 +425,9 @@ private void updateRowWrappers() {
final long headerIndex = realmResults.getTable().getColumnIndex(headerColumnName);
int i = 0;
for (RealmObject result : realmResults) {
String header = createHeaderFromColumnValue(result.row.getString(headerIndex));
String rawHeader = ((RealmObjectProxy) result)
.realmGet$proxyState().getRow$realm().getString(headerIndex);
String header = createHeaderFromColumnValue(rawHeader);
if (!TextUtils.equals(lastHeader, header)) {
// Insert new header view and update section data.
sectionFirstPosition = i + headerCount;
Expand Down Expand Up @@ -573,7 +578,7 @@ public void removeFooter() {
public void onItemSwipedDismiss(int position) {
final BaseRealm realm = realmResults.realm;
realm.beginTransaction();
realmResults.get(position).removeFromRealm();
realmResults.get(position).deleteFromRealm();
realm.commitTransaction();
}
}
Expand Down

0 comments on commit 67a4557

Please sign in to comment.