@Override
        public void onClick(View v) {

          String msg = "";
          switch (curPlayMode) {
            case CommonConstDef.PLAY_MODE_CIRCLE_LIST:
              {
                curPlayMode = CommonConstDef.PLAY_MODE_SHUFFLE_LIST;
                ((ImageButton) v).setImageResource(R.drawable.btn_shuffle_off_holo_dark);
                v.invalidate();
                msg = "随机播放模式";
              }
              break;
            case CommonConstDef.PLAY_MODE_CIRCLE_SINGLE:
              {
                curPlayMode = CommonConstDef.PLAY_MODE_CIRCLE_LIST;
                ((ImageButton) v).setImageResource(R.drawable.btn_repeat_all_off_holo_dark);
                v.invalidate();
                msg = "列表循环播放模式";
              }
              break;
            case CommonConstDef.PLAY_MODE_SHUFFLE_LIST:
              {
                curPlayMode = CommonConstDef.PLAY_MODE_CIRCLE_SINGLE;
                ((ImageButton) v).setImageResource(R.drawable.btn_repeat_once_off_holo_dark);
                v.invalidate();
                msg = "单曲循环播放模式";
              }
              break;
          }

          Toast.makeText(getActivity(), msg, Toast.LENGTH_LONG).show();
        }
예제 #2
1
파일: Game.java 프로젝트: rabaut/project1
  /**
   * Handle a touch event from the view.
   *
   * @param view The view that is the source of the touch
   * @param event The motion event describing the touch
   * @return true if the touch is handled.
   */
  public boolean onTouchEvent(View view, MotionEvent event) {
    float relX = event.getX() / width;
    float relY = event.getY() / height;

    switch (event.getActionMasked()) {
      case MotionEvent.ACTION_DOWN:
        return onTouched(relX, relY);

      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        if (dragging) {
          dragging = false;
          return true;
        }
        break;

      case MotionEvent.ACTION_MOVE:
        // If we are dragging, move the piece and force a redraw
        if (dragging) {
          tempBlock.move(relX - lastRelX);
          lastRelX = relX;
          view.invalidate();
          return true;
        } else {
          scrollOffset += (relY - lastRelY);
          if (scrollOffset < 0) scrollOffset = 0;
          lastRelY = relY;
          view.invalidate();
          return true;
        }
    }

    return false;
  }
예제 #3
1
 public boolean onDrag(View v, DragEvent event) {
   final int action = event.getAction();
   switch (action) {
     case DragEvent.ACTION_DRAG_STARTED:
       if (event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
         ((ImageView) v).setColorFilter(Color.BLUE);
         Toast.makeText(DragAndDropActivity.this, "ACTION_DRAG_STARTED", Toast.LENGTH_SHORT)
             .show();
         v.invalidate();
         return true;
       } else {
         return false;
       }
     case DragEvent.ACTION_DRAG_ENTERED:
       ((ImageView) v).setColorFilter(Color.GREEN);
       Toast.makeText(DragAndDropActivity.this, "ACTION_DRAG_ENTERED", Toast.LENGTH_SHORT)
           .show();
       v.invalidate();
       return true;
     case DragEvent.ACTION_DRAG_LOCATION:
       return true;
     case DragEvent.ACTION_DRAG_EXITED:
       ((ImageView) v).setColorFilter(Color.RED);
       Toast.makeText(DragAndDropActivity.this, "ACTION_DRAG_EXITED", Toast.LENGTH_SHORT).show();
       v.invalidate();
       return true;
     case DragEvent.ACTION_DROP:
       ClipData.Item item = event.getClipData().getItemAt(0);
       CharSequence dragData = item.getText();
       Toast.makeText(
               DragAndDropActivity.this, "Dragged data is " + dragData, Toast.LENGTH_SHORT)
           .show();
       ((ImageView) v).clearColorFilter();
       v.invalidate();
       return true;
     case DragEvent.ACTION_DRAG_ENDED:
       ((ImageView) v).clearColorFilter();
       v.invalidate();
       if (event.getResult()) {
         Toast.makeText(DragAndDropActivity.this, "The drop was handled.", Toast.LENGTH_SHORT)
             .show();
       } else {
         Toast.makeText(DragAndDropActivity.this, "The drop didn't work.", Toast.LENGTH_SHORT)
             .show();
       }
       ;
       return true;
     default:
       Log.e("DragDrop Example", "Unknown action type received by OnDragListener.");
       break;
   }
   ;
   return false;
 };
예제 #4
1
 public void graphDataChanged() {
   horlabels = null;
   verlabels = null;
   viewVerLabels.invalidate();
   for (int i = 0; i < this.getChildCount(); i++) {
     View view = getChildAt(i);
     if (view instanceof GraphViewContentView) {
       view.invalidate();
     }
   }
 }
예제 #5
1
 public void setVisible(boolean value, boolean invalidate) {
   if (isVisible == value) {
     return;
   }
   isVisible = value;
   if (invalidate && parentView != null) {
     if (invalidateAll) {
       parentView.invalidate();
     } else {
       parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH);
     }
   }
 }
예제 #6
0
        @Override
        public void run() {
          // Make sure the user entered a name. Quit if they didn't
          final String name = mNameInput.getText().toString();
          if (name.trim().isEmpty()) {
            Toast.makeText(me, "Please enter a name", Toast.LENGTH_SHORT).show();
            return;
          }

          // Update user profile
          mFinalName = name;
          GameApp.CurrentUser.SetName(name);

          // Create the animation to shrink the submit layout
          Animation collapse = AnimationUtils.loadAnimation(me, R.anim.collapse);
          collapse.setAnimationListener(
              new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {}

                @Override
                public void onAnimationEnd(Animation animation) {
                  onCollapseEnd();
                }

                @Override
                public void onAnimationRepeat(Animation animation) {}
              });
          mSubmitLayout.startAnimation(collapse);
          mSubmitLayout.invalidate();
        }
 /**
  * When fragment finishes loading data, it should call startEntranceTransition() to execute the
  * entrance transition. startEntranceTransition() will start transition only if both two
  * conditions are satisfied:
  * <li>prepareEntranceTransition() was called.
  * <li>has not executed entrance transition yet.
  *
  *     <p>If startEntranceTransition() is called before onViewCreated(), it will be pending and
  *     executed when view is created.
  */
 public void startEntranceTransition() {
   if (!mEntranceTransitionEnabled || mEntranceTransition != null) {
     return;
   }
   // if view is not created yet, delay until onViewCreated()
   if (getView() == null) {
     mStartEntranceTransitionPending = true;
     return;
   }
   // wait till views get their initial position before start transition
   final View view = getView();
   view.getViewTreeObserver()
       .addOnPreDrawListener(
           new ViewTreeObserver.OnPreDrawListener() {
             @Override
             public boolean onPreDraw() {
               view.getViewTreeObserver().removeOnPreDrawListener(this);
               internalCreateEntranceTransition();
               mEntranceTransitionEnabled = false;
               runEntranceTransition(mEntranceTransition);
               return false;
             }
           });
   view.invalidate();
 }
예제 #8
0
 void displaySelection(int left, int leftSelected, int right, int rightSelected) {
   ((TextView) view.findViewById(R.id.text))
       .setCompoundDrawablesWithIntrinsicBounds(
           isSelected ? leftSelected : left, 0, isSelected ? rightSelected : right, 0);
   view.setSelected(isSelected);
   view.invalidate();
 }
예제 #9
0
  public void rollDie2(View view) {
    // make random number generator
    Random generator = new Random();

    // calculate random number
    int num = generator.nextInt(6) + 1;

    // update die1 image view with new image
    ImageView die2 = (ImageView) findViewById(R.id.die2ImageView);

    switch (num) {
      case 1:
        die2.setImageResource(R.drawable.roll1);
        break;
      case 2:
        die2.setImageResource(R.drawable.roll2);
        break;
      case 3:
        die2.setImageResource(R.drawable.roll3);
        break;
      case 4:
        die2.setImageResource(R.drawable.roll4);
        break;
      case 5:
        die2.setImageResource(R.drawable.roll5);
        break;
      case 6:
        die2.setImageResource(R.drawable.roll6);
        break;
      default:
        break;
    }
    view.invalidate(); // redraw
  }
예제 #10
0
 @Override
 public void onThumbnailUpdated(Tab t) {
   View v = mTabViews.get(t);
   if (v != null) {
     v.invalidate();
   }
 }
예제 #11
0
  public void setMode(ModifyMode mode) {

    if (mode != mMode) {
      mMode = mode;
      mContext.invalidate();
    }
  }
예제 #12
0
        @Override
        public void run() {
          startAds();

          // Create congrats message TODO add message about scrap once upgrading is implemented
          String r = (mFinalScore == 1) ? "robot" : "robots";
          String congratsMessage = "Congrats, you destroyed " + mFinalScore + " " + r;

          mMessageView.setText(congratsMessage);

          mNameInput.setText(GameApp.CurrentUser.GetName());

          mGameOverLayout.setVisibility(View.VISIBLE);

          Animation expand = AnimationUtils.loadAnimation(me, R.anim.expand);
          expand.setAnimationListener(
              new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                  mSubmitLayout.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animation animation) {}

                @Override
                public void onAnimationRepeat(Animation animation) {}
              });

          mSubmitLayout.startAnimation(expand);
          mSubmitLayout.invalidate();
        }
예제 #13
0
  private void trySlideAttachmentView(final ViewWrapper viewWrapper) {
    if (!(viewWrapper.attachment instanceof MediaPickerMessagePartData)) {
      return;
    }
    final View view = viewWrapper.view;

    final int xOffset = viewWrapper.prevLeft - view.getLeft();
    final int yOffset = viewWrapper.prevTop - view.getTop();
    final float scaleX = viewWrapper.prevWidth / (float) view.getWidth();
    final float scaleY = viewWrapper.prevHeight / (float) view.getHeight();

    if (xOffset == 0 && yOffset == 0 && scaleX == 1 && scaleY == 1) {
      // Layout hasn't changed
      return;
    }

    final AnimationSet animationSet = new AnimationSet(true /* shareInterpolator */);
    animationSet.addAnimation(new TranslateAnimation(xOffset, 0, yOffset, 0));
    animationSet.addAnimation(new ScaleAnimation(scaleX, 1, scaleY, 1));
    animationSet.setDuration(UiUtils.MEDIAPICKER_TRANSITION_DURATION);
    animationSet.setInterpolator(UiUtils.DEFAULT_INTERPOLATOR);
    view.startAnimation(animationSet);
    view.invalidate();
    viewWrapper.prevLeft = view.getLeft();
    viewWrapper.prevTop = view.getTop();
    viewWrapper.prevWidth = view.getWidth();
    viewWrapper.prevHeight = view.getHeight();
  }
예제 #14
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
      return true;
    }

    if (id == R.id.action_search) {
      Intent intent = new Intent(this, SearchActivity.class);
      startActivity(intent);

      tabs.animate().translationY(-tabs.getHeight());
      viewPager.animate().translationY(-tabs.getHeight());
      isPageViewWithOffset = Boolean.TRUE;

      // this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
      // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

      View contactFragmentRootView = ((ContactsFragment) viewPagerAdapter.getItem(1)).getRootView();
      contactFragmentRootView.invalidate();

      return true;
    }

    return super.onOptionsItemSelected(item);
  }
예제 #15
0
 // invalidate a rectangle relative to the view's coordinate system all the way up the view
 // hierarchy
 @SuppressLint("NewApi")
 public static void invalidateGlobalRegion(View view, RectF childBounds) {
   // childBounds.offset(view.getTranslationX(), view.getTranslationY());
   if (DEBUG_INVALIDATE) if (DebugLog.DEBUG) DebugLog.d(TAG, "-------------");
   while (view.getParent() != null && view.getParent() instanceof View) {
     view = (View) view.getParent();
     view.getMatrix().mapRect(childBounds);
     view.invalidate(
         (int) Math.floor(childBounds.left),
         (int) Math.floor(childBounds.top),
         (int) Math.ceil(childBounds.right),
         (int) Math.ceil(childBounds.bottom));
     if (DebugLog.DEBUG) {
       DebugLog.v(
           TAG,
           "INVALIDATE("
               + (int) Math.floor(childBounds.left)
               + ","
               + (int) Math.floor(childBounds.top)
               + ","
               + (int) Math.ceil(childBounds.right)
               + ","
               + (int) Math.ceil(childBounds.bottom));
     }
   }
 }
예제 #16
0
 public void reload(int index) {
   if (mNativeViewView != null) {
     mNativeViewView.invalidate();
   } else {
     webView.reload();
   }
 }
예제 #17
0
  /**
   * Grow by.
   *
   * @param dx the dx
   * @param dy the dy
   */
  void growBy(float dx, float dy) {
    if (mMaintainAspectRatio) {
      if (dx != 0) {
        dy = dx / mInitialAspectRatio;
      } else if (dy != 0) {
        dx = dy * mInitialAspectRatio;
      }
    }

    // Don't let the cropping rectangle grow too fast.
    // Grow at most half of the difference between the image rectangle and
    // the cropping rectangle.
    RectF r = new RectF(mCropRect);
    if (dx > 0F && r.width() + 2 * dx > mImageRect.width()) {

      float adjustment = (mImageRect.width() - r.width()) / 2F;
      dx = adjustment;
      if (mMaintainAspectRatio) {
        dy = dx / mInitialAspectRatio;
      }
    }
    if (dy > 0F && r.height() + 2 * dy > mImageRect.height()) {
      float adjustment = (mImageRect.height() - r.height()) / 2F;
      dy = adjustment;
      if (mMaintainAspectRatio) {
        dx = dy * mInitialAspectRatio;
      }
    }

    r.inset(-dx, -dy);

    // Don't let the cropping rectangle shrink too fast.
    final float widthCap = 25F;
    if (r.width() < widthCap) {
      return;
      //            r.inset(-(widthCap - r.width()) / 2F, 0F);
    }
    float heightCap = mMaintainAspectRatio ? (widthCap / mInitialAspectRatio) : widthCap;
    if (r.height() < heightCap) {
      return;
      //            r.inset(0F, -(heightCap - r.height()) / 2F);
    }

    // Put the cropping rectangle inside the image rectangle.
    if (r.left < mImageRect.left) {
      r.offset(mImageRect.left - r.left, 0F);
    } else if (r.right > mImageRect.right) {
      r.offset(-(r.right - mImageRect.right), 0);
    }
    if (r.top < mImageRect.top) {
      r.offset(0F, mImageRect.top - r.top);
    } else if (r.bottom > mImageRect.bottom) {
      r.offset(0F, -(r.bottom - mImageRect.bottom));
    }

    mCropRect.set(r);
    mDrawRect = computeLayout();
    mContext.invalidate();
  }
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       {
         v.getBackground().setColorFilter(selectionColor, Mode.SRC_ATOP);
         v.invalidate();
         break;
       }
     case MotionEvent.ACTION_UP:
       {
         v.getBackground().clearColorFilter();
         v.invalidate();
         break;
       }
   }
   return false;
 }
예제 #19
0
 /**
  * 设置foot的底部边距
  *
  * @param topPadding
  */
 private void setFootBottomPadding(int bottomPadding) {
   footView.setPadding(
       footView.getPaddingLeft(),
       footView.getPaddingTop(),
       footView.getPaddingRight(),
       bottomPadding);
   footView.invalidate();
 }
예제 #20
0
 public static void invalidate(View view) {
   m_tempRect.set(
       view.getScrollX(),
       view.getScrollY(),
       view.getScrollX() + view.getWidth(),
       view.getScrollY() + view.getHeight());
   view.invalidate(m_tempRect);
 }
예제 #21
0
 private void checkAlphaAnimation() {
   if (currentAlpha != 1) {
     long currentTime = System.currentTimeMillis();
     currentAlpha += (currentTime - lastUpdateAlphaTime) / 150.0f;
     if (currentAlpha > 1) {
       currentAlpha = 1;
     }
     lastUpdateAlphaTime = System.currentTimeMillis();
     if (parentView != null) {
       if (invalidateAll) {
         parentView.invalidate();
       } else {
         parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH);
       }
     }
   }
 }
예제 #22
0
  /**
   * 下拉move事件处理
   *
   * @param moveY
   */
  private void doMovement(int moveY) {
    // TODO Auto-generated method stub
    LinearLayout.LayoutParams lp = (LayoutParams) refreshView.getLayoutParams();
    if (moveY > 0) {
      // 获取view的上边距
      float f1 = lp.topMargin;
      float f2 = moveY * 0.3F; // 在这里之所以这么写,是因为滑动距离不同,上面所显示的拉开的范围也会不同
      int i = (int) (f1 + f2);
      // 修改上边距
      lp.topMargin = i;
      // 修改后刷新
      refreshView.setLayoutParams(lp);
      refreshView.invalidate();
      invalidate(); // 该方法为提醒底层,该重新绘制view了 ,因为参数发生了改变
    } else {
      float f1 = lp.topMargin;
      int i = (int) (f1 + moveY * 0.9F);
      Log.i("aa", String.valueOf(i));
      if (i >= refreshTargetTop) {
        lp.topMargin = i;
        // 修改后刷新
        refreshView.setLayoutParams(lp);
        refreshView.invalidate();
        invalidate();
      } else {

      }
    }

    timeTextView.setVisibility(View.VISIBLE);
    //        if(refreshTime!= null){
    //            setRefreshTime(refreshTime);
    //        }
    downTextView.setVisibility(View.VISIBLE);

    refreshIndicatorView.setVisibility(View.VISIBLE);
    bar.setVisibility(View.GONE);
    if (lp.topMargin > 0) {
      /** 这里是取消了图片 */
      downTextView.setText(R.string.refresh_release_text);
      //            refreshIndicatorView.setImageResource(R.drawable.refresh_arrow_up);
    } else {
      downTextView.setText(R.string.refresh_down_text);
      //            refreshIndicatorView.setImageResource(R.drawable.refresh_arrow_down);
    }
  }
예제 #23
0
 public void redrawAll() {
   verlabels = null;
   horlabels = null;
   numberformatter[0] = null;
   numberformatter[1] = null;
   invalidate();
   viewVerLabels.invalidate();
 }
예제 #24
0
  @Override
  public void invalidate() {
    super.invalidate();
    if (getParent() == null || !(getParent() instanceof View)) return;

    if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless)
      ((View) getParent()).invalidate();
  }
예제 #25
0
 @Override
 public boolean onSingleTapUp(MotionEvent event) {
   Log.i(TAG, "onSingleTapUp");
   mCenterX = event.getX();
   mCenterY = event.getY();
   Log.i(TAG, "mX, mY = " + mCenterX + ", " + mCenterY);
   mView.invalidate();
   return true;
 }
예제 #26
0
 public void setAlpha(float alpha) {
   if (mAlpha != alpha) {
     mAlpha = alpha;
     View view = mView.get();
     if (view != null) {
       view.invalidate();
     }
   }
 }
예제 #27
0
 protected void setOpacity(View view, float opacity) {
   if (view != null) {
     TiUIHelper.setDrawableOpacity(view.getBackground(), opacity);
     if (opacity == 1) {
       clearOpacity(view);
     }
     view.invalidate();
   }
 }
 private static void a(View paramView, RectF paramRectF)
 {
   while ((paramView.getParent() instanceof View))
   {
     paramView = (View)paramView.getParent();
     paramView.getMatrix().mapRect(paramRectF);
     paramView.invalidate((int)Math.floor(left), (int)Math.floor(top), (int)Math.ceil(right), (int)Math.ceil(bottom));
   }
 }
 private boolean clearAccessibilityFocus(int i) {
   if (isAccessibilityFocused(i)) {
     mFocusedVirtualViewId = 0x80000000;
     mView.invalidate();
     sendEventForVirtualView(i, 0x10000);
     return true;
   } else {
     return false;
   }
 }
예제 #30
0
 @Override
 public void didReceivedNotification(int id, Object... args) {
   if (id == NotificationCenter.messageThumbGenerated) {
     String key = (String) args[1];
     if (currentThumbKey != null && currentThumbKey.equals(key)) {
       if (currentThumb == null) {
         ImageLoader.getInstance().incrementUseCount(currentThumbKey);
       }
       currentThumb = (BitmapDrawable) args[0];
       if (staticThumb instanceof BitmapDrawable) {
         staticThumb = null;
       }
       if (parentView != null) {
         if (invalidateAll) {
           parentView.invalidate();
         } else {
           parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH);
         }
       }
     }
   } else if (id == NotificationCenter.didReplacedPhotoInMemCache) {
     String oldKey = (String) args[0];
     if (currentKey != null && currentKey.equals(oldKey)) {
       currentKey = (String) args[1];
       currentImageLocation = (TLRPC.FileLocation) args[2];
     }
     if (currentThumbKey != null && currentThumbKey.equals(oldKey)) {
       currentThumbKey = (String) args[1];
       currentThumbLocation = (TLRPC.FileLocation) args[2];
     }
     if (setImageBackup != null) {
       if (currentKey != null && currentKey.equals(oldKey)) {
         currentKey = (String) args[1];
         currentImageLocation = (TLRPC.FileLocation) args[2];
       }
       if (currentThumbKey != null && currentThumbKey.equals(oldKey)) {
         currentThumbKey = (String) args[1];
         currentThumbLocation = (TLRPC.FileLocation) args[2];
       }
     }
   }
 }