Skip to content

Commit

Permalink
优化了代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCShou committed Aug 29, 2021
1 parent 789244a commit 495d075
Show file tree
Hide file tree
Showing 18 changed files with 1,160 additions and 1,186 deletions.
1,348 changes: 674 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/build
/build
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ android {
applicationId "com.zcshou.gogogo"
minSdkVersion 27
targetSdkVersion 29
versionCode 175
versionName '1.7.5' // 语义化版本 https://semver.org/lang/zh-CN/
versionCode 176
versionName '1.7.6' // 语义化版本 https://semver.org/lang/zh-CN/
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
ndkVersion '22.1.7171670'
ndkVersion '23.0.7599858'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '30.0.3'
buildToolsVersion '31.0.0'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 175,
"versionName": "1.7.5",
"versionCode": 176,
"versionName": "1.7.6",
"outputFile": "app-release.apk"
}
],
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/zcshou/gogogo/FragmentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import androidx.preference.SwitchPreferenceCompat;

import com.elvishew.xlog.XLog;
import com.zcshou.utils.AppUtils;
import com.zcshou.utils.GoUtils;

/* */
public class FragmentSettings extends PreferenceFragmentCompat {
Expand All @@ -23,7 +23,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

// 设置版本号
String verName;
verName = AppUtils.getVersionName(FragmentSettings.this.getContext());
verName = GoUtils.getVersionName(FragmentSettings.this.getContext());
Preference pfVersion = findPreference("setting_version");
if (pfVersion != null) {
pfVersion.setSummary(verName);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/zcshou/gogogo/HistoryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.Map;

import com.zcshou.database.DataBaseHistoryLocation;
import com.zcshou.utils.AppUtils;
import com.zcshou.utils.GoUtils;

public class HistoryActivity extends BaseActivity {
public static final String KEY_ID = "KEY_ID";
Expand Down Expand Up @@ -147,7 +147,7 @@ private List<Map<String, Object>> fetchAllRecord() {
double doubleBDLatitude = bigDecimalBDLatitude.setScale(11, BigDecimal.ROUND_HALF_UP).doubleValue();
item.put(KEY_ID, Integer.toString(ID));
item.put(KEY_LOCATION, Location);
item.put(KEY_TIME, AppUtils.timeStamp2Date(Long.toString(TimeStamp)));
item.put(KEY_TIME, GoUtils.timeStamp2Date(Long.toString(TimeStamp)));
item.put(KEY_LNG_LAT_WGS, "[经度:" + doubleLongitude + " 纬度:" + doubleLatitude + "]");
item.put(KEY_LNG_LAT_CUSTOM, "[经度:" + doubleBDLongitude + " 纬度:" + doubleBDLatitude + "]");
data.add(item);
Expand Down
45 changes: 21 additions & 24 deletions app/src/main/java/com/zcshou/gogogo/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
Expand All @@ -23,13 +22,14 @@
import androidx.preference.PreferenceManager;

import com.zcshou.utils.GoUtils;
import com.zcshou.utils.GoUtils.TimeCount;

import java.util.ArrayList;
import java.util.Locale;

public class WelcomeActivity extends AppCompatActivity {
private Button startBtn;
private TimeCount time;
private TimeCount mTimer;
private boolean isNetwork = false;

private static final String KEY_IS_FIRST_USAGE = "KEY_IS_FIRST_USAGE";
Expand Down Expand Up @@ -61,8 +61,21 @@ protected void onCreate(Bundle savedInstanceState) {
// 生成默认参数的值(一定要尽可能早的调用,因为后续有些界面可能需要使用参数)
PreferenceManager.setDefaultValues(this, R.xml.preferences_main, false);

/* 定时器 */
int cnt = Integer.parseInt(getResources().getString(R.string.welcome_btn_cnt));
time = new TimeCount(cnt, 1000);
mTimer = new TimeCount(cnt, 1000);
mTimer.setListener(new TimeCount.TimeCountListener() {
@Override
public void onTick(long millisUntilFinished) {
startBtn.setText(String.format(Locale.getDefault(), "%d秒", millisUntilFinished / 1000));
}

@Override
public void onFinish() {
startMainActivity();
}
});

startBtn = findViewById(R.id.startButton);
startBtn.setOnClickListener(v -> startMainActivity());
startBtn.setClickable(false); // 放在 setOnClickListener 之后才能生效
Expand Down Expand Up @@ -99,7 +112,7 @@ protected void onStop() {

@Override
protected void onDestroy() {
time.cancel();
mTimer.cancel();

super.onDestroy();
}
Expand All @@ -116,7 +129,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis

if (i >= ReqPermissions.size()) {
isPermission = true;
time.start();
mTimer.start();
} else {
startBtn.setText(getResources().getString(R.string.welcome_permission_error));
startBtn.setClickable(true);
Expand Down Expand Up @@ -154,7 +167,7 @@ private void checkDefaultPermissions() {

if (ReqPermissions.size() <= 0) {
isPermission = true;
time.start();
mTimer.start();
} else {
requestPermissions(ReqPermissions.toArray(new String[0]), SDK_PERMISSION_REQUEST);
}
Expand All @@ -170,7 +183,7 @@ private void startMainActivity() {
checkDefaultPermissions();
}
}
time.cancel();
mTimer.cancel();
}

private void showProtocolDialog() {
Expand Down Expand Up @@ -208,7 +221,7 @@ private void showProtocolDialog() {
}

if (isPermission) {
time.start();
mTimer.start();
} else {
checkDefaultPermissions();
}
Expand All @@ -217,20 +230,4 @@ private void showProtocolDialog() {
});
}
}

class TimeCount extends CountDownTimer {
public TimeCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔
}

@Override
public void onFinish() {//计时完毕时触发
startMainActivity();
}

@Override
public void onTick(long millisUntilFinished) { //计时过程显示
startBtn.setText(String.format(Locale.getDefault(), "%d秒", millisUntilFinished / 1000));
}
}
}
Loading

0 comments on commit 495d075

Please sign in to comment.