Commit 1b154fb9 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #296 from RocketChat/fix_251

Fix 251
parents 8f8d9816 f91727db
...@@ -7,7 +7,7 @@ before_script: ...@@ -7,7 +7,7 @@ before_script:
- echo y | android update sdk --no-ui --all --filter android-25 - echo y | android update sdk --no-ui --all --filter android-25
- echo y | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support - echo y | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support
- echo y | android update sdk --no-ui --all --filter extra-google-m2repository,extra-google-google_play_services - echo y | android update sdk --no-ui --all --filter extra-google-m2repository,extra-google-google_play_services
- echo y | android update sdk --no-ui --all --filter build-tools-25.0.2 - echo y | android update sdk --no-ui --all --filter build-tools-25.0.3
- ./gradlew dependencies - ./gradlew dependencies
script: script:
......
...@@ -6,7 +6,7 @@ buildscript { ...@@ -6,7 +6,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'me.tatarka:gradle-retrolambda:3.6.1' classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
} }
...@@ -14,7 +14,7 @@ buildscript { ...@@ -14,7 +14,7 @@ buildscript {
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion '25.0.2' buildToolsVersion '25.0.3'
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
...@@ -35,7 +35,7 @@ android { ...@@ -35,7 +35,7 @@ android {
} }
ext { ext {
supportVersion = '25.1.1' supportVersion = '25.3.1'
} }
dependencies { dependencies {
......
...@@ -10,7 +10,7 @@ buildscript { ...@@ -10,7 +10,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
...@@ -28,7 +28,7 @@ buildscript { ...@@ -28,7 +28,7 @@ buildscript {
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion '25.0.2' buildToolsVersion '25.0.3'
defaultConfig { defaultConfig {
applicationId "chat.rocket.android" applicationId "chat.rocket.android"
minSdkVersion 16 minSdkVersion 16
...@@ -75,13 +75,13 @@ play { ...@@ -75,13 +75,13 @@ play {
} }
ext { ext {
supportVersion = '25.2.0' supportVersion = '25.3.1'
playLibVersion = '10.2.0' playLibVersion = '10.2.6'
stethoVersion = '1.4.2' stethoVersion = '1.4.2'
rxbindingVersion = '2.0.0' rxbindingVersion = '2.0.0'
rxlifecycleVersion = '2.0.1' rxlifecycleVersion = '2.1.0'
icepickVersion = '3.2.0' icepickVersion = '3.2.0'
permissionsdispatcherVersion = '2.3.1' permissionsdispatcherVersion = '2.4.0'
} }
dependencies { dependencies {
...@@ -101,7 +101,7 @@ dependencies { ...@@ -101,7 +101,7 @@ dependencies {
compile "com.google.android.gms:play-services-gcm:$playLibVersion" compile "com.google.android.gms:play-services-gcm:$playLibVersion"
compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile "com.facebook.stetho:stetho:$stethoVersion" compile "com.facebook.stetho:stetho:$stethoVersion"
compile "com.facebook.stetho:stetho-okhttp3:$stethoVersion" compile "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
......
package chat.rocket.android.renderer; package chat.rocket.android.renderer;
import android.content.Context; import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View; import android.view.View;
import chat.rocket.android.renderer.optional.Condition; import chat.rocket.android.renderer.optional.Condition;
...@@ -15,27 +16,28 @@ abstract class AbstractRenderer<T> { ...@@ -15,27 +16,28 @@ abstract class AbstractRenderer<T> {
this.object = object; this.object = object;
} }
// TODO should we get rid of this simpler version of 'shouldHandle'?
protected boolean shouldHandle(View view) { protected boolean shouldHandle(View view) {
return object != null && view != null; return object != null && view != null;
} }
protected boolean shouldHandle(View target, Condition additionalCondition, Optional optional, protected boolean shouldHandle(View target,
String key) { @Nullable Condition additionalCondition,
if (target == null || object == null) { Optional optional,
if (optional != null) { @Nullable String key) {
optional.onNoData(key); if (target == null) {
}
return false; return false;
} }
if (object == null) {
if (optional != null) {
if (!additionalCondition.isOK()) {
optional.onNoData(key); optional.onNoData(key);
return false;
} else { } else {
if (additionalCondition == null || additionalCondition.isOK()) {
optional.onDataExists(key); optional.onDataExists(key);
return true;
} else {
optional.onNoData(key);
} }
} }
return true; return false;
} }
} }
...@@ -26,10 +26,10 @@ dependencies: ...@@ -26,10 +26,10 @@ dependencies:
- echo y | android update sdk --no-ui --all --filter android-25 - echo y | android update sdk --no-ui --all --filter android-25
- echo y | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support - echo y | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support
- echo y | android update sdk --no-ui --all --filter extra-google-m2repository,extra-google-google_play_services - echo y | android update sdk --no-ui --all --filter extra-google-m2repository,extra-google-google_play_services
- echo y | android update sdk --no-ui --all --filter build-tools-25.0.2 - echo y | android update sdk --no-ui --all --filter build-tools-25.0.3
cache_directories: cache_directories:
- /usr/local/android-sdk-linux/tools - /usr/local/android-sdk-linux/tools
- /usr/local/android-sdk-linux/build-tools/25.0.2 - /usr/local/android-sdk-linux/build-tools/25.0.3
test: test:
override: override:
......
...@@ -5,13 +5,13 @@ buildscript { ...@@ -5,13 +5,13 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.2'
} }
} }
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion '25.0.2' buildToolsVersion '25.0.3'
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
......
...@@ -8,7 +8,7 @@ buildscript { ...@@ -8,7 +8,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'io.realm:realm-gradle-plugin:2.3.2' classpath 'io.realm:realm-gradle-plugin:2.3.2'
classpath 'me.tatarka:gradle-retrolambda:3.5.0' classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
...@@ -18,7 +18,7 @@ buildscript { ...@@ -18,7 +18,7 @@ buildscript {
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion '25.0.2' buildToolsVersion '25.0.3'
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
...@@ -39,7 +39,7 @@ android { ...@@ -39,7 +39,7 @@ android {
} }
ext { ext {
supportVersion = '25.2.0' supportVersion = '25.3.1'
} }
dependencies { dependencies {
...@@ -50,10 +50,10 @@ dependencies { ...@@ -50,10 +50,10 @@ dependencies {
compile "com.android.support:appcompat-v7:$supportVersion" compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:design:$supportVersion" compile "com.android.support:design:$supportVersion"
compile 'io.reactivex.rxjava2:rxjava:2.0.6' compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.github.akarnokd:rxjava2-interop:0.9.1' compile 'com.github.akarnokd:rxjava2-interop:0.10.0'
compile 'com.parse.bolts:bolts-tasks:1.4.0' compile 'com.parse.bolts:bolts-tasks:1.4.0'
......
...@@ -2,7 +2,9 @@ package chat.rocket.persistence.realm.repositories; ...@@ -2,7 +2,9 @@ package chat.rocket.persistence.realm.repositories;
import android.os.Looper; import android.os.Looper;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import com.fernandocejas.arrow.optional.Optional; import com.fernandocejas.arrow.optional.Optional;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
...@@ -12,6 +14,7 @@ import io.realm.Sort; ...@@ -12,6 +14,7 @@ import io.realm.Sort;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import chat.rocket.core.models.Message; import chat.rocket.core.models.Message;
import chat.rocket.core.models.Room; import chat.rocket.core.models.Room;
import chat.rocket.core.models.User; import chat.rocket.core.models.User;
...@@ -75,10 +78,11 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe ...@@ -75,10 +78,11 @@ public class RealmMessageRepository extends RealmRepository implements MessageRe
RealmUser realmUser = realmMessage.getUser(); RealmUser realmUser = realmMessage.getUser();
if (realmUser == null) { if (realmUser == null) {
realmUser = new RealmUser(); realmUser = realm.where(RealmUser.class)
.equalTo(RealmUser.ID, message.getUser().getId())
.findFirst();
} }
realmMessage.setUser(realmUser);
realmUser.setId(message.getUser().getId());
realm.beginTransaction(); realm.beginTransaction();
......
...@@ -5,13 +5,13 @@ buildscript { ...@@ -5,13 +5,13 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.2'
} }
} }
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion '25.0.2' buildToolsVersion '25.0.3'
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
...@@ -30,8 +30,8 @@ android { ...@@ -30,8 +30,8 @@ android {
} }
ext { ext {
supportVersion = '25.2.0' supportVersion = '25.3.1'
frescoVersion = '1.1.0' frescoVersion = '1.3.0'
rxbindingVersion = '2.0.0' rxbindingVersion = '2.0.0'
} }
...@@ -49,7 +49,7 @@ dependencies { ...@@ -49,7 +49,7 @@ dependencies {
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.github.yusukeiwaki.android-widget:widget-fontawesome:0.0.1' compile 'com.github.yusukeiwaki.android-widget:widget-fontawesome:0.0.1'
......
...@@ -12,6 +12,7 @@ import com.amulyakhare.textdrawable.TextDrawable; ...@@ -12,6 +12,7 @@ import com.amulyakhare.textdrawable.TextDrawable;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import chat.rocket.android.widget.AbsoluteUrl; import chat.rocket.android.widget.AbsoluteUrl;
import chat.rocket.android.widget.R; import chat.rocket.android.widget.R;
import chat.rocket.android.widget.RocketChatAvatar; import chat.rocket.android.widget.RocketChatAvatar;
...@@ -81,6 +82,7 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> { ...@@ -81,6 +82,7 @@ public class UserViewHolder extends AutocompleteViewHolder<UserItem> {
//REMARK! this is often SVG image! (see: Rocket.Chat:server/startup/avatar.coffee) //REMARK! this is often SVG image! (see: Rocket.Chat:server/startup/avatar.coffee)
try { try {
final String avatarUrl = "/avatar/" + URLEncoder.encode(username, "UTF-8") + ".jpg"; final String avatarUrl = "/avatar/" + URLEncoder.encode(username, "UTF-8") + ".jpg";
// TODO why absoluteUrl is nullable? By allowing that, the app tries to load non-existing images
if (absoluteUrl == null) { if (absoluteUrl == null) {
return avatarUrl; return avatarUrl;
} }
......
...@@ -12,7 +12,7 @@ dependencies { ...@@ -12,7 +12,7 @@ dependencies {
compile 'com.google.code.findbugs:jsr305:3.0.1' compile 'com.google.code.findbugs:jsr305:3.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.6' compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'com.fernandocejas:arrow:1.0.0' compile 'com.fernandocejas:arrow:1.0.0'
......
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