From 070d3ab2d6f382ab74988df71eba137424df525f Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 12 Jun 2013 19:29:10 +0300 Subject: [PATCH] Remove trailing whitespace --- gson/com/google/gson/Gson.java | 2 +- gson/com/google/gson/JsonIOException.java | 2 +- gson/com/google/gson/JsonNull.java | 126 ++++++------ gson/com/google/gson/JsonParser.java | 186 +++++++++--------- gson/com/google/gson/JsonStreamParser.java | 14 +- .../google/gson/LongSerializationPolicy.java | 6 +- gson/com/google/gson/annotations/Expose.java | 4 +- gson/com/google/gson/annotations/Until.java | 2 +- .../google/gson/annotations/package-info.java | 2 +- .../gson/internal/$Gson$Preconditions.java | 90 ++++----- .../bind/TypeAdapterRuntimeTypeWrapper.java | 162 +++++++-------- .../gson/internal/bind/TypeAdapters.java | 4 +- .../com/google/gson/reflect/package-info.java | 2 +- res/drawable-hdpi/ic_launcher.png | Bin 1111 -> 1109 bytes res/drawable-mdpi/ic_launcher.png | Bin 758 -> 757 bytes res/drawable-xhdpi/ic_launcher.png | Bin 1461 -> 1460 bytes res/drawable-xxhdpi/ic_launcher.png | Bin 2215 -> 2214 bytes res/layout/event_row_layout.xml | 2 +- res/menu/add_event.xml | 2 +- res/menu/event.xml | 14 +- res/menu/main.xml | 4 +- res/values/strings.xml | 2 +- src/ro/ieval/unical/AddEventActivity.java | 18 +- src/ro/ieval/unical/AddEventTabListener.java | 2 +- src/ro/ieval/unical/Calendar.java | 2 +- src/ro/ieval/unical/DisplayEventActivity.java | 10 +- src/ro/ieval/unical/Event.java | 6 +- src/ro/ieval/unical/EventAdapter.java | 4 +- src/ro/ieval/unical/EventListActivity.java | 18 +- src/ro/ieval/unical/LoginActivity.java | 6 +- src/ro/ieval/unical/MainActivity.java | 8 +- 31 files changed, 350 insertions(+), 350 deletions(-) diff --git a/gson/com/google/gson/Gson.java b/gson/com/google/gson/Gson.java index a54188a..7a52ac6 100644 --- a/gson/com/google/gson/Gson.java +++ b/gson/com/google/gson/Gson.java @@ -408,7 +408,7 @@ public final class Gson { * } * Note that since you can not override type adapter factories for String and Java primitive * types, our stats factory will not count the number of String or primitives that will be - * read or written. + * read or written. * @param skipPast The type adapter factory that needs to be skipped while searching for * a matching type adapter. In most cases, you should just pass this (the type adapter * factory from where {@link #getDelegateAdapter} method is being invoked). diff --git a/gson/com/google/gson/JsonIOException.java b/gson/com/google/gson/JsonIOException.java index dfeccd8..310e506 100644 --- a/gson/com/google/gson/JsonIOException.java +++ b/gson/com/google/gson/JsonIOException.java @@ -18,7 +18,7 @@ package com.google.gson; /** * This exception is raised when Gson was unable to read an input stream * or write to one. - * + * * @author Inderjeet Singh * @author Joel Leitch */ diff --git a/gson/com/google/gson/JsonNull.java b/gson/com/google/gson/JsonNull.java index 5688336..c82cedb 100644 --- a/gson/com/google/gson/JsonNull.java +++ b/gson/com/google/gson/JsonNull.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.gson; - -/** - * A class representing a Json {@code null} value. - * - * @author Inderjeet Singh - * @author Joel Leitch - * @since 1.2 - */ -public final class JsonNull extends JsonElement { - /** - * singleton for JsonNull - * - * @since 1.8 - */ - public static final JsonNull INSTANCE = new JsonNull(); - - /** - * Creates a new JsonNull object. - * Deprecated since Gson version 1.8. Use {@link #INSTANCE} instead - */ - @Deprecated - public JsonNull() { - // Do nothing - } - - @Override - JsonNull deepCopy() { - return INSTANCE; - } - - /** - * All instances of JsonNull have the same hash code since they are indistinguishable - */ - @Override - public int hashCode() { - return JsonNull.class.hashCode(); - } - - /** - * All instances of JsonNull are the same - */ - @Override - public boolean equals(Object other) { - return this == other || other instanceof JsonNull; - } -} +/* + * Copyright (C) 2008 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.gson; + +/** + * A class representing a Json {@code null} value. + * + * @author Inderjeet Singh + * @author Joel Leitch + * @since 1.2 + */ +public final class JsonNull extends JsonElement { + /** + * singleton for JsonNull + * + * @since 1.8 + */ + public static final JsonNull INSTANCE = new JsonNull(); + + /** + * Creates a new JsonNull object. + * Deprecated since Gson version 1.8. Use {@link #INSTANCE} instead + */ + @Deprecated + public JsonNull() { + // Do nothing + } + + @Override + JsonNull deepCopy() { + return INSTANCE; + } + + /** + * All instances of JsonNull have the same hash code since they are indistinguishable + */ + @Override + public int hashCode() { + return JsonNull.class.hashCode(); + } + + /** + * All instances of JsonNull are the same + */ + @Override + public boolean equals(Object other) { + return this == other || other instanceof JsonNull; + } +} diff --git a/gson/com/google/gson/JsonParser.java b/gson/com/google/gson/JsonParser.java index a8ae337..4865813 100644 --- a/gson/com/google/gson/JsonParser.java +++ b/gson/com/google/gson/JsonParser.java @@ -1,93 +1,93 @@ -/* - * Copyright (C) 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; - -import com.google.gson.internal.Streams; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.MalformedJsonException; - -/** - * A parser to parse Json into a parse tree of {@link JsonElement}s - * - * @author Inderjeet Singh - * @author Joel Leitch - * @since 1.3 - */ -public final class JsonParser { - - /** - * Parses the specified JSON string into a parse tree - * - * @param json JSON text - * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON - * @throws JsonParseException if the specified text is not valid JSON - * @since 1.3 - */ - public JsonElement parse(String json) throws JsonSyntaxException { - return parse(new StringReader(json)); - } - - /** - * Parses the specified JSON string into a parse tree - * - * @param json JSON text - * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON - * @throws JsonParseException if the specified text is not valid JSON - * @since 1.3 - */ - public JsonElement parse(Reader json) throws JsonIOException, JsonSyntaxException { - try { - JsonReader jsonReader = new JsonReader(json); - JsonElement element = parse(jsonReader); - if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) { - throw new JsonSyntaxException("Did not consume the entire document."); - } - return element; - } catch (MalformedJsonException e) { - throw new JsonSyntaxException(e); - } catch (IOException e) { - throw new JsonIOException(e); - } catch (NumberFormatException e) { - throw new JsonSyntaxException(e); - } - } - - /** - * Returns the next value from the JSON stream as a parse tree. - * - * @throws JsonParseException if there is an IOException or if the specified - * text is not valid JSON - * @since 1.6 - */ - public JsonElement parse(JsonReader json) throws JsonIOException, JsonSyntaxException { - boolean lenient = json.isLenient(); - json.setLenient(true); - try { - return Streams.parse(json); - } catch (StackOverflowError e) { - throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e); - } catch (OutOfMemoryError e) { - throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e); - } finally { - json.setLenient(lenient); - } - } -} +/* + * Copyright (C) 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.gson; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +import com.google.gson.internal.Streams; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.MalformedJsonException; + +/** + * A parser to parse Json into a parse tree of {@link JsonElement}s + * + * @author Inderjeet Singh + * @author Joel Leitch + * @since 1.3 + */ +public final class JsonParser { + + /** + * Parses the specified JSON string into a parse tree + * + * @param json JSON text + * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON + * @throws JsonParseException if the specified text is not valid JSON + * @since 1.3 + */ + public JsonElement parse(String json) throws JsonSyntaxException { + return parse(new StringReader(json)); + } + + /** + * Parses the specified JSON string into a parse tree + * + * @param json JSON text + * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON + * @throws JsonParseException if the specified text is not valid JSON + * @since 1.3 + */ + public JsonElement parse(Reader json) throws JsonIOException, JsonSyntaxException { + try { + JsonReader jsonReader = new JsonReader(json); + JsonElement element = parse(jsonReader); + if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) { + throw new JsonSyntaxException("Did not consume the entire document."); + } + return element; + } catch (MalformedJsonException e) { + throw new JsonSyntaxException(e); + } catch (IOException e) { + throw new JsonIOException(e); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + /** + * Returns the next value from the JSON stream as a parse tree. + * + * @throws JsonParseException if there is an IOException or if the specified + * text is not valid JSON + * @since 1.6 + */ + public JsonElement parse(JsonReader json) throws JsonIOException, JsonSyntaxException { + boolean lenient = json.isLenient(); + json.setLenient(true); + try { + return Streams.parse(json); + } catch (StackOverflowError e) { + throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e); + } catch (OutOfMemoryError e) { + throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e); + } finally { + json.setLenient(lenient); + } + } +} diff --git a/gson/com/google/gson/JsonStreamParser.java b/gson/com/google/gson/JsonStreamParser.java index f0438db..0c66127 100644 --- a/gson/com/google/gson/JsonStreamParser.java +++ b/gson/com/google/gson/JsonStreamParser.java @@ -30,11 +30,11 @@ import com.google.gson.stream.MalformedJsonException; /** * A streaming parser that allows reading of multiple {@link JsonElement}s from the specified reader * asynchronously. - * + * *

This class is conditionally thread-safe (see Item 70, Effective Java second edition). To * properly use this class across multiple threads, you will need to add some external * synchronization. For example: - * + * *

  * JsonStreamParser parser = new JsonStreamParser("['first'] {'second':10} 'third'");
  * JsonElement element;
@@ -58,9 +58,9 @@ public final class JsonStreamParser implements Iterator {
    * @since 1.4
    */
   public JsonStreamParser(String json) {
-    this(new StringReader(json));      
+    this(new StringReader(json));
   }
-  
+
   /**
    * @param reader The data stream containing JSON elements concatenated to each other.
    * @since 1.4
@@ -70,10 +70,10 @@ public final class JsonStreamParser implements Iterator {
     parser.setLenient(true);
     lock = new Object();
   }
-  
+
   /**
    * Returns the next available {@link JsonElement} on the reader. Null if none available.
-   * 
+   *
    * @return the next available {@link JsonElement} on the reader. Null if none available.
    * @throws JsonParseException if the incoming stream is malformed JSON.
    * @since 1.4
@@ -82,7 +82,7 @@ public final class JsonStreamParser implements Iterator {
     if (!hasNext()) {
       throw new NoSuchElementException();
     }
-    
+
     try {
       return Streams.parse(parser);
     } catch (StackOverflowError e) {
diff --git a/gson/com/google/gson/LongSerializationPolicy.java b/gson/com/google/gson/LongSerializationPolicy.java
index 3d9a2da..a141189 100644
--- a/gson/com/google/gson/LongSerializationPolicy.java
+++ b/gson/com/google/gson/LongSerializationPolicy.java
@@ -36,9 +36,9 @@ public enum LongSerializationPolicy {
       return new JsonPrimitive(value);
     }
   },
-  
+
   /**
-   * Serializes a long value as a quoted string.  For example, assume an object has a long field 
+   * Serializes a long value as a quoted string.  For example, assume an object has a long field
    * named "f" then the serialized output would be:
    * {@code {"f":"123"}}.
    */
@@ -47,7 +47,7 @@ public enum LongSerializationPolicy {
       return new JsonPrimitive(String.valueOf(value));
     }
   };
-  
+
   /**
    * Serialize this {@code value} using this serialization policy.
    *
diff --git a/gson/com/google/gson/annotations/Expose.java b/gson/com/google/gson/annotations/Expose.java
index 1b9c70d..99fd86f 100644
--- a/gson/com/google/gson/annotations/Expose.java
+++ b/gson/com/google/gson/annotations/Expose.java
@@ -60,7 +60,7 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.FIELD)
 public @interface Expose {
-  
+
   /**
    * If {@code true}, the field marked with this annotation is written out in the JSON while
    * serializing. If {@code false}, the field marked with this annotation is skipped from the
@@ -71,7 +71,7 @@ public @interface Expose {
 
   /**
    * If {@code true}, the field marked with this annotation is deserialized from the JSON.
-   * If {@code false}, the field marked with this annotation is skipped during deserialization. 
+   * If {@code false}, the field marked with this annotation is skipped during deserialization.
    * Defaults to {@code true}.
    * @since 1.4
    */
diff --git a/gson/com/google/gson/annotations/Until.java b/gson/com/google/gson/annotations/Until.java
index 4648b8a..3fe69c4 100644
--- a/gson/com/google/gson/annotations/Until.java
+++ b/gson/com/google/gson/annotations/Until.java
@@ -46,7 +46,7 @@ import java.lang.annotation.Target;
  * methods will use all the fields for serialization and deserialization. However, if you created
  * Gson with {@code Gson gson = new GsonBuilder().setVersion(1.2).create()} then the
  * {@code toJson()} and {@code fromJson()} methods of Gson will exclude the {@code emailAddress}
- * and {@code password} fields from the example above, because the version number passed to the 
+ * and {@code password} fields from the example above, because the version number passed to the
  * GsonBuilder, {@code 1.2}, exceeds the version number set on the {@code Until} annotation,
  * {@code 1.1}, for those fields.
  *
diff --git a/gson/com/google/gson/annotations/package-info.java b/gson/com/google/gson/annotations/package-info.java
index 1c461fd..e14b72a 100644
--- a/gson/com/google/gson/annotations/package-info.java
+++ b/gson/com/google/gson/annotations/package-info.java
@@ -1,6 +1,6 @@
 /**
  * This package provides annotations that can be used with {@link com.google.gson.Gson}.
- * 
+ *
  * @author Inderjeet Singh, Joel Leitch
  */
 package com.google.gson.annotations;
\ No newline at end of file
diff --git a/gson/com/google/gson/internal/$Gson$Preconditions.java b/gson/com/google/gson/internal/$Gson$Preconditions.java
index ccc0390..2042f47 100644
--- a/gson/com/google/gson/internal/$Gson$Preconditions.java
+++ b/gson/com/google/gson/internal/$Gson$Preconditions.java
@@ -1,45 +1,45 @@
-/*
- * Copyright (C) 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.gson.internal;
-
-/**
- * A simple utility class used to check method Preconditions.
- *
- * 
- * public long divideBy(long value) {
- *   Preconditions.checkArgument(value != 0);
- *   return this.value / value;
- * }
- * 
- * - * @author Inderjeet Singh - * @author Joel Leitch - */ -public final class $Gson$Preconditions { - public static T checkNotNull(T obj) { - if (obj == null) { - throw new NullPointerException(); - } - return obj; - } - - public static void checkArgument(boolean condition) { - if (!condition) { - throw new IllegalArgumentException(); - } - } -} +/* + * Copyright (C) 2008 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.gson.internal; + +/** + * A simple utility class used to check method Preconditions. + * + *
+ * public long divideBy(long value) {
+ *   Preconditions.checkArgument(value != 0);
+ *   return this.value / value;
+ * }
+ * 
+ * + * @author Inderjeet Singh + * @author Joel Leitch + */ +public final class $Gson$Preconditions { + public static T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + + public static void checkArgument(boolean condition) { + if (!condition) { + throw new IllegalArgumentException(); + } + } +} diff --git a/gson/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java b/gson/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java index 7e52c27..839d49c 100644 --- a/gson/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java +++ b/gson/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java @@ -1,81 +1,81 @@ -/* - * Copyright (C) 2011 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.internal.bind; - -import com.google.gson.Gson; -import com.google.gson.TypeAdapter; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; - -final class TypeAdapterRuntimeTypeWrapper extends TypeAdapter { - private final Gson context; - private final TypeAdapter delegate; - private final Type type; - - TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter delegate, Type type) { - this.context = context; - this.delegate = delegate; - this.type = type; - } - - @Override - public T read(JsonReader in) throws IOException { - return delegate.read(in); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - public void write(JsonWriter out, T value) throws IOException { - // Order of preference for choosing type adapters - // First preference: a type adapter registered for the runtime type - // Second preference: a type adapter registered for the declared type - // Third preference: reflective type adapter for the runtime type (if it is a sub class of the declared type) - // Fourth preference: reflective type adapter for the declared type - - TypeAdapter chosen = delegate; - Type runtimeType = getRuntimeTypeIfMoreSpecific(type, value); - if (runtimeType != type) { - TypeAdapter runtimeTypeAdapter = context.getAdapter(TypeToken.get(runtimeType)); - if (!(runtimeTypeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) { - // The user registered a type adapter for the runtime type, so we will use that - chosen = runtimeTypeAdapter; - } else if (!(delegate instanceof ReflectiveTypeAdapterFactory.Adapter)) { - // The user registered a type adapter for Base class, so we prefer it over the - // reflective type adapter for the runtime type - chosen = delegate; - } else { - // Use the type adapter for runtime type - chosen = runtimeTypeAdapter; - } - } - chosen.write(out, value); - } - - /** - * Finds a compatible runtime type if it is more specific - */ - private Type getRuntimeTypeIfMoreSpecific(Type type, Object value) { - if (value != null - && (type == Object.class || type instanceof TypeVariable || type instanceof Class)) { - type = value.getClass(); - } - return type; - } -} +/* + * Copyright (C) 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.gson.internal.bind; + +import com.google.gson.Gson; +import com.google.gson.TypeAdapter; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; + +final class TypeAdapterRuntimeTypeWrapper extends TypeAdapter { + private final Gson context; + private final TypeAdapter delegate; + private final Type type; + + TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter delegate, Type type) { + this.context = context; + this.delegate = delegate; + this.type = type; + } + + @Override + public T read(JsonReader in) throws IOException { + return delegate.read(in); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void write(JsonWriter out, T value) throws IOException { + // Order of preference for choosing type adapters + // First preference: a type adapter registered for the runtime type + // Second preference: a type adapter registered for the declared type + // Third preference: reflective type adapter for the runtime type (if it is a sub class of the declared type) + // Fourth preference: reflective type adapter for the declared type + + TypeAdapter chosen = delegate; + Type runtimeType = getRuntimeTypeIfMoreSpecific(type, value); + if (runtimeType != type) { + TypeAdapter runtimeTypeAdapter = context.getAdapter(TypeToken.get(runtimeType)); + if (!(runtimeTypeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) { + // The user registered a type adapter for the runtime type, so we will use that + chosen = runtimeTypeAdapter; + } else if (!(delegate instanceof ReflectiveTypeAdapterFactory.Adapter)) { + // The user registered a type adapter for Base class, so we prefer it over the + // reflective type adapter for the runtime type + chosen = delegate; + } else { + // Use the type adapter for runtime type + chosen = runtimeTypeAdapter; + } + } + chosen.write(out, value); + } + + /** + * Finds a compatible runtime type if it is more specific + */ + private Type getRuntimeTypeIfMoreSpecific(Type type, Object value) { + if (value != null + && (type == Object.class || type instanceof TypeVariable || type instanceof Class)) { + type = value.getClass(); + } + return type; + } +} diff --git a/gson/com/google/gson/internal/bind/TypeAdapters.java b/gson/com/google/gson/internal/bind/TypeAdapters.java index 8412ad5..21a5f64 100644 --- a/gson/com/google/gson/internal/bind/TypeAdapters.java +++ b/gson/com/google/gson/internal/bind/TypeAdapters.java @@ -362,7 +362,7 @@ public final class TypeAdapters { out.value(value); } }; - + public static final TypeAdapter BIG_DECIMAL = new TypeAdapter() { @Override public BigDecimal read(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { @@ -380,7 +380,7 @@ public final class TypeAdapters { out.value(value); } }; - + public static final TypeAdapter BIG_INTEGER = new TypeAdapter() { @Override public BigInteger read(JsonReader in) throws IOException { if (in.peek() == JsonToken.NULL) { diff --git a/gson/com/google/gson/reflect/package-info.java b/gson/com/google/gson/reflect/package-info.java index e666c43..5e43ee9 100644 --- a/gson/com/google/gson/reflect/package-info.java +++ b/gson/com/google/gson/reflect/package-info.java @@ -1,6 +1,6 @@ /** * This package provides utility classes for finding type information for generic types. - * + * * @author Inderjeet Singh, Joel Leitch */ package com.google.gson.reflect; \ No newline at end of file diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png index f48ba3e7ab21714b7ac58bbc1ee587b1d1a543f7..d72c84bb5f2ea9462d9752662da82aaf01b75da5 100644 GIT binary patch delta 16 Ycmcc4ag~FmGr-S%BI~w|duB5O05$^#h5!Hn delta 19 bcmcc0ah-#;Gr-TCcOuI+M$V19W-|i-LfQtK diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png index 3ff2b76fddaea5f943dce050060b9632c129bd04..42219b60e7d855e3018929bc26b674e15de70bb3 100644 GIT binary patch delta 13 Ucmeyy`jwTXGr-S%BkM;d0453r5dZ)H delta 14 Vcmey$`i+&fGr-TCcO%P3CIBh81s(tZ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png index 774763e0522097c753ceb3d32feea29311715e03..129453f652d8eee6efcee162a959779e4ef103e7 100644 GIT binary patch delta 13 UcmdnWy@i{lGr-S%BkKlM03Y`RT>t<8 delta 14 VcmdnOy_K7_Gr-TCcO%ONRsbU}1Zn^P diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png index 32da992de27fd2a45a80888677722ea832bc649f..361d98461b98fd47c42a904a23421bc9c9fdd1d7 100644 GIT binary patch delta 13 UcmZ23xJ;0xGr-S%BkLj#03Q+rLI3~& delta 14 VcmZ1`xLlC6Gr-TCcO%Op4gexL1Wy0} diff --git a/res/layout/event_row_layout.xml b/res/layout/event_row_layout.xml index 048a6b3..fb66d81 100644 --- a/res/layout/event_row_layout.xml +++ b/res/layout/event_row_layout.xml @@ -14,7 +14,7 @@ android:layout_width="match_parent" android:layout_height="7dp" /> - + - + diff --git a/res/menu/event.xml b/res/menu/event.xml index f4ce275..1dde058 100644 --- a/res/menu/event.xml +++ b/res/menu/event.xml @@ -1,18 +1,18 @@ - - + - - + - + diff --git a/res/menu/main.xml b/res/menu/main.xml index 799568d..757150c 100644 --- a/res/menu/main.xml +++ b/res/menu/main.xml @@ -4,8 +4,8 @@ android:visible="true" android:showAsAction="always" android:icon="@android:drawable/ic_menu_add" android:titleCondensed="NEW"> - + - + diff --git a/res/values/strings.xml b/res/values/strings.xml index e2c68c2..289dde3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -37,7 +37,7 @@ End: Repeat Repeat every - + Daily Weekly diff --git a/src/ro/ieval/unical/AddEventActivity.java b/src/ro/ieval/unical/AddEventActivity.java index d16b426..606685f 100644 --- a/src/ro/ieval/unical/AddEventActivity.java +++ b/src/ro/ieval/unical/AddEventActivity.java @@ -34,7 +34,7 @@ public final class AddEventActivity extends Activity implements OnDateSetListene final ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1)); final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2)); final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3)); - + final Fragment f1 = new TrivialFragment(); final Bundle b1=new Bundle(); b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab); @@ -49,24 +49,24 @@ public final class AddEventActivity extends Activity implements OnDateSetListene final Bundle b3=new Bundle(); b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab); f3.setArguments(b3); - + t1.setTabListener(new AddEventTabListener(f1)); t2.setTabListener(new AddEventTabListener(f2)); t3.setTabListener(new AddEventTabListener(f3)); - + actionBar.addTab(t1); actionBar.addTab(t2); actionBar.addTab(t3); - + handleViews(f1,f2,f3); - + } - + private void handleViews(Fragment f1,Fragment f2,Fragment f3) { Switch repeatSwitch = (Switch) this.getFragmentManager().findFragmentById(f1.getId()).getView().findViewById(R.id.repeat_switch); final Spinner repeatSpinner = (Spinner) this.getFragmentManager().findFragmentById(f1.getId()).getView().findViewById(R.id.repeat_spinner); repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { - + @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked) { @@ -84,7 +84,7 @@ public final class AddEventActivity extends Activity implements OnDateSetListene inflater.inflate(R.menu.add_event, menu); return true; } - + @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { @@ -95,7 +95,7 @@ public final class AddEventActivity extends Activity implements OnDateSetListene return false; } } - + public void showDateTimePickerDialog(final View v) { dateTimeTextView=(TextView) v; if(v.getId()==R.id.date_start || v.getId()==R.id.date_end) diff --git a/src/ro/ieval/unical/AddEventTabListener.java b/src/ro/ieval/unical/AddEventTabListener.java index 61ac236..ea67b63 100644 --- a/src/ro/ieval/unical/AddEventTabListener.java +++ b/src/ro/ieval/unical/AddEventTabListener.java @@ -25,6 +25,6 @@ public class AddEventTabListener implements ActionBar.TabListener { @Override public void onTabReselected(final Tab tab, final FragmentTransaction ft) { // TODO Auto-generated method stub - + } } diff --git a/src/ro/ieval/unical/Calendar.java b/src/ro/ieval/unical/Calendar.java index 1ab1988..192c937 100644 --- a/src/ro/ieval/unical/Calendar.java +++ b/src/ro/ieval/unical/Calendar.java @@ -27,7 +27,7 @@ final class Calendar { public final boolean visible; /** Name of the account used to sync this calendar */ public final String accountName; - /** Type of the calendar used to sync this calendar */ + /** Type of the calendar used to sync this calendar */ public final String accountType; /** Calendar colour */ public final int colour; diff --git a/src/ro/ieval/unical/DisplayEventActivity.java b/src/ro/ieval/unical/DisplayEventActivity.java index 48b8068..798adc6 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -28,20 +28,20 @@ public class DisplayEventActivity extends Activity { final Event e=getIntent().getParcelableExtra(EXTRA_EVENT); setContentView(R.layout.event_view); setTitle(e.title); - + final TextView startDay= (TextView) findViewById(R.id.startday); final TextView endDay= (TextView) findViewById(R.id.endday); final TextView startDate= (TextView) findViewById(R.id.startdate); final TextView endDate= (TextView) findViewById(R.id.enddate); final TextView startTime= (TextView) findViewById(R.id.starttime); final TextView endTime= (TextView) findViewById(R.id.endtime); - + final Date start=new Date(e.dtstart); final Date end=new Date(e.dtend); final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.UK); final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.UK); final SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK); - + startDay.setText(dayOfWeekFormat.format(start)); if(dateFormat.format(start)!=dateFormat.format(end)) { endDay.setText(dayOfWeekFormat.format(end)); @@ -51,14 +51,14 @@ public class DisplayEventActivity extends Activity { startTime.setText(timeFormat.format(start)); endTime.setText(timeFormat.format(end)); } - + @Override public boolean onCreateOptionsMenu(final Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.event, menu); return true; } - + @Override public boolean onOptionsItemSelected(final MenuItem item) { // Handle item selection diff --git a/src/ro/ieval/unical/Event.java b/src/ro/ieval/unical/Event.java index a069a9f..c164805 100644 --- a/src/ro/ieval/unical/Event.java +++ b/src/ro/ieval/unical/Event.java @@ -48,7 +48,7 @@ final class Event implements Parcelable{ public final String description; /** Event colour */ public final int eventColour; - /** Event start time (UTC milliseconds since epoch) */ + /** Event start time (UTC milliseconds since epoch) */ public final long dtstart; /** Event end time (UTC milliseconds since epoch) */ public final long dtend; @@ -85,7 +85,7 @@ final class Event implements Parcelable{ cursor.close(); return events; } - + public static Event[] getAllEvents(final Context context) { final ArrayList r = new ArrayList(); for(final Calendar calendar : Calendar.getAllCalendars(context)) @@ -98,7 +98,7 @@ final class Event implements Parcelable{ final ContentResolver cr=context.getContentResolver(); cr.delete(Uri.withAppendedPath(Events.CONTENT_URI, Long.toString(_id)), null, null); } - + @Override public int describeContents() { return 0; diff --git a/src/ro/ieval/unical/EventAdapter.java b/src/ro/ieval/unical/EventAdapter.java index 577ea0c..a9e0181 100644 --- a/src/ro/ieval/unical/EventAdapter.java +++ b/src/ro/ieval/unical/EventAdapter.java @@ -18,7 +18,7 @@ public class EventAdapter extends ArrayAdapter { this.context=context; this.values=values; } - + @Override public View getView(final int position, final View convertView, final ViewGroup parent) { final LayoutInflater inflater = (LayoutInflater) context @@ -32,7 +32,7 @@ public class EventAdapter extends ArrayAdapter { title.setText(values[position].title); dstart.setText(new Date(values[position].dtstart).toString()); dend.setText(new Date(values[position].dtend).toString()); - + return rowView; } } diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java index 67e0a7f..b8c81ab 100644 --- a/src/ro/ieval/unical/EventListActivity.java +++ b/src/ro/ieval/unical/EventListActivity.java @@ -17,17 +17,17 @@ import android.widget.ListView; public class EventListActivity extends Activity { - + //Used to refresh events if the user wants to display only certain events //Sry for bad english //Muie la comisie private void displayEvents() { final Event events[]=Event.getAllEvents(getBaseContext()); final ListView lv = (ListView) findViewById(R.id.eventlist); - + Arrays.sort(events,new EventComparator()); int idx=-1;//index of the first event to be displayed - for(int i=0; inew Date().getTime()) idx=i; if(idx==-1) idx=0; @@ -41,10 +41,10 @@ public class EventListActivity extends Activity { final long arg3) { DisplayEventActivity.displayEvent(EventListActivity.this,events[arg2]); } - + }); } - + private static class EventComparator implements Comparator { @Override public int compare(final Event lhs, final Event rhs) { @@ -61,17 +61,17 @@ public class EventListActivity extends Activity { protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.event_list); - + displayEvents(); } - + @Override public boolean onCreateOptionsMenu(final Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); return true; } - + @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { @@ -83,5 +83,5 @@ public class EventListActivity extends Activity { return false; } } - + } diff --git a/src/ro/ieval/unical/LoginActivity.java b/src/ro/ieval/unical/LoginActivity.java index 3dd3636..dcda4a8 100644 --- a/src/ro/ieval/unical/LoginActivity.java +++ b/src/ro/ieval/unical/LoginActivity.java @@ -6,7 +6,7 @@ import android.view.View; import android.widget.Button; public final class LoginActivity extends Activity { - + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -16,9 +16,9 @@ public final class LoginActivity extends Activity { //final EditText user=(EditText) findViewById(R.id.editText1); //final EditText pass=(EditText) findViewById(R.id.editText2); final Button logIn=(Button) findViewById(R.id.button1); - + logIn.setOnClickListener(new View.OnClickListener() { - + @Override public void onClick(final View v) { setContentView(R.layout.event_view); diff --git a/src/ro/ieval/unical/MainActivity.java b/src/ro/ieval/unical/MainActivity.java index b779d06..f94eb5f 100644 --- a/src/ro/ieval/unical/MainActivity.java +++ b/src/ro/ieval/unical/MainActivity.java @@ -8,11 +8,11 @@ import android.view.MenuInflater; import android.view.MenuItem; public class MainActivity extends android.app.Activity { - + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this); if(prefs.getBoolean("FirstTime", true)) { prefs.edit().putBoolean("FirstTime", false).commit(); @@ -23,14 +23,14 @@ public class MainActivity extends android.app.Activity { final Intent intent=new Intent(this, EventListActivity.class); startActivity(intent); } - + @Override public boolean onCreateOptionsMenu(final Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); return true; } - + @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { -- 2.39.2