Skip to content

Commit

Permalink
update gradle version and simplify some code
Browse files Browse the repository at this point in the history
  • Loading branch information
huzongyao committed May 7, 2019
1 parent 2fc5c0f commit b763181
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 58 deletions.
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ android {
signingConfig signingConfigs.demokey
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand All @@ -39,8 +43,7 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.blankj:utilcode:1.21.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.blankj:utilcode:1.23.7'
implementation 'com.jakewharton:butterknife:9.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0'
}
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<data
android:host="chinese.chess"
android:scheme="game" />
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,7 @@ public void postPlaySound(final int soundIndex) {

@Override
public void postShowMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
showMessage(message);
}
});
runOnUiThread(() -> showMessage(message));
}

private void showMessage(String message) {
Expand All @@ -166,21 +161,11 @@ public void postShowMessage(int messageId) {

@Override
public void postStartThink() {
runOnUiThread(new Runnable() {
@Override
public void run() {
mGameProgress.setVisibility(View.VISIBLE);
}
});
runOnUiThread(() -> mGameProgress.setVisibility(View.VISIBLE));
}

@Override
public void postEndThink() {
runOnUiThread(new Runnable() {
@Override
public void run() {
mGameProgress.setVisibility(View.GONE);
}
});
runOnUiThread(() -> mGameProgress.setVisibility(View.GONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,53 @@


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.blankj.utilcode.util.ActivityUtils;
import com.hzy.chinese.jchess.R;
import com.hzy.chinese.jchess.game.GameConfig;
import com.hzy.chinese.jchess.xqwlight.Position;

import java.io.InputStream;
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
* Created by HZY on 2018/3/6.
*/

public class SplashActivity extends Activity {

private static boolean mDataLoaded = false;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
loadBookAndStartGame();
if (mDataLoaded) {
startGame();
} else {
loadBookAndStartGame();
}
}

private void loadBookAndStartGame() {
Observable.create(new ObservableOnSubscribe<Boolean>() {
new Thread() {
@Override
public void subscribe(ObservableEmitter<Boolean> emitter) throws Exception {
InputStream is = getAssets().open(GameConfig.DAT_ASSETS_PATH);
boolean result = Position.loadBook(is);
emitter.onNext(result);
emitter.onComplete();
public void run() {
try {
InputStream is = getAssets().open(GameConfig.DAT_ASSETS_PATH);
Position.loadBook(is);
mDataLoaded = true;
} catch (Exception e) {
e.printStackTrace();
}
startGame();
}
}).delay(GameConfig.SPLASH_DELAY_MILLISECONDS, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Boolean>() {
@Override
public void accept(Boolean loadOk) throws Exception {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
}
});
}.start();
}

private void startGame() {
ActivityUtils.startActivity(MainActivity.class);
finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public void onResume() {
@Override
public void onDestroy() {
if (mWebViewWeb != null) {
mWebViewWeb.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
mWebViewWeb.loadDataWithBaseURL(null, "",
"text/html", "utf-8", null);
mWebViewWeb.clearHistory();
mWebViewWeb.destroy();
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.1'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 28 20:38:45 CST 2018
#Tue May 07 15:47:46 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0 comments on commit b763181

Please sign in to comment.