Skip to content

Commit

Permalink
version-0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
郑晓勇 committed Feb 7, 2017
1 parent 1c0f67e commit a40cdb8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README-Chinese.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A crash recovery framework!
**Gradle**

```
compile 'com.zxy.android:recovery:0.1.1'
compile 'com.zxy.android:recovery:0.1.2'
```

**Maven**
Expand All @@ -36,7 +36,7 @@ A crash recovery framework!
<dependency>
<groupId>com.zxy.android</groupId>
<artifactId>recovery</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<type>pom</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A crash recovery framework!
**Using Gradle**

```gradle
compile 'com.zxy.android:recovery:0.1.1'
compile 'com.zxy.android:recovery:0.1.2'
```

**Using Maven**
Expand All @@ -36,7 +36,7 @@ compile 'com.zxy.android:recovery:0.1.1'
<dependency>
<groupId>com.zxy.android</groupId>
<artifactId>recovery</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<type>pom</type>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion recovery/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {

ext {
upload_group_id = 'com.zxy.android'
upload_version = '0.1.1'
upload_version = '0.1.2'

site_url = 'https://github.com/Sunzxyong/Recovery'
git_url = 'https://github.com/Sunzxyong/Recovery.git'
Expand Down
3 changes: 2 additions & 1 deletion recovery/src/main/java/com/zxy/recovery/core/Recovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public void init(Context context) {
throw new RecoveryException("Context can not be null!");
if (!(context instanceof Application))
context = context.getApplicationContext();
// if (!RecoveryUtil.isMainProcess(context)) return;
mContext = context;
if (!RecoveryUtil.isMainProcess(context))
return;
registerRecoveryHandler();
registerRecoveryLifecycleCallback();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;

/**
* Created by zhengxiaoyong on 16/8/26.
Expand Down Expand Up @@ -311,8 +309,7 @@ private ArrayList<Intent> getRecoveryIntents() {
}

private boolean saveCrashData() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
String date = format.format(new Date(System.currentTimeMillis()));
String date = RecoveryUtil.getDateFormat().format(new Date(System.currentTimeMillis()));
File dir = new File(getExternalFilesDir(null) + File.separator + DEFAULT_CRASH_FILE_DIR_NAME);
if (!dir.exists())
dir.mkdirs();
Expand Down
13 changes: 13 additions & 0 deletions recovery/src/main/java/com/zxy/recovery/tools/RecoveryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@
import com.zxy.recovery.exception.ReflectException;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

/**
* Created by zhengxiaoyong on 16/8/28.
*/
public class RecoveryUtil {

private static final ThreadLocal<DateFormat> DATE_FORMAT_THREAD_LOCAL = new ThreadLocal<DateFormat>() {
@Override
protected DateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};

private RecoveryUtil() {
throw new RecoveryException("Stub!");
}
Expand Down Expand Up @@ -128,4 +137,8 @@ public static int dp2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}

public static DateFormat getDateFormat() {
return DATE_FORMAT_THREAD_LOCAL.get();
}
}

0 comments on commit a40cdb8

Please sign in to comment.