change JavaScriptEngine to LoopBasedJavaScriptEngine

Everything works like Node.js. loop() will not need be called explicitly any more.
Including some changes:
* Every thread of script has a looper.
* Use a servant thread in gestures functions of GlobalActionAutomator and image available listener of ScreenCapture.
* For keeping events key and touch listener alive, add Loopers.waitWhenIdle to control whether or not Looper should quit when it has nothing to do
This commit is contained in:
hyb1996
2017-07-29 17:46:23 +08:00
parent 11b87d9a51
commit 12037ba488
21 changed files with 382 additions and 173 deletions

View File

@@ -292,6 +292,12 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
mDrawerHeaderBackgroundSaver.select(this, mActivityResultMediator);
}
@Override
protected void onPause() {
super.onPause();
stopService(new Intent(this, DownloadService.class));
}
@Override
protected void onResume() {
super.onResume();
@@ -477,6 +483,11 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
EventBus.getDefault().unregister(this);
}
@NonNull
@Override
public OnActivityResultDelegate.Mediator getOnActivityResultDelegateMediator() {
return mActivityResultMediator;
}
public static void onRecordStop(Context context, String script) {
Intent intent = new Intent(context, MainActivity_.class)
@@ -488,11 +499,5 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
context.startActivity(intent);
}
@NonNull
@Override
public OnActivityResultDelegate.Mediator getOnActivityResultDelegateMediator() {
return mActivityResultMediator;
}
}

View File

@@ -44,7 +44,6 @@ import java.util.concurrent.Executor;
@EFragment(R.layout.fragment_side_menu)
public class SideMenuFragment extends android.support.v4.app.Fragment {
public static void setFragment(FragmentActivity activity, int viewId) {
SideMenuFragment fragment = new SideMenuFragment_();
activity.getSupportFragmentManager().beginTransaction().replace(viewId, fragment).commit();