* }</pre>
* 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 <i>this</i> (the type adapter
* factory from where {@link #getDelegateAdapter} method is being invoked).
/**
* This exception is raised when Gson was unable to read an input stream
* or write to one.
- *
+ *
* @author Inderjeet Singh
* @author Joel Leitch
*/
-/*\r
- * Copyright (C) 2008 Google Inc.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package com.google.gson;\r
-\r
-/**\r
- * A class representing a Json {@code null} value.\r
- *\r
- * @author Inderjeet Singh\r
- * @author Joel Leitch\r
- * @since 1.2\r
- */\r
-public final class JsonNull extends JsonElement {\r
- /**\r
- * singleton for JsonNull\r
- *\r
- * @since 1.8\r
- */\r
- public static final JsonNull INSTANCE = new JsonNull();\r
-\r
- /**\r
- * Creates a new JsonNull object.\r
- * Deprecated since Gson version 1.8. Use {@link #INSTANCE} instead\r
- */\r
- @Deprecated\r
- public JsonNull() {\r
- // Do nothing\r
- }\r
-\r
- @Override\r
- JsonNull deepCopy() {\r
- return INSTANCE;\r
- }\r
-\r
- /**\r
- * All instances of JsonNull have the same hash code since they are indistinguishable\r
- */\r
- @Override\r
- public int hashCode() {\r
- return JsonNull.class.hashCode();\r
- }\r
-\r
- /**\r
- * All instances of JsonNull are the same\r
- */\r
- @Override\r
- public boolean equals(Object other) {\r
- return this == other || other instanceof JsonNull;\r
- }\r
-}\r
+/*
+ * 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;
+ }
+}
-/*\r
- * Copyright (C) 2009 Google Inc.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.google.gson;\r
-\r
-import java.io.IOException;\r
-import java.io.Reader;\r
-import java.io.StringReader;\r
-\r
-import com.google.gson.internal.Streams;\r
-import com.google.gson.stream.JsonReader;\r
-import com.google.gson.stream.JsonToken;\r
-import com.google.gson.stream.MalformedJsonException;\r
-\r
-/**\r
- * A parser to parse Json into a parse tree of {@link JsonElement}s\r
- *\r
- * @author Inderjeet Singh\r
- * @author Joel Leitch\r
- * @since 1.3\r
- */\r
-public final class JsonParser {\r
-\r
- /**\r
- * Parses the specified JSON string into a parse tree\r
- *\r
- * @param json JSON text\r
- * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON\r
- * @throws JsonParseException if the specified text is not valid JSON\r
- * @since 1.3\r
- */\r
- public JsonElement parse(String json) throws JsonSyntaxException {\r
- return parse(new StringReader(json));\r
- }\r
-\r
- /**\r
- * Parses the specified JSON string into a parse tree\r
- *\r
- * @param json JSON text\r
- * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON\r
- * @throws JsonParseException if the specified text is not valid JSON\r
- * @since 1.3\r
- */\r
- public JsonElement parse(Reader json) throws JsonIOException, JsonSyntaxException {\r
- try {\r
- JsonReader jsonReader = new JsonReader(json);\r
- JsonElement element = parse(jsonReader);\r
- if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {\r
- throw new JsonSyntaxException("Did not consume the entire document.");\r
- }\r
- return element;\r
- } catch (MalformedJsonException e) {\r
- throw new JsonSyntaxException(e);\r
- } catch (IOException e) {\r
- throw new JsonIOException(e);\r
- } catch (NumberFormatException e) {\r
- throw new JsonSyntaxException(e);\r
- }\r
- }\r
-\r
- /**\r
- * Returns the next value from the JSON stream as a parse tree.\r
- *\r
- * @throws JsonParseException if there is an IOException or if the specified\r
- * text is not valid JSON\r
- * @since 1.6\r
- */\r
- public JsonElement parse(JsonReader json) throws JsonIOException, JsonSyntaxException {\r
- boolean lenient = json.isLenient();\r
- json.setLenient(true);\r
- try {\r
- return Streams.parse(json);\r
- } catch (StackOverflowError e) {\r
- throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e);\r
- } catch (OutOfMemoryError e) {\r
- throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e);\r
- } finally {\r
- json.setLenient(lenient);\r
- }\r
- }\r
-}\r
+/*
+ * 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);
+ }
+ }
+}
/**
* A streaming parser that allows reading of multiple {@link JsonElement}s from the specified reader
* asynchronously.
- *
+ *
* <p>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:
- *
+ *
* <pre>
* JsonStreamParser parser = new JsonStreamParser("['first'] {'second':10} 'third'");
* JsonElement element;
* @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
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
if (!hasNext()) {
throw new NoSuchElementException();
}
-
+
try {
return Streams.parse(parser);
} catch (StackOverflowError e) {
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"}}.
*/
return new JsonPrimitive(String.valueOf(value));
}
};
-
+
/**
* Serialize this {@code value} using this serialization policy.
*
@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
/**
* 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
*/
* 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.
*
/**
* 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
-/*\r
- * Copyright (C) 2008 Google Inc.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package com.google.gson.internal;\r
-\r
-/**\r
- * A simple utility class used to check method Preconditions.\r
- *\r
- * <pre>\r
- * public long divideBy(long value) {\r
- * Preconditions.checkArgument(value != 0);\r
- * return this.value / value;\r
- * }\r
- * </pre>\r
- *\r
- * @author Inderjeet Singh\r
- * @author Joel Leitch\r
- */\r
-public final class $Gson$Preconditions {\r
- public static <T> T checkNotNull(T obj) {\r
- if (obj == null) {\r
- throw new NullPointerException();\r
- }\r
- return obj;\r
- }\r
-\r
- public static void checkArgument(boolean condition) {\r
- if (!condition) {\r
- throw new IllegalArgumentException();\r
- }\r
- }\r
-}\r
+/*
+ * 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.
+ *
+ * <pre>
+ * public long divideBy(long value) {
+ * Preconditions.checkArgument(value != 0);
+ * return this.value / value;
+ * }
+ * </pre>
+ *
+ * @author Inderjeet Singh
+ * @author Joel Leitch
+ */
+public final class $Gson$Preconditions {
+ public static <T> T checkNotNull(T obj) {
+ if (obj == null) {
+ throw new NullPointerException();
+ }
+ return obj;
+ }
+
+ public static void checkArgument(boolean condition) {
+ if (!condition) {
+ throw new IllegalArgumentException();
+ }
+ }
+}
-/*\r
- * Copyright (C) 2011 Google Inc.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.google.gson.internal.bind;\r
-\r
-import com.google.gson.Gson;\r
-import com.google.gson.TypeAdapter;\r
-import com.google.gson.reflect.TypeToken;\r
-import com.google.gson.stream.JsonReader;\r
-import com.google.gson.stream.JsonWriter;\r
-import java.io.IOException;\r
-import java.lang.reflect.Type;\r
-import java.lang.reflect.TypeVariable;\r
-\r
-final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {\r
- private final Gson context;\r
- private final TypeAdapter<T> delegate;\r
- private final Type type;\r
-\r
- TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter<T> delegate, Type type) {\r
- this.context = context;\r
- this.delegate = delegate;\r
- this.type = type;\r
- }\r
-\r
- @Override\r
- public T read(JsonReader in) throws IOException {\r
- return delegate.read(in);\r
- }\r
-\r
- @SuppressWarnings({"rawtypes", "unchecked"})\r
- @Override\r
- public void write(JsonWriter out, T value) throws IOException {\r
- // Order of preference for choosing type adapters\r
- // First preference: a type adapter registered for the runtime type\r
- // Second preference: a type adapter registered for the declared type\r
- // Third preference: reflective type adapter for the runtime type (if it is a sub class of the declared type)\r
- // Fourth preference: reflective type adapter for the declared type\r
-\r
- TypeAdapter chosen = delegate;\r
- Type runtimeType = getRuntimeTypeIfMoreSpecific(type, value);\r
- if (runtimeType != type) {\r
- TypeAdapter runtimeTypeAdapter = context.getAdapter(TypeToken.get(runtimeType));\r
- if (!(runtimeTypeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) {\r
- // The user registered a type adapter for the runtime type, so we will use that\r
- chosen = runtimeTypeAdapter;\r
- } else if (!(delegate instanceof ReflectiveTypeAdapterFactory.Adapter)) {\r
- // The user registered a type adapter for Base class, so we prefer it over the\r
- // reflective type adapter for the runtime type\r
- chosen = delegate;\r
- } else {\r
- // Use the type adapter for runtime type\r
- chosen = runtimeTypeAdapter;\r
- }\r
- }\r
- chosen.write(out, value);\r
- }\r
-\r
- /**\r
- * Finds a compatible runtime type if it is more specific\r
- */\r
- private Type getRuntimeTypeIfMoreSpecific(Type type, Object value) {\r
- if (value != null\r
- && (type == Object.class || type instanceof TypeVariable<?> || type instanceof Class<?>)) {\r
- type = value.getClass();\r
- }\r
- return type;\r
- }\r
-}\r
+/*
+ * 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<T> extends TypeAdapter<T> {
+ private final Gson context;
+ private final TypeAdapter<T> delegate;
+ private final Type type;
+
+ TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter<T> 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;
+ }
+}
out.value(value);
}
};
-
+
public static final TypeAdapter<BigDecimal> BIG_DECIMAL = new TypeAdapter<BigDecimal>() {
@Override public BigDecimal read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
out.value(value);
}
};
-
+
public static final TypeAdapter<BigInteger> BIG_INTEGER = new TypeAdapter<BigInteger>() {
@Override public BigInteger read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
/**
* 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
android:layout_width="match_parent"
android:layout_height="7dp"
/>
-
+
<View
android:layout_width="match_parent"
android:layout_height="1dp"
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/save" android:icon="@android:drawable/ic_menu_save" android:title="@string/save" android:titleCondensed="SAVE" android:showAsAction="always"></item>
<item android:id="@+id/cancel" android:icon="@android:drawable/ic_menu_close_clear_cancel" android:title="@string/cancel" android:titleCondensed="CANCEL" android:showAsAction="ifRoom"></item>
-
+
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/deleteevent" android:icon="@android:drawable/ic_menu_delete" android:title="Delete Event" android:visible="true" android:titleCondensed="DELETE" android:showAsAction="always"></item>
- <item android:id="@+id/NewEvent" android:title="New event"
+ <item android:id="@+id/NewEvent" android:title="New event"
android:visible="true" android:showAsAction="ifRoom"
android:icon="@android:drawable/ic_menu_add"
android:titleCondensed="NEW">
-
+
</item>
- <item android:id="@+id/eventlist"
- android:title="@string/eventlist"
- android:visible="true"
+ <item android:id="@+id/eventlist"
+ android:title="@string/eventlist"
+ android:visible="true"
android:showAsAction="never" >
-
+
</item>
-
+
</menu>
android:visible="true" android:showAsAction="always"
android:icon="@android:drawable/ic_menu_add"
android:titleCondensed="NEW">
-
+
</item>
-
+
</menu>
<string name="end_label">End: </string>
<string name="repeat">Repeat</string>
<string name="repeat_every">Repeat every</string>
-
+
<string-array name="repeat_array">
<item>Daily</item>
<item>Weekly</item>
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);
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) {
inflater.inflate(R.menu.add_event, menu);
return true;
}
-
+
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
return false;
}
}
-
+
public void showDateTimePickerDialog(final View v) {
dateTimeTextView=(TextView) v;
if(v.getId()==R.id.date_start || v.getId()==R.id.date_end)
@Override
public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
// TODO Auto-generated method stub
-
+
}
}
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;
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));
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
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;
cursor.close();
return events;
}
-
+
public static Event[] getAllEvents(final Context context) {
final ArrayList<Event> r = new ArrayList<Event>();
for(final Calendar calendar : Calendar.getAllCalendars(context))
final ContentResolver cr=context.getContentResolver();
cr.delete(Uri.withAppendedPath(Events.CONTENT_URI, Long.toString(_id)), null, null);
}
-
+
@Override
public int describeContents() {
return 0;
this.context=context;
this.values=values;
}
-
+
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
final LayoutInflater inflater = (LayoutInflater) context
title.setText(values[position].title);
dstart.setText(new Date(values[position].dtstart).toString());
dend.setText(new Date(values[position].dtend).toString());
-
+
return rowView;
}
}
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; i<events.length; ++i)
+ for(int i=0; i<events.length; ++i)
if(idx==-1 && events[i].dtend>new Date().getTime()) idx=i;
if(idx==-1) idx=0;
final long arg3) {
DisplayEventActivity.displayEvent(EventListActivity.this,events[arg2]);
}
-
+
});
}
-
+
private static class EventComparator implements Comparator<Event> {
@Override
public int compare(final Event lhs, final Event rhs) {
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()) {
return false;
}
}
-
+
}
import android.widget.Button;
public final class LoginActivity extends Activity {
-
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//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);
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();
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()) {