Revert change
This commit is contained in:
parent
ecd51d491c
commit
42a5dccdd0
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.catvod.spider;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
|
|
@ -9,6 +10,9 @@ import android.widget.Toast;
|
|||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public class Init {
|
||||
|
||||
private final Handler handler;
|
||||
|
|
@ -43,4 +47,29 @@ public class Init {
|
|||
public static void show(String msg) {
|
||||
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
public static Activity getActivity() {
|
||||
try {
|
||||
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
||||
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
||||
activitiesField.setAccessible(true);
|
||||
Map<?, ?> activities = (Map<?, ?>) activitiesField.get(activityThread);
|
||||
for (Object activityRecord : activities.values()) {
|
||||
Class<?> activityRecordClass = activityRecord.getClass();
|
||||
Field pausedField = activityRecordClass.getDeclaredField("paused");
|
||||
pausedField.setAccessible(true);
|
||||
if (!pausedField.getBoolean(activityRecord)) {
|
||||
Field activityField = activityRecordClass.getDeclaredField("activity");
|
||||
activityField.setAccessible(true);
|
||||
Activity activity = (Activity) activityField.get(activityRecord);
|
||||
SpiderDebug.log(activity.getComponentName().getClassName());
|
||||
return activity;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@ import java.util.Objects;
|
|||
|
||||
public class YiSo extends Spider {
|
||||
|
||||
private Context ctx;
|
||||
private Ali ali;
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
ali = new Ali(extend);
|
||||
ctx = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -42,7 +40,7 @@ public class YiSo extends Spider {
|
|||
public String searchContent(String key, boolean quick) {
|
||||
String url = "https://yiso.fun/api/search?name=" + URLEncoder.encode(key) + "&from=ali";
|
||||
Map<String, String> result = new HashMap<>();
|
||||
Misc.loadWebView(ctx, url, getWebViewClient(result));
|
||||
Misc.loadWebView(url, getWebViewClient(result));
|
||||
while (!result.containsKey("json")) SystemClock.sleep(250);
|
||||
String json = JsonParser.parseString(Objects.requireNonNull(result.get("json"))).getAsJsonPrimitive().getAsString();
|
||||
return Result.string(Item.objectFrom(json).getData().getList());
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.github.catvod.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.webkit.WebSettings;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
|
|
@ -139,16 +138,14 @@ public class Misc {
|
|||
}
|
||||
}
|
||||
|
||||
public static void loadWebView(Context context, String url, WebViewClient client) {
|
||||
public static void loadWebView(String url, WebViewClient client) {
|
||||
Init.run(() -> {
|
||||
WebView webView = new WebView(context);
|
||||
webView.getSettings().setUseWideViewPort(true);
|
||||
WebView webView = new WebView(Init.context());
|
||||
webView.getSettings().setDatabaseEnabled(true);
|
||||
webView.getSettings().setDomStorageEnabled(true);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.getSettings().setLoadWithOverviewMode(true);
|
||||
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
|
||||
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0);
|
||||
Init.getActivity().addContentView(webView, params);
|
||||
webView.setWebViewClient(client);
|
||||
webView.loadUrl(url);
|
||||
});
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
b29b008f7a563d1ee0417ee8bc66127b
|
||||
4a9fb96a761413d887c348fffb241387
|
||||
|
|
|
|||
Loading…
Reference in New Issue