Skip to content

Commit d4cea09

Browse files
committed
[commit]ignore some file
1 parent d29ffe5 commit d4cea09

File tree

6 files changed

+33
-43
lines changed

6 files changed

+33
-43
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
/build
88
/captures
99
/.idea
10+
/library/src/test
11+
/library/src/androidTest

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# 常用工具类
2-
- 每一个Android开发者在日常开发中都会积累一些自己的代码片段.
3-
- 本项目就是收集一些日常开发中的常用工具类,减少功能性代码的重复编写,方便快速开发.
4-
- 通过封装一层工具类的好处是以后只需要修改工具类的实现,就可以替换整体的框架.
5-
- 部分方法没有经过测试,请使用者自行测试并反馈问题.
6-
- 参考了众多项目并加以改进和总结,如有疑问,请来信说明.
2+
- 每一个Android开发者在日常开发中都会积累一些自己的代码片段
3+
- 目的:
4+
* 1.将常用功能模块做成工具类
5+
* 2.将常用第三方框架封装成工具类
6+
* 3.收集一些高效的正确的代码片段避免下次踩坑
7+
- 还在努力维护中,暂时不加入依赖仓库中,待代码经过检验,功能完善再加入到依赖中
8+
- 大部分参考一些技术文章或者开源项目源码,未经测试,有Bug请<a href="https://github.com/h4de5ing/AndroidCommon/issues">反馈</a>
9+
- 如果你有更好的封装,请提交<a href="https://github.com/h4de5ing/AndroidCommon/pulls">Pull request</a>
710

811
## app Module中的类:
912
MainActivity.java 测试项目中的主类
@@ -37,12 +40,13 @@
3740
- FileUtils.java 文件工具
3841
* deleteFile 删除文件
3942
* existsFile 判断文件是否存在
40-
* writeFile 写文件
41-
* readFile 读文件
43+
* writeFile 将字符串写入到文件中
44+
* readFile 从文件中读取字符串
4245
* copyFileFast 快速复制
4346
* closeIO 关闭IO流
4447
* zip zip压缩
4548
* unzip zip解压
49+
* formatFileSize 格式化文件大小
4650

4751
- JsonUtils.java Json相关工具
4852
* toJson 对象转json

library/src/androidTest/java/com/code19/library/ApplicationTest.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

library/src/main/java/com/code19/library/DeviceInfo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,10 @@ public String getGSFID() {
934934
String[] params = {ID_KEY};
935935
Cursor c = context.getContentResolver().query(URI, null, null, params, null);
936936

937-
if (!c.moveToFirst() || c.getColumnCount() < 2) {
937+
if (c == null || !c.moveToFirst() || c.getColumnCount() < 2) {
938+
if(c != null) {
939+
c.close();
940+
}
938941
c.close();
939942
return null;
940943
}

library/src/main/java/com/code19/library/FileUtils.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.code19.library;
1818

1919
import android.content.Context;
20+
import android.text.format.Formatter;
2021

2122
import java.io.BufferedReader;
2223
import java.io.BufferedWriter;
@@ -35,7 +36,6 @@
3536

3637
/**
3738
* Create by h4de5ing 2016/5/7 007
38-
* 文件工具类,实现对文件的创建,删除,读,写,压缩,解压,流的转换
3939
*/
4040
public class FileUtils {
4141

@@ -53,23 +53,21 @@ public static boolean deleteFile(Context context, String filename) {
5353
/**
5454
* 判断文件是否存在
5555
*
56-
* @param context 上下文
5756
* @param filename 文件名称,传入文件的完整路径
5857
* @return 存在返回 true
5958
*/
60-
public static boolean existsFile(Context context, String filename) {
59+
public static boolean existsFile(String filename) {
6160
return new File(filename).exists();
6261
}
6362

6463
/**
65-
* 将字符串写入到文件中去
64+
* 将字符串写入到文件中
6665
*
67-
* @param context 上下文
6866
* @param filename 文件名称,传入文件的完整路径
6967
* @param content 写入的内容
7068
* @return 写入成功返回 true
7169
*/
72-
public static boolean writeFile(Context context, String filename, String content) {
70+
public static boolean writeFile(String filename, String content) {
7371
boolean isSuccess = false;
7472
BufferedWriter bufferedWriter = null;
7573
try {
@@ -92,7 +90,7 @@ public static boolean writeFile(Context context, String filename, String content
9290
}
9391

9492
/**
95-
* 读取文件
93+
* 从文件中读取字符串
9694
*
9795
* @param filename 文件名称,传入文件的完整路径
9896
* @return 返回文件中的字符串
@@ -201,4 +199,15 @@ public static void unzip(InputStream is, OutputStream os) {
201199
}
202200
}
203201

202+
/**
203+
* 格式化文件大小
204+
*
205+
* @param context
206+
* @param size
207+
* @return
208+
*/
209+
public static String formatFileSize(Context context, long size) {
210+
return Formatter.formatFileSize(context, size);
211+
}
212+
204213
}

library/src/test/java/com/code19/library/ExampleUnitTest.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)