Skip to content

Commit 9a19bf6

Browse files
committed
Migrate to Realm v2.0.2, fix example
1 parent 9b7cffa commit 9a19bf6

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmBaseActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected void onResume() {
8383
super.onResume();
8484

8585
// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
86-
RealmConfiguration realmConfig = new RealmConfiguration.Builder(getApplicationContext()).build();
86+
RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
8787
Realm.setDefaultConfiguration(realmConfig);
8888

8989
mRealm = Realm.getDefaultInstance();
@@ -189,8 +189,8 @@ protected void writeToDBPie() {
189189
float value4 = 15f + (float) (Math.random() * 8f);
190190
float value5 = 100f - value1 - value2 - value3 - value4;
191191

192-
float[] values = new float[] { value1, value2, value3, value4, value5 };
193-
String[] labels = new String[]{ "iOS", "Android", "WP 10", "BlackBerry", "Other"};
192+
float[] values = new float[]{value1, value2, value3, value4, value5};
193+
String[] labels = new String[]{"iOS", "Android", "WP 10", "BlackBerry", "Other"};
194194

195195
for (int i = 0; i < values.length; i++) {
196196
RealmDemoData d = new RealmDemoData(values[i], labels[i]);

MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityPie.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ private void setData() {
5353

5454
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
5555

56-
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
57-
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue", "label"); // stacked entries
56+
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue", "label");
5857
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
5958
set.setLabel("Example market share");
6059
set.setSliceSpace(2);

MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmMainActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ protected void onCreate(Bundle savedInstanceState) {
5656

5757
lv.setOnItemClickListener(this);
5858

59+
Realm.init(this);
60+
5961
// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
60-
RealmConfiguration realmConfig = new RealmConfiguration.Builder(getApplicationContext()).build();
62+
RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
6163
Realm.setDefaultConfiguration(realmConfig);
6264

6365
Realm realm = Realm.getDefaultInstance();

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath "io.realm:realm-gradle-plugin:1.1.0"
10+
classpath "io.realm:realm-gradle-plugin:2.0.2"
1111
classpath 'com.android.tools.build:gradle:2.2.1'
1212
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
1313
}

0 commit comments

Comments
 (0)