Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from maoruibin/develop
Browse files Browse the repository at this point in the history
release 1.7.1
  • Loading branch information
maoruibin authored Aug 20, 2017
2 parents 61172b7 + 4753280 commit 580fcc2
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 101 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ dependencies {
exclude module: 'recyclerview-v7'
}

compile 'net.grandcentrix.tray:tray:0.11.0'
compile "com.readystatesoftware.sqliteasset:sqliteassethelper:${libs.sqliteassethelper}"

compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
compile "net.grandcentrix.tray:tray:${libs.tray}"

compile "com.facebook.stetho:stetho:${libs.stetho}"
compile "com.facebook.stetho:stetho-okhttp3:${libs.stetho_okhttp3}"
}
7 changes: 4 additions & 3 deletions app/src/main/assets/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@
咕咚翻译 - 一个实现手机端『划词翻译』功能的 App,可能是目前 Android 市场上翻译效率最高的应用。
</p>

<h3>Version 1.6.0</h3>
<h3>Version 1.7.0</h3>

<ol>
<li><b> 优化:</b> 增加离线翻译支持(仅对以前查询过的单词有效)(thanks 张涛)(04-13)</li>
<li><b> 解决:</b> 循环翻译乱序问题(04-03)</li>
<li><b> 新增:</b> 输入单词自动联想提示(By <a href="https://github.com/70kg">70kg</a>)</li>
<li><b> 优化:</b> 设置页面层级以及一个错别字 </li>
<li><b> 修复:</b> 背单词时偶现的奔溃 </li>
</ol>

<p>
Expand Down
Binary file added app/src/main/assets/databases/sample_oxford.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ public void onCloseAnimEnd(Animator animation) {
});
return null;
}
});
}).error(new ReciteException());
mHideTipTask.subscribe();
}

protected class ReciteException extends Exception{

}

private void removeTipViewInner(TipView tipView) {
if (tipView.getParent() != null) {
mWindowManager.removeView(tipView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ public String wrapAmPhonetic() {

@Override
public String wrapEnMp3() {
if(getBasic() == null)return "";
return getBasic().getUkSpeech();
}

@Override
public String wrapAmMp3() {
if(getBasic() == null)return "";
return getBasic().getUsSpeech();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class BasePresenter<V extends IBaseView> {

protected FileManager mFileManager = new FileManager();

public BasePresenter(LiteOrm liteOrm, WarpAipService apiService,Context context) {
public BasePresenter(LiteOrm liteOrm, WarpAipService apiService, Context context) {
mLiteOrm = liteOrm;
mWarpApiService = apiService;
mContext = context;
Expand All @@ -79,21 +79,23 @@ public BasePresenter(LiteOrm liteOrm, WarpAipService apiService, SingleRequestSe
mContext = context;
}

public void onCreate(){}
public void onCreate() {
}

/**
* attach IBaseView to Presenter
*
* @param view view
*/
public void attachView(V view){
public void attachView(V view) {
this.mView = view;
}

public void onDestroy(){
public void onDestroy() {
this.mView = null;
}

protected Context getContext(){
protected Context getContext() {
return mContext;
}

Expand All @@ -106,81 +108,75 @@ protected Context getContext(){
public Result isFavorite(String word) {
QueryBuilder queryBuilder = new QueryBuilder(Result.class);
queryBuilder = queryBuilder.whereEquals("query ", word);
List<Result>list = mLiteOrm.query(queryBuilder);
if(list.isEmpty()){
List<Result> list = mLiteOrm.query(queryBuilder);
if (list.isEmpty()) {
return null;
}
return list.get(0);
}

protected long insertResultToDb(Result entity){
protected long insertResultToDb(Result entity) {
return mLiteOrm.insert(entity);
}

protected int deleteResultFromDb(Result entity){
protected int deleteResultFromDb(Result entity) {
return mLiteOrm.delete(entity);
}

public void playSound(String fileName,String mp3Url) {
Observable.just(mp3Url)
.subscribe(new Action1<String>() {
@Override
public void call(String entity) {
File cacheFile = mFileManager.getCacheFileByUrl(getContext(), fileName);
if (cacheFile != null && cacheFile.exists()) {
playSound(cacheFile);
return;
}
Call<ResponseBody> call = mSingleRequestService.downloadSoundFile(mp3Url);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
try {
cacheAndPlaySound(getContext(), fileName, response.body().bytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Logger.e(t.getMessage());
t.printStackTrace();
}
});
public void playSound(String fileName, String mp3Url) {
File cacheFile = mFileManager.getCacheFileByUrl(getContext(), fileName);
if (cacheFile != null && cacheFile.exists()) {
playSound(cacheFile);
return;
}
Call<ResponseBody> call = mSingleRequestService.downloadSoundFile(mp3Url);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
try {
cacheAndPlaySound(getContext(), fileName, response.body().bytes());
} catch (IOException e) {
e.printStackTrace();
}
});
}
}

@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Logger.e(t.getMessage());
t.printStackTrace();
}
});
}

public void startSoundAnim(View view){
addScaleAnim(view,1000,null);
public void startSoundAnim(View view) {
addScaleAnim(view, 1000, null);
}

public void startFavoriteAnim(View view,AnimationEndListener listener){
addScaleAnim(view,500,listener);
public void startFavoriteAnim(View view, AnimationEndListener listener) {
addScaleAnim(view, 500, listener);
}

private void addScaleAnim(View view, long duration, AnimationEndListener listener) {
ObjectAnimator animY = ObjectAnimator.ofFloat(view, "scaleY", 1f,0.5f, 1f, 1.2f,1f);
ObjectAnimator animX = ObjectAnimator.ofFloat(view, "scaleX", 1f,0.5f, 1f, 1.2f,1f);
ObjectAnimator animY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.5f, 1f, 1.2f, 1f);
ObjectAnimator animX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.5f, 1f, 1.2f, 1f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animX,animY);
animatorSet.playTogether(animX, animY);
animatorSet.setDuration(duration);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if(listener != null){
if (listener != null) {
listener.onAnimationEnd(animation);
}
}
});
animatorSet.start();
}

public interface AnimationEndListener{
public interface AnimationEndListener {
void onAnimationEnd(Animator animation);
}

Expand All @@ -197,9 +193,9 @@ public void call(File file) {
}

private void playSound(File file) {
if(file == null)return;
if (file == null) return;
Uri myUri = Uri.fromFile(file);
Logger.i("播放 "+file.getAbsolutePath());
Logger.i("播放 " + file.getAbsolutePath());
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
Expand All @@ -212,7 +208,6 @@ private void playSound(File file) {
}



private Callable<File> cacheFileObservable(Context context, String fileName, byte[] data) {
return new Callable<File>() {
@Override
Expand All @@ -224,11 +219,12 @@ public File call() throws Exception {

/**
* make a operation observable
*
* @param func
* @param <T>
* @return the Observable
*/
protected <T> Observable<T> makeObservable(final Callable<T> func) {
protected <T> Observable<T> makeObservable(final Callable<T> func) {
return Observable.create(new Observable.OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> subscriber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import rx.functions.Action1;
import rx.schedulers.Schedulers;

import static android.support.v7.widget.StaggeredGridLayoutManager.TAG;

/**
* Created by GuDong on 2/28/16 17:02.
Expand All @@ -60,6 +59,7 @@
public class BookPresenter extends BasePresenter<IBookView> {
private static final String KEY_TIP_OF_RECITE_OPEN = "TIP_OF_RECITE_OPEN";
private static final String KEY_RECITE_MODE_SWITCH = "RECITE_MODE_SWITCH";
private static final String TAG = "BOOK_PRESENTER";
@Inject
public BookPresenter(LiteOrm liteOrm, WarpAipService apiService, SingleRequestService singleRequestService, Context context) {
super(liteOrm, apiService, singleRequestService,context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import name.gudong.translate.mvp.views.IMainView;
import name.gudong.translate.ui.activitys.MainActivity;
import name.gudong.translate.util.DialogUtil;
import name.gudong.translate.util.LocalDicHelper;
import name.gudong.translate.util.SpUtils;
import name.gudong.translate.util.Utils;
import rx.Observable;
Expand Down Expand Up @@ -91,6 +92,21 @@ public void checkIntentFromClickTipView(Intent intent) {
}
}

public void analysisLocalDic() {
makeObservable(new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
return LocalDicHelper.getLocalDic(mContext);
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<List<String>>() {
@Override
public void call(List<String> strings) {
mView.attachLocalDic(strings);
}
});
}
public boolean hasExtraResult(Intent intent) {
return intent.hasExtra(KEY_RESULT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package name.gudong.translate.mvp.views;

import java.util.List;

import name.gudong.translate.mvp.model.entity.dayline.IDayLine;
import name.gudong.translate.mvp.model.entity.translate.Result;
import name.gudong.translate.mvp.model.type.ETranslateFrom;
Expand Down Expand Up @@ -58,4 +60,7 @@ public interface IMainView extends IBaseView {
void initWithNotFavorite();

void fillDayline(IDayLine entity);

void attachLocalDic(List<String> dic);

}
Loading

0 comments on commit 580fcc2

Please sign in to comment.