-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FileCallback,StringCallback,JsonCallback
- Loading branch information
Edwin Wu
committed
Jun 15, 2017
1 parent
be053ac
commit 89efb9d
Showing
7 changed files
with
123 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/github/why168/androidhttputils/http/FileCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.why168.androidhttputils.http; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author Edwin.Wu | ||
* @version 2017/6/15 21:57 | ||
* @since JDK1.8 | ||
*/ | ||
public class FileCallback implements Callback { | ||
@Override | ||
public void onFailure(Exception e) { | ||
|
||
} | ||
|
||
@Override | ||
public void onResponse(String results) throws IOException { | ||
|
||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/github/why168/androidhttputils/http/JsonCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.why168.androidhttputils.http; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author Edwin.Wu | ||
* @version 2017/6/15 21:56 | ||
* @since JDK1.8 | ||
*/ | ||
public class JsonCallback implements Callback { | ||
@Override | ||
public void onFailure(Exception e) { | ||
|
||
} | ||
|
||
@Override | ||
public void onResponse(String results) throws IOException { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/github/why168/androidhttputils/http/StringCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.why168.androidhttputils.http; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author Edwin.Wu | ||
* @version 2017/6/15 21:56 | ||
* @since JDK1.8 | ||
*/ | ||
public class StringCallback implements Callback{ | ||
@Override | ||
public void onFailure(Exception e) { | ||
|
||
} | ||
|
||
@Override | ||
public void onResponse(String results) throws IOException { | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/github/why168/androidhttputils/util/StringUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.github.why168.androidhttputils.util; | ||
|
||
/** | ||
* @author Edwin.Wu | ||
* @version 2017/6/15 21:48 | ||
* @since JDK1.8 | ||
*/ | ||
public class StringUtils { | ||
|
||
public static String getPrintSize(long size) { | ||
//如果字节数少于1024,则直接以B为单位,否则先除于1024,后3位因太少无意义 | ||
if (size < 1024) { | ||
return String.valueOf(size) + "B"; | ||
} else { | ||
size = size / 1024; | ||
} | ||
//如果原字节数除于1024之后,少于1024,则可以直接以KB作为单位 | ||
//因为还没有到达要使用另一个单位的时候 | ||
//接下去以此类推 | ||
if (size < 1024) { | ||
return String.valueOf(size) + "KB"; | ||
} else { | ||
size = size / 1024; | ||
} | ||
if (size < 1024) { | ||
//因为如果以MB为单位的话,要保留最后1位小数, | ||
//因此,把此数乘以100之后再取余 | ||
size = size * 100; | ||
return String.valueOf((size / 100)) + "." | ||
+ String.valueOf((size % 100)) + "MB"; | ||
} else { | ||
//否则如果要以GB为单位的,先除于1024再作同样的处理 | ||
size = size * 100 / 1024; | ||
return String.valueOf((size / 100)) + "." | ||
+ String.valueOf((size % 100)) + "GB"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters