Skip to content

Commit

Permalink
[UPDATE] 修改cookie隔500毫秒打印一次
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuSky committed Sep 1, 2021
1 parent 43ddf79 commit f29ca7a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/src/main/java/com/app/jdcookie/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private final static String JD_URL = "https://m.jd.com/";
private MyAdapter adapter;
private RecyclerView recyclerView;
private long oldTime = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -104,12 +105,19 @@ private void initWebView() {

// WebView.setWebContentsDebuggingEnabled(BuilD);
webBridgeWebView.setWebViewClient(new MyWebViewClient(webBridgeProgressBar, (cookie, pt_key) -> runOnUiThread(() -> {
adapter.addData(pt_key);
recyclerView.scrollToPosition(adapter.getData().size() - 1);

//限制 500 毫秒 刷新一次
long time = System.currentTimeMillis();
if (time - oldTime > 500) {
adapter.addData(pt_key);
recyclerView.scrollToPosition(adapter.getData().size() - 1);
oldTime = time;
}
})));
webBridgeWebView.setWebChromeClient(new MyWebChromeClient(webBridgeProgressBar));
}
webBridgeWebView.setWebChromeClient(new

MyWebChromeClient(webBridgeProgressBar));
}

public static class MyWebViewClient extends WebViewClient {

Expand Down

0 comments on commit f29ca7a

Please sign in to comment.