Skip to content

Commit aa7cdb7

Browse files
committed
Renamed main package. Added AssetsRequest.java
1 parent 532e88e commit aa7cdb7

22 files changed

+226
-56
lines changed

.settings/org.eclipse.jdt.ui.prefs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.ui.javadoc=true
3+
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*******************************************************************************\r\n * Copyright (c) ${year} Alexandr Tsvetkov.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the GNU Lesser General Public License\r\n * which accompanies this distribution, and is available at\r\n * http\://www.gnu.org/licenses/lgpl.html\r\n *\r\n * Contributors\:\r\n * Alexandr Tsvetkov - initial API and implementation\r\n *\r\n * Project\:\r\n * ${project_name}\r\n *\r\n * License agreement\:\r\n *\r\n * 1. This code is published AS IS. Author is not responsible for any damage that can be\r\n * caused by any application that uses this code.\r\n * 2. Author does not give a garantee, that this code is error free.\r\n * 3. This code can be used in NON-COMMERCIAL applications AS IS without any special\r\n * permission from author.\r\n * 4. This code can be modified without any special permission from author IF AND ONLY IF\r\n * this license agreement will remain unchanged.\r\n ******************************************************************************/\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>

AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="ua.at.tsvetkov.tdataprocessor"
2+
package="ua.at.tsvetkov.data_processor"
33
android:versionCode="1"
44
android:versionName="1.0" >
55

src/ua/at/tsvetkov/dataprocessor/DataProcessor.java renamed to src/ua/at/tsvetkov/data_processor/DataProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor;
24+
package ua.at.tsvetkov.data_processor;
2525

26-
//import ua.at.tsvetkov.dataprocessor.interfaces.InputStreamDataInterface;
27-
//import ua.at.tsvetkov.dataprocessor.interfaces.StringDataInterface;
28-
import ua.at.tsvetkov.dataprocessor.requests.Request;
26+
//import ua.at.tsvetkov.data_processor.interfaces.InputStreamDataInterface;
27+
//import ua.at.tsvetkov.data_processor.interfaces.StringDataInterface;
28+
import ua.at.tsvetkov.data_processor.requests.Request;
2929
import ua.at.tsvetkov.netchecker.Net;
3030
import ua.at.tsvetkov.netchecker.NetChecker;
3131
import ua.at.tsvetkov.netchecker.NetStatus;

src/ua/at/tsvetkov/dataprocessor/DataProcessorConfiguration.java renamed to src/ua/at/tsvetkov/data_processor/DataProcessorConfiguration.java

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor;
24+
package ua.at.tsvetkov.data_processor;
25+
26+
import ua.at.tsvetkov.util.Log;
2527

2628
/**
2729
* @author lordtao
@@ -53,6 +55,12 @@ private DataProcessorConfiguration(final Builder builder) {
5355
isCheckingRequestStringEnabled = builder.isCheckingRequestStringEnabled;
5456
isShowProcessingTime = builder.isShowProcessingTime;
5557
testServerUrl = builder.testServerUrl;
58+
if (isLogEnabled) {
59+
Log.i("isLogEnabled = " + isLogEnabled);
60+
Log.i("isShowProcessingTime = " + isShowProcessingTime);
61+
Log.i("httpUserAgent = " + httpUserAgent);
62+
Log.i("testServerUrl = " + testServerUrl);
63+
}
5664
}
5765

5866
public boolean isLogEnabled() {
@@ -130,8 +138,8 @@ public static class Builder {
130138

131139
private int timeout = 0;
132140
public boolean isCheckingRequestStringEnabled = false;
133-
private boolean isLogEnabled = false;
134-
public boolean isShowProcessingTime = false;
141+
private boolean isLogEnabled = true;
142+
public boolean isShowProcessingTime = true;
135143
private String httpUserAgent = null;
136144
private String host = null;
137145
private String port = null;
@@ -148,6 +156,11 @@ public DataProcessorConfiguration build() {
148156
return new DataProcessorConfiguration(this);
149157
}
150158

159+
public DataProcessorConfiguration buildForAssets() {
160+
initWithAssetsValues();
161+
return new DataProcessorConfiguration(this);
162+
}
163+
151164
public Builder setHttpUserAgent(String httpUserAgent) {
152165
this.httpUserAgent = httpUserAgent;
153166
return this;
@@ -217,5 +230,28 @@ private void initWithDefaultValues() {
217230
}
218231
}
219232

233+
private void initWithAssetsValues() {
234+
if (host == null) {
235+
host = "";
236+
}
237+
if (port == null) {
238+
port = "";
239+
}
240+
if (scheme == null) {
241+
scheme = Scheme.ASSETS.toString();
242+
}
243+
if (encoding == null) {
244+
encoding = Encoding.UTF_8.getString();
245+
}
246+
if (timeout == 0) {
247+
timeout = DEFAULT_TIMEOUT;
248+
}
249+
if (httpUserAgent == null) {
250+
httpUserAgent = "";
251+
}
252+
if (testServerUrl == null) {
253+
testServerUrl = "";
254+
}
255+
}
220256
}
221257
}

src/ua/at/tsvetkov/dataprocessor/Encoding.java renamed to src/ua/at/tsvetkov/data_processor/Encoding.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor;
24+
package ua.at.tsvetkov.data_processor;
2525

2626
public enum Encoding {
2727
ISO_8859_1("ISO-8859-1"), US_ASCII("US-ASCII"), UTF_16("UTF-16"), UTF_16BE("UTF-16BE"), UTF_16LE("UTF-16LE"), UTF_8("UTF-8");

src/ua/at/tsvetkov/dataprocessor/ProcessingCentre.java renamed to src/ua/at/tsvetkov/data_processor/ProcessingCentre.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor;
24+
package ua.at.tsvetkov.data_processor;
2525

2626
import java.io.File;
2727
import java.io.FileInputStream;
@@ -33,16 +33,17 @@
3333

3434
import org.apache.http.HttpStatus;
3535

36-
import ua.at.tsvetkov.dataprocessor.DataProcessor.Callback;
37-
import ua.at.tsvetkov.dataprocessor.interfaces.InputStreamDataInterface;
38-
import ua.at.tsvetkov.dataprocessor.interfaces.StringDataInterface;
39-
import ua.at.tsvetkov.dataprocessor.processors.InputStreamProcessor;
40-
import ua.at.tsvetkov.dataprocessor.processors.StringProcessor;
41-
import ua.at.tsvetkov.dataprocessor.processors.abstractclasses.AbstractProcessor;
42-
import ua.at.tsvetkov.dataprocessor.requests.Request;
36+
import ua.at.tsvetkov.data_processor.DataProcessor.Callback;
37+
import ua.at.tsvetkov.data_processor.interfaces.InputStreamDataInterface;
38+
import ua.at.tsvetkov.data_processor.interfaces.StringDataInterface;
39+
import ua.at.tsvetkov.data_processor.processors.InputStreamProcessor;
40+
import ua.at.tsvetkov.data_processor.processors.StringProcessor;
41+
import ua.at.tsvetkov.data_processor.processors.abstractclasses.AbstractProcessor;
42+
import ua.at.tsvetkov.data_processor.requests.Request;
4343
import ua.at.tsvetkov.util.Const;
4444
import ua.at.tsvetkov.util.Log;
4545
import android.os.Handler;
46+
import android.os.Looper;
4647

4748
public class ProcessingCentre {
4849

@@ -65,7 +66,7 @@ public class ProcessingCentre {
6566
private Class<?> clazz;
6667
private Callback callback;
6768
private Thread thread;
68-
private final Handler handler = new Handler();
69+
private final Handler handler;
6970

7071
/**
7172
* @param request
@@ -78,6 +79,11 @@ public ProcessingCentre(Request request, Class<?> clazz) {
7879
this.request = request;
7980
this.clazz = clazz;
8081
this.callback = null;
82+
83+
if (Looper.myLooper() != null)
84+
handler = new Handler();
85+
else
86+
handler = null;
8187
thread = Thread.currentThread();
8288
}
8389

@@ -93,6 +99,11 @@ public ProcessingCentre(Request request, Class<?> clazz, Callback callback) {
9399
this.request = request;
94100
this.clazz = clazz;
95101
this.callback = callback;
102+
103+
if (Looper.myLooper() != null)
104+
handler = new Handler();
105+
else
106+
handler = null;
96107
thread = Thread.currentThread();
97108
}
98109

@@ -123,7 +134,8 @@ public Object execute() {
123134
sendMessage(ERROR, e);
124135
} finally {
125136
try {
126-
inputStream.close();
137+
if (inputStream != null)
138+
inputStream.close();
127139
request.close();
128140
} catch (Exception e) {
129141
Log.e(e);
@@ -133,7 +145,10 @@ public Object execute() {
133145
long time = System.currentTimeMillis() - request.getStartTime();
134146
Log.v("Processing time = " + time + " ms. [ " + request + " ]");
135147
}
136-
return processor.getResult();
148+
if (processor != null)
149+
return processor.getResult();
150+
else
151+
return null;
137152
}
138153

139154
/**

src/ua/at/tsvetkov/dataprocessor/Scheme.java renamed to src/ua/at/tsvetkov/data_processor/Scheme.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor;
24+
package ua.at.tsvetkov.data_processor;
2525

2626
/**
2727
* Protocol for URL like "http" or "file". This is also known as the scheme. The returned string is lower case.
2828
*
2929
* @author lordtao
3030
*/
3131
public enum Scheme {
32-
HTTP("http://"), HTTPS("https://"), FILE("file://");
32+
HTTP("http://"), HTTPS("https://"), FILE("file://"), ASSETS("");
3333

3434
private String mType;
3535

src/ua/at/tsvetkov/dataprocessor/interfaces/InputStreamDataInterface.java renamed to src/ua/at/tsvetkov/data_processor/interfaces/InputStreamDataInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor.interfaces;
24+
package ua.at.tsvetkov.data_processor.interfaces;
2525

2626
import java.io.IOException;
2727
import java.io.InputStream;

src/ua/at/tsvetkov/dataprocessor/interfaces/StringDataInterface.java renamed to src/ua/at/tsvetkov/data_processor/interfaces/StringDataInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor.interfaces;
24+
package ua.at.tsvetkov.data_processor.interfaces;
2525

2626
public interface StringDataInterface {
2727

src/ua/at/tsvetkov/dataprocessor/processors/InputStreamProcessor.java renamed to src/ua/at/tsvetkov/data_processor/processors/InputStreamProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
* 4. This code can be modified without any special permission from author IF AND ONLY IF
2222
* this license agreement will remain unchanged.
2323
******************************************************************************/
24-
package ua.at.tsvetkov.dataprocessor.processors;
24+
package ua.at.tsvetkov.data_processor.processors;
2525

2626
import java.io.InputStream;
2727

28-
import ua.at.tsvetkov.dataprocessor.interfaces.InputStreamDataInterface;
29-
import ua.at.tsvetkov.dataprocessor.processors.abstractclasses.AbstractProcessor;
28+
import ua.at.tsvetkov.data_processor.interfaces.InputStreamDataInterface;
29+
import ua.at.tsvetkov.data_processor.processors.abstractclasses.AbstractProcessor;
3030

3131
public class InputStreamProcessor extends AbstractProcessor {
3232

0 commit comments

Comments
 (0)