Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VolleyEx
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
zihan
VolleyEx
Commits
48489758
Commit
48489758
authored
Mar 24, 2016
by
ssngah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete some unused files
parent
76443225
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
133 deletions
+18
-133
BaseWebRequest.java
...x/src/main/java/com/xiaogu/xgvolleyex/BaseWebRequest.java
+17
-15
MultipartRequest.java
...src/main/java/com/xiaogu/xgvolleyex/MultipartRequest.java
+1
-5
XGCommonWSResult.java
...in/java/com/xiaogu/xgvolleyex/utils/XGCommonWSResult.java
+0
-113
No files found.
xgvolleyex/src/main/java/com/xiaogu/xgvolleyex/BaseWebRequest.java
View file @
48489758
...
...
@@ -12,6 +12,7 @@ import com.android.volley.RequestQueue;
import
com.android.volley.Response
;
import
com.android.volley.RetryPolicy
;
import
com.android.volley.VolleyError
;
import
com.android.volley.VolleyLog
;
import
com.android.volley.toolbox.HurlStack
;
import
com.android.volley.toolbox.Volley
;
import
com.google.gson.reflect.TypeToken
;
...
...
@@ -34,14 +35,12 @@ import javax.net.ssl.TrustManagerFactory;
import
javax.xml.transform.ErrorListener
;
/**
* An instance for an activity which need to do web request is suggested
* Request will not be performed if the certificate factory can not be created when use the https
* Request will not be performed if the certificate factory can not be created when you use the https
* mode
* Created by Phyllis on 15-4-11.
*/
public
abstract
class
BaseWebRequest
{
private
RequestQueue
mQueue
;
public
static
final
String
TAG
=
"XG_VOLLEY"
;
private
static
RequestQueue
mTryBestQueue
;
private
int
mTimeOut
=
10
*
1000
;
private
static
List
<
Request
>
mSuspendedRequest
;
...
...
@@ -128,7 +127,9 @@ public abstract class BaseWebRequest {
);
mQueue
.
add
(
jsonObjectRequest
);
Log
.
d
(
TAG
,
"sent request to url:"
+
url
);
if
(
VolleyLog
.
DEBUG
)
{
Log
.
d
(
VolleyLog
.
TAG
,
"sent request to url:"
+
url
);
}
return
jsonObjectRequest
;
...
...
@@ -143,13 +144,14 @@ public abstract class BaseWebRequest {
netErrorListener
);
mQueue
.
add
(
jsonObjectRequest
);
Log
.
d
(
TAG
,
"sent request to url:"
+
url
);
if
(
VolleyLog
.
DEBUG
)
{
Log
.
d
(
VolleyLog
.
TAG
,
"sent request to url:"
+
url
);
}
return
jsonObjectRequest
;
}
/**
* the request will go on and on until it gets response
*
* @param netErrorListener the call back listener when net error happens,null is allowed
* @return The request used to request data from web server
*/
...
...
@@ -180,7 +182,9 @@ public abstract class BaseWebRequest {
return
jsonObjectRequest
;
}
mTryBestQueue
.
add
(
jsonObjectRequest
);
Log
.
d
(
TAG
,
"sent request to url:"
+
url
);
if
(
VolleyLog
.
DEBUG
)
{
Log
.
d
(
VolleyLog
.
TAG
,
"sent request to url:"
+
url
);
}
return
jsonObjectRequest
;
...
...
@@ -256,7 +260,9 @@ public abstract class BaseWebRequest {
listener
.
onWebCallFinish
(
false
,
error
);
}
if
(!
TextUtils
.
isEmpty
(
error
.
getMessage
())){
Log
.
e
(
TAG
,
error
.
getMessage
());
if
(
VolleyLog
.
DEBUG
)
{
Log
.
e
(
VolleyLog
.
TAG
,
error
.
getMessage
());
}
}
}
...
...
@@ -266,14 +272,8 @@ public abstract class BaseWebRequest {
/**
* You can override this method to return a custom request you need,if you do this ,it is
* your responsibility to init the request parameters like the RetryPolicy and shouldcatch etc.
*
* @param httpMethodName
* @param url
* @param params This can be an object ,if it is a String,then you it should be a
* jsonString
* @param targetType
* @param listener
* @param errorListener
* @return The request will be added to the request queue;
*/
protected
Request
getRequest
(
int
httpMethodName
,
String
url
,
...
...
@@ -312,7 +312,9 @@ public abstract class BaseWebRequest {
listener
.
onWebCallFinish
(
false
,
null
);
}
else
{
Log
.
d
(
TAG
,
response
);
if
(
VolleyLog
.
DEBUG
)
{
Log
.
d
(
VolleyLog
.
TAG
,
response
);
}
Object
result
;
if
(
isAutoParseJson
())
{
result
=
JsonUtils
...
...
xgvolleyex/src/main/java/com/xiaogu/xgvolleyex/MultipartRequest.java
View file @
48489758
...
...
@@ -61,8 +61,6 @@ public class MultipartRequest extends JsonStringRequest {
/**
* 注意Map里面的value中,将会使用toString方法来获得值
*
* @param params
*/
private
void
buildMultipartEntity
(
HashMap
<
String
,
Object
>
params
)
{
mEntityBuilder
=
MultipartEntityBuilder
.
create
();
...
...
@@ -79,9 +77,7 @@ public class MultipartRequest extends JsonStringRequest {
int
i
=
0
;
for
(
Object
object
:
list
)
{
if
(
object
instanceof
File
)
{
// FileBody fileBody = new FileBody((File)object);
// mEntityBuilder.addPart(entry.getKey() + "[" + String.valueOf(i++) + "]",
// fileBody);
addFile
((
File
)
object
,
entry
.
getKey
());
}
else
if
(
object
instanceof
Bitmap
)
{
addBitmap
((
Bitmap
)
object
,
entry
.
getKey
());
...
...
xgvolleyex/src/main/java/com/xiaogu/xgvolleyex/utils/XGCommonWSResult.java
deleted
100644 → 0
View file @
76443225
package
com
.
xiaogu
.
xgvolleyex
.
utils
;
import
android.text.TextUtils
;
/**
* Created by Phyllis on 15-4-11.
*/
public
class
XGCommonWSResult
<
T
>
{
/* 调用正常 响应正常 返回的appstate=1 */
public
static
final
int
APPSTATE_RESP_OK
=
1
;
/* 无网络连接 */
public
static
final
int
APPSTATE_NO_NETWORK_CONNECTION
=
-
97
;
/* 调用参数为空 */
public
static
final
int
APPSTATE_INVOKE_PARAMS_ERR
=
-
96
;
/* 服务器响应超时 (服务器异常) */
public
static
final
int
APPSTATE_RESP_TIMEOUT
=
-
95
;
/***
* appState用于指示ws程序的执行状况
* -3表示使用该ws的开发者的apiKey不正确
* -2表示传递给ws接口的传入参数有误(即不符合要求,验证不通过)
* -1表示ws程序执行失败,程序发生异常或者错误导致
* 1表示ws程序执行成功,默认为执行正确
*
* -99 表示客户端调用ws接口的程序发生异常
* -98 表示网络状况不佳
*/
private
int
appState
=
1
;
public
static
final
String
STATE_ERROR
=
"FAILED"
;
public
static
final
String
STATE_SUCCESS
=
"SUCCESS"
;
public
static
final
String
STATE_NO_DATA
=
"NO_DATA"
;
private
String
action
;
private
String
v
;
private
boolean
success
;
private
String
retCode
;
private
String
msg
;
/***
* ws接口返回的结果值
*/
private
T
data
;
public
XGCommonWSResult
(){
super
();
}
public
XGCommonWSResult
(
T
data
,
String
action
,
String
v
,
String
retCode
,
String
msg
)
{
super
();
this
.
data
=
data
;
this
.
action
=
action
;
this
.
v
=
v
;
this
.
retCode
=
retCode
;
this
.
msg
=
msg
;
}
public
boolean
isSuccess
(){
if
(!
TextUtils
.
isEmpty
(
retCode
)){
return
this
.
retCode
.
equals
(
"SUCCESS"
);
}
else
{
return
success
;
}
}
public
T
getResult
()
{
return
data
;
}
public
void
setResult
(
T
data
)
{
this
.
data
=
data
;
}
public
int
getAppState
()
{
return
appState
;
}
public
void
setAppState
(
int
appState
)
{
this
.
appState
=
appState
;
}
@Override
public
String
toString
()
{
return
"WsResult [appState="
+
appState
+
", action="
+
action
+
", v="
+
v
+
", retCode="
+
retCode
+
", msg="
+
msg
+
", data="
+
data
+
"]"
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
void
setState
(
String
state
){
this
.
retCode
=
state
;
}
public
String
getState
(){
return
retCode
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment