Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wd1105040417
retrofit
提交
6d520856
R
retrofit
项目概览
wd1105040417
/
retrofit
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
retrofit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d520856
编写于
11月 15, 2015
作者:
J
Jesse Wilson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1283 from square/jw/docs
Fill out some documentation on public types.
上级
87af99d0
19bd400e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
11 deletion
+42
-11
retrofit/src/main/java/retrofit/Call.java
retrofit/src/main/java/retrofit/Call.java
+21
-0
retrofit/src/main/java/retrofit/CallAdapter.java
retrofit/src/main/java/retrofit/CallAdapter.java
+3
-2
retrofit/src/main/java/retrofit/Callback.java
retrofit/src/main/java/retrofit/Callback.java
+11
-3
retrofit/src/main/java/retrofit/Converter.java
retrofit/src/main/java/retrofit/Converter.java
+7
-6
未找到文件。
retrofit/src/main/java/retrofit/Call.java
浏览文件 @
6d520856
...
...
@@ -27,10 +27,31 @@ import java.io.IOException;
* #enqueue}. In either case the call can be canceled at any time with {@link #cancel}. A call that
* is busy writing its request or reading its response may receive a {@link IOException}; this is
* working as designed.
*
* @param <T> Successful response body type.
*/
public
interface
Call
<
T
>
extends
Cloneable
{
/**
* Synchronously send the request and return its response.
*
* @throws IOException if a problem occurred talking to the server.
* @throws RuntimeException (and subclasses) if an unexpected error occurs creating the request
* or processing the response.
*/
Response
<
T
>
execute
()
throws
IOException
;
/**
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred talking to the server, creating the request, or processing the response.
*/
void
enqueue
(
Callback
<
T
>
callback
);
/**
* Cancel this call. An attempt will be made to cancel in-flight calls, and if the call has not
* yet been executed it never will be.
*/
void
cancel
();
/** Create a new, identical call to this one. */
Call
<
T
>
clone
();
}
retrofit/src/main/java/retrofit/CallAdapter.java
浏览文件 @
6d520856
...
...
@@ -33,10 +33,11 @@ public interface CallAdapter<T> {
/** Returns an instance of the {@code T} which adapts the execution of {@code call}. */
<
R
>
T
adapt
(
Call
<
R
>
call
);
/** Creates {@link CallAdapter} instances based on a desired type. */
interface
Factory
{
/**
* Returns a call adapter for interface methods that return {@code returnType}, or null if
this
*
factory doesn't adapt that type
.
* Returns a call adapter for interface methods that return {@code returnType}, or null if
it
*
cannot be handled by this factory
.
*/
CallAdapter
<?>
get
(
Type
returnType
,
Annotation
[]
annotations
,
Retrofit
retrofit
);
}
...
...
retrofit/src/main/java/retrofit/Callback.java
浏览文件 @
6d520856
...
...
@@ -26,12 +26,20 @@ package retrofit;
* <li>JVM: Callbacks are executed on the background thread which performed the request.</li>
* </ul>
*
* @param <T>
expected response type
* @param <T>
Successful response body type.
*/
public
interface
Callback
<
T
>
{
/** Successful HTTP response. */
/**
* Invoked for a received HTTP response.
* <p>
* Note: An HTTP response may still indicate an application-level failure such as a 404 or 500.
* Call {@link Response#isSuccess()} to determine if the response indicates success.
*/
void
onResponse
(
Response
<
T
>
response
);
/** Invoked when a network or unexpected exception occurred during the HTTP request. */
/**
* Invoked when a network exception occurred talking to the server or when an unexpected
* exception occurred creating the request or processing the response.
*/
void
onFailure
(
Throwable
t
);
}
retrofit/src/main/java/retrofit/Converter.java
浏览文件 @
6d520856
...
...
@@ -22,24 +22,25 @@ import java.lang.annotation.Annotation;
import
java.lang.reflect.Type
;
/**
* Convert objects to and from their representation
as HTTP bodies. Register a converter with
*
Retrofit
using {@link Retrofit.Builder#addConverterFactory(Factory)}.
* Convert objects to and from their representation
in HTTP. Register a converter with Retrofit
* using {@link Retrofit.Builder#addConverterFactory(Factory)}.
*/
public
interface
Converter
<
F
,
T
>
{
T
convert
(
F
value
)
throws
IOException
;
/** Creates {@link Converter} instances based on a type and target usage. */
abstract
class
Factory
{
/**
*
Create a {@link Converter} for converting an HTTP response body to {@code type} or null if it
* cannot be handled by this factory.
*
Returns a {@link Converter} for converting an HTTP response body to {@code type}, or null if
*
{@code type}
cannot be handled by this factory.
*/
public
Converter
<
ResponseBody
,
?>
fromResponseBody
(
Type
type
,
Annotation
[]
annotations
)
{
return
null
;
}
/**
*
Create a {@link Converter} for converting {@code type} to an HTTP request body or null if it
* cannot be handled by this factory.
*
Returns a {@link Converter} for converting {@code type} to an HTTP request body, or null if
*
{@code type}
cannot be handled by this factory.
*/
public
Converter
<?,
RequestBody
>
toRequestBody
(
Type
type
,
Annotation
[]
annotations
)
{
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录