fix(app): change documentation source and refresh cannot apply changes immediately
docs: update to latest
This commit is contained in:
@@ -4,13 +4,17 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.ui.main.QueryEvent;
|
||||
import org.autojs.autojs.ui.main.ViewPagerFragment;
|
||||
|
||||
import com.stardust.util.BackPressedHandler;
|
||||
|
||||
import org.autojs.autojs.ui.widget.EWebView;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
@@ -48,15 +52,29 @@ public class DocsFragment extends ViewPagerFragment implements BackPressedHandle
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
mWebView = mEWebView.getWebView();
|
||||
String url = Pref.getDocumentationUrl() + "index.html";
|
||||
mEWebView.getSwipeRefreshLayout().setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
if (TextUtils.equals(mWebView.getUrl(), mWebView.getOriginalUrl())) {
|
||||
loadUrl();
|
||||
} else {
|
||||
mEWebView.onRefresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
Bundle savedWebViewState = getArguments().getBundle("savedWebViewState");
|
||||
if (savedWebViewState != null) {
|
||||
mWebView.restoreState(savedWebViewState);
|
||||
} else {
|
||||
mWebView.loadUrl(getArguments().getString(ARGUMENT_URL, url));
|
||||
loadUrl();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadUrl() {
|
||||
String url = Pref.getDocumentationUrl() + "index.html";
|
||||
mWebView.loadUrl(getArguments().getString(ARGUMENT_URL, url));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.autojs.autojs.ui.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -13,22 +12,17 @@ import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.prefs.MaterialEditTextPreference;
|
||||
import com.stardust.pio.PFiles;
|
||||
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.storage.file.FileObservable;
|
||||
import org.autojs.autojs.storage.file.StorageFileProvider;
|
||||
import org.autojs.autojs.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import org.autojs.autojs.tool.SimpleObserver;
|
||||
import org.autojs.autojs.ui.widget.SimpleTextWatcher;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class ScriptDirPathPreference extends MaterialEditTextPreference {
|
||||
@@ -55,13 +49,9 @@ public class ScriptDirPathPreference extends MaterialEditTextPreference {
|
||||
protected void onAddEditTextToDialogView(@NonNull View dialogView, @NonNull EditText editText) {
|
||||
super.onAddEditTextToDialogView(dialogView, editText);
|
||||
mRadioGroup = (RadioGroup) View.inflate(getContext(), R.layout.script_dir_pref_radio_group, null);
|
||||
editText.addTextChangedListener(new SimpleTextWatcher(this::verifyInput));
|
||||
((ViewGroup) dialogView).addView(mRadioGroup);
|
||||
}
|
||||
|
||||
private void verifyInput(Editable text) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
|
||||
@@ -60,6 +60,9 @@ public class EWebView extends FrameLayout implements SwipeRefreshLayout.OnRefres
|
||||
init();
|
||||
}
|
||||
|
||||
public SwipeRefreshLayout getSwipeRefreshLayout() {
|
||||
return mSwipeRefreshLayout;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.ewebview, this);
|
||||
@@ -95,6 +98,7 @@ public class EWebView extends FrameLayout implements SwipeRefreshLayout.OnRefres
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mWebView.reload();
|
||||
|
||||
Reference in New Issue
Block a user