0

変更されたPullToRefreshライブラリに問題があります

https://github.com/johannilsson/android-pulltorefresh/pull/40

Androidバージョン2.xでは正常に動作しますが、4.xではクラッシュします(動作するかどうかを確認するための3.xデバイスがありません)。

4.xでは、次の方法で失敗します。

 private void applyHeaderPadding(MotionEvent ev) {
    // Workaround for getPointerCount() which is unavailable in 1.5
    // (it's always 1 in 1.5)
    int pointerCount = 1;
    try {
        Method method = MotionEvent.class.getMethod("getPointerCount");
        pointerCount = (Integer)method.invoke(ev);
    } catch (NoSuchMethodException e) {
        pointerCount = 1;
    } catch (IllegalArgumentException e) {
        throw e;
    } catch (IllegalAccessException e) {
        System.err.println("unexpected " + e);
    } catch (InvocationTargetException e) {
        System.err.println("unexpected " + e);
    }

    for (int p = 0; p < pointerCount; p++) {
        if (mRefreshState == RELEASE_TO_REFRESH) {
            if (isVerticalFadingEdgeEnabled()) {
                setVerticalScrollBarEnabled(false);
            }

            int historicalY = (int) ev.getHistoricalY(p);

            // Calculate the padding to apply, we divide by 1.7 to
            // simulate a more resistant effect during pull.
            int topPadding = (int) (((historicalY - mLastMotionY)
                    - mRefreshViewHeight) / 1.7);

            mRefreshView.setPadding(
                    mRefreshView.getPaddingLeft(),
                    topPadding,
                    mRefreshView.getPaddingRight(),
                    mRefreshView.getPaddingBottom());
        }
    }
}

クラッシュの行は次のとおりです。

int historicalY = (int) ev.getHistoricalY(p);

例外を除いて:

java.lang.IllegalArgumentException: historyPos out of range
at android.view.MotionEvent.nativeGetAxisValue(Native Method)
at android.view.MotionEvent.getHistoricalY(MotionEvent.java:2314)
at com.usualbike.cbike.PullToRefresh.applyHeaderPadding(PullToRefresh.java:241)
at com.usualbike.cbike.PullToRefresh.onTouchEvent(PullToRefresh.java:212)
at android.view.View.dispatchTouchEvent(View.java:5717)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1956)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1717)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1731)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2064)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1400)
at android.app.Activity.dispatchTouchEvent(Activity.java:2369)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2012)
at android.view.View.dispatchPointerEvent(View.java:5897)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3115)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2657)
at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:1021)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2666)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)

この問題を解決するにはどうすればよいですか?

4

2 に答える 2

1

よくわかりませんが、変更してみてください

int historicalY = (int) ev.getHistoricalY(p);

if(p>pointerCount)
{
int historicalY = (int) ev.getHistoricalY(p);
}
于 2013-01-11T09:28:54.970 に答える
0

代わりに私のライブラリを試してみることをお勧めします:https ://github.com/chrisbanes/Android-PullToRefresh

于 2013-01-11T10:11:46.283 に答える