导航菜单

页面标题

页面副标题

St.John's v1.0.9 - PullToRefreshWebView2.java 源代码

正在查看: St.John's v1.0.9 应用的 PullToRefreshWebView2.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.handmark.pulltorefresh.library.extras;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshWebView;
import java.util.concurrent.atomic.AtomicBoolean;

public class PullToRefreshWebView2 extends PullToRefreshWebView {
    static final String DEF_JS_READY_PULL_DOWN_CALL = "javascript:isReadyForPullDown();";
    static final String DEF_JS_READY_PULL_UP_CALL = "javascript:isReadyForPullUp();";
    static final String JS_INTERFACE_PKG = "ptr";
    private final AtomicBoolean mIsReadyForPullDown;
    private final AtomicBoolean mIsReadyForPullUp;
    private JsValueCallback mJsCallback;

    public PullToRefreshWebView2(Context context) {
        super(context);
        this.mIsReadyForPullDown = new AtomicBoolean(false);
        this.mIsReadyForPullUp = new AtomicBoolean(false);
    }

    public PullToRefreshWebView2(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.mIsReadyForPullDown = new AtomicBoolean(false);
        this.mIsReadyForPullUp = new AtomicBoolean(false);
    }

    public PullToRefreshWebView2(Context context, PullToRefreshBase.Mode mode) {
        super(context, mode);
        this.mIsReadyForPullDown = new AtomicBoolean(false);
        this.mIsReadyForPullUp = new AtomicBoolean(false);
    }

    @Override
    public WebView createRefreshableView(Context context, AttributeSet attributeSet) {
        WebView createRefreshableView = super.createRefreshableView(context, attributeSet);
        JsValueCallback jsValueCallback = new JsValueCallback();
        this.mJsCallback = jsValueCallback;
        createRefreshableView.addJavascriptInterface(jsValueCallback, JS_INTERFACE_PKG);
        return createRefreshableView;
    }

    @Override
    protected boolean isReadyForPullStart() {
        getRefreshableView().loadUrl(DEF_JS_READY_PULL_DOWN_CALL);
        return this.mIsReadyForPullDown.get();
    }

    @Override
    protected boolean isReadyForPullEnd() {
        getRefreshableView().loadUrl(DEF_JS_READY_PULL_UP_CALL);
        return this.mIsReadyForPullUp.get();
    }

    final class JsValueCallback {
        JsValueCallback() {
        }

        public void isReadyForPullUpResponse(boolean z) {
            PullToRefreshWebView2.this.mIsReadyForPullUp.set(z);
        }

        public void isReadyForPullDownResponse(boolean z) {
            PullToRefreshWebView2.this.mIsReadyForPullDown.set(z);
        }
    }
}