Example #1
0
    public ViewHolder(View itemView) {
      super(itemView);
      view = itemView;

      llApplication = (LinearLayout) itemView.findViewById(R.id.llApplication);
      ivIcon = (ImageView) itemView.findViewById(R.id.ivIcon);
      ivExpander = (ImageView) itemView.findViewById(R.id.ivExpander);
      tvName = (TextView) itemView.findViewById(R.id.tvName);

      cbWifi = (CheckBox) itemView.findViewById(R.id.cbWifi);
      cbOther = (CheckBox) itemView.findViewById(R.id.cbOther);

      llAttributes = (LinearLayout) itemView.findViewById(R.id.llAttributes);
      ivUsing = (ImageView) itemView.findViewById(R.id.ivUsing);
      tvRoaming = (TextView) itemView.findViewById(R.id.tvRoaming);

      llConfiguration = (LinearLayout) itemView.findViewById(R.id.llConfiguration);
      tvPackage = (TextView) itemView.findViewById(R.id.tvPackage);
      tvDisabled = (TextView) itemView.findViewById(R.id.tvDisabled);
      tvInternet = (TextView) itemView.findViewById(R.id.tvInternet);
      cbUsing = (CheckBox) itemView.findViewById(R.id.cbUsing);
      cbRoaming = (CheckBox) itemView.findViewById(R.id.cbRoaming);
      btnSettings = (ImageButton) itemView.findViewById(R.id.btnSettings);
      btnLaunch = (Button) itemView.findViewById(R.id.btnLaunch);

      final View wifiParent = (View) cbWifi.getParent();
      wifiParent.post(
          new Runnable() {
            public void run() {
              Rect rect = new Rect();
              cbWifi.getHitRect(rect);
              rect.bottom += rect.top;
              rect.right += rect.left;
              rect.top = 0;
              rect.left = 0;
              wifiParent.setTouchDelegate(new TouchDelegate(rect, cbWifi));
            }
          });

      final View otherParent = (View) cbOther.getParent();
      otherParent.post(
          new Runnable() {
            public void run() {
              Rect rect = new Rect();
              cbOther.getHitRect(rect);
              rect.bottom += rect.top;
              rect.right += rect.left;
              rect.top = 0;
              rect.left = 0;
              otherParent.setTouchDelegate(new TouchDelegate(rect, cbOther));
            }
          });
    }
  /**
   * Set the view to showcase
   *
   * @param view The {@link View} to showcase.
   */
  public void setShowcaseView(final View view) {
    if (isRedundant || view == null) {
      isRedundant = true;
      return;
    }
    isRedundant = false;

    view.post(
        new Runnable() {
          @Override
          public void run() {
            init();
            if (mOptions.insert == INSERT_TO_VIEW) {
              showcaseX = (float) (view.getLeft() + view.getWidth() / 2);
              showcaseY = (float) (view.getTop() + view.getHeight() / 2);
            } else {
              int[] coordinates = new int[2];
              view.getLocationInWindow(coordinates);
              showcaseX = (float) (coordinates[0] + view.getWidth() / 2);
              showcaseY = (float) (coordinates[1] + view.getHeight() / 2);
            }
            invalidate();
          }
        });
  }
Example #3
0
  public void setTitleBack(View v) {
    final View back = v.findViewById(R.id.normal_title_back);
    if (back == null) {
      return;
    }
    back.post(
        new Runnable() {

          @Override
          public void run() {
            Rect r = new Rect();
            back.getHitRect(r);
            r.left -= 50;
            r.right += 50;
            r.top -= 50;
            r.bottom += 50;
            ((View) back.getParent()).setTouchDelegate(new TouchDelegate(r, back));
          }
        });

    if (clickListener != null) {
      back.setOnClickListener(clickListener);
    } else {
      back.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              finish();
            }
          });
    }
  }
 @Override
 public void refreshView() {
   super.refreshView();
   //
   _view.post(
       new Runnable() {
         @Override
         public void run() {
           _groupText.setText(_module.getDisplayAddress());
           ModuleParameter levelParam = _module.getParameter("Status.Level");
           if (levelParam != null) _levelText.setText(_module.getDisplayLevel(levelParam.Value));
           else _levelText.setText("");
           ModuleParameter colorParam = _module.getParameter("Status.ColorHsb");
           if (colorParam != null && colorParam.Value != null) {
             try {
               String[] sRgb = colorParam.Value.split(",");
               int red = Integer.parseInt(sRgb[0]);
               int green = Integer.parseInt(sRgb[1]);
               int blue = Integer.parseInt(sRgb[2]);
               int color = Color.rgb(red, green, blue);
               _colorPicker.setColor(color);
               _colorPreview.setBackgroundColor(color);
             } catch (Exception e) {
               // TODO parsing errors
             }
           }
           //
           // _levelBar.setProgress((int)Math.round(_moduleHolder.getDoubleValue(levelParam.Value)
           // * 100));
         }
       });
 }
Example #5
0
  /**
   * 显示进度条对话框
   *
   * @param activity
   * @param popupWindow
   * @param title
   */
  public static void showProgressDialog(
      Activity activity, LoadingPopupWindow popupWindow, String title) {
    if ((activity == null || activity.isFinishing()) || (popupWindow == null)) {
      return;
    }

    final LoadingPopupWindow tmpPopupWindow = popupWindow;
    View popupView = popupWindow.getContentView();
    if (popupView != null) {
      TextView tvTitlename = (TextView) popupView.findViewById(R.id.tv_titlename);
      if (tvTitlename != null && !title.isEmpty()) {
        tvTitlename.setText(title);
      }
    }

    if (popupWindow != null && !popupWindow.isShowing()) {
      final View rootView1 =
          ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
      rootView1.post(
          new Runnable() {

            @Override
            public void run() {
              try {
                tmpPopupWindow.showAtLocation(rootView1, Gravity.CENTER, 0, 0);
                tmpPopupWindow.startAnimation();
              } catch (Exception e) {
                Global.errorLog(e);
              }
            }
          });
    }
  }
  private void initFirstScreenViews(View rootView, final Bundle savedInstanceState) {

    mCenterBox = (ImageView) rootView.findViewById(R.id.center_box);
    mCamcordImage = (ImageView) rootView.findViewById(R.id.imageView);
    mClockImage = (ImageView) rootView.findViewById(R.id.imageView6);
    mGraphImage = (ImageView) rootView.findViewById(R.id.imageView3);
    mAudioImage = (ImageView) rootView.findViewById(R.id.imageView4);
    mQuoteImage = (ImageView) rootView.findViewById(R.id.imageView5);
    mMapImage = (ImageView) rootView.findViewById(R.id.imageView2);
    mWordPressImage = (ImageView) rootView.findViewById(R.id.imageView7);

    initializeAlpha();

    rootView.post(
        new Runnable() {
          @Override
          public void run() {

            getOriginalXValues(savedInstanceState);
          }
        });

    if (savedInstanceState == null) {
      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {

                  doFadeAnimation();
                }
              },
              700);
    }
  }
 @Override
 public void refreshView() {
   super.refreshView();
   //
   _view.post(
       new Runnable() {
         @Override
         public void run() {
           if (!_module.DeviceType.equals("Dimmer")
               && !_module.DeviceType.equals("Siren")
               && !_module.DeviceType.equals("Shutter")) {
             _levelBar.setVisibility(View.GONE);
           }
           _groupText.setText(_module.getDisplayAddress());
           ModuleParameter levelParam = _module.getParameter("Status.Level");
           if (levelParam != null) {
             String level = _module.getDisplayLevel(levelParam.Value);
             if (_module.DeviceType.equals("Shutter")) {
               if (level.equals("OFF")) {
                 level = "Closed";
               } else if (level.equals("ON")) {
                 level = "Open";
               }
             }
             _levelText.setText(level);
             _levelBar.setProgress(
                 (int) Math.round(_module.getDoubleValue(levelParam.Value) * 100));
           } else {
             _levelText.setText("");
           }
         }
       });
 }
 /**
  * @param top
  * @param left
  * @param bottom
  * @param right
  * @param delegate
  */
 public static void increaseHitRectBy(
     final float top,
     final float left,
     final float bottom,
     final float right,
     final View delegate) {
   final View parent = (View) delegate.getParent();
   if (parent != null && delegate.getContext() != null) {
     parent.post(
         new Runnable() {
           // Post in the parent's message queue to make sure the parent
           // lays out its children before we call getHitRect()
           public void run() {
             final float densityDpi =
                 delegate.getContext().getResources().getDisplayMetrics().densityDpi;
             final Rect r = new Rect();
             delegate.getHitRect(r);
             r.top -= transformToDensityPixel(top, densityDpi);
             r.left -= transformToDensityPixel(left, densityDpi);
             r.bottom += transformToDensityPixel(bottom, densityDpi);
             r.right += transformToDensityPixel(right, densityDpi);
             parent.setTouchDelegate(new TouchDelegate(r, delegate));
           }
         });
   }
 }
 private void updateChartView() {
   final List<String> free = HKMTools.getInstance().readFromFile(SysfsLib.MON_MEM);
   if (free != null) {
     List<Integer> values = new ArrayList<>();
     for (String row : free) {
       if (row.startsWith("MemTotal:")) {
         values.add(extractInteger(row.split(":")[1]));
       } else if (row.startsWith("MemFree:")) {
         values.add(extractInteger(row.split(":")[1]));
       } else if (row.startsWith("Cached:")) {
         values.add(extractInteger(row.split(":")[1]));
         break;
       }
     }
     if (values.size() == 3) {
       portions =
           new int[] {values.get(0) - values.get(1) - values.get(2), values.get(2), values.get(1)};
       mView.post(
           new Runnable() {
             @Override
             public void run() {
               ((ChartView) findViewById(R.id.chart))
                   .update(
                       portions,
                       colors,
                       legend,
                       "kb",
                       (LinearLayout) findViewById(R.id.chartLegend));
             }
           });
     }
     values.clear();
   }
 }
    @Override
    public void run() {
      // TODO Auto-generated method stub
      super.run();
      while (true && !isInterrupted()) {
        if (!view.isShown() && flag == true) {

          view.post(
              new Runnable() {

                @Override
                public void run() {
                  // TODO Auto-generated method stub
                  view.setVisibility(View.VISIBLE);
                  view.layout(0, 0, 1, 1);
                  // CommonUtil.tolog("post");
                  flag = true;
                }
              });
        } else {
          flag = true;
        }

        try {
          Thread.sleep(100);
          // CommonUtil.tolog("Thread sleep");
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
 protected void relayout(final View view) {
   view.post(
       new Runnable() {
         public void run() {
           view.requestLayout();
         }
       });
 }
  @SuppressLint("ClickableViewAccessibility")
  @Override
  public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
      ViewParent parent = v.getParent();
      switch (ev.getAction()) {
        case ACTION_DOWN:
          // First, disable the Parent from intercepting the touch
          // event
          if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
          } else {
            LogManager.getLogger().i(LOG_TAG, "onTouch getParent() returned null");
          }

          // If we're flinging, and the user presses down, cancel
          // fling
          cancelFling();
          break;

        case ACTION_CANCEL:
        case ACTION_UP:
          // If the user has zoomed less than min scale, zoom back
          // to min scale
          if (getScale() < mMinScale) {
            RectF rect = getDisplayRect();
            if (null != rect) {
              v.post(
                  new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
              handled = true;
            }
          }
          break;
      }

      // Try the Scale/Drag detector
      if (null != mScaleDragDetector) {
        boolean wasScaling = mScaleDragDetector.isScaling();
        boolean wasDragging = mScaleDragDetector.isDragging();

        handled = mScaleDragDetector.onTouchEvent(ev);

        boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
        boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();

        mBlockParentIntercept = didntScale && didntDrag;
      }

      // Check to see if the user double tapped
      if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
        handled = true;
      }
    }

    return handled;
  }
 private void showWarning(final String msg) {
   view.post(
       new Runnable() {
         @Override
         public void run() {
           AccessibleToast.makeText(ctx, msg, Toast.LENGTH_LONG).show();
         }
       });
 }
 public void hideScrim() {
   mScrim.post(
       new Runnable() {
         @Override
         public void run() {
           mScrim.setVisibility(View.GONE);
         }
       });
 }
 public void showScrim() {
   mScrim.post(
       new Runnable() {
         @Override
         public void run() {
           mScrim.setVisibility(View.VISIBLE);
         }
       });
 }
Example #16
0
 /**
  * run on ui thread
  *
  * @param view
  * @param runnable
  */
 public static void runOnUiThread(final View view, final Runnable runnable) {
   if (view != null) {
     if (view.getContext() instanceof Activity) {
       ((Activity) view.getContext()).runOnUiThread(runnable);
     } else {
       view.post(runnable);
     }
   }
 }
 public void showScrim() {
   if (!mKeyguardState.deviceHasKeyguard) return;
   mScrim.post(
       new Runnable() {
         @Override
         public void run() {
           mScrim.setVisibility(View.VISIBLE);
         }
       });
 }
  public void onAnimationUpdate(final ValueAnimator animation) {
    final long currentTime = System.currentTimeMillis();
    if (mStartTime == -1) {
      mStartFrame = sGlobalFrameCounter;
      mStartTime = currentTime;
    }

    final long currentPlayTime = animation.getCurrentPlayTime();
    boolean isFinalFrame = Float.compare(1f, animation.getAnimatedFraction()) == 0;

    if (!mHandlingOnAnimationUpdate
        && sVisible
        &&
        // If the current play time exceeds the duration, or the animated fraction is 1,
        // the animation will get finished, even if we call setCurrentPlayTime -- therefore
        // don't adjust the animation in that case
        currentPlayTime < animation.getDuration()
        && !isFinalFrame) {
      mHandlingOnAnimationUpdate = true;
      long frameNum = sGlobalFrameCounter - mStartFrame;
      // If we haven't drawn our first frame, reset the time to t = 0
      // (give up after MAX_DELAY ms of waiting though - might happen, for example, if we
      // are no longer in the foreground and no frames are being rendered ever)
      if (frameNum == 0 && currentTime < mStartTime + MAX_DELAY && currentPlayTime > 0) {
        // The first frame on animations doesn't always trigger an invalidate...
        // force an invalidate here to make sure the animation continues to advance
        mTarget.getRootView().invalidate();
        animation.setCurrentPlayTime(0);
        // For the second frame, if the first frame took more than 16ms,
        // adjust the start time and pretend it took only 16ms anyway. This
        // prevents a large jump in the animation due to an expensive first frame
      } else if (frameNum == 1
          && currentTime < mStartTime + MAX_DELAY
          && !mAdjustedSecondFrameTime
          && currentTime > mStartTime + IDEAL_FRAME_DURATION
          && currentPlayTime > IDEAL_FRAME_DURATION) {
        animation.setCurrentPlayTime(IDEAL_FRAME_DURATION);
        mAdjustedSecondFrameTime = true;
      } else {
        if (frameNum > 1) {
          mTarget.post(
              new Runnable() {
                public void run() {
                  animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
                }
              });
        }
        if (DEBUG) print(animation);
      }
      mHandlingOnAnimationUpdate = false;
    } else {
      if (DEBUG) print(animation);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.color_selector);

    view = (LinearLayout) findViewById(R.id.contentSelector);
    backView = (RelativeLayout) findViewById(R.id.rootSelector);
    backView.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getX() < view.getLeft()
                || event.getX() > view.getRight()
                || event.getY() > view.getBottom()
                || event.getY() < view.getTop()) {
              dismiss();
            }
            return false;
          }
        });

    colorView = findViewById(R.id.viewColor);
    colorView.setBackgroundColor(color);
    // Resize ColorView
    colorView.post(
        new Runnable() {

          @Override
          public void run() {
            LayoutParams params = (LayoutParams) colorView.getLayoutParams();
            params.height = colorView.getWidth();
            colorView.setLayoutParams(params);
          }
        });

    // Configure Sliders
    red = (Slider) findViewById(R.id.red);
    green = (Slider) findViewById(R.id.green);
    blue = (Slider) findViewById(R.id.blue);

    int r = (this.color >> 16) & 0xFF;
    int g = (this.color >> 8) & 0xFF;
    int b = (this.color >> 0) & 0xFF;

    red.setValue(r);
    green.setValue(g);
    blue.setValue(b);

    red.setOnValueChangedListener(this);
    green.setOnValueChangedListener(this);
    blue.setOnValueChangedListener(this);
  }
Example #20
0
  @Test
  public void shouldPostActionsToTheMessageQueue() throws Exception {
    Robolectric.pauseMainLooper();

    TestRunnable runnable = new TestRunnable();
    view.post(runnable);
    assertFalse(runnable.wasRun);

    Robolectric.unPauseMainLooper();
    assertTrue(runnable.wasRun);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));
    chatLayoutView = inflater.inflate(R.layout.chat_layout, container, false);

    sendMessage = (Button) chatLayoutView.findViewById(R.id.sendChat);
    chatMessage = (EditText) chatLayoutView.findViewById(R.id.chatMessage);

    String[] values = {};
    cma = new ChatMessageAdapter(context, values);
    pma = new ParticipantMessageAdapter(context, values);

    messageView = (ListView) chatLayoutView.findViewById(R.id.chatWindow);
    participantsView = (ListView) chatLayoutView.findViewById(R.id.chatParticipants);
    participantsView.setAdapter(pma);
    sendMessage.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            String message = chatMessage.getText().toString();
            if (message.length() > 0) {
              Message msgObj = Message.obtain(null, XMPPService.PUSH_MESSAGE_TO_QUEUE);
              Bundle b = new Bundle();
              b.putString("chatMessage", message);
              msgObj.setData(b);
              try {
                if (messenger != null) messenger.send(msgObj);
              } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }

            } else {
              UtilsWhatAmIdoing.displayGenericToast(context, "Enter Some Text");
            }
          }
        });
    messageView.setAdapter(cma);

    chatLayoutView.post(
        new Runnable() {
          @Override
          public void run() {
            int height = sendMessage.getHeight();

            chatMessage.getLayoutParams().height = height;
            RelativeLayout sendChatLayout =
                (RelativeLayout) chatLayoutView.findViewById(R.id.sendChatLayout);
            sendChatLayout.requestLayout();
          }
        });
    return chatLayoutView;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.touch_delegate_ui);
    // Get the parent view
    View parentView = findViewById(R.id.parent_layout);

    parentView.post(
        new Runnable() {
          // Post in the parent's message queue to make sure the parent
          // lays out its children before you call getHitRect()
          @Override
          public void run() {
            // The bounds for the delegate view (an ImageButton
            // in this example)
            Rect delegateArea = new Rect();
            ImageButton myButton = (ImageButton) findViewById(R.id.button);
            myButton.setEnabled(true);
            myButton.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    Toast.makeText(
                            TouchDelegateUI.this,
                            "Touch occurred within ImageButton touch region.",
                            Toast.LENGTH_SHORT)
                        .show();
                  }
                });

            // The hit rectangle for the ImageButton
            myButton.getHitRect(delegateArea);

            // Extend the touch area of the ImageButton beyond its bounds
            // on the right and bottom.
            delegateArea.right += 100;
            delegateArea.bottom += 100;

            // Instantiate a TouchDelegate.
            // "delegateArea" is the bounds in local coordinates of
            // the containing view to be mapped to the delegate view.
            // "myButton" is the child view that should receive motion
            // events.
            TouchDelegate touchDelegate = new TouchDelegate(delegateArea, myButton);

            // Sets the TouchDelegate on the parent view, such that touches
            // within the touch delegate bounds are routed to the child.
            if (View.class.isInstance(myButton.getParent())) {
              ((View) myButton.getParent()).setTouchDelegate(touchDelegate);
            }
          }
        });
  }
Example #23
0
  private void setupFragmentContainer() {
    mConFragments.post(
        new Runnable() {
          @Override
          public void run() {
            PointF shrinkPercents = getShrinkPercents();
            mConFragments.setScaleX(shrinkPercents.x);
            mConFragments.setScaleY(shrinkPercents.y);

            mTxtTitle.setAlpha(0);
          }
        });
  }
  @Override
  public final boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
      ViewParent parent = v.getParent();
      switch (ev.getAction()) {
        case ACTION_DOWN:
          // First, disable the Parent from intercepting the touch
          // event
          if (null != parent) parent.requestDisallowInterceptTouchEvent(true);
          else Log.i(LOG_TAG, "onTouch getParent() returned null");

          // If we're flinging, and the user presses down, cancel
          // fling
          cancelFling();
          break;

        case ACTION_CANCEL:
        case ACTION_UP:
          // If the user has zoomed less than min scale, zoom back
          // to min scale
          if (getScale() < mMinScale) {
            RectF rect = getDisplayRect();
            if (null != rect) {
              v.post(
                  new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
              handled = true;
            }
          }
          break;
      }

      // Check to see if the user double tapped
      if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
        handled = true;
      }

      if (!handled && null != parent) {
        parent.requestDisallowInterceptTouchEvent(false);
      }

      // Finally, try the Scale/Drag detector
      if (null != mScaleDragDetector && mScaleDragDetector.onTouchEvent(ev)) {
        handled = true;
      }
    }

    return handled;
  }
 @Override
 public void onClick(final View v) {
   v.post(
       new Runnable() {
         @Override
         public void run() {
           v.setVisibility(View.INVISIBLE);
         }
       });
   if (conversation.isDomainBlocked()) {
     BlockContactDialog.show(activity, activity.xmppConnectionService, conversation);
   } else {
     activity.unblockConversation(conversation);
   }
 }
 private void postStartMessage(ViewPropertyAnimatorCompat vpa, View view) {
   Runnable starter = null;
   if (mStarterMap != null) {
     starter = mStarterMap.get(view);
   }
   if (starter == null) {
     starter = new Starter(vpa, view);
     if (mStarterMap == null) {
       mStarterMap = new WeakHashMap<View, Runnable>();
     }
     mStarterMap.put(view, starter);
   }
   view.removeCallbacks(starter);
   view.post(starter);
 }
Example #27
0
  @SuppressLint("ClickableViewAccessibility")
  @Override
  public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (mZoomEnabled && hasDrawable((ImageView) v)) {
      getViewParentsFromImageView(v);
      switch (ev.getAction()) {
        case ACTION_DOWN:
          // First, disable the Parent from intercepting the touch
          // event
          setParentDisallowInterceptTouchEvent(true);
          // If we're flinging, and the user presses down, cancel
          // fling
          cancelFling();
          break;

        case ACTION_CANCEL:
        case ACTION_UP:
          // If the user has zoomed less than min scale, zoom back
          // to min scale
          if (getScale() < mMinScale) {
            RectF rect = getDisplayRect();
            if (null != rect) {
              v.post(
                  new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
              handled = true;
            }
          }
          break;
      }

      // Try the Scale/Drag detector
      if (null != mScaleDragDetector && mScaleDragDetector.onTouchEvent(ev)) {
        handled = true;
      }

      // Check to see if the user double tapped
      if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) {
        handled = true;
      }
    }

    return handled;
  }
    @Override
    public void start(
        Profile profile, String url, final String text, boolean preventInlineAutocomplete) {
      mSuggestionsDispatcher =
          new Runnable() {
            @Override
            public void run() {
              List<SuggestionsResult> suggestions = mSuggestions.get(text.toLowerCase(Locale.US));
              if (suggestions == null) return;

              for (int i = 0; i < suggestions.size(); i++) {
                onSuggestionsReceived(
                    suggestions.get(i).mSuggestions, suggestions.get(i).mAutocompleteText, 0);
              }
            }
          };
      mView.post(mSuggestionsDispatcher);
    }
  @Override
  public final boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;

    if (isZoomEnabled) {
      switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
          // First, disable the Parent from intercepting the touch
          // event
          if (v.getParent() != null) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
          }

          // If we're flinging, and the user presses down, cancel
          // fling
          if (currentFlingRunnable != null) {
            currentFlingRunnable.cancelFling();
            currentFlingRunnable = null;
          }
          break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
          // If the user has zoomed less than min scale, zoom back
          // to min scale
          if (getScale() < minScale) {
            RectF rect = getDisplayRect();
            if (null != rect) {
              v.post(
                  new AnimatedZoomRunnable(getScale(), minScale, rect.centerX(), rect.centerY()));
              handled = true;
            }
          }
          break;
      }

      // Finally, try the scale/drag/tap detector
      if ((multiGestureDetector != null) && multiGestureDetector.onTouchEvent(ev)) {
        handled = true;
      }
    }

    return handled;
  }
Example #30
0
  /**
   * Set the view to showcase
   *
   * @param view The {@link View} to showcase.
   * @deprecated Use setShowcase with a {@link com.espian.showcaseview.targets.ViewTarget}
   */
  @Deprecated
  public void setShowcaseView(final View view) {
    if (mIsRedundant || view == null) {
      mIsRedundant = true;
      return;
    }
    mIsRedundant = false;

    view.post(
        new Runnable() {
          @Override
          public void run() {
            // init();
            Point viewPoint = Calculator.getShowcasePointFromView(view, getConfigOptions());
            setShowcasePosition(viewPoint);
            invalidate();
          }
        });
  }