fix: root_automator cannot be force stopped

This commit is contained in:
hyb1996
2017-10-27 11:34:41 +08:00
parent ece78e5903
commit 19bbbe9fe1
7 changed files with 83 additions and 59 deletions

View File

@@ -80,19 +80,15 @@ public class CircularMenu implements Recorder.OnStateChangedListener {
}
private void setupListeners() {
mWindow.setOnActionViewClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mState == STATE_RECORDING) {
stopRecord();
} else if (mWindow.isExpanded()) {
mWindow.collapse();
} else {
AutoJs.getInstance().getLayoutInspector().captureCurrentWindow();
mWindow.expand();
}
mWindow.setOnActionViewClickListener(v -> {
if (mState == STATE_RECORDING) {
stopRecord();
} else if (mWindow.isExpanded()) {
mWindow.collapse();
} else {
AutoJs.getInstance().getLayoutInspector().captureCurrentWindow();
mWindow.expand();
}
});
}
@@ -130,12 +126,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener {
.customView(listView, false)
.positiveText(R.string.cancel)
.build();
listView.setOnItemOperatedListener(new ScriptListView.OnItemOperatedListener() {
@Override
public void OnItemOperated(ScriptFile file) {
dialog.dismiss();
}
});
listView.setOnItemOperatedListener(file -> dialog.dismiss());
DialogUtils.showDialog(dialog);
}

View File

@@ -307,7 +307,6 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
@Override
public void onBindViewHolder(BindableViewHolder<?> holder, int position) {
int positionOfCategoryFile = positionOfCategoryFile();
Log.d(LOG_TAG, String.format("view holder = %s, pos = %d, posOfCategory = %d, size = %d", holder.getClass().toString(), position, positionOfCategoryFile, mScriptList.count()));
BindableViewHolder bindableViewHolder = (BindableViewHolder) holder;
if (position == positionOfCategoryDir || position == positionOfCategoryFile) {
// FIXME: 2017/10/20 java.lang.ClassCastException: java.lang.Boolean cannot be cast to com.stardust.scriptdroid.model.script.ScriptFile
@@ -323,17 +322,14 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
@Override
public int getItemViewType(int position) {
int viewType;
int positionOfCategoryFile = positionOfCategoryFile();
if (position == positionOfCategoryDir || position == positionOfCategoryFile) {
viewType = VIEW_TYPE_CATEGORY;
return VIEW_TYPE_CATEGORY;
} else if (position < positionOfCategoryFile) {
viewType = VIEW_TYPE_DIRECTORY;
return VIEW_TYPE_DIRECTORY;
} else {
viewType = VIEW_TYPE_FILE;
return VIEW_TYPE_FILE;
}
Log.d(LOG_TAG, String.format("view type = %d, pos = %d, posOfCategory = %d, size = %d", viewType, position, positionOfCategoryFile, mScriptList.count()));
return viewType;
}
@Override

View File

@@ -3,6 +3,8 @@ package com.stardust.scriptdroid;
import org.junit.Test;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
@@ -20,28 +22,10 @@ public class ExampleUnitTest {
@Test
public void test() {
Observable.fromCallable(new Callable<String>() {
@Override
public String call() throws Exception {
System.out.println(Thread.currentThread());
return "";
}
})
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.newThread())
.doOnComplete(new Action() {
@Override
public void run() throws Exception {
System.out.println(Thread.currentThread());
}
})
.observeOn(Schedulers.newThread())
.subscribe(new Consumer<String>() {
@Override
public void accept(@NonNull String s) throws Exception {
System.out.println(Thread.currentThread());
}
});
Matcher matcher = Pattern.compile("[0-9]+").matcher("2937Finish!");
if (matcher.find()) {
System.out.println(matcher.group());
}
}
@Test