[android] Runtime Style Filter enhancements (#6623)

* [android] Additional null check - prevents errors in array conversion

* [android] style conversion - delete local refs asap to avoid ref table overflow

* [android] Filter - hide concrete implementation classes to avoid confusion
This commit is contained in:
Ivo van Dongen
2016-10-11 10:30:38 +03:00
committed by GitHub
parent efc1bff65f
commit 61d8ecefda
3 changed files with 12 additions and 6 deletions

View File

@@ -31,7 +31,7 @@ public class Filter {
/**
* Represents a {@link Filter} statement. Can be unary (eg `has()`, etc) or take any number of values.
*/
public static class SimpleStatement extends Statement {
private static class SimpleStatement extends Statement {
private final String key;
private final Object[] values;
@@ -40,7 +40,7 @@ public class Filter {
* @param key the property key
* @param values the values to operate on, if any
*/
public SimpleStatement(String operator, String key, Object... values) {
SimpleStatement(String operator, String key, Object... values) {
super(operator);
this.key = key;
this.values = values;
@@ -63,14 +63,14 @@ public class Filter {
/**
* Represents a collection of {@link Statement}s with an operator that describes their relationship
*/
public static class CompoundStatement extends Statement {
private static class CompoundStatement extends Statement {
private final Statement[] statements;
/**
* @param operator the relationship operator
* @param statements the statements to compound
*/
public CompoundStatement(String operator, Statement... statements) {
CompoundStatement(String operator, Statement... statements) {
super(operator);
this.statements = statements;
}

View File

@@ -75,7 +75,9 @@ inline optional<std::string> toString(const mbgl::android::Value& value) {
}
inline optional<Value> toValue(const mbgl::android::Value& value) {
if (value.isBool()) {
if (value.isNull()) {
return {};
} else if (value.isBool()) {
return { value.toBool() };
} else if (value.isString()) {
return { value.toString() };

View File

@@ -9,7 +9,11 @@ namespace android {
Value::Value(jni::JNIEnv& env, jni::jobject* _value) : jenv(env), value(_value) {}
Value::~Value() {}
Value::~Value() {
if (value) {
jni::DeleteLocalRef(jenv, value);
}
}
bool Value::isNull() const {
return value == nullptr;