Created
May 4, 2016 11:27
-
-
Save kneth/d892973141e09fa12276ba7fc13c98f4 to your computer and use it in GitHub Desktop.
"git diff" for updated app
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
diff --git a/app/build.gradle b/app/build.gradle | |
index 169734a..96caf6e 100644 | |
--- a/app/build.gradle | |
+++ b/app/build.gradle | |
@@ -32,4 +32,5 @@ dependencies { | |
compile 'io.reactivex:rxjava:1.1.0' | |
compile 'com.google.dagger:dagger:2.0.2' | |
provided 'org.glassfish:javax.annotation:10.0-b28' | |
+ compile 'com.github.realm:realm-android-adapters:v1.0.0' | |
} | |
diff --git a/app/src/main/java/com/example/darrengu/songstest/MainActivity.java b/app/src/main/java/com/example/darrengu/songstest/MainActivity.java | |
index 3ee76fd..1f75e9d 100644 | |
--- a/app/src/main/java/com/example/darrengu/songstest/MainActivity.java | |
+++ b/app/src/main/java/com/example/darrengu/songstest/MainActivity.java | |
@@ -34,7 +34,7 @@ public class MainActivity extends AppCompatActivity implements OnClickInterface | |
ButterKnife.bind(this); | |
setSupportActionBar(toolBar); | |
realm = Realm.getDefaultInstance(); | |
- adapter = new RealmListviewAdapter(this, null, true); | |
+ adapter = new RealmListviewAdapter(this, null ); | |
adapter.setListener(this); | |
list.setAdapter(adapter); | |
if (isChecked) { | |
@@ -66,9 +66,9 @@ public class MainActivity extends AppCompatActivity implements OnClickInterface | |
@OnClick(R.id.tool_bar) | |
public void onClickToolbar() { | |
if (sort) { | |
- adapter.getRealmResults().sort("_id"); | |
+ adapter.doSort("_id", Sort.ASCENDING); | |
} else { | |
- adapter.getRealmResults().sort("_id", Sort.DESCENDING); | |
+ adapter.doSort("_id", Sort.DESCENDING); | |
} | |
sort = !sort; | |
adapter.notifyDataSetChanged(); | |
diff --git a/app/src/main/java/com/example/darrengu/songstest/RealmListviewAdapter.java b/app/src/main/java/com/example/darrengu/songstest/RealmListviewAdapter.java | |
index af05ab9..ec25365 100644 | |
--- a/app/src/main/java/com/example/darrengu/songstest/RealmListviewAdapter.java | |
+++ b/app/src/main/java/com/example/darrengu/songstest/RealmListviewAdapter.java | |
@@ -1,21 +1,18 @@ | |
package com.example.darrengu.songstest; | |
import android.content.Context; | |
- import android.util.Log; | |
- import android.view.View; | |
- import android.view.ViewGroup; | |
- import android.widget.ImageView; | |
- import android.widget.ListAdapter; | |
- import android.widget.SectionIndexer; | |
- import android.widget.TextView; | |
+import android.util.Log; | |
+import android.view.View; | |
+import android.view.ViewGroup; | |
+import android.widget.ImageView; | |
+import android.widget.ListAdapter; | |
+import android.widget.TextView; | |
- import java.util.HashMap; | |
- | |
- import butterknife.Bind; | |
- import butterknife.ButterKnife; | |
- import butterknife.OnClick; | |
- import io.realm.RealmBaseAdapter; | |
- import io.realm.RealmResults; | |
+import butterknife.Bind; | |
+import butterknife.ButterKnife; | |
+import butterknife.OnClick; | |
+import io.realm.RealmBaseAdapter; | |
+import io.realm.RealmResults; | |
/** | |
* Created by darrengu on 3/27/16. | |
@@ -23,8 +20,8 @@ | |
public class RealmListviewAdapter extends RealmBaseAdapter<Song> implements ListAdapter{ | |
private OnClickInterface _listener; | |
- public RealmListviewAdapter(Context context, RealmResults<Song> realmResults, boolean automaticUpdate) { | |
- super(context, realmResults, automaticUpdate); | |
+ public RealmListviewAdapter(Context context, RealmResults<Song> realmResults) { | |
+ super(context, realmResults); | |
} | |
@Override | |
@@ -37,7 +34,7 @@ | |
} else { | |
viewHolder = (SongViewHolder) convertView.getTag(); | |
} | |
- Song song = realmResults.get(position); | |
+ Song song = adapterData.get(position); | |
viewHolder.track.setText(String.valueOf(song.get_trackNumber())); | |
viewHolder.title.setText(song.get_title()); | |
viewHolder.position = position; | |
@@ -45,12 +42,16 @@ | |
} | |
public void updateRealmResults(RealmResults<Song> queryResults) { | |
- super.updateRealmResults(queryResults); | |
+ super.updateData(queryResults); | |
Log.d("Adapter", "UpdateRealmResults is called"); | |
} | |
public RealmResults<Song> getRealmResults() { | |
- return realmResults; | |
+ return (RealmResults<Song>) adapterData; | |
+ } | |
+ | |
+ public void doSort(String fieldName, io.realm.Sort sortOrder) { | |
+ adapterData = adapterData.sort(fieldName, sortOrder); | |
} | |
public void setListener(OnClickInterface listener) { | |
diff --git a/build.gradle b/build.gradle | |
index 23d7e2e..53247e7 100644 | |
--- a/build.gradle | |
+++ b/build.gradle | |
@@ -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 'com.neenbedankt.gradle.plugins:android-apt:1.8' | |
- classpath "io.realm:realm-gradle-plugin:0.88.2" | |
+ classpath "io.realm:realm-gradle-plugin:0.90.0" | |
// NOTE: Do not place your application dependencies here; they belong | |
// in the individual module build.gradle files | |
@@ -17,6 +17,7 @@ buildscript { | |
allprojects { | |
repositories { | |
jcenter() | |
+ maven { url "https://jitpack.io" } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment