This repository has been archived by the owner on Jun 7, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change MethodCall to RealmModel! and fix get room operation...(not co…
…mpletely fixed...)
- Loading branch information
Yusuke Iwaki
committed
Sep 11, 2016
1 parent
a863de3
commit 0c9353e
Showing
21 changed files
with
571 additions
and
562 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
package chat.rocket.android; | ||
|
||
import android.util.Log; | ||
|
||
import bolts.Continuation; | ||
import bolts.Task; | ||
|
||
public class Constants { | ||
public static final String LOG_TAG = "Rocket.Chat.Android"; | ||
|
||
public static final String AUTHORITY = "chat.rocket.android"; | ||
|
||
public static final Continuation ERROR_LOGGING = new Continuation() { | ||
@Override | ||
public Object then(Task task) throws Exception { | ||
if (task.isFaulted()) { | ||
Log.e(LOG_TAG, "error", task.getError()); | ||
} | ||
return null; | ||
} | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package chat.rocket.android; | ||
|
||
import android.content.Context; | ||
|
||
import io.realm.Realm; | ||
import io.realm.RealmConfiguration; | ||
|
||
public class RealmConfig { | ||
private static RealmConfiguration sConfig; | ||
public static void setDefault(Context context) { | ||
sConfig = new RealmConfiguration.Builder(context) | ||
.name("default.realm") | ||
.schemaVersion(1) | ||
.deleteRealmIfMigrationNeeded() | ||
.build(); | ||
Realm.setDefaultConfiguration(sConfig); | ||
} | ||
} |
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
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
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
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
33 changes: 0 additions & 33 deletions
33
app/src/main/java/chat/rocket/android/content/RocketChatOnMemoryDatabaseHelper.java
This file was deleted.
Oops, something went wrong.
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
57 changes: 57 additions & 0 deletions
57
app/src/main/java/chat/rocket/android/content/observer/AbstractRealmObserver.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package chat.rocket.android.content.observer; | ||
|
||
import android.content.Context; | ||
import android.os.Handler; | ||
import android.os.Looper; | ||
|
||
import chat.rocket.android.Constants; | ||
import chat.rocket.android.api.ws.RocketChatWSAPI; | ||
import chat.rocket.android.content.Registerable; | ||
import io.realm.RealmObject; | ||
import jp.co.crowdworks.realm_java_helpers.RealmObjectObserver; | ||
|
||
public abstract class AbstractRealmObserver<T extends RealmObject> extends RealmObjectObserver<T> implements Registerable { | ||
protected static final String TAG = Constants.LOG_TAG; | ||
protected final Context mContext; | ||
protected final RocketChatWSAPI mAPI; | ||
private final Handler mHandler; | ||
|
||
public AbstractRealmObserver(Context context, Looper looper, RocketChatWSAPI api) { | ||
super(); | ||
mContext = context; | ||
mHandler = new Handler(looper); | ||
mAPI = api; | ||
} | ||
|
||
@Override | ||
public void register() { | ||
mHandler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
sub(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void unregister() { | ||
mHandler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
unsub(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected final void onChange(final T t) { | ||
mHandler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
onModelChanged(t); | ||
} | ||
}); | ||
} | ||
|
||
protected abstract void onModelChanged(T t); | ||
} |
Oops, something went wrong.