[app] Fix compile snackbar (#1255)
This commit is contained in:
parent
568d1e5e40
commit
1eab21c3fc
|
|
@ -283,7 +283,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
ConfigManager.startActivityAsUserWithFeature(launchIntent, module.userId);
|
ConfigManager.startActivityAsUserWithFeature(launchIntent, module.userId);
|
||||||
}
|
}
|
||||||
} else if (itemId == R.id.menu_compile_speed) {
|
} else if (itemId == R.id.menu_compile_speed) {
|
||||||
CompileDialogFragment.speed(fragment.getChildFragmentManager(), info);
|
CompileDialogFragment.speed(fragment.getChildFragmentManager(), info, fragment.binding.snackbar);
|
||||||
} else if (itemId == R.id.menu_other_app) {
|
} else if (itemId == R.id.menu_other_app) {
|
||||||
var intent = new Intent(Intent.ACTION_SHOW_APP_INFO);
|
var intent = new Intent(Intent.ACTION_SHOW_APP_INFO);
|
||||||
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, module.packageName);
|
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, module.packageName);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -50,26 +51,20 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
||||||
|
|
||||||
private static final String[] COMPILE_RESET_COMMAND = new String[]{"cmd", "package", "compile", "-f", "-m", "speed", ""};
|
private static final String[] COMPILE_RESET_COMMAND = new String[]{"cmd", "package", "compile", "-f", "-m", "speed", ""};
|
||||||
|
|
||||||
private static final String KEY_APP_INFO = "app_info";
|
|
||||||
private ApplicationInfo appInfo;
|
private ApplicationInfo appInfo;
|
||||||
|
private View snackBar;
|
||||||
|
|
||||||
public static void speed(FragmentManager fragmentManager, ApplicationInfo info) {
|
public static void speed(FragmentManager fragmentManager, ApplicationInfo info, View snackBar) {
|
||||||
Bundle arguments = new Bundle();
|
|
||||||
arguments.putParcelable(KEY_APP_INFO, info);
|
|
||||||
CompileDialogFragment fragment = new CompileDialogFragment();
|
CompileDialogFragment fragment = new CompileDialogFragment();
|
||||||
fragment.setArguments(arguments);
|
|
||||||
fragment.setCancelable(false);
|
fragment.setCancelable(false);
|
||||||
|
fragment.appInfo = info;
|
||||||
|
fragment.snackBar = snackBar;
|
||||||
fragment.show(fragmentManager, "compile_dialog");
|
fragment.show(fragmentManager, "compile_dialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
Bundle arguments = getArguments();
|
|
||||||
if (arguments == null) {
|
|
||||||
throw new IllegalStateException("arguments should not be null.");
|
|
||||||
}
|
|
||||||
appInfo = arguments.getParcelable(KEY_APP_INFO);
|
|
||||||
if (appInfo == null) {
|
if (appInfo == null) {
|
||||||
throw new IllegalStateException("appInfo should not be null.");
|
throw new IllegalStateException("appInfo should not be null.");
|
||||||
}
|
}
|
||||||
|
|
@ -87,15 +82,9 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
Bundle arguments = getArguments();
|
String[] command = COMPILE_RESET_COMMAND;
|
||||||
if (arguments != null) {
|
command[6] = appInfo.packageName;
|
||||||
appInfo = arguments.getParcelable(KEY_APP_INFO);
|
new CompileTask(this).executeOnExecutor(App.getExecutorService(), command);
|
||||||
String[] command = COMPILE_RESET_COMMAND;
|
|
||||||
command[6] = appInfo.packageName;
|
|
||||||
new CompileTask(this).executeOnExecutor(App.getExecutorService(), command);
|
|
||||||
} else {
|
|
||||||
dismissAllowingStateLoss();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CompileTask extends AsyncTask<String, Void, String> {
|
private static class CompileTask extends AsyncTask<String, Void, String> {
|
||||||
|
|
@ -154,9 +143,9 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
|
||||||
CompileDialogFragment fragment = outerRef.get();
|
CompileDialogFragment fragment = outerRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
fragment.dismissAllowingStateLoss();
|
fragment.dismissAllowingStateLoss();
|
||||||
AppListFragment appListFragment = (AppListFragment) fragment.getParentFragment();
|
var parent = fragment.getParentFragment();
|
||||||
if (appListFragment != null && appListFragment.binding != null && appListFragment.isResumed()) {
|
if (fragment.snackBar != null && parent != null && parent.isResumed()) {
|
||||||
Snackbar.make(appListFragment.binding.snackbar, text, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(fragment.snackBar, text, Snackbar.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ public class ModulesFragment extends BaseFragment implements ModuleUtil.ModuleLi
|
||||||
getNavController().navigate(ModulesFragmentDirections.actionModulesFragmentToRepoItemFragment(selectedModule.packageName, selectedModule.getAppName()));
|
getNavController().navigate(ModulesFragmentDirections.actionModulesFragmentToRepoItemFragment(selectedModule.packageName, selectedModule.getAppName()));
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.menu_compile_speed) {
|
} else if (itemId == R.id.menu_compile_speed) {
|
||||||
CompileDialogFragment.speed(getChildFragmentManager(), selectedModule.pkg.applicationInfo);
|
CompileDialogFragment.speed(getChildFragmentManager(), selectedModule.pkg.applicationInfo, binding.snackbar);
|
||||||
}
|
}
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue