Commit 42fb1f71 authored by Yusuke Iwaki's avatar Yusuke Iwaki

remove Timber.

parent 2a77ce1f
......@@ -40,9 +40,9 @@ android {
}
dependencies {
compile project(':log-wrapper-dev')
compile rootProject.ext.supportAnnotations
compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
compile rootProject.ext.rxJava
compile rootProject.ext.boltsTask
compile rootProject.ext.timber
}
......@@ -7,7 +7,6 @@ import chat.rocket.android_ddp.rx.RxWebSocketCallback;
import okhttp3.OkHttpClient;
import org.json.JSONArray;
import rx.Observable;
import timber.log.Timber;
public class DDPClient {
// reference: https://github.com/eddflrs/meteor-ddp/blob/master/meteor-ddp.js
......@@ -16,7 +15,6 @@ public class DDPClient {
public DDPClient(OkHttpClient client) {
impl = new DDPClientImpl(this, client);
Timber.plant(new Timber.DebugTree());
}
public Task<DDPClientCallback.Connect> connect(String url) {
......
......@@ -5,6 +5,7 @@ import android.support.annotation.Nullable;
import android.text.TextUtils;
import bolts.Task;
import bolts.TaskCompletionSource;
import chat.rocket.android.log.RCLog;
import chat.rocket.android_ddp.rx.RxWebSocket;
import chat.rocket.android_ddp.rx.RxWebSocketCallback;
import java.util.concurrent.TimeUnit;
......@@ -16,7 +17,6 @@ import org.json.JSONObject;
import rx.Observable;
import rx.functions.Func1;
import rx.subscriptions.CompositeSubscription;
import timber.log.Timber;
public class DDPClientImpl {
private final DDPClient client;
......@@ -86,7 +86,7 @@ public class DDPClientImpl {
subscribeBaseListeners();
} catch (Exception e) {
Timber.e(e);
RCLog.e(e);
}
}
......@@ -304,9 +304,7 @@ public class DDPClientImpl {
observable.filter(callback -> callback instanceof RxWebSocketCallback.Close)
.cast(RxWebSocketCallback.Close.class)
.subscribe(close -> {
task.setResult(close);
}, err -> {
.subscribe(task::setResult, err -> {
if (err instanceof Exception) {
task.setError((Exception) err);
} else {
......@@ -326,7 +324,7 @@ public class DDPClientImpl {
String msg2 = (json == null ? origJson : json.create(origJson)).toString();
websocket.sendText(msg2);
} catch (Exception e) {
Timber.e(e);
RCLog.e(e);
}
}
......@@ -342,7 +340,7 @@ public class DDPClientImpl {
try {
websocket.close(code, reason);
} catch (Exception e) {
Timber.e(e);
RCLog.e(e);
}
}
......
package chat.rocket.android_ddp.rx;
import chat.rocket.android.log.RCLog;
import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
......@@ -14,7 +15,6 @@ import rx.Observable;
import rx.Subscriber;
import rx.exceptions.OnErrorNotImplementedException;
import rx.observables.ConnectableObservable;
import timber.log.Timber;
public class RxWebSocket {
private OkHttpClient httpClient;
......@@ -44,7 +44,7 @@ public class RxWebSocket {
isConnected = false;
subscriber.onError(new RxWebSocketCallback.Failure(webSocket, e, response));
} catch (OnErrorNotImplementedException ex) {
Timber.w(ex, "OnErrorNotImplementedException ignored");
RCLog.w(ex, "OnErrorNotImplementedException ignored");
}
}
......
package chat.rocket.android_ddp.rx;
import chat.rocket.android.log.RCLog;
import java.io.IOException;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.ws.WebSocket;
import okio.Buffer;
import timber.log.Timber;
import static android.R.attr.type;
......@@ -60,7 +60,7 @@ public class RxWebSocketCallback {
try {
this.responseBodyString = responseBody.string();
} catch (Exception e) {
Timber.e(e, "error in reading response(Message)");
RCLog.e(e, "error in reading response(Message)");
}
}
......
......@@ -75,14 +75,14 @@ android {
repositories {
mavenCentral()
maven { url 'https://github.com/YusukeIwaki/realm-java-helpers/raw/master/repo' }
maven { url 'https://github.com/lijingle1/stetho-realm/raw/master/maven-repo' }
maven { url 'https://github.com/RocketChat/Android-DDP/raw/master/repository' }
maven { url 'http://dl.bintray.com/amulyakhare/maven' }
maven { url "https://clojars.org/repo/" } //for icepick.
}
dependencies {
debugCompile project(':log-wrapper-dev')
releaseCompile project(':log-wrapper-rel')
compile project(':android-ddp')
compile project(':rocket-chat-android-widgets')
compile project(':realm-helpers')
......@@ -104,7 +104,6 @@ dependencies {
compile 'com.facebook.stetho:stetho-okhttp3:1.4.1'
compile 'com.uphyca:stetho_realm:2.0.1'
compile rootProject.ext.timber
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
......
......@@ -11,7 +11,6 @@ import com.uphyca.stetho_realm.RealmInspectorModulesProvider;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import java.util.List;
import timber.log.Timber;
/**
* Customized Application-class for Rocket.Chat
......@@ -20,8 +19,6 @@ public class RocketChatApplication extends MultiDexApplication {
@Override public void onCreate() {
super.onCreate();
Timber.plant(new Timber.DebugTree());
Realm.init(this);
Realm.setDefaultConfiguration(
new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build());
......
......@@ -7,10 +7,10 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.MotionEvent;
import chat.rocket.android.helper.OnBackPressListener;
import chat.rocket.android.log.RCLog;
import com.instabug.library.InstabugTrackingDelegate;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import icepick.Icepick;
import timber.log.Timber;
abstract class AbstractFragmentActivity extends RxAppCompatActivity {
......@@ -70,7 +70,7 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
try {
InstabugTrackingDelegate.notifyActivityGotTouchEvent(event, this);
} catch (IllegalStateException exception) {
Timber.w(exception, "Instabug error (ignored)");
RCLog.w(exception, "Instabug error (ignored)");
}
return super.dispatchTouchEvent(event);
}
......
......@@ -4,6 +4,7 @@ import android.support.annotation.Nullable;
import bolts.Task;
import chat.rocket.android.helper.OkHttpHelper;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.android_ddp.DDPClient;
import chat.rocket.android_ddp.DDPClientCallback;
import chat.rocket.android_ddp.DDPSubscription;
......@@ -11,7 +12,6 @@ import java.util.UUID;
import org.json.JSONArray;
import org.json.JSONException;
import rx.Observable;
import timber.log.Timber;
/**
* DDP client wrapper.
......@@ -83,13 +83,13 @@ public class DDPClientWraper {
*/
public Task<DDPClientCallback.RPC> rpc(String methodCallId, String methodName, String params,
long timeoutMs) {
Timber.d("rpc:[%s]> %s(%s) timeout=%d", methodCallId, methodName, params, timeoutMs);
RCLog.d("rpc:[%s]> %s(%s) timeout=%d", methodCallId, methodName, params, timeoutMs);
if (TextUtils.isEmpty(params)) {
return ddpClient.rpc(methodName, null, methodCallId, timeoutMs).continueWithTask(task -> {
if (task.isFaulted()) {
Timber.d("rpc:[%s]< error = %s", methodCallId, task.getError());
RCLog.d("rpc:[%s]< error = %s", methodCallId, task.getError());
} else {
Timber.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result);
RCLog.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result);
}
return task;
});
......@@ -99,9 +99,9 @@ public class DDPClientWraper {
return ddpClient.rpc(methodName, new JSONArray(params), methodCallId, timeoutMs)
.continueWithTask(task -> {
if (task.isFaulted()) {
Timber.d("rpc:[%s]< error = %s", methodCallId, task.getError());
RCLog.d("rpc:[%s]< error = %s", methodCallId, task.getError());
} else {
Timber.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result);
RCLog.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result);
}
return task;
});
......
......@@ -19,6 +19,7 @@ import chat.rocket.android.helper.OnBackPressListener;
import chat.rocket.android.layouthelper.chatroom.MessageComposerManager;
import chat.rocket.android.layouthelper.chatroom.MessageListAdapter;
import chat.rocket.android.layouthelper.chatroom.PairedMessage;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.ddp.Message;
......@@ -37,7 +38,6 @@ import io.realm.Sort;
import java.lang.reflect.Field;
import java.util.UUID;
import org.json.JSONObject;
import timber.log.Timber;
/**
* Chat room screen.
......@@ -175,7 +175,7 @@ public class RoomFragment extends AbstractChatRoomFragment
fieldSlidable.setAccessible(true);
fieldSlidable.setBoolean(pane, !opened);
} catch (Exception exception) {
Timber.w(exception, "failed to set CanSlide.");
RCLog.w(exception);
}
});
}
......@@ -233,7 +233,7 @@ public class RoomFragment extends AbstractChatRoomFragment
MessageListAdapter adapter = (MessageListAdapter) listView.getAdapter();
final int syncstate = procedure.getSyncstate();
final boolean hasNext = procedure.isHasNext();
Timber.d("hasNext: %s syncstate: %d", hasNext, syncstate);
RCLog.d("hasNext: %s syncstate: %d", hasNext, syncstate);
if (syncstate == SyncState.SYNCED || syncstate == SyncState.FAILED) {
scrollListener.setLoadingDone();
adapter.updateFooter(hasNext, true);
......
......@@ -10,6 +10,7 @@ import android.widget.TextView;
import chat.rocket.android.R;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.layouthelper.chatroom.dialog.RoomUserAdapter;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.internal.GetUsersOfRoomsProcedure;
import chat.rocket.android.realm_helper.RealmObjectObserver;
......@@ -19,7 +20,6 @@ import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import timber.log.Timber;
/**
* Dialog to show members in a room.
......@@ -122,7 +122,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatroomDialogFragment {
}
onRenderUsers(users);
} catch (JSONException exception) {
Timber.e(exception);
RCLog.e(exception);
}
}
}
......
......@@ -9,13 +9,13 @@ import android.webkit.WebView;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.fragment.AbstractWebViewFragment;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.ddp.MeteorLoginServiceConfiguration;
import chat.rocket.android.realm_helper.RealmStore;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import timber.log.Timber;
public abstract class AbstractOAuthFragment extends AbstractWebViewFragment {
......@@ -91,7 +91,7 @@ public abstract class AbstractOAuthFragment extends AbstractWebViewFragment {
handleOAuthCallback(credentialToken, credentialSecret);
resultOK = true;
} catch (JSONException exception) {
Timber.e(exception, "failed to parse OAuth result.");
RCLog.e(exception, "failed to parse OAuth result.");
}
}
......
......@@ -10,12 +10,12 @@ import chat.rocket.android.R;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.layouthelper.oauth.OAuthProviderInfo;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ddp.MeteorLoginServiceConfiguration;
import chat.rocket.android.realm_helper.RealmListObserver;
import chat.rocket.android.realm_helper.RealmStore;
import java.util.HashMap;
import java.util.List;
import timber.log.Timber;
/**
* Login screen.
......@@ -87,7 +87,7 @@ public class LoginFragment extends AbstractServerConfigFragment {
try {
fragment = info.fragmentClass.newInstance();
} catch (Exception exception) {
Timber.w(exception, "failed to create new Fragment");
RCLog.w(exception, "failed to create new Fragment");
}
if (fragment != null) {
Bundle args = new Bundle();
......
......@@ -11,14 +11,12 @@ import android.os.Looper;
import android.widget.ImageView;
import bolts.Task;
import bolts.TaskCompletionSource;
import chat.rocket.android.log.RCLog;
import com.amulyakhare.textdrawable.TextDrawable;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import timber.log.Timber;
import static android.R.attr.bitmap;
/**
* Helper for rendering user avatar image.
......@@ -66,7 +64,7 @@ public class Avatar {
try {
return "https://" + hostname + "/avatar/" + URLEncoder.encode(username, "UTF-8") + ".jpg";
} catch (UnsupportedEncodingException exception) {
Timber.e(exception, "failed to get URL for user: %s", username);
RCLog.e(exception, "failed to get URL for user: %s", username);
return null;
}
}
......
package chat.rocket.android.helper;
import chat.rocket.android.log.RCLog;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import timber.log.Timber;
/**
* Utility class for converting epoch ms and date-time string.
......@@ -64,7 +64,7 @@ public class DateTime {
cal.setTime(DATE_FORMAT.parse(dateString));
return cal.getTimeInMillis();
} catch (ParseException exception) {
Timber.w(exception, "failed to parse date: %s", dateString);
RCLog.w(exception, "failed to parse date: %s", dateString);
}
return 0;
}
......
......@@ -2,7 +2,7 @@ package chat.rocket.android.helper;
import bolts.Continuation;
import bolts.Task;
import timber.log.Timber;
import chat.rocket.android.log.RCLog;
/**
* Bolts-Task continuation for just logging if error occurred.
......@@ -10,7 +10,7 @@ import timber.log.Timber;
public class LogcatIfError implements Continuation {
@Override public Object then(Task task) throws Exception {
if (task.isFaulted()) {
Timber.w(task.getError());
RCLog.w(task.getError());
}
return task;
}
......
......@@ -6,6 +6,7 @@ import bolts.Task;
import bolts.TaskCompletionSource;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState;
import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.realm_helper.RealmObjectObserver;
......@@ -15,7 +16,6 @@ import io.realm.annotations.PrimaryKey;
import java.util.HashMap;
import java.util.UUID;
import org.json.JSONObject;
import timber.log.Timber;
public class MethodCall extends RealmObject {
......@@ -116,7 +116,7 @@ public class MethodCall extends RealmObject {
realm.where(MethodCall.class).equalTo("methodCallId", newId));
observer.setOnUpdateListener(methodCall -> {
int syncstate = methodCall.getSyncstate();
Timber.d("MethodCall[%s] syncstate=%d", methodCall.getMethodCallId(), syncstate);
RCLog.d("MethodCall[%s] syncstate=%d", methodCall.getMethodCallId(), syncstate);
if (syncstate == SyncState.SYNCED) {
String resultJson = methodCall.getResultJson();
if (TextUtils.isEmpty(resultJson)) {
......
......@@ -9,6 +9,7 @@ import bolts.TaskCompletionSource;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.internal.Session;
import chat.rocket.android.realm_helper.RealmHelper;
......@@ -29,7 +30,6 @@ import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import org.json.JSONObject;
import timber.log.Timber;
/**
* Thread for handling WebSocket connection.
......@@ -112,7 +112,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
@Override public boolean quit() {
if (isAlive()) {
new Handler(getLooper()).post(() -> {
Timber.d("thread %s: quit()", Thread.currentThread().getId());
RCLog.d("thread %s: quit()", Thread.currentThread().getId());
unregisterListeners();
RocketChatWebSocketThread.super.quit();
});
......@@ -225,7 +225,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
listeners.add(registerable);
}
} catch (Exception exception) {
Timber.w(exception, "Failed to register listeners!!");
RCLog.w(exception, "Failed to register listeners!!");
}
}
}
......
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.text.TextUtils;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.service.Registerable;
import chat.rocket.android_ddp.DDPSubscription;
......@@ -14,7 +15,6 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import rx.Subscription;
import timber.log.Timber;
public abstract class AbstractDDPDocEventSubscriber implements Registerable {
protected final Context context;
......@@ -65,7 +65,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
return null;
}).continueWith(task -> {
if (task.isFaulted()) {
Timber.w(task.getError(), "DDP subscription failed.");
RCLog.w(task.getError(), "DDP subscription failed.");
}
return null;
});
......@@ -103,7 +103,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
//ignore movedBefore
}
} catch (Exception exception) {
Timber.w(exception, "failed to handle subscription callback");
RCLog.w(exception, "failed to handle subscription callback");
}
});
}
......
......@@ -3,13 +3,13 @@ package chat.rocket.android.service.ddp.stream;
import android.content.Context;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.service.ddp.AbstractDDPDocEventSubscriber;
import chat.rocket.android_ddp.DDPSubscription;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import timber.log.Timber;
abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSubscriber {
protected AbstractStreamNotifyEventSubscriber(Context context, String hostname,
......@@ -49,7 +49,7 @@ abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSu
handleArgs(docEvent.fields.getJSONArray("args"));
} catch (Exception exception) {
Timber.w(exception, "failed to save stream-notify event.");
RCLog.w(exception, "failed to save stream-notify event.");
}
}
......
......@@ -4,6 +4,7 @@ import android.content.Context;
import bolts.Task;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.internal.GetUsersOfRoomsProcedure;
import chat.rocket.android.realm_helper.RealmHelper;
......@@ -11,7 +12,6 @@ import io.realm.Realm;
import io.realm.RealmResults;
import java.util.List;
import org.json.JSONObject;
import timber.log.Timber;
/**
* Model observer for executing getUsersOfRooms.
......@@ -58,7 +58,7 @@ public class GetUsersOfRoomsProcedureObserver
})
).continueWithTask(task -> {
if (task.isFaulted()) {
Timber.w(task.getError());
RCLog.w(task.getError());
return realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(GetUsersOfRoomsProcedure.class, new JSONObject()
.put("roomId", roomId)
......
......@@ -2,18 +2,18 @@ package chat.rocket.android.service.observer;
import android.content.Context;
import bolts.Task;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.model.internal.LoadMessageProcedure;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.ddp.Message;
import chat.rocket.android.model.internal.LoadMessageProcedure;
import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.api.DDPClientWraper;
import io.realm.Realm;
import io.realm.RealmResults;
import io.realm.Sort;
import java.util.List;
import org.json.JSONObject;
import timber.log.Timber;
/**
* Background process for loading messages.
......@@ -70,7 +70,7 @@ public class LoadMessageProcedureObserver extends AbstractModelObserver<LoadMess
})
).continueWithTask(task -> {
if (task.isFaulted()) {
Timber.w(task.getError());
RCLog.w(task.getError());
return realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(LoadMessageProcedure.class, new JSONObject()
.put("roomId", roomId)
......
......@@ -4,6 +4,7 @@ import android.content.Context;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.ddp.Message;
import chat.rocket.android.realm_helper.RealmHelper;
......@@ -11,7 +12,6 @@ import io.realm.Realm;
import io.realm.RealmResults;
import java.util.List;
import org.json.JSONObject;
import timber.log.Timber;
/**
* Observe messages for sending.
......@@ -69,7 +69,7 @@ public class NewMessageObserver extends AbstractModelObserver<Message> {
})
).continueWith(task -> {
if (task.isFaulted()) {
Timber.w(task.getError());
RCLog.w(task.getError());
realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(Message.class, new JSONObject()
.put("_id", messageId)
......
......@@ -16,7 +16,6 @@ ext {
rxJava = 'io.reactivex:rxjava:1.2.2'
boltsTask = 'com.parse.bolts:bolts-tasks:1.4.0'
timber = 'com.jakewharton.timber:timber:4.3.1'
okhttp3 = 'com.squareup.okhttp3:okhttp:3.4.1'
picasso = 'com.squareup.picasso:picasso:2.5.2'
picasso2Okhttp3Downloader = 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
......
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath rootProject.ext.androidPlugin
}
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile rootProject.ext.supportAnnotations
}
\ No newline at end of file
<manifest package="chat.rocket.android.log"/>
\ No newline at end of file
package chat.rocket.android.log;
import android.util.Log;
public class RCLog {
public static void d(String log, Object... args) {
Log.d(getTag(), String.format(log, args));
}
public static void d(Throwable throwable) {
Log.d(getTag(), throwable.getMessage(), throwable);
}
public static void d(Throwable throwable, String log, Object... args) {
Log.d(getTag(), String.format(log, args), throwable);
}
public static void w(String log, Object... args) {
Log.w(getTag(), String.format(log, args));
}
public static void w(Throwable throwable) {
Log.w(getTag(), throwable.getMessage(), throwable);
}
public static void w(Throwable throwable, String log, Object... args) {
Log.w(getTag(), String.format(log, args), throwable);
}
public static void e(String log, Object... args) {
Log.e(getTag(), String.format(log, args));
}
public static void e(Throwable throwable) {
Log.e(getTag(), throwable.getMessage(), throwable);
}
public static void e(Throwable throwable, String log, Object... args) {
Log.e(getTag(), String.format(log, args), throwable);
}
private static String getTag() {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
if (elements.length >= 5) {
return getSimpleName(elements[4].getClassName());
} else {
return "Rocket.Chat";
}
}
private static String getSimpleName(String className) {
int idx = className.lastIndexOf(".");
return className.substring(idx + 1);
}
}
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath rootProject.ext.androidPlugin
}
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile rootProject.ext.supportAnnotations
}
\ No newline at end of file
<manifest package="chat.rocket.android.log"/>
\ No newline at end of file
package chat.rocket.android.log;
public class RCLog {
public static void d(String log, Object... args) {
}
public static void d(Throwable throwable) {
}
public static void d(Throwable throwable, String log, Object... args) {
}
public static void w(String log, Object... args) {
}
public static void w(Throwable throwable) {
}
public static void w(Throwable throwable, String log, Object... args) {
}
public static void e(String log, Object... args) {
}
public static void e(Throwable throwable) {
}
public static void e(Throwable throwable, String log, Object... args) {
}
}
......@@ -43,8 +43,8 @@ android {
dependencies {
testCompile 'junit:junit:4.12'
compile project(':log-wrapper-rel')
compile rootProject.ext.boltsTask
compile rootProject.ext.timber
compile rootProject.ext.supportAnnotations
compile rootProject.ext.supportAppCompat
compile rootProject.ext.supportDesign
......
......@@ -6,6 +6,7 @@ import android.os.Looper;
import android.support.v7.widget.RecyclerView;
import bolts.Task;
import bolts.TaskCompletionSource;
import chat.rocket.android.log.RCLog;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmObject;
......@@ -13,7 +14,6 @@ import io.realm.RealmResults;
import java.util.Collections;
import java.util.List;
import org.json.JSONException;
import timber.log.Timber;
@SuppressLint("NewApi")
public class RealmHelper {
......@@ -61,7 +61,7 @@ public class RealmHelper {
T source = transaction.execute(realm);
return source != null ? realm.copyFromRealm(source) : null;
} catch (Exception exception) {
Timber.w(exception, "failed to execute copyFromRealm");
RCLog.w(exception);
return null;
}
}
......@@ -71,7 +71,7 @@ public class RealmHelper {
try (Realm realm = instance()) {
return realm.copyFromRealm(transaction.execute(realm));
} catch (Exception exception) {
Timber.w(exception, "failed to execute copyFromRealm");
RCLog.w(exception);
return Collections.emptyList();
}
}
......@@ -85,13 +85,11 @@ public class RealmHelper {
final TaskCompletionSource<Void> task = new TaskCompletionSource<>();
try (Realm realm = instance()) {
realm.executeTransaction(new Realm.Transaction() {
@Override public void execute(Realm realm) {
try {
transaction.execute(realm);
} catch (JSONException exception) {
throw new RuntimeException(exception);
}
realm.executeTransaction(_realm -> {
try {
transaction.execute(_realm);
} catch (JSONException exception) {
throw new RuntimeException(exception);
}
});
task.setResult(null);
......
include ':app', ':android-ddp', ':rocket-chat-android-widgets', ':realm-helpers'
include ':app', ':android-ddp', ':rocket-chat-android-widgets', ':realm-helpers',
':log-wrapper-dev',
':log-wrapper-rel'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment