mobile/android/base/widget/GeckoViewFlipper.java

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:df76228d8f31
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 package org.mozilla.gecko.widget;
7
8 import org.mozilla.gecko.animation.ViewHelper;
9
10 import android.content.Context;
11 import android.graphics.Rect;
12 import android.os.Build;
13 import android.view.MotionEvent;
14 import android.widget.ViewFlipper;
15 import android.util.Log;
16 import android.util.AttributeSet;
17
18 /* This extends the normal ViewFlipper only to fix bug 956075 on < 3.0 devices.
19 * i.e. It ignores touch events on the ViewFlipper when its hidden. */
20
21 public class GeckoViewFlipper extends ViewFlipper {
22 private static final String LOGTAG = "GeckoViewFlipper";
23 private Rect mRect = new Rect();
24
25 public GeckoViewFlipper(Context context) {
26 super(context);
27 }
28
29 public GeckoViewFlipper(Context context, AttributeSet attrs) {
30 super(context, attrs);
31 }
32
33 @Override
34 public boolean dispatchTouchEvent(MotionEvent ev) {
35 if (Build.VERSION.SDK_INT < 11) {
36 // Fix bug 956075. Don't allow touching this View if its hidden.
37 getHitRect(mRect);
38 mRect.offset((int) ViewHelper.getTranslationX(this), (int) ViewHelper.getTranslationY(this));
39
40 if (!mRect.contains((int) ev.getX(), (int) ev.getY())) {
41 return false;
42 }
43 }
44
45 return super.dispatchTouchEvent(ev);
46 }
47 }

mercurial