Skip to content
Permalink
Browse files

Merge pull request #53 from mcharmas/dev-mapsparcelation

Maps parcelation and multiple fixes
  • Loading branch information...
mcharmas committed May 10, 2016
2 parents 4d02297 + febbe19 commit 68a5879f9a5da10ec597218f2a20b9202dd0fca8
Showing with 1,876 additions and 134 deletions.
  1. +6 −0 .gitignore
  2. +1 −1 META-INF/plugin.xml
  3. +6 −0 ParcelableTestApp/.gitignore
  4. +1 −0 ParcelableTestApp/app/.gitignore
  5. +42 −0 ParcelableTestApp/app/build.gradle
  6. +17 −0 ParcelableTestApp/app/proguard-rules.pro
  7. +13 −0 ParcelableTestApp/app/src/androidTest/java/com/example/sampleapp/app/ApplicationTest.java
  8. +73 −0 ParcelableTestApp/app/src/androidTest/java/com/example/sampleapp/app/PrimitivesParcelableTest.java
  9. +21 −0 ParcelableTestApp/app/src/main/AndroidManifest.xml
  10. +95 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/BoxedPrimitivesParcelable.java
  11. +61 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/BundleParcelable.java
  12. +62 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/DateParcelable.java
  13. +79 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/EnumParcelable.java
  14. +74 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/GenericListParcelable.java
  15. +85 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/MapParcelable.java
  16. +64 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/NestedParcelable.java
  17. +99 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/PrimitiveArrayParcelable.java
  18. +98 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/PrimitivesParcelable.java
  19. +92 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/SerializableParcelable.java
  20. +66 −0 ParcelableTestApp/app/src/main/java/com/example/sampleapp/app/SparseParcelable.java
  21. +16 −0 ParcelableTestApp/app/src/main/res/layout/activity_main.xml
  22. +9 −0 ParcelableTestApp/app/src/main/res/menu/menu_main.xml
  23. BIN ParcelableTestApp/app/src/main/res/mipmap-hdpi/ic_launcher.png
  24. BIN ParcelableTestApp/app/src/main/res/mipmap-mdpi/ic_launcher.png
  25. BIN ParcelableTestApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png
  26. BIN ParcelableTestApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  27. +6 −0 ParcelableTestApp/app/src/main/res/values-w820dp/dimens.xml
  28. +5 −0 ParcelableTestApp/app/src/main/res/values/dimens.xml
  29. +6 −0 ParcelableTestApp/app/src/main/res/values/strings.xml
  30. +8 −0 ParcelableTestApp/app/src/main/res/values/styles.xml
  31. +19 −0 ParcelableTestApp/build.gradle
  32. +18 −0 ParcelableTestApp/gradle.properties
  33. BIN ParcelableTestApp/gradle/wrapper/gradle-wrapper.jar
  34. +6 −0 ParcelableTestApp/gradle/wrapper/gradle-wrapper.properties
  35. +164 −0 ParcelableTestApp/gradlew
  36. +90 −0 ParcelableTestApp/gradlew.bat
  37. +1 −0 ParcelableTestApp/settings.gradle
  38. +2 −2 README.md
  39. +11 −2 android-parcelable-intellij-plugin.iml
  40. +6 −5 src/pl/charmas/parcelablegenerator/CodeGenerator.java
  41. +5 −2 src/pl/charmas/parcelablegenerator/GenerateDialog.java
  42. +1 −0 src/pl/charmas/parcelablegenerator/typeserializers/BundleSerializerFactory.java
  43. +12 −0 src/pl/charmas/parcelablegenerator/typeserializers/ChainSerializerFactory.java
  44. +1 −0 src/pl/charmas/parcelablegenerator/typeserializers/DateSerializerFactory.java
  45. +1 −5 src/pl/charmas/parcelablegenerator/typeserializers/EnumerationSerializerFactory.java
  46. +1 −0 src/pl/charmas/parcelablegenerator/typeserializers/ListSerializerFactory.java
  47. +37 −0 src/pl/charmas/parcelablegenerator/typeserializers/MapSerializerFactory.java
  48. +3 −2 src/pl/charmas/parcelablegenerator/typeserializers/ParcelableSerializerFactory.java
  49. +3 −2 src/pl/charmas/parcelablegenerator/typeserializers/PrimitiveArraySerializerFactory.java
  50. +2 −1 src/pl/charmas/parcelablegenerator/typeserializers/PrimitiveTypeArraySerializerFactory.java
  51. +4 −3 src/pl/charmas/parcelablegenerator/typeserializers/PrimitiveTypeSerializerFactory.java
  52. +4 −8 src/pl/charmas/parcelablegenerator/typeserializers/SerializableSerializerFactory.java
  53. +97 −0 src/pl/charmas/parcelablegenerator/typeserializers/SerializableValue.java
  54. +34 −0 src/pl/charmas/parcelablegenerator/typeserializers/SparseArraySerializerFactory.java
  55. +3 −4 src/pl/charmas/parcelablegenerator/typeserializers/TypeSerializer.java
  56. +4 −4 src/pl/charmas/parcelablegenerator/typeserializers/serializers/BooleanPrimitiveSerializer.java
  57. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/BooleanSparseArraySerializer.java
  58. +3 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/BundleSerializer.java
  59. +4 −4 src/pl/charmas/parcelablegenerator/typeserializers/serializers/CharPrimitiveSerializer.java
  60. +6 −8 src/pl/charmas/parcelablegenerator/typeserializers/serializers/DateSerializer.java
  61. +7 −8 src/pl/charmas/parcelablegenerator/typeserializers/serializers/EnumerationSerializer.java
  62. +26 −16 src/pl/charmas/parcelablegenerator/typeserializers/serializers/GenericListSerializer.java
  63. +75 −0 src/pl/charmas/parcelablegenerator/typeserializers/serializers/MapSerializer.java
  64. +5 −5 ...pl/charmas/parcelablegenerator/typeserializers/serializers/NullablePrimitivesArraySerializer.java
  65. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/NullablePrimitivesSerializer.java
  66. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/ParcelableArraySerializer.java
  67. +4 −4 src/pl/charmas/parcelablegenerator/typeserializers/serializers/ParcelableListSerializer.java
  68. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/ParcelableObjectSerializer.java
  69. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/PrimitiveArraySerializer.java
  70. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/PrimitiveTypeSerializer.java
  71. +5 −5 src/pl/charmas/parcelablegenerator/typeserializers/serializers/SerializableObjectSerializer.java
  72. +5 −6 src/pl/charmas/parcelablegenerator/typeserializers/serializers/ShortPrimitiveSerializer.java
  73. +33 −0 src/pl/charmas/parcelablegenerator/typeserializers/serializers/SparseArraySerializer.java
  74. +39 −2 src/pl/charmas/parcelablegenerator/util/PsiUtils.java
@@ -1,3 +1,9 @@
out/
.idea/
*.iml
.DS_Store
build/
*.zip

# Build output
android-parcelable-intellij-plugin.jar
@@ -17,7 +17,7 @@
-->
<idea-plugin version="7">
<id>pl.charmas.parcelablegenerator</id>
<name>Android Parcelable code generator.</name>
<name>Android Parcelable code generator</name>
<version>0.6.3</version>
<vendor email="michal@charmas.pl" url="http://blog.charmas.pl">Michal Charmas</vendor>

@@ -0,0 +1,6 @@
.gradle
.idea
/local.properties
.DS_Store
/build
/captures
@@ -0,0 +1 @@
/build
@@ -0,0 +1,42 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'

repositories {
jcenter()
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.sampleapp.app"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
}
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/mcharmas/Development/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,13 @@
package com.example.sampleapp.app;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
@@ -0,0 +1,73 @@
package com.example.sampleapp.app;

import android.os.Parcel;
import android.os.Parcelable;
import android.test.AndroidTestCase;

public class PrimitivesParcelableTest extends AndroidTestCase {

public void testParcelsPrimitives() throws Exception {
assertParcels(PrimitivesParcelable.create(), PrimitivesParcelable.CREATOR);
}

public void testParcelsPrimitiveArrays() throws Exception {
assertParcels(PrimitiveArrayParcelable.create(), PrimitiveArrayParcelable.CREATOR);
}

public void testParcelsBoxedPrimitives() throws Exception {
assertParcels(BoxedPrimitivesParcelable.create(), BoxedPrimitivesParcelable.CREATOR);
}

public void testParcelsBundleParcelable() throws Exception {
assertParcels(BundleParcelable.create(), BundleParcelable.CREATOR);
}

public void testParcelsDateParcelable() throws Exception {
assertParcels(DateParcelable.create(), DateParcelable.CREATOR);
}

public void testParcelsEnumParcelable() throws Exception {
assertParcels(EnumParcelable.create(), EnumParcelable.CREATOR);
}

public void testParcelsSerializableParcelable() throws Exception {
assertParcels(SerializableParcelable.create(), SerializableParcelable.CREATOR);
}

public void testParcelsNestedParcelables() throws Exception {
NestedParcelable toParcel = NestedParcelable.create();
NestedParcelable readParcelable = parcelAndRead(toParcel, NestedParcelable.CREATOR);
assertEquals(toParcel.getBitmap().getWidth(), readParcelable.getBitmap().getWidth());
assertEquals(toParcel.getBitmapList().size(), readParcelable.getBitmapList().size());
}

public void testParcelsMapParcelables() throws Exception {
MapParcelable toParcel = MapParcelable.create();
MapParcelable readParcelalbe = parcelAndRead(toParcel, MapParcelable.CREATOR);
assertEquals(toParcel.getSampleMap().size(), readParcelalbe.getSampleMap().size());
assertEquals(toParcel.getMapWithParcelableValues().size(), readParcelalbe.getMapWithParcelableValues().size());
}

public void testParcelsGenericListParcelables() throws Exception {
assertParcels(GenericListParcelable.create(), GenericListParcelable.CREATOR);
}

public void testParcelsSparseParcelable() throws Exception {
SparseParcelable sparseParcelable = SparseParcelable.create();
SparseParcelable readParcelable = parcelAndRead(sparseParcelable, SparseParcelable.CREATOR);
assertEquals(sparseParcelable.getSampleSparseArray().size(), readParcelable.getSampleSparseArray().size());
assertEquals(sparseParcelable.getSparseBooleanArray().size(), readParcelable.getSparseBooleanArray().size());
}

private <T extends Parcelable> void assertParcels(T parcelable, Parcelable.Creator<T> creator) {
Parcelable fromParcel = parcelAndRead(parcelable, creator);
assertEquals(parcelable, fromParcel);
}

private <T extends Parcelable> T parcelAndRead(T parcelable, Parcelable.Creator<T> creator) {
Parcel parcel = Parcel.obtain();
parcelable.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
return creator.createFromParcel(parcel);
}
}
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sampleapp.app">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
@@ -0,0 +1,95 @@
package com.example.sampleapp.app;

import android.os.Parcel;
import android.os.Parcelable;

public class BoxedPrimitivesParcelable implements Parcelable {
private final Integer a;
private final Double b;
private final String c;
private final Short d;
private final Float e;
private final Boolean f;
private final Byte g;

private BoxedPrimitivesParcelable(Integer a, Double b, String c, Short d, Float e, Boolean f, Byte g) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.g = g;
}

public static BoxedPrimitivesParcelable create() {
return new BoxedPrimitivesParcelable(0, 1.0, "2", (short) 3, 6f, true, (byte) 1);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

BoxedPrimitivesParcelable that = (BoxedPrimitivesParcelable) o;

if (a != null ? !a.equals(that.a) : that.a != null) return false;
if (b != null ? !b.equals(that.b) : that.b != null) return false;
if (c != null ? !c.equals(that.c) : that.c != null) return false;
if (d != null ? !d.equals(that.d) : that.d != null) return false;
if (e != null ? !e.equals(that.e) : that.e != null) return false;
if (f != null ? !f.equals(that.f) : that.f != null) return false;
return g != null ? g.equals(that.g) : that.g == null;

}

@Override
public int hashCode() {
int result = a != null ? a.hashCode() : 0;
result = 31 * result + (b != null ? b.hashCode() : 0);
result = 31 * result + (c != null ? c.hashCode() : 0);
result = 31 * result + (d != null ? d.hashCode() : 0);
result = 31 * result + (e != null ? e.hashCode() : 0);
result = 31 * result + (f != null ? f.hashCode() : 0);
result = 31 * result + (g != null ? g.hashCode() : 0);
return result;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(this.a);
dest.writeValue(this.b);
dest.writeString(this.c);
dest.writeValue(this.d);
dest.writeValue(this.e);
dest.writeValue(this.f);
dest.writeValue(this.g);
}

protected BoxedPrimitivesParcelable(Parcel in) {
this.a = (Integer) in.readValue(Integer.class.getClassLoader());
this.b = (Double) in.readValue(Double.class.getClassLoader());
this.c = in.readString();
this.d = (Short) in.readValue(Short.class.getClassLoader());
this.e = (Float) in.readValue(Float.class.getClassLoader());
this.f = (Boolean) in.readValue(Boolean.class.getClassLoader());
this.g = (Byte) in.readValue(Byte.class.getClassLoader());
}

public static final Creator<BoxedPrimitivesParcelable> CREATOR = new Creator<BoxedPrimitivesParcelable>() {
@Override
public BoxedPrimitivesParcelable createFromParcel(Parcel source) {
return new BoxedPrimitivesParcelable(source);
}

@Override
public BoxedPrimitivesParcelable[] newArray(int size) {
return new BoxedPrimitivesParcelable[size];
}
};
}
@@ -0,0 +1,61 @@
package com.example.sampleapp.app;

import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

public class BundleParcelable implements Parcelable {
private final Bundle bundle;

private BundleParcelable(Bundle bundle) {
this.bundle = bundle;
}

public static BundleParcelable create() {
Bundle bundle = new Bundle();
bundle.putString("sample", "string");
return new BundleParcelable(bundle);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

BundleParcelable that = (BundleParcelable) o;

return bundle != null && bundle.keySet().equals(((BundleParcelable) o).bundle.keySet());

}

@Override
public int hashCode() {
return bundle != null ? bundle.hashCode() : 0;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeBundle(this.bundle);
}

protected BundleParcelable(Parcel in) {
this.bundle = in.readBundle();
}

public static final Creator<BundleParcelable> CREATOR = new Creator<BundleParcelable>() {
@Override
public BundleParcelable createFromParcel(Parcel source) {
return new BundleParcelable(source);
}

@Override
public BundleParcelable[] newArray(int size) {
return new BundleParcelable[size];
}
};
}

0 comments on commit 68a5879

Please sign in to comment.
You can’t perform that action at this time.