Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Takeya-Yuki
RubyLib
提交
cae7d9b7
R
RubyLib
项目概览
Takeya-Yuki
/
RubyLib
8 个月 前同步成功
通知
39
Star
19
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RubyLib
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cae7d9b7
编写于
2月 05, 2018
作者:
Y
Yuki Takeya
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Async Exceptions
上级
f762eea2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
108 addition
and
27 deletion
+108
-27
ajaxlib/build.gradle
ajaxlib/build.gradle
+2
-2
ajaxlib/src/main/java/yuki/control/extended/HttpAsyncClient.java
.../src/main/java/yuki/control/extended/HttpAsyncClient.java
+95
-25
ajaxlib/src/main/java/yuki/control/extended/OnException.java
ajaxlib/src/main/java/yuki/control/extended/OnException.java
+11
-0
未找到文件。
ajaxlib/build.gradle
浏览文件 @
cae7d9b7
...
...
@@ -5,7 +5,7 @@ publish {
userOrg
=
'takeya-yuki-studio'
//bintray注册的用户名
groupId
=
'jp.ruby.rubylib'
//compile引用时的第1部分groupId
artifactId
=
'ajaxlib'
//compile引用时的第2部分项目名
publishVersion
=
'2.0.
1
'
//compile引用时的第3部分版本号
publishVersion
=
'2.0.
2
'
//compile引用时的第3部分版本号
desc
=
'Ruby Extended Controls - AjaxLib'
website
=
'https://github.com/Takeya-Yuki/RubyLib.git'
}
...
...
@@ -17,7 +17,7 @@ android {
defaultConfig
{
minSdkVersion
21
targetSdkVersion
26
versionCode
1
versionCode
2
versionName
"2.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
...
...
ajaxlib/src/main/java/yuki/control/extended/HttpAsyncClient.java
浏览文件 @
cae7d9b7
...
...
@@ -17,7 +17,7 @@ public final class HttpAsyncClient {
* @param activity Window
* @param get Response Handler
**/
public
static
void
AsyncGetString
(
final
String
Url
,
final
Activity
activity
,
final
OnGet
get
)
{
public
static
void
AsyncGetString
(
final
String
Url
,
final
Activity
activity
,
final
OnGet
get
,
final
OnException
onException
)
{
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -38,10 +38,24 @@ public final class HttpAsyncClient {
}
);
}
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
MalformedURLException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
catch
(
final
IOException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
finally
{
urlConnection
.
disconnect
();
}
...
...
@@ -66,7 +80,7 @@ public final class HttpAsyncClient {
* @param get Download Finished Handler
**/
public
static
void
AsyncGetFile
(
final
String
Url
,
final
Activity
activity
,
final
String
savePath
,
final
String
saveFileName
,
final
OnProgress
progress
,
final
OnGet
get
)
{
final
String
saveFileName
,
final
OnProgress
progress
,
final
OnGet
get
,
final
OnException
onException
)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -117,10 +131,24 @@ public final class HttpAsyncClient {
}
while
(
true
);
fos
.
close
();
is
.
close
();
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
MalformedURLException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
catch
(
final
IOException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
}
}).
start
();
...
...
@@ -136,7 +164,7 @@ public final class HttpAsyncClient {
* @param get Download Finished Handler
**/
public
static
void
AsyncGetFile
(
final
String
Url
,
final
Activity
activity
,
final
String
savePath
,
final
OnProgress
progress
,
final
OnGet
get
)
{
,
final
OnProgress
progress
,
final
OnGet
get
,
final
OnException
onException
)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -187,16 +215,30 @@ public final class HttpAsyncClient {
}
while
(
true
);
fos
.
close
();
is
.
close
();
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
MalformedURLException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
catch
(
final
IOException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
}
}).
start
();
}
public
static
void
AsyncPostString
(
final
String
Url
,
final
Activity
activity
,
final
String
ContentType
,
final
String
rawData
,
final
OnPost
post
){
public
static
void
AsyncPostString
(
final
String
Url
,
final
Activity
activity
,
final
String
ContentType
,
final
String
rawData
,
final
OnPost
post
,
final
OnException
onException
){
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -227,10 +269,24 @@ public final class HttpAsyncClient {
}
);
}
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
MalformedURLException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
catch
(
final
IOException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
finally
{
urlConnection
.
disconnect
();
}
...
...
@@ -238,7 +294,7 @@ public final class HttpAsyncClient {
}).
start
();
}
public
static
void
AsyncRESTString
(
final
String
Url
,
final
Activity
activity
,
final
String
RESTMethod
,
final
String
ContentType
,
final
String
rawData
,
final
OnREST
post
){
public
static
void
AsyncRESTString
(
final
String
Url
,
final
Activity
activity
,
final
String
RESTMethod
,
final
String
ContentType
,
final
String
rawData
,
final
OnREST
post
,
final
OnException
onException
){
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -269,10 +325,24 @@ public final class HttpAsyncClient {
}
);
}
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
final
MalformedURLException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
catch
(
final
IOException
e
)
{
if
(
onException
!=
null
){
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
onException
.
OnError
(
e
);
}
});
}
}
finally
{
urlConnection
.
disconnect
();
}
...
...
ajaxlib/src/main/java/yuki/control/extended/OnException.java
0 → 100644
浏览文件 @
cae7d9b7
package
yuki.control.extended
;
/**
* Created by Yuki on 2018-02-05.
*/
/* On Exception Handler*/
public
interface
OnException
{
public
void
OnError
(
Exception
error
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录