瀏覽代碼

switched luticate utils to maven

tags/v1.0.0
Robin Thoni 8 年之前
父節點
當前提交
e4c13970b3
共有 42 個文件被更改,包括 5 次插入2688 次删除
  1. 1
    1
      app/build.gradle
  2. 0
    1
      app/src/main/java/com/rthoni/stssaguenay/business/STSBusiness.java
  3. 3
    3
      build.gradle
  4. 0
    1
      luticateutils/.gitignore
  5. 0
    36
      luticateutils/build.gradle
  6. 0
    11
      luticateutils/local.properties
  7. 0
    17
      luticateutils/proguard-rules.pro
  8. 0
    11
      luticateutils/src/main/AndroidManifest.xml
  9. 0
    7
      luticateutils/src/main/java/com/luticate/utils/business/LuBusiness.java
  10. 0
    9
      luticateutils/src/main/java/com/luticate/utils/business/LuConsumer.java
  11. 0
    9
      luticateutils/src/main/java/com/luticate/utils/business/LuConverter.java
  12. 0
    128
      luticateutils/src/main/java/com/luticate/utils/business/LuPromise.java
  13. 0
    37
      luticateutils/src/main/java/com/luticate/utils/dataaccess/LuDataAccess.java
  14. 0
    172
      luticateutils/src/main/java/com/luticate/utils/dataaccess/LuRequest.java
  15. 0
    20
      luticateutils/src/main/java/com/luticate/utils/dbo/JSONContainer/LuAbstractJsonContainer.java
  16. 0
    58
      luticateutils/src/main/java/com/luticate/utils/dbo/JSONContainer/LuJSONArrayContainer.java
  17. 0
    59
      luticateutils/src/main/java/com/luticate/utils/dbo/JSONContainer/LuJSONObjectContainer.java
  18. 0
    26
      luticateutils/src/main/java/com/luticate/utils/dbo/LuBoolDbo.java
  19. 0
    57
      luticateutils/src/main/java/com/luticate/utils/dbo/LuDataAccessConfigDbo.java
  20. 0
    272
      luticateutils/src/main/java/com/luticate/utils/dbo/LuDbo.java
  21. 0
    27
      luticateutils/src/main/java/com/luticate/utils/dbo/LuDoubleDbo.java
  22. 0
    27
      luticateutils/src/main/java/com/luticate/utils/dbo/LuIntDbo.java
  23. 0
    27
      luticateutils/src/main/java/com/luticate/utils/dbo/LuLongDbo.java
  24. 0
    66
      luticateutils/src/main/java/com/luticate/utils/dbo/LuPaginatedDbo.java
  25. 0
    44
      luticateutils/src/main/java/com/luticate/utils/dbo/LuPromiseError.java
  26. 0
    27
      luticateutils/src/main/java/com/luticate/utils/dbo/LuStringDbo.java
  27. 0
    7
      luticateutils/src/main/java/com/luticate/utils/dbo/LuVoidDbo.java
  28. 0
    143
      luticateutils/src/main/java/com/luticate/utils/ui/fragments/AbstractPaginationFragment.java
  29. 0
    54
      luticateutils/src/main/java/com/luticate/utils/ui/fragments/ViewPaginationFragment.java
  30. 0
    134
      luticateutils/src/main/java/com/luticate/utils/ui/views/AbstractPaginationView.java
  31. 0
    65
      luticateutils/src/main/java/com/luticate/utils/ui/views/DefaultPaginationView.java
  32. 0
    30
      luticateutils/src/main/res/layout/default_pagination_view_layout.xml
  33. 0
    52
      luticateutils/src/main/res/layout/view_pagination_fragment_layout.xml
  34. 0
    6
      luticateutils/src/main/res/values/attrs.xml
  35. 0
    3
      luticateutils/src/main/res/values/strings.xml
  36. 0
    222
      luticateutils/src/test/java/com/luticate/utils/BasicDboTest.java
  37. 0
    35
      luticateutils/src/test/java/com/luticate/utils/NameDboTest.java
  38. 0
    181
      luticateutils/src/test/java/com/luticate/utils/PromiseTest.java
  39. 0
    49
      luticateutils/src/test/java/com/luticate/utils/Test2Dbo.java
  40. 0
    365
      luticateutils/src/test/java/com/luticate/utils/TestDbo.java
  41. 0
    188
      luticateutils/src/test/java/com/luticate/utils/TestDboTest.java
  42. 1
    1
      settings.gradle

+ 1
- 1
app/build.gradle 查看文件

@@ -44,7 +44,7 @@ dependencies {
44 44
     compile 'com.android.support:design:23.4.0'
45 45
     compile 'com.jakewharton:butterknife:8.0.1'
46 46
     apt 'com.jakewharton:butterknife-compiler:8.0.1'
47
-    compile project(path: ':luticateutils')
47
+    compile 'com.luticate:utils:0.2.0'
48 48
     compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
49 49
     compile 'com.google.firebase:firebase-ads:9.6.1'
50 50
     compile 'com.facebook.android:facebook-android-sdk:4.5.0'

+ 0
- 1
app/src/main/java/com/rthoni/stssaguenay/business/STSBusiness.java 查看文件

@@ -34,7 +34,6 @@ public class STSBusiness {
34 34
                 _config = null;
35 35
                 return null;
36 36
             }
37
-//            _config.setBaseUrl("http://gigi-eth:8089/");
38 37
         }
39 38
         return _config;
40 39
     }

+ 3
- 3
build.gradle 查看文件

@@ -7,9 +7,6 @@ buildscript {
7 7
         maven {
8 8
             url 'http://dl.bintray.com/amulyakhare/maven'
9 9
         }
10
-        maven {
11
-            url 'https://maven.rthoni.com'
12
-        }
13 10
     }
14 11
     dependencies {
15 12
         classpath 'com.android.tools.build:gradle:2.2.2'
@@ -28,6 +25,9 @@ allprojects {
28 25
         maven {
29 26
             url 'https://jitpack.io'
30 27
         }
28
+        maven {
29
+            url 'http://maven.rthoni.com'
30
+        }
31 31
     }
32 32
 }
33 33
 

+ 0
- 1
luticateutils/.gitignore 查看文件

@@ -1 +0,0 @@
1
-/build

+ 0
- 36
luticateutils/build.gradle 查看文件

@@ -1,36 +0,0 @@
1
-apply plugin: 'com.android.library'
2
-apply plugin: 'de.mobilej.unmock'
3
-
4
-android {
5
-    compileSdkVersion 22
6
-    buildToolsVersion "22.0.1"
7
-
8
-    defaultConfig {
9
-        minSdkVersion 14
10
-        targetSdkVersion 22
11
-        versionCode 1
12
-        versionName "1.0"
13
-    }
14
-    buildTypes {
15
-        release {
16
-            minifyEnabled false
17
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18
-        }
19
-    }
20
-}
21
-
22
-unMock {
23
-    // URI to download the android-all.jar from. e.g. https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/
24
-    downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.jar'
25
-
26
-    keepStartingWith "org.json."
27
-
28
-    keep "android.util.Base64"
29
-}
30
-
31
-dependencies {
32
-    compile fileTree(dir: 'libs', include: ['*.jar'])
33
-    testCompile 'junit:junit:4.12'
34
-    compile 'com.android.volley:volley:1.0.0'
35
-    compile 'net.danlew:android.joda:2.9.4.2'
36
-}

+ 0
- 11
luticateutils/local.properties 查看文件

@@ -1,11 +0,0 @@
1
-## This file is automatically generated by Android Studio.
2
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3
-#
4
-# This file must *NOT* be checked into Version Control Systems,
5
-# as it contains information specific to your local configuration.
6
-#
7
-# Location of the SDK. This is only used by Gradle.
8
-# For customization when using a Version Control System, please read the
9
-# header note.
10
-#Fri Jun 17 21:43:56 CEST 2016
11
-sdk.dir=/home/robin/Android/Sdk

+ 0
- 17
luticateutils/proguard-rules.pro 查看文件

@@ -1,17 +0,0 @@
1
-# Add project specific ProGuard rules here.
2
-# By default, the flags in this file are appended to flags specified
3
-# in /home/robin/Android/Sdk/tools/proguard/proguard-android.txt
4
-# You can edit the include path and order by changing the proguardFiles
5
-# directive in build.gradle.
6
-#
7
-# For more details, see
8
-#   http://developer.android.com/guide/developing/tools/proguard.html
9
-
10
-# Add any project specific keep options here:
11
-
12
-# If your project uses WebView with JS, uncomment the following
13
-# and specify the fully qualified class name to the JavaScript interface
14
-# class:
15
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16
-#   public *;
17
-#}

+ 0
- 11
luticateutils/src/main/AndroidManifest.xml 查看文件

@@ -1,11 +0,0 @@
1
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
-    package="com.luticate.utils">
3
-
4
-    <application
5
-        android:allowBackup="true"
6
-        android:label="@string/app_name"
7
-        android:supportsRtl="true">
8
-
9
-    </application>
10
-
11
-</manifest>

+ 0
- 7
luticateutils/src/main/java/com/luticate/utils/business/LuBusiness.java 查看文件

@@ -1,7 +0,0 @@
1
-package com.luticate.utils.business;
2
-
3
-/**
4
- * Created by robin on 11/27/15.
5
- */
6
-public abstract class LuBusiness {
7
-}

+ 0
- 9
luticateutils/src/main/java/com/luticate/utils/business/LuConsumer.java 查看文件

@@ -1,9 +0,0 @@
1
-package com.luticate.utils.business;
2
-
3
-/**
4
- * Created by robin on 10/22/16.
5
- */
6
-
7
-public interface LuConsumer<T> {
8
-    void execute(T data);
9
-}

+ 0
- 9
luticateutils/src/main/java/com/luticate/utils/business/LuConverter.java 查看文件

@@ -1,9 +0,0 @@
1
-package com.luticate.utils.business;
2
-
3
-/**
4
- * Created by robin on 10/22/16.
5
- */
6
-
7
-public interface LuConverter<T, T2> {
8
-    T2 convert(T data);
9
-}

+ 0
- 128
luticateutils/src/main/java/com/luticate/utils/business/LuPromise.java 查看文件

@@ -1,128 +0,0 @@
1
-package com.luticate.utils.business;
2
-
3
-import com.luticate.utils.dbo.LuPromiseError;
4
-
5
-import java.util.List;
6
-import java.util.Vector;
7
-
8
-/**
9
- *
10
- * Created by robin on 11/27/15.
11
- */
12
-public class LuPromise<T> {
13
-
14
-    public enum LuPromiseStatus {
15
-        Running,
16
-        Resolved,
17
-        Failed
18
-    }
19
-
20
-    private List<LuConsumer<T>> _onSuccess = new Vector<>();
21
-
22
-    private List<LuConsumer<LuPromiseError>> _onFailed = new Vector<>();
23
-
24
-    protected LuPromiseStatus _status = LuPromiseStatus.Running;
25
-
26
-    protected T _data = null;
27
-
28
-    protected LuPromiseError _error = null;
29
-
30
-    public LuPromiseStatus getStatus()
31
-    {
32
-        return _status;
33
-    }
34
-
35
-    public T getData()
36
-    {
37
-        return _data;
38
-    }
39
-
40
-    public LuPromiseError getError()
41
-    {
42
-        return _error;
43
-    }
44
-
45
-    public LuPromise<T> then(LuConsumer<T> onSuccess, LuConsumer<LuPromiseError> onFailed)
46
-    {
47
-        _onFailed.add(onFailed);
48
-        if (_status == LuPromiseStatus.Failed) {
49
-            if (onFailed != null) {
50
-                onFailed.execute(_error);
51
-            }
52
-        }
53
-        return then(onSuccess);
54
-    }
55
-
56
-    public LuPromise<T> then(LuConsumer<T> onSuccess)
57
-    {
58
-        _onSuccess.add(onSuccess);
59
-        if (_status == LuPromiseStatus.Resolved) {
60
-            if (onSuccess != null) {
61
-                onSuccess.execute(_data);
62
-            }
63
-        }
64
-        return this;
65
-    }
66
-
67
-    public LuPromise<T> resolve(T data)
68
-    {
69
-        if (_status == LuPromiseStatus.Running) {
70
-            _data = data;
71
-            _error = null;
72
-            _status = LuPromiseStatus.Resolved;
73
-            onSuccess();
74
-        }
75
-        return this;
76
-    }
77
-
78
-    public LuPromise<T> reject(LuPromiseError error)
79
-    {
80
-        if (_status == LuPromiseStatus.Running) {
81
-            _data = null;
82
-            _error = error;
83
-            _status = LuPromiseStatus.Failed;
84
-            onFailed();
85
-        }
86
-        return this;
87
-    }
88
-
89
-    public <T2> LuPromise<T2> map(final LuConverter<T, T2> converter)
90
-    {
91
-        final LuPromise<T2> promise = new LuPromise<>();
92
-        then(new LuConsumer<T>() {
93
-            @Override
94
-            public void execute(T data) {
95
-                promise.resolve(converter.convert(data));
96
-            }
97
-        }, getRejectConsumer());
98
-        return promise;
99
-    }
100
-
101
-    public LuConsumer<LuPromiseError> getRejectConsumer()
102
-    {
103
-        return new LuConsumer<LuPromiseError>() {
104
-            @Override
105
-            public void execute(LuPromiseError error) {
106
-                reject(error);
107
-            }
108
-        };
109
-    }
110
-
111
-    protected void onSuccess()
112
-    {
113
-        for (LuConsumer<T> c : _onSuccess) {
114
-            if (c != null) {
115
-                c.execute(_data);
116
-            }
117
-        }
118
-    }
119
-
120
-    protected void onFailed()
121
-    {
122
-        for (LuConsumer<LuPromiseError> c : _onFailed) {
123
-            if (c != null) {
124
-                c.execute(_error);
125
-            }
126
-        }
127
-    }
128
-}

+ 0
- 37
luticateutils/src/main/java/com/luticate/utils/dataaccess/LuDataAccess.java 查看文件

@@ -1,37 +0,0 @@
1
-package com.luticate.utils.dataaccess;
2
-
3
-import com.luticate.utils.business.LuPromise;
4
-import com.luticate.utils.dbo.LuDataAccessConfigDbo;
5
-import com.luticate.utils.dbo.LuDbo;
6
-
7
-import java.util.HashMap;
8
-
9
-/**
10
- * Created by robin on 11/27/15.
11
- */
12
-public abstract class LuDataAccess {
13
-
14
-    public static <T extends LuDbo> LuPromise<T> get(final LuDataAccessConfigDbo config, Class<T> type,
15
-                                                     String url, final HashMap<String, String> getParams)
16
-    {
17
-        return LuRequest.get(config, type, url, getParams);
18
-    }
19
-
20
-    public static <T extends LuDbo> LuPromise<T> get(LuDataAccessConfigDbo config, Class<T> type,
21
-                                                     String url)
22
-    {
23
-        return LuRequest.get(config, type, url);
24
-    }
25
-
26
-    public static <T extends LuDbo> LuPromise<T> post(LuDataAccessConfigDbo config, Class<T> type,
27
-                                                      String url, final HashMap<String, String> postParams)
28
-    {
29
-        return LuRequest.post(config, type, url, postParams);
30
-    }
31
-
32
-    public static <T extends LuDbo> LuPromise<T> post(LuDataAccessConfigDbo config, Class<T> type,
33
-                                                      String url)
34
-    {
35
-        return LuRequest.post(config, type, url);
36
-    }
37
-}

+ 0
- 172
luticateutils/src/main/java/com/luticate/utils/dataaccess/LuRequest.java 查看文件

@@ -1,172 +0,0 @@
1
-package com.luticate.utils.dataaccess;
2
-
3
-import android.content.Context;
4
-import android.net.Uri;
5
-
6
-import com.android.volley.DefaultRetryPolicy;
7
-import com.android.volley.Request;
8
-import com.android.volley.RequestQueue;
9
-import com.android.volley.Response;
10
-import com.android.volley.VolleyError;
11
-import com.android.volley.toolbox.StringRequest;
12
-import com.android.volley.toolbox.Volley;
13
-import com.luticate.utils.business.LuPromise;
14
-import com.luticate.utils.dbo.LuDataAccessConfigDbo;
15
-import com.luticate.utils.dbo.LuDbo;
16
-import com.luticate.utils.dbo.LuPromiseError;
17
-
18
-import org.json.JSONObject;
19
-
20
-import java.util.HashMap;
21
-import java.util.Map;
22
-
23
-/**
24
- *
25
- * Created by robin on 11/27/15.
26
- */
27
-public class LuRequest {
28
-
29
-    private static RequestQueue _requestQueue = null;
30
-
31
-    public static void init(Context ctx)
32
-    {
33
-        _requestQueue = Volley.newRequestQueue(ctx.getApplicationContext());
34
-    }
35
-
36
-    protected static <T extends LuDbo> Response.Listener<String> getListener(final Class<T> type, final LuPromise<T> promise)
37
-    {
38
-        return new Response.Listener<String>()
39
-        {
40
-            @Override
41
-            public void onResponse(String response) {
42
-                try {
43
-                    T dbo = type.newInstance();
44
-                    try {
45
-                        JSONObject json = new JSONObject(response);
46
-                        JSONObject obj = null;
47
-                        if (json.has("data")) {
48
-                            obj = json.optJSONObject("data");
49
-                            if (obj == null) {
50
-                                obj = new JSONObject();
51
-                                obj.put("value", json.opt("data"));
52
-                            }
53
-                        }
54
-                        dbo.fromJson(obj);
55
-                        promise.resolve(dbo);
56
-                    } catch (Exception e)
57
-                    {
58
-                        e.printStackTrace();
59
-                        promise.reject(new LuPromiseError("Failed to parse success server response", 200));
60
-                    }
61
-                } catch (Exception e) {
62
-                    e.printStackTrace();
63
-                    promise.reject(new LuPromiseError("Failed to initialize server response", 200));
64
-                }
65
-            }
66
-        };
67
-    }
68
-
69
-    protected static <T extends LuDbo> Response.ErrorListener getErrorListener(final LuPromise<T> promise)
70
-    {
71
-        return new Response.ErrorListener() {
72
-            @Override
73
-            public void onErrorResponse(VolleyError error) {
74
-                int code = 0;
75
-                try
76
-                {
77
-                    if (error != null) {
78
-                        if (error.networkResponse != null)
79
-                        {
80
-                            code = error.networkResponse.statusCode;
81
-                            JSONObject data = new JSONObject(new String(error.networkResponse.data));
82
-                            promise.reject(new LuPromiseError(data.getString("Message"), code));
83
-                        }
84
-                        else {
85
-                            if (error.getCause() != null) {
86
-                                promise.reject(new LuPromiseError(error.getCause().getMessage(), code));
87
-                            }
88
-                            else {
89
-                                promise.reject(new LuPromiseError(error.toString(), code));
90
-                            }
91
-                        }
92
-                    }
93
-                    else {
94
-                        promise.reject(new LuPromiseError("Unknown network error", code));
95
-                    }
96
-                } catch (Exception e)
97
-                {
98
-                    promise.reject(new LuPromiseError(e.getMessage(), code));
99
-                }
100
-            }
101
-        };
102
-    }
103
-
104
-    protected static <T extends LuDbo> LuPromise<T> request(final LuDataAccessConfigDbo config,
105
-                                                            int method, Class<T> type, String url,
106
-                                                            final HashMap<String, String> params)
107
-    {
108
-        LuPromise<T> promise = new LuPromise<>();
109
-        StringRequest request = new StringRequest(method, config.getBaseUrl() + url,
110
-                getListener(type, promise), getErrorListener(promise))
111
-        {
112
-            @Override
113
-            public String getBodyContentType() {
114
-                return "application/x-www-form-urlencoded; charset=UTF-8";
115
-            }
116
-
117
-            @Override
118
-            protected Map<String, String> getParams() {
119
-                return params;
120
-            }
121
-
122
-            @Override
123
-            public Map<String, String> getHeaders() {
124
-                return config.getHeaders();
125
-            }
126
-        };
127
-        request.setRetryPolicy(new DefaultRetryPolicy(10000,
128
-                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
129
-                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
130
-        _requestQueue.add(request);
131
-        return promise;
132
-    }
133
-
134
-    public static <T extends LuDbo> LuPromise<T> get(final LuDataAccessConfigDbo config, Class<T> type,
135
-                                                     String url, final HashMap<String, String> getParams)
136
-    {
137
-        Uri.Builder uri = Uri.parse(url).buildUpon();
138
-        for (String key : getParams.keySet())
139
-        {
140
-            uri.appendQueryParameter(key, getParams.get(key));
141
-        }
142
-        LuPromise<T> promise = new LuPromise<>();
143
-        StringRequest request = new StringRequest(Request.Method.GET, config.getBaseUrl() + uri.toString(),
144
-                getListener(type, promise), getErrorListener(promise))
145
-        {
146
-            @Override
147
-            public Map<String, String> getHeaders() {
148
-                return config.getHeaders();
149
-            }
150
-        };
151
-        _requestQueue.add(request);
152
-        return promise;
153
-    }
154
-
155
-    public static <T extends LuDbo> LuPromise<T> get(LuDataAccessConfigDbo config, Class<T> type,
156
-                                                     String url)
157
-    {
158
-        return get(config, type, url, new HashMap<String, String>());
159
-    }
160
-
161
-    public static <T extends LuDbo> LuPromise<T> post(LuDataAccessConfigDbo config, Class<T> type,
162
-                                                      String url, final HashMap<String, String> postParams)
163
-    {
164
-        return request(config, Request.Method.POST, type, url, postParams);
165
-    }
166
-
167
-    public static <T extends LuDbo> LuPromise<T> post(LuDataAccessConfigDbo config, Class<T> type,
168
-                                                      String url)
169
-    {
170
-        return post(config, type, url, new HashMap<String, String>());
171
-    }
172
-}

+ 0
- 20
luticateutils/src/main/java/com/luticate/utils/dbo/JSONContainer/LuAbstractJsonContainer.java 查看文件

@@ -1,20 +0,0 @@
1
-package com.luticate.utils.dbo.JSONContainer;
2
-
3
-import org.json.JSONArray;
4
-import org.json.JSONException;
5
-import org.json.JSONObject;
6
-
7
-/**
8
- * Created by robin on 10/21/16.
9
- */
10
-
11
-public interface LuAbstractJsonContainer {
12
-    int getInt(Object key) throws JSONException;
13
-    String getString(Object key) throws JSONException;
14
-    long getLong(Object key) throws JSONException;
15
-    double getDouble(Object key) throws JSONException;
16
-    boolean getBoolean(Object key) throws JSONException;
17
-    JSONObject getJSONObject(Object key) throws JSONException;
18
-    JSONArray getJSONArray(Object key) throws JSONException;
19
-    boolean isNull(Object key) throws JSONException;
20
-}

+ 0
- 58
luticateutils/src/main/java/com/luticate/utils/dbo/JSONContainer/LuJSONArrayContainer.java 查看文件

@@ -1,58 +0,0 @@
1
-package com.luticate.utils.dbo.JSONContainer;
2
-
3
-import org.json.JSONArray;
4
-import org.json.JSONException;
5
-import org.json.JSONObject;
6
-
7
-/**
8
- * Created by robin on 10/21/16.
9
- */
10
-
11
-public class LuJSONArrayContainer implements LuAbstractJsonContainer {
12
-    protected JSONArray _jsonArray;
13
-
14
-    public LuJSONArrayContainer(JSONArray jsonArray)
15
-    {
16
-        _jsonArray = jsonArray;
17
-    }
18
-
19
-    @Override
20
-    public int getInt(Object key) throws JSONException {
21
-        return _jsonArray.getInt((int) key);
22
-    }
23
-
24
-    @Override
25
-    public String getString(Object key) throws JSONException {
26
-        return _jsonArray.getString((int) key);
27
-    }
28
-
29
-    @Override
30
-    public long getLong(Object key) throws JSONException {
31
-        return _jsonArray.getLong((int) key);
32
-    }
33
-
34
-    @Override
35
-    public double getDouble(Object key) throws JSONException {
36
-        return _jsonArray.getDouble((int) key);
37
-    }
38
-
39
-    @Override
40
-    public boolean getBoolean(Object key) throws JSONException {
41
-        return _jsonArray.getBoolean((int) key);
42
-    }
43
-
44
-    @Override
45
-    public JSONObject getJSONObject(Object key) throws JSONException {
46
-        return _jsonArray.getJSONObject((int) key);
47
-    }
48
-
49
-    @Override
50
-    public JSONArray getJSONArray(Object key) throws JSONException {
51
-        return _jsonArray.getJSONArray((int) key);
52
-    }
53
-
54
-    @Override
55
-    public boolean isNull(Object key) throws JSONException {
56
-        return _jsonArray.isNull((int) key);
57
-    }
58
-}

+ 0
- 59
luticateutils/src/main/java/com/luticate/utils/dbo/JSONContainer/LuJSONObjectContainer.java 查看文件

@@ -1,59 +0,0 @@
1
-package com.luticate.utils.dbo.JSONContainer;
2
-
3
-import org.json.JSONArray;
4
-import org.json.JSONException;
5
-import org.json.JSONObject;
6
-
7
-/**
8
- * Created by robin on 10/21/16.
9
- */
10
-
11
-public class LuJSONObjectContainer implements LuAbstractJsonContainer {
12
-
13
-    protected JSONObject _jsonObject;
14
-
15
-    public LuJSONObjectContainer(JSONObject jsonObject)
16
-    {
17
-        _jsonObject = jsonObject;
18
-    }
19
-
20
-    @Override
21
-    public int getInt(Object key) throws JSONException {
22
-        return _jsonObject.getInt((String) key);
23
-    }
24
-
25
-    @Override
26
-    public String getString(Object key) throws JSONException {
27
-        return _jsonObject.getString((String) key);
28
-    }
29
-
30
-    @Override
31
-    public long getLong(Object key) throws JSONException {
32
-        return _jsonObject.getLong((String) key);
33
-    }
34
-
35
-    @Override
36
-    public double getDouble(Object key) throws JSONException {
37
-        return _jsonObject.getDouble((String) key);
38
-    }
39
-
40
-    @Override
41
-    public boolean getBoolean(Object key) throws JSONException {
42
-        return _jsonObject.getBoolean((String) key);
43
-    }
44
-
45
-    @Override
46
-    public JSONObject getJSONObject(Object key) throws JSONException {
47
-        return _jsonObject.getJSONObject((String) key);
48
-    }
49
-
50
-    @Override
51
-    public JSONArray getJSONArray(Object key) throws JSONException {
52
-        return _jsonObject.getJSONArray((String) key);
53
-    }
54
-
55
-    @Override
56
-    public boolean isNull(Object key) throws JSONException {
57
-        return _jsonObject.isNull((String) key);
58
-    }
59
-}

+ 0
- 26
luticateutils/src/main/java/com/luticate/utils/dbo/LuBoolDbo.java 查看文件

@@ -1,26 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 11/27/15.
5
- */
6
-public class LuBoolDbo extends LuDbo {
7
-
8
-    private Boolean _value;
9
-
10
-    public LuBoolDbo()
11
-    {
12
-    }
13
-
14
-    public LuBoolDbo(Boolean value)
15
-    {
16
-        _value = value;
17
-    }
18
-
19
-    public Boolean getBool() {
20
-        return _value;
21
-    }
22
-
23
-    public void setBool(Boolean value) {
24
-        _value = value;
25
-    }
26
-}

+ 0
- 57
luticateutils/src/main/java/com/luticate/utils/dbo/LuDataAccessConfigDbo.java 查看文件

@@ -1,57 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-import android.util.Base64;
4
-
5
-import org.json.JSONException;
6
-import org.json.JSONObject;
7
-
8
-import java.util.HashMap;
9
-import java.util.Map;
10
-
11
-/**
12
- *
13
- * Created by robin on 11/28/15.
14
- */
15
-public class LuDataAccessConfigDbo extends LuDbo {
16
-
17
-    protected String _baseUrl;
18
-
19
-    protected String _httpUsername;
20
-
21
-    protected String _httpPassword;
22
-
23
-    public String getBaseUrl() {
24
-        return _baseUrl;
25
-    }
26
-
27
-    public void setBaseUrl(String baseUrl) {
28
-        _baseUrl = baseUrl;
29
-    }
30
-
31
-    public String getHttpUsername() {
32
-        return _httpUsername;
33
-    }
34
-
35
-    public void setHttpUsername(String httpUsername) {
36
-        _httpUsername = httpUsername;
37
-    }
38
-
39
-    public String getHttpPassword() {
40
-        return _httpPassword;
41
-    }
42
-
43
-    public void setHttpPassword(String httpPassword) {
44
-        _httpPassword = httpPassword;
45
-    }
46
-
47
-    public Map<String, String> getHeaders()
48
-    {
49
-        Map<String, String> map = new HashMap<>();
50
-        if (_httpUsername != null) {
51
-            map.put("Authorization", "Basic " + Base64.encodeToString(
52
-                    String.format("%s:%s", _httpUsername, _httpPassword).getBytes(), Base64.NO_WRAP));
53
-        }
54
-        return map;
55
-    }
56
-
57
-}

+ 0
- 272
luticateutils/src/main/java/com/luticate/utils/dbo/LuDbo.java 查看文件

@@ -1,272 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-import com.luticate.utils.dbo.JSONContainer.LuAbstractJsonContainer;
4
-import com.luticate.utils.dbo.JSONContainer.LuJSONArrayContainer;
5
-import com.luticate.utils.dbo.JSONContainer.LuJSONObjectContainer;
6
-
7
-import org.joda.time.DateTime;
8
-import org.joda.time.LocalDate;
9
-import org.joda.time.LocalDateTime;
10
-import org.joda.time.format.DateTimeFormat;
11
-import org.json.JSONArray;
12
-import org.json.JSONException;
13
-import org.json.JSONObject;
14
-
15
-import java.lang.reflect.Array;
16
-import java.lang.reflect.Field;
17
-import java.lang.reflect.Modifier;
18
-import java.lang.reflect.ParameterizedType;
19
-import java.util.AbstractMap;
20
-import java.util.HashMap;
21
-import java.util.Iterator;
22
-import java.util.List;
23
-import java.util.Vector;
24
-
25
-/**
26
- * Created by robin on 11/27/15.
27
- */
28
-public abstract class LuDbo {
29
-
30
-    public static String DEFAULT_DATE_FORMAT = "yy-MM-dd";
31
-
32
-    public static String DEFAULT_TIME_FORMAT = "HH:mm:ss";
33
-
34
-    public static String DEFAULT_DATE_TIME_FORMAT = DEFAULT_DATE_FORMAT + " " + DEFAULT_TIME_FORMAT;
35
-
36
-    public String getFieldFromJson(String jsonName)
37
-    {
38
-        if (!jsonName.startsWith("_")) {
39
-            return String.format("_%s", jsonName);
40
-        }
41
-        return jsonName;
42
-    }
43
-
44
-    public String getJsonFromField(String fieldName)
45
-    {
46
-        if (fieldName.startsWith("_")) {
47
-            return fieldName.substring(1);
48
-        }
49
-        return fieldName;
50
-    }
51
-
52
-    public Object getObjectFromJson(Class clazz, LuAbstractJsonContainer json, Object key) throws Exception {
53
-        if (json.isNull(key)) {
54
-            return null;
55
-        }
56
-
57
-        if (clazz == Byte.class || clazz == byte.class) {
58
-            return (byte) json.getInt(key);
59
-        }
60
-        if (clazz == Character.class || clazz == char.class) {
61
-            return json.getString(key).charAt(0);
62
-        }
63
-        if (clazz == Short.class || clazz == short.class) {
64
-            return (short) json.getInt(key);
65
-        }
66
-        if (clazz == Integer.class || clazz == int.class) {
67
-            return json.getInt(key);
68
-        }
69
-        if (clazz == Long.class || clazz == long.class) {
70
-            return json.getLong(key);
71
-        }
72
-        if (clazz == Float.class || clazz == float.class) {
73
-            return (float) json.getDouble(key);
74
-        }
75
-        if (clazz == Double.class || clazz == double.class) {
76
-            return json.getDouble(key);
77
-        }
78
-        if (clazz == Boolean.class || clazz == boolean.class) {
79
-            return json.getBoolean(key);
80
-        }
81
-        if (clazz == String.class) {
82
-            return json.getString(key);
83
-        }
84
-        if (clazz == LocalDateTime.class) {
85
-            return LocalDateTime.parse(json.getString(key), DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
86
-        }
87
-        if (clazz == DateTime.class) {
88
-            return DateTime.parse(json.getString(key), DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
89
-        }
90
-        if (LuDbo.class.isAssignableFrom(clazz)) {
91
-            LuDbo dbo = (LuDbo) getInstance(clazz);
92
-            dbo.fromJson(json.getJSONObject(key));
93
-            return dbo;
94
-        }
95
-        return null;
96
-    }
97
-
98
-    public Object getJsonFromObject(Class clazz, Object obj)
99
-    {
100
-        if (obj == null) {
101
-            return null;
102
-        }
103
-        if (clazz == char.class || clazz == Character.class) {
104
-            return obj.toString();
105
-        }
106
-        if (clazz.isPrimitive() || clazz == Byte.class || clazz == Character.class
107
-                || clazz == Short.class || clazz == Integer.class || clazz == Long.class
108
-                || clazz == Float.class || clazz == Double.class || clazz == Boolean.class
109
-                || clazz == String.class) {
110
-            return obj;
111
-        }
112
-        if (clazz == LocalDateTime.class) {
113
-            return ((LocalDateTime)obj).toString(DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
114
-        }
115
-        if (clazz == DateTime.class) {
116
-            return ((DateTime)obj).toString(DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
117
-        }
118
-        if (LuDbo.class.isAssignableFrom(clazz)) {
119
-            return ((LuDbo)obj).toJson();
120
-        }
121
-        if (List.class.isAssignableFrom(clazz)) {
122
-            List objList = (List) obj;
123
-            JSONArray list = new JSONArray();
124
-
125
-            for (Object item : objList) {
126
-                list.put(getJsonFromObject(getClazz(item), item));
127
-            }
128
-
129
-            return list;
130
-        }
131
-        if (AbstractMap.class.isAssignableFrom(clazz)) {
132
-            HashMap objMap = (HashMap) obj;
133
-            JSONObject map = new JSONObject();
134
-
135
-            for (Object k : objMap.keySet()) {
136
-                if (k.getClass() == String.class) {
137
-                    Object item = objMap.get(k);
138
-                    try {
139
-                        map.put((String) k, getJsonFromObject(getClazz(item), item));
140
-                    } catch (JSONException ignored) {
141
-                    }
142
-                }
143
-            }
144
-
145
-            return map;
146
-        }
147
-        if (clazz.isArray()) {
148
-            JSONArray list = new JSONArray();
149
-
150
-            for (int i = 0; i < Array.getLength(obj); ++i) {
151
-                Object item = Array.get(obj, i);
152
-                list.put(getJsonFromObject(item == null ? null : item.getClass(), item));
153
-            }
154
-
155
-            return list;
156
-        }
157
-        return null;
158
-    }
159
-
160
-    public Object getInstance(Class clazz) throws Exception {
161
-        if (clazz == List.class) {
162
-            return new Vector<>();
163
-        }
164
-        if (clazz == AbstractMap.class) {
165
-            return new HashMap<>();
166
-        }
167
-        return clazz.newInstance();
168
-    }
169
-
170
-    public Class getClazz(Object obj)
171
-    {
172
-        return obj == null ? null : obj.getClass();
173
-    }
174
-
175
-    public void fromJson(String data) throws Exception
176
-    {
177
-        JSONObject json = new JSONObject(data);
178
-        fromJson(json);
179
-    }
180
-
181
-    public void fromJson(JSONObject json) throws Exception
182
-    {
183
-        for (Field field : getClass().getDeclaredFields()) {
184
-            if (Modifier.isTransient(field.getModifiers())) {
185
-                continue;
186
-            }
187
-            String key = getJsonFromField(field.getName());
188
-            Class clazz = field.getType();
189
-            if (json.has(key)) {
190
-                Object value = null;
191
-
192
-                if (List.class.isAssignableFrom(clazz)) {
193
-                    ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
194
-                    Class type = (Class) parameterizedType.getActualTypeArguments()[0];
195
-                    List<Object> list = (List<Object>) getInstance(clazz);
196
-                    JSONArray jsonArray = json.getJSONArray(key);
197
-                    for (int i = 0; i < jsonArray.length(); ++i) {
198
-                        list.add(getObjectFromJson(type, new LuJSONArrayContainer(jsonArray), i));
199
-                    }
200
-                    value = list;
201
-                }
202
-                else if (clazz.isArray()) {
203
-                    Class type = clazz.getComponentType();
204
-                    JSONArray jsonArray = json.getJSONArray(key);
205
-                    Object array = Array.newInstance(type, jsonArray.length());
206
-                    for (int i = 0; i < jsonArray.length(); ++i) {
207
-                        Array.set(array, i, getObjectFromJson(type, new LuJSONArrayContainer(jsonArray), i));
208
-                    }
209
-                    value = array;
210
-                }
211
-                else if (AbstractMap.class.isAssignableFrom(clazz)) {
212
-                    ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
213
-                    Class type = (Class) parameterizedType.getActualTypeArguments()[0];
214
-                    if (type == String.class) {
215
-                        type = (Class) parameterizedType.getActualTypeArguments()[1];
216
-                        AbstractMap<String, Object> map = (AbstractMap<String, Object>) getInstance(clazz);
217
-                        JSONObject obj = json.getJSONObject(key);
218
-                        Iterator<String> it = obj.keys();
219
-                        while (it.hasNext()) {
220
-                            String k = it.next();
221
-                            map.put(k, getObjectFromJson(type, new LuJSONObjectContainer(obj), k));
222
-                        }
223
-                        value = map;
224
-                    }
225
-                }
226
-                else {
227
-                    value = getObjectFromJson(clazz, new LuJSONObjectContainer(json), key);
228
-                }
229
-                field.setAccessible(true);
230
-                field.set(this, value);
231
-                field.setAccessible(false);
232
-            }
233
-        }
234
-    }
235
-
236
-    public HashMap<String, Object> toArray()
237
-    {
238
-        HashMap<String, Object> map = new HashMap<>();
239
-
240
-        for (Field field : getClass().getDeclaredFields()) {
241
-            if (Modifier.isTransient(field.getModifiers())) {
242
-                continue;
243
-            }
244
-            String key = getJsonFromField(field.getName());
245
-            Class clazz = field.getType();
246
-            field.setAccessible(true);
247
-            Object obj = null;
248
-            try {
249
-                obj = field.get(this);
250
-            } catch (IllegalAccessException ignored) {
251
-            }
252
-            field.setAccessible(false);
253
-            map.put(key, getJsonFromObject(clazz, obj));
254
-        }
255
-
256
-        return map;
257
-    }
258
-
259
-    public JSONObject toJson()
260
-    {
261
-        HashMap<String, Object> array = toArray();
262
-        JSONObject json = new JSONObject(array);
263
-        return json;
264
-    }
265
-
266
-    @Override
267
-    public String toString()
268
-    {
269
-        return toJson().toString();
270
-    }
271
-
272
-}

+ 0
- 27
luticateutils/src/main/java/com/luticate/utils/dbo/LuDoubleDbo.java 查看文件

@@ -1,27 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 10/22/16.
5
- */
6
-
7
-public class LuDoubleDbo extends LuDbo {
8
-
9
-    protected Double _value;
10
-
11
-    public LuDoubleDbo()
12
-    {
13
-    }
14
-
15
-    public LuDoubleDbo(Double value)
16
-    {
17
-        _value = value;
18
-    }
19
-
20
-    public Double getDouble() {
21
-        return _value;
22
-    }
23
-
24
-    public void setDouble(Double aDouble) {
25
-        _value = aDouble;
26
-    }
27
-}

+ 0
- 27
luticateutils/src/main/java/com/luticate/utils/dbo/LuIntDbo.java 查看文件

@@ -1,27 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 11/27/15.
5
- */
6
-public class LuIntDbo extends LuDbo {
7
-
8
-    private Integer _value;
9
-
10
-    public LuIntDbo()
11
-    {
12
-    }
13
-
14
-    public LuIntDbo(Integer value)
15
-    {
16
-        _value = value;
17
-    }
18
-
19
-    public Integer getInt() {
20
-        return _value;
21
-    }
22
-
23
-    public void setInt(Integer value) {
24
-        _value = value;
25
-    }
26
-
27
-}

+ 0
- 27
luticateutils/src/main/java/com/luticate/utils/dbo/LuLongDbo.java 查看文件

@@ -1,27 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 10/22/16.
5
- */
6
-
7
-public class LuLongDbo extends LuDbo {
8
-
9
-    protected Long _value;
10
-
11
-    public LuLongDbo()
12
-    {
13
-    }
14
-
15
-    public LuLongDbo(Long value)
16
-    {
17
-        _value = value;
18
-    }
19
-
20
-    public Long getLong() {
21
-        return _value;
22
-    }
23
-
24
-    public void setLong(Long aLong) {
25
-        _value = aLong;
26
-    }
27
-}

+ 0
- 66
luticateutils/src/main/java/com/luticate/utils/dbo/LuPaginatedDbo.java 查看文件

@@ -1,66 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-import org.json.JSONArray;
4
-import org.json.JSONObject;
5
-
6
-import java.util.HashMap;
7
-import java.util.List;
8
-import java.util.Vector;
9
-
10
-/**
11
- *
12
- * Created by robin on 11/27/15.
13
- */
14
-public class LuPaginatedDbo<T extends LuDbo> extends LuDbo {
15
-
16
-    private transient Class<T> _clazz;
17
-
18
-    private List<T> _data = new Vector<>();
19
-
20
-    private int _count;
21
-
22
-    public LuPaginatedDbo(Class<T> clazz)
23
-    {
24
-        _clazz = clazz;
25
-    }
26
-
27
-    public List<T> getData() {
28
-        return _data;
29
-    }
30
-
31
-    public void setData(List<T> data) {
32
-        _data = data;
33
-    }
34
-
35
-    public int getCount() {
36
-        return _count;
37
-    }
38
-
39
-    public void setCount(int count) {
40
-        _count = count;
41
-    }
42
-
43
-    @Override
44
-    public void fromJson(JSONObject json) throws Exception {
45
-        _count = json.getInt("count");
46
-        JSONArray array = json.getJSONArray("data");
47
-
48
-        for (int i = 0; i < array.length(); ++i) {
49
-            T dbo = _clazz.newInstance();
50
-            dbo.fromJson(array.getJSONObject(i));
51
-            _data.add(dbo);
52
-        }
53
-    }
54
-
55
-    @Override
56
-    public HashMap<String, Object> toArray() {
57
-        HashMap<String, Object> array = new HashMap<>();
58
-        array.put("count", _count);
59
-        Vector<HashMap<String, Object>> data = new Vector<>();
60
-        for (T value : _data) {
61
-            data.add(value.toArray());
62
-        }
63
-        array.put("data", data);
64
-        return array;
65
-    }
66
-}

+ 0
- 44
luticateutils/src/main/java/com/luticate/utils/dbo/LuPromiseError.java 查看文件

@@ -1,44 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 10/22/16.
5
- */
6
-
7
-public class LuPromiseError {
8
-
9
-    private String _error;
10
-
11
-    private int _statusCode;
12
-
13
-    public LuPromiseError()
14
-    {
15
-    }
16
-
17
-    public LuPromiseError(String error, int statusCode)
18
-    {
19
-        _error = error;
20
-        _statusCode = statusCode;
21
-    }
22
-
23
-    public String getError() {
24
-        return _error;
25
-    }
26
-
27
-    public void setError(String error) {
28
-        _error = error;
29
-    }
30
-
31
-    public int getStatusCode() {
32
-        return _statusCode;
33
-    }
34
-
35
-    public void setStatusCode(int statusCode) {
36
-        _statusCode = statusCode;
37
-    }
38
-
39
-    @Override
40
-    public String toString() {
41
-        return _error + " (Status code : " + _statusCode + ")";
42
-    }
43
-
44
-}

+ 0
- 27
luticateutils/src/main/java/com/luticate/utils/dbo/LuStringDbo.java 查看文件

@@ -1,27 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 11/27/15.
5
- */
6
-public class LuStringDbo extends LuDbo {
7
-
8
-    private String _value;
9
-
10
-    public LuStringDbo()
11
-    {
12
-    }
13
-
14
-    public LuStringDbo(String value)
15
-    {
16
-        _value = value;
17
-    }
18
-
19
-    public String getString() {
20
-        return _value;
21
-    }
22
-
23
-    public void setString(String value) {
24
-        _value = value;
25
-    }
26
-
27
-}

+ 0
- 7
luticateutils/src/main/java/com/luticate/utils/dbo/LuVoidDbo.java 查看文件

@@ -1,7 +0,0 @@
1
-package com.luticate.utils.dbo;
2
-
3
-/**
4
- * Created by robin on 11/27/15.
5
- */
6
-public class LuVoidDbo extends LuDbo {
7
-}

+ 0
- 143
luticateutils/src/main/java/com/luticate/utils/ui/fragments/AbstractPaginationFragment.java 查看文件

@@ -1,143 +0,0 @@
1
-package com.luticate.utils.ui.fragments;
2
-
3
-import android.animation.Animator;
4
-import android.animation.AnimatorListenerAdapter;
5
-import android.app.Fragment;
6
-import android.os.Build;
7
-import android.os.Bundle;
8
-import android.view.LayoutInflater;
9
-import android.view.View;
10
-import android.view.ViewGroup;
11
-
12
-import com.luticate.utils.business.LuConsumer;
13
-import com.luticate.utils.business.LuPromise;
14
-import com.luticate.utils.dbo.LuDbo;
15
-import com.luticate.utils.dbo.LuPaginatedDbo;
16
-import com.luticate.utils.dbo.LuPromiseError;
17
-import com.luticate.utils.ui.views.AbstractPaginationView;
18
-
19
-import java.util.Vector;
20
-
21
-/**
22
- * Created by robin on 12/6/15.
23
- */
24
-public abstract class AbstractPaginationFragment<Dbo extends LuDbo> extends Fragment {
25
-
26
-    protected int _page = 0;
27
-
28
-    protected int _perPage = 15;
29
-
30
-    protected int _maxPage = 1;
31
-
32
-    protected String _query = "";
33
-
34
-    protected LuPaginatedDbo<Dbo> _items = null;
35
-
36
-    @Override
37
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
38
-    {
39
-        return inflater.inflate(getLayoutId(), container, false);
40
-    }
41
-
42
-    @Override
43
-    public void onStart() {
44
-        super.onStart();
45
-        View v = getView();
46
-        AbstractPaginationView paginationView = (AbstractPaginationView) v.findViewById(getPaginationViewId());
47
-        paginationView.setOnPageChanged(new LuConsumer<Integer>() {
48
-            @Override
49
-            public void execute(Integer page) {
50
-                loadPage(page);
51
-            }
52
-        });
53
-        if (_items == null) {
54
-            loadPage(_page);
55
-        }
56
-    }
57
-
58
-    protected void showProgress(final boolean show)
59
-    {
60
-        View v = getView();
61
-        if (!isAdded() || v == null)
62
-            return;
63
-
64
-        final View imagesScrollView = v.findViewById(getScrollViewId());
65
-        final View loadingView = v.findViewById(getLoaderViewId());
66
-
67
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
68
-        {
69
-            int shortAnimTime =
70
-                    getResources().getInteger(android.R.integer.config_shortAnimTime);
71
-
72
-            loadingView.setVisibility(View.VISIBLE);
73
-            loadingView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0)
74
-                    .setListener(new AnimatorListenerAdapter()
75
-                    {
76
-                        @Override
77
-                        public void onAnimationEnd(Animator animation)
78
-                        {
79
-                            loadingView.setVisibility(show ? View.VISIBLE : View.GONE);
80
-                        }
81
-                    });
82
-
83
-            imagesScrollView.setVisibility(View.VISIBLE);
84
-            imagesScrollView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
85
-                    .setListener(new AnimatorListenerAdapter()
86
-                    {
87
-                        @Override
88
-                        public void onAnimationEnd(Animator animation)
89
-                        {
90
-                            imagesScrollView.setVisibility(show ? View.GONE : View.VISIBLE);
91
-                        }
92
-                    });
93
-        }
94
-        else
95
-        {
96
-            loadingView.setVisibility(show ? View.VISIBLE : View.GONE);
97
-            imagesScrollView.setVisibility(show ? View.GONE : View.VISIBLE);
98
-        }
99
-    }
100
-
101
-    public void loadPage(final int page)
102
-    {
103
-        final View v = getView();
104
-        if (!isAdded() || v == null) {
105
-            return;
106
-        }
107
-        showProgress(true);
108
-        if (_items != null) {
109
-            _items.setData(new Vector<Dbo>());
110
-        }
111
-        getLoadPagePromise(page, _perPage, _query).then(new LuConsumer<LuPaginatedDbo<Dbo>>() {
112
-            @Override
113
-            public void execute(LuPaginatedDbo<Dbo> items) {
114
-                _items = items;
115
-                _page = page;
116
-                _maxPage = Math.max(items.getCount() / _perPage, 1);
117
-                AbstractPaginationView paginationView = (AbstractPaginationView) v.findViewById(getPaginationViewId());
118
-                paginationView.setMaxPage(_maxPage);
119
-                paginationView.setPage(_page);
120
-                onPageChanged();
121
-                showProgress(false);
122
-            }
123
-        }, new LuConsumer<LuPromiseError>() {
124
-            @Override
125
-            public void execute(LuPromiseError error) {
126
-
127
-                showProgress(false);
128
-            }
129
-        });
130
-    }
131
-
132
-    protected abstract void onPageChanged();
133
-
134
-    protected abstract LuPromise<LuPaginatedDbo<Dbo>> getLoadPagePromise(int page, int perPage, String query);
135
-
136
-    protected abstract int getScrollViewId();
137
-
138
-    protected abstract int getLoaderViewId();
139
-
140
-    protected abstract int getLayoutId();
141
-
142
-    protected abstract int getPaginationViewId();
143
-}

+ 0
- 54
luticateutils/src/main/java/com/luticate/utils/ui/fragments/ViewPaginationFragment.java 查看文件

@@ -1,54 +0,0 @@
1
-package com.luticate.utils.ui.fragments;
2
-
3
-import android.view.View;
4
-import android.widget.LinearLayout;
5
-
6
-import com.luticate.utils.R;
7
-import com.luticate.utils.dbo.LuDbo;
8
-
9
-import java.util.List;
10
-import java.util.Vector;
11
-
12
-/**
13
- * Created by robin on 12/6/15.
14
- */
15
-public abstract class ViewPaginationFragment<Dbo extends LuDbo, DboView extends View> extends AbstractPaginationFragment<Dbo> {
16
-
17
-    protected List<DboView> _views = new Vector<>();
18
-
19
-    @Override
20
-    protected int getLoaderViewId() {
21
-        return R.id.loadStatus;
22
-    }
23
-
24
-    @Override
25
-    protected int getScrollViewId() {
26
-        return R.id.mainScrollView;
27
-    }
28
-
29
-    @Override
30
-    protected int getLayoutId() {
31
-        return R.layout.view_pagination_fragment_layout;
32
-    }
33
-
34
-    @Override
35
-    protected int getPaginationViewId() {
36
-        return R.id.paginationView;
37
-    }
38
-
39
-    @Override
40
-    protected void onPageChanged() {
41
-        View view = getView();
42
-        LinearLayout layout = (LinearLayout) view.findViewById(R.id.itemsLayoutScrollView);
43
-        layout.removeAllViews();
44
-        _views.clear();
45
-        for (Dbo item : _items.getData())
46
-        {
47
-            DboView v = getDboView(item);
48
-            layout.addView(v);
49
-            _views.add(v);
50
-        }
51
-    }
52
-
53
-    protected abstract DboView getDboView(Dbo dbo);
54
-}

+ 0
- 134
luticateutils/src/main/java/com/luticate/utils/ui/views/AbstractPaginationView.java 查看文件

@@ -1,134 +0,0 @@
1
-package com.luticate.utils.ui.views;
2
-
3
-import android.content.Context;
4
-import android.util.AttributeSet;
5
-import android.widget.LinearLayout;
6
-
7
-import com.luticate.utils.business.LuConsumer;
8
-import com.luticate.utils.business.LuPromise;
9
-
10
-import java.util.List;
11
-import java.util.Vector;
12
-
13
-/**
14
- * Created by robin on 12/8/15.
15
- */
16
-public abstract class AbstractPaginationView extends LinearLayout {
17
-
18
-    private LuConsumer<Integer> _onPageChanged = null;
19
-
20
-    private int _page = 0;
21
-
22
-    private int _maxPage = 1;
23
-
24
-    private int _contextPagesCount = 2;
25
-
26
-    public AbstractPaginationView(Context context) {
27
-        super(context);
28
-        init();
29
-    }
30
-
31
-    public AbstractPaginationView(Context context, AttributeSet attrs) {
32
-        super(context, attrs);
33
-        init(attrs);
34
-    }
35
-
36
-    public AbstractPaginationView(Context context, AttributeSet attrs, int defStyleAttr) {
37
-        super(context, attrs, defStyleAttr);
38
-        init(attrs);
39
-    }
40
-
41
-    private void init(AttributeSet attrs)
42
-    {
43
-        init();
44
-        //_contextPagesCount = attrs.getAttributeIntValue(R.styleable.DefaultPaginationView_contextPagesCount, _contextPagesCount);
45
-    }
46
-
47
-    private void init()
48
-    {
49
-
50
-    }
51
-
52
-    @Override
53
-    protected void onAttachedToWindow() {
54
-        super.onAttachedToWindow();
55
-
56
-        if (isInEditMode())
57
-        {
58
-            onUpdatePages();
59
-        }
60
-    }
61
-
62
-    protected List<Integer> getPages()
63
-    {
64
-        List<Integer> pages = new Vector<>();
65
-        int start = Math.max(0, getPage() - getContextPagesCount());
66
-        int end = Math.min(start + getContextPagesCount() + 1, getMaxPage());
67
-        for (int i = start; i < end; ++i)
68
-        {
69
-            pages.add(i);
70
-        }
71
-        return pages;
72
-    }
73
-
74
-    protected abstract void onUpdatePages();
75
-
76
-    public int getMaxPage() {
77
-        return isInEditMode() ? 50 : _maxPage;
78
-    }
79
-
80
-    public void setMaxPage(int maxPage) {
81
-        _maxPage = maxPage;
82
-        onUpdatePages();
83
-    }
84
-
85
-    public int getContextPagesCount() {
86
-        return _contextPagesCount;
87
-    }
88
-
89
-    public void setContextPagesCount(int contextPagesCount) {
90
-        _contextPagesCount = contextPagesCount;
91
-        onUpdatePages();
92
-    }
93
-
94
-    public void setPage(int page)
95
-    {
96
-        _page = page;
97
-        onUpdatePages();
98
-    }
99
-
100
-    public int getPage()
101
-    {
102
-        return isInEditMode() ? 24 : _page;
103
-    }
104
-
105
-    public void setOnPageChanged(LuConsumer<Integer> onPageChanged) {
106
-        _onPageChanged = onPageChanged;
107
-    }
108
-
109
-    public void loadPage(int page)
110
-    {
111
-        if (_onPageChanged != null)
112
-        {
113
-            _onPageChanged.execute(page);
114
-        }
115
-    }
116
-
117
-    public void loadNextPage()
118
-    {
119
-        int page = getPage();
120
-        if (page < getMaxPage() - 1)
121
-        {
122
-            loadPage(page + 1);
123
-        }
124
-    }
125
-
126
-    public void loadPreviousPage()
127
-    {
128
-        int page = getPage();
129
-        if (page > 0)
130
-        {
131
-            loadPage(page - 1);
132
-        }
133
-    }
134
-}

+ 0
- 65
luticateutils/src/main/java/com/luticate/utils/ui/views/DefaultPaginationView.java 查看文件

@@ -1,65 +0,0 @@
1
-package com.luticate.utils.ui.views;
2
-
3
-import android.content.Context;
4
-import android.util.AttributeSet;
5
-import android.view.View;
6
-import android.view.ViewGroup;
7
-import android.widget.TextView;
8
-
9
-import com.luticate.utils.R;
10
-
11
-/**
12
- * Created by robin on 12/8/15.
13
- */
14
-public class DefaultPaginationView extends AbstractPaginationView {
15
-    public DefaultPaginationView(Context context) {
16
-        super(context);
17
-        init();
18
-    }
19
-
20
-    public DefaultPaginationView(Context context, AttributeSet attrs) {
21
-        super(context, attrs);
22
-        init();
23
-    }
24
-
25
-    public DefaultPaginationView(Context context, AttributeSet attrs, int defStyleAttr) {
26
-        super(context, attrs, defStyleAttr);
27
-        init();
28
-    }
29
-
30
-    public void init()
31
-    {
32
-        inflate(getContext(), R.layout.default_pagination_view_layout, this);
33
-        findViewById(R.id.previousPageView).setOnClickListener(new OnClickListener() {
34
-            @Override
35
-            public void onClick(View v) {
36
-                loadPreviousPage();
37
-            }
38
-        });
39
-        findViewById(R.id.nextPageView).setOnClickListener(new OnClickListener() {
40
-            @Override
41
-            public void onClick(View v) {
42
-                loadNextPage();
43
-            }
44
-        });
45
-    }
46
-
47
-    @Override
48
-    protected void onUpdatePages() {
49
-        ViewGroup layout = (ViewGroup) findViewById(R.id.pagesLayout);
50
-        layout.removeAllViews();
51
-        for (final int page : getPages())
52
-        {
53
-            TextView tv = new TextView(getContext());
54
-            tv.setText(" " + String.valueOf(page + 1) + " ");
55
-            tv.setOnClickListener(new View.OnClickListener() {
56
-                    @Override
57
-                    public void onClick(View v) {
58
-                        loadPage(page);
59
-                    }
60
-                });
61
-            tv.setTextAppearance(getContext(), android.R.style.TextAppearance_DeviceDefault_Large);
62
-            layout.addView(tv);
63
-        }
64
-    }
65
-}

+ 0
- 30
luticateutils/src/main/res/layout/default_pagination_view_layout.xml 查看文件

@@ -1,30 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-              android:layout_width="match_parent"
4
-              android:layout_height="wrap_content"
5
-              android:gravity="center">
6
-
7
-    <TextView
8
-        android:layout_width="wrap_content"
9
-        android:layout_height="wrap_content"
10
-        android:id="@+id/previousPageView"
11
-        android:textAppearance="?android:attr/textAppearanceLarge"
12
-        android:layout_margin="2dp"
13
-        android:text=" &lt; "/>
14
-
15
-    <LinearLayout
16
-        android:id="@+id/pagesLayout"
17
-        android:layout_width="wrap_content"
18
-        android:layout_height="match_parent"
19
-        android:layout_gravity="center_horizontal"
20
-        android:orientation="horizontal">
21
-    </LinearLayout>
22
-
23
-    <TextView
24
-        android:layout_width="wrap_content"
25
-        android:layout_height="wrap_content"
26
-        android:id="@+id/nextPageView"
27
-        android:textAppearance="?android:attr/textAppearanceLarge"
28
-        android:layout_margin="2dp"
29
-        android:text=" &gt; "/>
30
-</LinearLayout>

+ 0
- 52
luticateutils/src/main/res/layout/view_pagination_fragment_layout.xml 查看文件

@@ -1,52 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-              android:layout_width="match_parent"
4
-              android:layout_height="match_parent"
5
-              xmlns:app="http://schemas.android.com/apk/res-auto"
6
-              android:orientation="vertical">
7
-
8
-    <!-- Loading progress -->
9
-
10
-    <LinearLayout
11
-        android:id="@+id/loadStatus"
12
-        android:layout_width="wrap_content"
13
-        android:layout_height="wrap_content"
14
-        android:layout_gravity="center"
15
-        android:gravity="center_horizontal"
16
-        android:orientation="vertical"
17
-        android:visibility="gone">
18
-
19
-        <ProgressBar
20
-            style="?android:attr/progressBarStyleLarge"
21
-            android:layout_width="wrap_content"
22
-            android:layout_height="wrap_content"
23
-            android:layout_marginBottom="8dp"/>
24
-    </LinearLayout>
25
-
26
-    <!-- Layout -->
27
-
28
-    <ScrollView
29
-        android:id="@+id/mainScrollView"
30
-        android:layout_width="match_parent"
31
-        android:layout_height="0dp"
32
-        android:layout_weight="0.33">
33
-
34
-        <RelativeLayout
35
-            android:layout_width="match_parent"
36
-            android:layout_height="wrap_content">
37
-
38
-            <LinearLayout
39
-                android:id="@+id/itemsLayoutScrollView"
40
-                android:layout_width="match_parent"
41
-                android:layout_height="match_parent"
42
-                android:orientation="vertical">
43
-            </LinearLayout>
44
-
45
-            <com.luticate.utils.ui.views.DefaultPaginationView
46
-                android:layout_width="match_parent"
47
-                android:layout_height="wrap_content"
48
-                android:layout_below="@+id/itemsLayoutScrollView"
49
-                android:id="@+id/paginationView"/>
50
-        </RelativeLayout>
51
-    </ScrollView>
52
-</LinearLayout>

+ 0
- 6
luticateutils/src/main/res/values/attrs.xml 查看文件

@@ -1,6 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<resources>
3
-    <declare-styleable name="DefaultPaginationView">
4
-        <attr name="contextPagesCount" format="integer" />
5
-    </declare-styleable>
6
-</resources>

+ 0
- 3
luticateutils/src/main/res/values/strings.xml 查看文件

@@ -1,3 +0,0 @@
1
-<resources>
2
-    <string name="app_name">LutcateUtils</string>
3
-</resources>

+ 0
- 222
luticateutils/src/test/java/com/luticate/utils/BasicDboTest.java 查看文件

@@ -1,222 +0,0 @@
1
-package com.luticate.utils;
2
-
3
-import com.luticate.utils.dbo.LuBoolDbo;
4
-import com.luticate.utils.dbo.LuDataAccessConfigDbo;
5
-import com.luticate.utils.dbo.LuDoubleDbo;
6
-import com.luticate.utils.dbo.LuIntDbo;
7
-import com.luticate.utils.dbo.LuLongDbo;
8
-import com.luticate.utils.dbo.LuPaginatedDbo;
9
-import com.luticate.utils.dbo.LuStringDbo;
10
-import com.luticate.utils.dbo.LuVoidDbo;
11
-
12
-import org.junit.Test;
13
-
14
-import java.util.HashMap;
15
-import java.util.List;
16
-import java.util.Map;
17
-import java.util.Vector;
18
-
19
-import static org.junit.Assert.*;
20
-
21
-/**
22
- * Created by robin on 10/22/16.
23
- */
24
-
25
-public class BasicDboTest {
26
-
27
-    @Test
28
-    public void boolTest() throws Exception {
29
-        LuBoolDbo dbo = new LuBoolDbo();
30
-        dbo.fromJson("{\"value\": true}");
31
-        assertTrue(dbo.getBool());
32
-
33
-        dbo = new LuBoolDbo();
34
-        dbo.fromJson("{\"value\": null}");
35
-        assertNull(dbo.getBool());
36
-
37
-        dbo = new LuBoolDbo();
38
-        dbo.fromJson("{\"value\": false}");
39
-        assertFalse(dbo.getBool());
40
-        dbo.setBool(true);
41
-
42
-        LuBoolDbo dbo2 = new LuBoolDbo();
43
-        dbo2.fromJson(dbo.toString());
44
-        assertTrue(dbo2.getBool());
45
-
46
-        dbo = new LuBoolDbo(false);
47
-        assertFalse(dbo.getBool());
48
-
49
-        dbo = new LuBoolDbo(true);
50
-        assertTrue(dbo.getBool());
51
-    }
52
-
53
-    @Test
54
-    public void intTest() throws Exception {
55
-        LuIntDbo dbo = new LuIntDbo();
56
-        dbo.fromJson("{\"value\": 42}");
57
-        assertEquals(42, dbo.getInt().intValue());
58
-
59
-        dbo = new LuIntDbo();
60
-        dbo.fromJson("{\"value\": null}");
61
-        assertNull(dbo.getInt());
62
-
63
-        dbo = new LuIntDbo();
64
-        dbo.fromJson("{\"value\": 24}");
65
-        assertEquals(24, dbo.getInt().intValue());
66
-        dbo.setInt(4242);
67
-
68
-        LuIntDbo dbo2 = new LuIntDbo();
69
-        dbo2.fromJson(dbo.toString());
70
-        assertEquals(4242, dbo2.getInt().intValue());
71
-
72
-        dbo = new LuIntDbo(42);
73
-        assertEquals(42, dbo.getInt().intValue());
74
-
75
-        dbo = new LuIntDbo(24);
76
-        assertEquals(24, dbo.getInt().intValue());
77
-    }
78
-
79
-    @Test
80
-    public void longTest() throws Exception {
81
-        LuLongDbo dbo = new LuLongDbo();
82
-        dbo.fromJson("{\"value\": 42}");
83
-        assertEquals(42, dbo.getLong().longValue());
84
-
85
-        dbo = new LuLongDbo();
86
-        dbo.fromJson("{\"value\": null}");
87
-        assertNull(dbo.getLong());
88
-
89
-        dbo = new LuLongDbo();
90
-        dbo.fromJson("{\"value\": 24}");
91
-        assertEquals(24, dbo.getLong().longValue());
92
-        dbo.setLong((long) 4242);
93
-
94
-        LuLongDbo dbo2 = new LuLongDbo();
95
-        dbo2.fromJson(dbo.toString());
96
-        assertEquals(4242, dbo2.getLong().longValue());
97
-
98
-        dbo = new LuLongDbo((long) 42);
99
-        assertEquals(42, dbo.getLong().longValue());
100
-
101
-        dbo = new LuLongDbo((long) 24);
102
-        assertEquals(24, dbo.getLong().longValue());
103
-    }
104
-
105
-    @Test
106
-    public void doubleTest() throws Exception {
107
-        LuDoubleDbo dbo = new LuDoubleDbo();
108
-        dbo.fromJson("{\"value\": 42.125}");
109
-        assertEquals(42.125, dbo.getDouble(), 0);
110
-
111
-        dbo = new LuDoubleDbo();
112
-        dbo.fromJson("{\"value\": null}");
113
-        assertNull(dbo.getDouble());
114
-
115
-        dbo = new LuDoubleDbo();
116
-        dbo.fromJson("{\"value\": 24.125}");
117
-        assertEquals(24.125, dbo.getDouble(), 0);
118
-        dbo.setDouble(4242.125);
119
-
120
-        LuDoubleDbo dbo2 = new LuDoubleDbo();
121
-        dbo2.fromJson(dbo.toString());
122
-        assertEquals(4242.125, dbo2.getDouble(), 0);
123
-
124
-        dbo = new LuDoubleDbo(42.125);
125
-        assertEquals(42.125, dbo.getDouble(), 0);
126
-
127
-        dbo = new LuDoubleDbo(24.125);
128
-        assertEquals(24.125, dbo.getDouble(), 0);
129
-    }
130
-
131
-    @Test
132
-    public void stringTest() throws Exception {
133
-        LuStringDbo dbo = new LuStringDbo();
134
-        dbo.fromJson("{\"value\": \"42\"}");
135
-        assertEquals("42", dbo.getString());
136
-
137
-        dbo = new LuStringDbo();
138
-        dbo.fromJson("{\"value\": null}");
139
-        assertNull(dbo.getString());
140
-
141
-        dbo = new LuStringDbo();
142
-        dbo.fromJson("{\"value\": \"24\"}");
143
-        assertEquals("24", dbo.getString());
144
-        dbo.setString("4242");
145
-
146
-        LuStringDbo dbo2 = new LuStringDbo();
147
-        dbo2.fromJson(dbo.toString());
148
-        assertEquals("4242", dbo2.getString());
149
-
150
-        dbo = new LuStringDbo("42 42");
151
-        assertEquals("42 42", dbo.getString());
152
-
153
-        dbo = new LuStringDbo("24 24");
154
-        assertEquals("24 24", dbo.getString());
155
-    }
156
-
157
-    @Test
158
-    public void paginatedTest() throws Exception {
159
-        LuPaginatedDbo<LuIntDbo> dbo = new LuPaginatedDbo<>(LuIntDbo.class);
160
-        dbo.fromJson("{\"count\": 42, \"data\": [{\"value\": 1}, {\"value\": 2}, {\"value\": 3}]}");
161
-        assertEquals(42, dbo.getCount());
162
-        assertNotNull(dbo.getData());
163
-        assertEquals(3, dbo.getData().size());
164
-        assertEquals(1, dbo.getData().get(0).getInt().intValue());
165
-        assertEquals(2, dbo.getData().get(1).getInt().intValue());
166
-        assertEquals(3, dbo.getData().get(2).getInt().intValue());
167
-
168
-        dbo.setCount(24);
169
-        List<LuIntDbo> list = new Vector<>();
170
-        list.add(new LuIntDbo(10));
171
-        list.add(new LuIntDbo(20));
172
-        dbo.setData(list);;
173
-        assertEquals(24, dbo.getCount());
174
-        assertNotNull(dbo.getData());
175
-        assertEquals(2, dbo.getData().size());
176
-        assertEquals(10, dbo.getData().get(0).getInt().intValue());
177
-        assertEquals(20, dbo.getData().get(1).getInt().intValue());
178
-
179
-        HashMap<String, Object> array = dbo.toArray();
180
-        assertEquals(2, array.size());
181
-        assertTrue(array.containsKey("count"));
182
-        assertEquals(24, array.get("count"));
183
-        assertTrue(array.containsKey("data"));
184
-        assertEquals(2, ((List)array.get("data")).size());
185
-    }
186
-
187
-    @Test
188
-    public void dataAccessConfigTest() throws Exception {
189
-        LuDataAccessConfigDbo dbo = new LuDataAccessConfigDbo();
190
-        dbo.fromJson("{\"baseUrl\": \"http://api/\", \"httpUsername\": \"root\", \"httpPassword\": \"toor42\"}");
191
-        assertEquals("http://api/", dbo.getBaseUrl());
192
-        assertEquals("root", dbo.getHttpUsername());
193
-        assertEquals("toor42", dbo.getHttpPassword());
194
-        Map<String, String> headers = dbo.getHeaders();
195
-        assertEquals(1, headers.size());
196
-        assertTrue(headers.containsKey("Authorization"));
197
-        assertEquals("Basic cm9vdDp0b29yNDI=", headers.get("Authorization"));
198
-
199
-        dbo = new LuDataAccessConfigDbo();
200
-        dbo.fromJson("{\"baseUrl\": \"http://api2/\"}");
201
-        assertEquals("http://api2/", dbo.getBaseUrl());
202
-        assertNull(dbo.getHttpUsername());
203
-        assertNull(dbo.getHttpPassword());
204
-        headers = dbo.getHeaders();
205
-        assertEquals(0, headers.size());
206
-        dbo.setBaseUrl("http://api/");
207
-        dbo.setHttpUsername("root");
208
-        dbo.setHttpPassword("toor42");
209
-        assertEquals("http://api/", dbo.getBaseUrl());
210
-        assertEquals("root", dbo.getHttpUsername());
211
-        assertEquals("toor42", dbo.getHttpPassword());
212
-
213
-        HashMap<String, Object> array = dbo.toArray();
214
-        assertEquals(3, array.size());
215
-        assertTrue(array.containsKey("baseUrl"));
216
-        assertEquals("http://api/", array.get("baseUrl"));
217
-        assertTrue(array.containsKey("httpUsername"));
218
-        assertEquals("root", array.get("httpUsername"));
219
-        assertTrue(array.containsKey("httpPassword"));
220
-        assertEquals("toor42", array.get("httpPassword"));
221
-    }
222
-}

+ 0
- 35
luticateutils/src/test/java/com/luticate/utils/NameDboTest.java 查看文件

@@ -1,35 +0,0 @@
1
-package com.luticate.utils;
2
-
3
-import com.luticate.utils.dbo.LuDbo;
4
-import com.luticate.utils.dbo.LuVoidDbo;
5
-
6
-import org.junit.Test;
7
-
8
-import static org.junit.Assert.*;
9
-
10
-/**
11
- * Created by robin on 10/20/16.
12
- */
13
-
14
-public class NameDboTest {
15
-
16
-    @Test
17
-    public void jsonFromFieldTest()
18
-    {
19
-        LuDbo dbo = new LuVoidDbo();
20
-        assertEquals("byte", dbo.getJsonFromField("_byte"));
21
-        assertEquals("anotherVariable", dbo.getJsonFromField("_anotherVariable"));
22
-        assertEquals("byte", dbo.getJsonFromField("byte"));
23
-        assertEquals("anotherVariable", dbo.getJsonFromField("anotherVariable"));
24
-    }
25
-
26
-    @Test
27
-    public void fieldFromJsonTest()
28
-    {
29
-        LuDbo dbo = new LuVoidDbo();
30
-        assertEquals("_byte", dbo.getFieldFromJson("byte"));
31
-        assertEquals("_anotherVariable", dbo.getFieldFromJson("anotherVariable"));
32
-        assertEquals("_byte", dbo.getFieldFromJson("_byte"));
33
-        assertEquals("_anotherVariable", dbo.getFieldFromJson("_anotherVariable"));
34
-    }
35
-}

+ 0
- 181
luticateutils/src/test/java/com/luticate/utils/PromiseTest.java 查看文件

@@ -1,181 +0,0 @@
1
-package com.luticate.utils;
2
-
3
-import com.luticate.utils.business.LuConsumer;
4
-import com.luticate.utils.business.LuConverter;
5
-import com.luticate.utils.business.LuPromise;
6
-import com.luticate.utils.dbo.LuPromiseError;
7
-import com.luticate.utils.dbo.LuVoidDbo;
8
-
9
-import org.junit.Test;
10
-
11
-import static org.junit.Assert.*;
12
-
13
-/**
14
- * Created by robin on 10/22/16.
15
- */
16
-
17
-public class PromiseTest {
18
-
19
-    @Test
20
-    public void resolveTest()
21
-    {
22
-        LuPromise<Integer> promise = new LuPromise<>();
23
-        final int[] results = new int[]{42, 24, 4242};
24
-
25
-        promise.then(new LuConsumer<Integer>() {
26
-            @Override
27
-            public void execute(Integer data) {
28
-                assertEquals(42, results[0]);
29
-                assertEquals(24, results[1]);
30
-                assertEquals(4242, results[2]);
31
-                ++results[0];
32
-            }
33
-        }, new LuConsumer<LuPromiseError>() {
34
-            @Override
35
-            public void execute(LuPromiseError data) {
36
-                assertEquals(42, results[0]);
37
-                assertEquals(24, results[1]);
38
-                assertEquals(4242, results[2]);
39
-                --results[0];
40
-            }
41
-        }).then(new LuConsumer<Integer>() {
42
-            @Override
43
-            public void execute(Integer data) {
44
-                assertEquals(43, results[0]);
45
-                assertEquals(24, results[1]);
46
-                assertEquals(4242, results[2]);
47
-                ++results[1];
48
-            }
49
-        }, new LuConsumer<LuPromiseError>() {
50
-            @Override
51
-            public void execute(LuPromiseError data) {
52
-                assertEquals(41, results[0]);
53
-                assertEquals(24, results[1]);
54
-                assertEquals(4242, results[2]);
55
-                --results[1];
56
-            }
57
-        });
58
-        assertEquals(42, results[0]);
59
-        assertEquals(24, results[1]);
60
-        assertEquals(4242, results[2]);
61
-        assertEquals(LuPromise.LuPromiseStatus.Running, promise.getStatus());
62
-        assertNull(promise.getData());
63
-
64
-        promise.resolve(4224).then(new LuConsumer<Integer>() {
65
-            @Override
66
-            public void execute(Integer data) {
67
-                assertEquals(43, results[0]);
68
-                assertEquals(25, results[1]);
69
-                assertEquals(4242, results[2]);
70
-                ++results[2];
71
-            }
72
-        }, new LuConsumer<LuPromiseError>() {
73
-            @Override
74
-            public void execute(LuPromiseError data) {
75
-                assertEquals(41, results[0]);
76
-                assertEquals(23, results[1]);
77
-                assertEquals(4242, results[2]);
78
-                --results[2];
79
-            }
80
-        });
81
-        assertEquals(43, results[0]);
82
-        assertEquals(25, results[1]);
83
-        assertEquals(4243, results[2]);
84
-        assertEquals(LuPromise.LuPromiseStatus.Resolved, promise.getStatus());
85
-        assertEquals(4224, promise.getData().intValue());
86
-    }
87
-
88
-    @Test
89
-    public void rejectTest()
90
-    {
91
-        LuPromise<Integer> promise = new LuPromise<>();
92
-        final int[] results = new int[]{42, 24, 4242};
93
-
94
-        promise.then(new LuConsumer<Integer>() {
95
-            @Override
96
-            public void execute(Integer data) {
97
-                assertEquals(42, results[0]);
98
-                assertEquals(24, results[1]);
99
-                assertEquals(4242, results[2]);
100
-                ++results[0];
101
-            }
102
-        }, new LuConsumer<LuPromiseError>() {
103
-            @Override
104
-            public void execute(LuPromiseError data) {
105
-                assertEquals(42, results[0]);
106
-                assertEquals(24, results[1]);
107
-                assertEquals(4242, results[2]);
108
-                --results[0];
109
-            }
110
-        }).then(new LuConsumer<Integer>() {
111
-            @Override
112
-            public void execute(Integer data) {
113
-                assertEquals(43, results[0]);
114
-                assertEquals(24, results[1]);
115
-                assertEquals(4242, results[2]);
116
-                ++results[1];
117
-            }
118
-        }, new LuConsumer<LuPromiseError>() {
119
-            @Override
120
-            public void execute(LuPromiseError data) {
121
-                assertEquals(41, results[0]);
122
-                assertEquals(24, results[1]);
123
-                assertEquals(4242, results[2]);
124
-                --results[1];
125
-            }
126
-        });
127
-        assertEquals(42, results[0]);
128
-        assertEquals(24, results[1]);
129
-        assertEquals(4242, results[2]);
130
-        assertEquals(LuPromise.LuPromiseStatus.Running, promise.getStatus());
131
-        assertNull(promise.getData());
132
-
133
-        promise.reject(null).then(new LuConsumer<Integer>() {
134
-            @Override
135
-            public void execute(Integer data) {
136
-                assertEquals(43, results[0]);
137
-                assertEquals(25, results[1]);
138
-                assertEquals(4242, results[2]);
139
-                ++results[2];
140
-            }
141
-        }, new LuConsumer<LuPromiseError>() {
142
-            @Override
143
-            public void execute(LuPromiseError data) {
144
-                assertEquals(41, results[0]);
145
-                assertEquals(23, results[1]);
146
-                assertEquals(4242, results[2]);
147
-                --results[2];
148
-            }
149
-        });
150
-        assertEquals(41, results[0]);
151
-        assertEquals(23, results[1]);
152
-        assertEquals(4241, results[2]);
153
-        assertEquals(LuPromise.LuPromiseStatus.Failed, promise.getStatus());
154
-        assertNull(promise.getData());
155
-    }
156
-
157
-    @Test
158
-    public void mapTest()
159
-    {
160
-        LuPromise<Integer> promise = new LuPromise<>();
161
-        final int[] result = new int[1];
162
-        promise.map(new LuConverter<Integer, Boolean>() {
163
-            @Override
164
-            public Boolean convert(Integer data) {
165
-                return data == 42;
166
-            }
167
-        }).then(new LuConsumer<Boolean>() {
168
-            @Override
169
-            public void execute(Boolean data) {
170
-                result[0] = data ? 4242 : 2424;
171
-            }
172
-        }, new LuConsumer<LuPromiseError>() {
173
-            @Override
174
-            public void execute(LuPromiseError data) {
175
-                result[0] = 2442;
176
-            }
177
-        });
178
-        promise.resolve(42);
179
-        assertEquals(result[0], 4242);
180
-    }
181
-}

+ 0
- 49
luticateutils/src/test/java/com/luticate/utils/Test2Dbo.java 查看文件

@@ -1,49 +0,0 @@
1
-package com.luticate.utils;
2
-
3
-import com.luticate.utils.dbo.LuDbo;
4
-
5
-/**
6
- * Created by robin on 10/20/16.
7
- */
8
-
9
-public class Test2Dbo extends LuDbo {
10
-
11
-    protected String _aString;
12
-
13
-    protected int _aInt;
14
-
15
-    public String getaString() {
16
-        return _aString;
17
-    }
18
-
19
-    public void setaString(String aString) {
20
-        _aString = aString;
21
-    }
22
-
23
-    public int getaInt() {
24
-        return _aInt;
25
-    }
26
-
27
-    public void setaInt(int aInt) {
28
-        _aInt = aInt;
29
-    }
30
-
31
-    @Override
32
-    public boolean equals(Object o) {
33
-        if (this == o) return true;
34
-        if (o == null || getClass() != o.getClass()) return false;
35
-
36
-        Test2Dbo test2Dbo = (Test2Dbo) o;
37
-
38
-        if (_aInt != test2Dbo._aInt) return false;
39
-        return _aString != null ? _aString.equals(test2Dbo._aString) : test2Dbo._aString == null;
40
-
41
-    }
42
-
43
-    @Override
44
-    public int hashCode() {
45
-        int result = _aString != null ? _aString.hashCode() : 0;
46
-        result = 31 * result + _aInt;
47
-        return result;
48
-    }
49
-}

+ 0
- 365
luticateutils/src/test/java/com/luticate/utils/TestDbo.java 查看文件

@@ -1,365 +0,0 @@
1
-package com.luticate.utils;
2
-
3
-import com.luticate.utils.dbo.LuDbo;
4
-
5
-import java.io.Serializable;
6
-import java.util.AbstractMap;
7
-import java.util.Arrays;
8
-import java.util.HashMap;
9
-import java.util.List;
10
-
11
-/**
12
- * Created by robin on 10/20/16.
13
- */
14
-
15
-public class TestDbo extends LuDbo implements Serializable {
16
-    protected byte _byte;
17
-    protected char _char;
18
-    protected short _short;
19
-    protected int _int;
20
-    protected long _long;
21
-    protected float _float;
22
-    protected double _double;
23
-    protected boolean _boolean;
24
-
25
-    protected Byte _byteObject;
26
-    protected Character _charObject;
27
-    protected Short _shortObject;
28
-    protected Integer _intObject;
29
-    protected Long _longObject;
30
-    protected Float _floatObject;
31
-    protected Double _doubleObject;
32
-    protected Boolean _booleanObject;
33
-
34
-    protected String _string;
35
-
36
-    protected Test2Dbo _test2Dbo;
37
-    protected Test2Dbo _test2Dbo2;
38
-
39
-    protected List<Integer> _integers;
40
-    protected int[] _ints;
41
-
42
-    protected List<Test2Dbo> _test2Dbos;
43
-    protected Test2Dbo[] _dbos;
44
-
45
-    protected HashMap<String, Integer> _hashMap;
46
-    protected AbstractMap<String, Test2Dbo> _hashMap2;
47
-
48
-    protected String _aNullString;
49
-    protected Class _object = TestDbo.class;
50
-
51
-    protected transient String _transientField;
52
-
53
-    public byte getByte() {
54
-        return _byte;
55
-    }
56
-
57
-    public void setByte(byte aByte) {
58
-        _byte = aByte;
59
-    }
60
-
61
-    public char getChar() {
62
-        return _char;
63
-    }
64
-
65
-    public void setChar(char aChar) {
66
-        _char = aChar;
67
-    }
68
-
69
-    public short getShort() {
70
-        return _short;
71
-    }
72
-
73
-    public void setShort(short aShort) {
74
-        _short = aShort;
75
-    }
76
-
77
-    public int getInt() {
78
-        return _int;
79
-    }
80
-
81
-    public void setInt(int anInt) {
82
-        _int = anInt;
83
-    }
84
-
85
-    public long getLong() {
86
-        return _long;
87
-    }
88
-
89
-    public void setLong(long aLong) {
90
-        _long = aLong;
91
-    }
92
-
93
-    public float getFloat() {
94
-        return _float;
95
-    }
96
-
97
-    public void setFloat(float aFloat) {
98
-        _float = aFloat;
99
-    }
100
-
101
-    public double getDouble() {
102
-        return _double;
103
-    }
104
-
105
-    public void setDouble(double aDouble) {
106
-        _double = aDouble;
107
-    }
108
-
109
-    public boolean isBoolean() {
110
-        return _boolean;
111
-    }
112
-
113
-    public void setBoolean(boolean aBoolean) {
114
-        _boolean = aBoolean;
115
-    }
116
-
117
-    public Byte getByteObject() {
118
-        return _byteObject;
119
-    }
120
-
121
-    public void setByteObject(Byte byteObject) {
122
-        _byteObject = byteObject;
123
-    }
124
-
125
-    public Character getCharObject() {
126
-        return _charObject;
127
-    }
128
-
129
-    public void setCharObject(Character charObject) {
130
-        _charObject = charObject;
131
-    }
132
-
133
-    public Short getShortObject() {
134
-        return _shortObject;
135
-    }
136
-
137
-    public void setShortObject(Short shortObject) {
138
-        _shortObject = shortObject;
139
-    }
140
-
141
-    public Integer getIntObject() {
142
-        return _intObject;
143
-    }
144
-
145
-    public void setIntObject(Integer intObject) {
146
-        _intObject = intObject;
147
-    }
148
-
149
-    public Long getLongObject() {
150
-        return _longObject;
151
-    }
152
-
153
-    public void setLongObject(Long longObject) {
154
-        _longObject = longObject;
155
-    }
156
-
157
-    public Float getFloatObject() {
158
-        return _floatObject;
159
-    }
160
-
161
-    public void setFloatObject(Float floatObject) {
162
-        _floatObject = floatObject;
163
-    }
164
-
165
-    public Double getDoubleObject() {
166
-        return _doubleObject;
167
-    }
168
-
169
-    public void setDoubleObject(Double doubleObject) {
170
-        _doubleObject = doubleObject;
171
-    }
172
-
173
-    public Boolean getBooleanObject() {
174
-        return _booleanObject;
175
-    }
176
-
177
-    public void setBooleanObject(Boolean booleanObject) {
178
-        _booleanObject = booleanObject;
179
-    }
180
-
181
-    public String getString() {
182
-        return _string;
183
-    }
184
-
185
-    public void setString(String string) {
186
-        _string = string;
187
-    }
188
-
189
-    public Test2Dbo getTest2Dbo() {
190
-        return _test2Dbo;
191
-    }
192
-
193
-    public void setTest2Dbo(Test2Dbo test2Dbo) {
194
-        _test2Dbo = test2Dbo;
195
-    }
196
-
197
-    public Test2Dbo getTest2Dbo2() {
198
-        return _test2Dbo2;
199
-    }
200
-
201
-    public void setTest2Dbo2(Test2Dbo test2Dbo2) {
202
-        _test2Dbo2 = test2Dbo2;
203
-    }
204
-
205
-    public List<Integer> getIntegers() {
206
-        return _integers;
207
-    }
208
-
209
-    public void setIntegers(List<Integer> integers) {
210
-        _integers = integers;
211
-    }
212
-
213
-    public int[] getInts() {
214
-        return _ints;
215
-    }
216
-
217
-    public void setInts(int[] ints) {
218
-        _ints = ints;
219
-    }
220
-
221
-    public List<Test2Dbo> getTest2Dbos() {
222
-        return _test2Dbos;
223
-    }
224
-
225
-    public void setTest2Dbos(List<Test2Dbo> test2Dbos) {
226
-        _test2Dbos = test2Dbos;
227
-    }
228
-
229
-    public Test2Dbo[] getDbos() {
230
-        return _dbos;
231
-    }
232
-
233
-    public void setDbos(Test2Dbo[] dbos) {
234
-        _dbos = dbos;
235
-    }
236
-
237
-    public HashMap<String, Integer> getHashMap() {
238
-        return _hashMap;
239
-    }
240
-
241
-    public void setHashMap(HashMap<String, Integer> hashMap) {
242
-        _hashMap = hashMap;
243
-    }
244
-
245
-    public AbstractMap<String, Test2Dbo> getHashMap2() {
246
-        return _hashMap2;
247
-    }
248
-
249
-    public void setHashMap2(AbstractMap<String, Test2Dbo> hashMap2) {
250
-        _hashMap2 = hashMap2;
251
-    }
252
-
253
-    public String getaNullString() {
254
-        return _aNullString;
255
-    }
256
-
257
-    public void setaNullString(String aNullString) {
258
-        _aNullString = aNullString;
259
-    }
260
-
261
-    public Class getObject() {
262
-        return _object;
263
-    }
264
-
265
-    public void setObject(Class object) {
266
-        _object = object;
267
-    }
268
-
269
-    public String getTransientField() {
270
-        return _transientField;
271
-    }
272
-
273
-    public void setTransientField(String transientField) {
274
-        _transientField = transientField;
275
-    }
276
-
277
-    @Override
278
-    public boolean equals(Object o) {
279
-        if (this == o) return true;
280
-        if (o == null || getClass() != o.getClass()) return false;
281
-
282
-        TestDbo testDbo = (TestDbo) o;
283
-
284
-        if (_byte != testDbo._byte) return false;
285
-        if (_char != testDbo._char) return false;
286
-        if (_short != testDbo._short) return false;
287
-        if (_int != testDbo._int) return false;
288
-        if (_long != testDbo._long) return false;
289
-        if (Float.compare(testDbo._float, _float) != 0) return false;
290
-        if (Double.compare(testDbo._double, _double) != 0) return false;
291
-        if (_boolean != testDbo._boolean) return false;
292
-        if (_byteObject != null ? !_byteObject.equals(testDbo._byteObject) : testDbo._byteObject != null)
293
-            return false;
294
-        if (_charObject != null ? !_charObject.equals(testDbo._charObject) : testDbo._charObject != null)
295
-            return false;
296
-        if (_shortObject != null ? !_shortObject.equals(testDbo._shortObject) : testDbo._shortObject != null)
297
-            return false;
298
-        if (_intObject != null ? !_intObject.equals(testDbo._intObject) : testDbo._intObject != null)
299
-            return false;
300
-        if (_longObject != null ? !_longObject.equals(testDbo._longObject) : testDbo._longObject != null)
301
-            return false;
302
-        if (_floatObject != null ? !_floatObject.equals(testDbo._floatObject) : testDbo._floatObject != null)
303
-            return false;
304
-        if (_doubleObject != null ? !_doubleObject.equals(testDbo._doubleObject) : testDbo._doubleObject != null)
305
-            return false;
306
-        if (_booleanObject != null ? !_booleanObject.equals(testDbo._booleanObject) : testDbo._booleanObject != null)
307
-            return false;
308
-        if (_string != null ? !_string.equals(testDbo._string) : testDbo._string != null)
309
-            return false;
310
-        if (_test2Dbo != null ? !_test2Dbo.equals(testDbo._test2Dbo) : testDbo._test2Dbo != null)
311
-            return false;
312
-        if (_test2Dbo2 != null ? !_test2Dbo2.equals(testDbo._test2Dbo2) : testDbo._test2Dbo2 != null)
313
-            return false;
314
-        if (_integers != null ? !_integers.equals(testDbo._integers) : testDbo._integers != null)
315
-            return false;
316
-        if (!Arrays.equals(_ints, testDbo._ints)) return false;
317
-        if (_test2Dbos != null ? !_test2Dbos.equals(testDbo._test2Dbos) : testDbo._test2Dbos != null)
318
-            return false;
319
-        // Probably incorrect - comparing Object[] arrays with Arrays.equals
320
-        if (!Arrays.equals(_dbos, testDbo._dbos)) return false;
321
-        if (_hashMap != null ? !_hashMap.equals(testDbo._hashMap) : testDbo._hashMap != null)
322
-            return false;
323
-        if (_hashMap2 != null ? !_hashMap2.equals(testDbo._hashMap2) : testDbo._hashMap2 != null)
324
-            return false;
325
-        if (_aNullString != null ? !_aNullString.equals(testDbo._aNullString) : testDbo._aNullString != null)
326
-            return false;
327
-        return _object != null ? _object.equals(testDbo._object) : testDbo._object == null;
328
-
329
-    }
330
-
331
-    @Override
332
-    public int hashCode() {
333
-        int result;
334
-        long temp;
335
-        result = (int) _byte;
336
-        result = 31 * result + (int) _char;
337
-        result = 31 * result + (int) _short;
338
-        result = 31 * result + _int;
339
-        result = 31 * result + (int) (_long ^ (_long >>> 32));
340
-        result = 31 * result + (_float != +0.0f ? Float.floatToIntBits(_float) : 0);
341
-        temp = Double.doubleToLongBits(_double);
342
-        result = 31 * result + (int) (temp ^ (temp >>> 32));
343
-        result = 31 * result + (_boolean ? 1 : 0);
344
-        result = 31 * result + (_byteObject != null ? _byteObject.hashCode() : 0);
345
-        result = 31 * result + (_charObject != null ? _charObject.hashCode() : 0);
346
-        result = 31 * result + (_shortObject != null ? _shortObject.hashCode() : 0);
347
-        result = 31 * result + (_intObject != null ? _intObject.hashCode() : 0);
348
-        result = 31 * result + (_longObject != null ? _longObject.hashCode() : 0);
349
-        result = 31 * result + (_floatObject != null ? _floatObject.hashCode() : 0);
350
-        result = 31 * result + (_doubleObject != null ? _doubleObject.hashCode() : 0);
351
-        result = 31 * result + (_booleanObject != null ? _booleanObject.hashCode() : 0);
352
-        result = 31 * result + (_string != null ? _string.hashCode() : 0);
353
-        result = 31 * result + (_test2Dbo != null ? _test2Dbo.hashCode() : 0);
354
-        result = 31 * result + (_test2Dbo2 != null ? _test2Dbo2.hashCode() : 0);
355
-        result = 31 * result + (_integers != null ? _integers.hashCode() : 0);
356
-        result = 31 * result + Arrays.hashCode(_ints);
357
-        result = 31 * result + (_test2Dbos != null ? _test2Dbos.hashCode() : 0);
358
-        result = 31 * result + Arrays.hashCode(_dbos);
359
-        result = 31 * result + (_hashMap != null ? _hashMap.hashCode() : 0);
360
-        result = 31 * result + (_hashMap2 != null ? _hashMap2.hashCode() : 0);
361
-        result = 31 * result + (_aNullString != null ? _aNullString.hashCode() : 0);
362
-        result = 31 * result + (_object != null ? _object.hashCode() : 0);
363
-        return result;
364
-    }
365
-}

+ 0
- 188
luticateutils/src/test/java/com/luticate/utils/TestDboTest.java 查看文件

@@ -1,188 +0,0 @@
1
-package com.luticate.utils;
2
-
3
-import org.json.JSONObject;
4
-import org.junit.Test;
5
-
6
-import static org.junit.Assert.*;
7
-
8
-/**
9
- * Created by robin on 10/20/16.
10
- */
11
-
12
-public class TestDboTest {
13
-
14
-    public static String TEST_DBO_JSON =  "{" +
15
-            "\"byte\": 42," +
16
-            "\"char\": \"h\"," +
17
-            "\"short\": 4200," +
18
-            "\"int\": 420042," +
19
-            "\"long\": 42004200," +
20
-            "\"float\": 42.24," +
21
-            "\"double\": 4200.0024," +
22
-            "\"boolean\": true," +
23
-
24
-            "\"byteObject\": 24," +
25
-            "\"charObject\": \"w\"," +
26
-            "\"shortObject\": 2400," +
27
-            "\"intObject\": 240024," +
28
-            "\"longObject\": 24002400," +
29
-            "\"floatObject\": 24.42," +
30
-            "\"doubleObject\": 2400.0042," +
31
-            "\"booleanObject\": false," +
32
-
33
-            "\"string\": \"Hello World!\"," +
34
-
35
-            "\"test2Dbo\": {" +
36
-            "\"aString\": \"a string\"," +
37
-            "\"aInt\": 4242" +
38
-            "}," +
39
-
40
-            "\"integers\": [" +
41
-            "0," +
42
-            "42," +
43
-            "24" +
44
-            "]," +
45
-            "ints: [" +
46
-            "24," +
47
-            "42," +
48
-            "0" +
49
-            "]," +
50
-
51
-            "test2Dbos: [" +
52
-            "{" +
53
-            "\"aString\": \"42 42\"," +
54
-            "\"aInt\": 4242" +
55
-            "}" +
56
-            "]," +
57
-            "dbos: [" +
58
-            "{" +
59
-            "\"aString\": \"24 24\"," +
60
-            "\"aInt\": 2424" +
61
-            "}" +
62
-            "]," +
63
-
64
-            "\"hashMap\": {" +
65
-            "\"forty-two\": 42," +
66
-            "\"twenty-four\": 24" +
67
-            "}," +
68
-
69
-            "\"hashMap2\": {" +
70
-            "\"an object\": {" +
71
-            "\"aString\": \"42 24\"," +
72
-            "\"aInt\": 4224" +
73
-            "}" +
74
-            "}," +
75
-
76
-            "\"aNullString\": null," +
77
-
78
-            "\"object\": {}," +
79
-
80
-            "\"transientField\": \"a transient field\"" +
81
-
82
-            "}";
83
-
84
-    public void testTestDbo(TestDbo test)
85
-    {
86
-        assertEquals(42, test.getByte());
87
-        assertEquals(24, test.getByteObject().byteValue());
88
-        assertEquals('h', test.getChar());
89
-        assertEquals('w', test.getCharObject().charValue());
90
-        assertEquals(4200, test.getShort());
91
-        assertEquals(2400, test.getShortObject().shortValue());
92
-        assertEquals(420042, test.getInt());
93
-        assertEquals(240024, test.getIntObject().intValue());
94
-        assertEquals(42004200, test.getLong());
95
-        assertEquals(24002400, test.getLongObject().longValue());
96
-        assertEquals(42.24, test.getFloat(), 0.1);
97
-        assertEquals(24.42, test.getFloatObject(), 0.1);
98
-        assertEquals(4200.0024, test.getDouble(), 0.1);
99
-        assertEquals(2400.0042, test.getDoubleObject(), 0.1);
100
-        assertEquals(true, test.isBoolean());
101
-        assertEquals(false, test.getBooleanObject());
102
-        assertEquals("Hello World!", test.getString());
103
-
104
-        assertNotNull(test.getTest2Dbo());
105
-        assertEquals("a string", test.getTest2Dbo().getaString());
106
-        assertEquals(4242, test.getTest2Dbo().getaInt());
107
-        assertNull(test.getTest2Dbo2());
108
-
109
-        assertNotNull(test.getIntegers());
110
-        assertEquals(3, test.getIntegers().size());
111
-        assertEquals(0, test.getIntegers().get(0).intValue());
112
-        assertEquals(42, test.getIntegers().get(1).intValue());
113
-        assertEquals(24, test.getIntegers().get(2).intValue());
114
-
115
-        assertNotNull(test.getInts());
116
-        assertEquals(3, test.getInts().length);
117
-        assertEquals(24, test.getInts()[0]);
118
-        assertEquals(42, test.getInts()[1]);
119
-        assertEquals(0, test.getInts()[2]);
120
-
121
-        assertNotNull(test.getTest2Dbos());
122
-        assertEquals(1, test.getTest2Dbos().size());
123
-        assertNotNull(test.getTest2Dbos().get(0));
124
-        assertEquals("42 42", test.getTest2Dbos().get(0).getaString());
125
-        assertEquals(4242, test.getTest2Dbos().get(0).getaInt());
126
-
127
-        assertNotNull(test.getDbos());
128
-        assertEquals(1, test.getDbos().length);
129
-        assertNotNull(test.getDbos()[0]);
130
-        assertEquals("24 24", test.getDbos()[0].getaString());
131
-        assertEquals(2424, test.getDbos()[0].getaInt());
132
-
133
-        assertNotNull(test.getHashMap());
134
-        assertEquals(2, test.getHashMap().size());
135
-        assertTrue(test.getHashMap().containsKey("forty-two"));
136
-        assertEquals(42, (int)test.getHashMap().get("forty-two"));
137
-        assertTrue(test.getHashMap().containsKey("twenty-four"));
138
-        assertEquals(24, (int)test.getHashMap().get("twenty-four"));
139
-
140
-        assertNotNull(test.getHashMap2());
141
-        assertEquals(1, test.getHashMap2().size());
142
-        assertTrue(test.getHashMap2().containsKey("an object"));
143
-        assertNotNull(test.getHashMap2().get("an object"));
144
-        assertEquals("42 24", test.getHashMap2().get("an object").getaString());
145
-        assertEquals(4224, test.getHashMap2().get("an object").getaInt());
146
-
147
-        assertNull(test.getaNullString());
148
-        assertNull(test.getObject());
149
-
150
-        assertNull(test.getTransientField());
151
-
152
-        assertEquals(test, test);
153
-    }
154
-
155
-    @Test
156
-    public void deserializeTest() throws Exception {
157
-        TestDbo test = new TestDbo();
158
-        test.fromJson(TEST_DBO_JSON);
159
-        testTestDbo(test);
160
-    }
161
-
162
-    @Test
163
-    public void serializeTest() throws Exception
164
-    {
165
-        TestDbo test = new TestDbo();
166
-        test.fromJson(TEST_DBO_JSON);
167
-        JSONObject json = test.toJson();
168
-
169
-        assertFalse(json.has("transientField"));
170
-
171
-        TestDbo test2 = new TestDbo();
172
-        test2.fromJson(json);
173
-
174
-        testTestDbo(test2);
175
-    }
176
-
177
-    @Test
178
-    public void serializeStringTest() throws Exception
179
-    {
180
-        TestDbo test = new TestDbo();
181
-        test.fromJson(TEST_DBO_JSON);
182
-
183
-        TestDbo test2 = new TestDbo();
184
-        test2.fromJson(test.toString());
185
-
186
-        testTestDbo(test2);
187
-    }
188
-}

+ 1
- 1
settings.gradle 查看文件

@@ -1 +1 @@
1
-include ':app', ':luticateutils'
1
+include ':app'

Loading…
取消
儲存