Ejemplo n.º 1
1
    @Override
    public void handleMessage(Message msg) {
      Context context = getContext();
      if (context == null) {
        Log.e(TAG, "error handling message, getContext() returned null");
        return;
      }
      switch (msg.arg1) {
        case COMMAND_CHANGE_TITLE:
          if (context instanceof Activity) {
            ((Activity) context).setTitle((String) msg.obj);
          } else {
            Log.e(TAG, "error handling message, getContext() returned no Activity");
          }
          break;
        case COMMAND_TEXTEDIT_HIDE:
          if (mTextEdit != null) {
            mTextEdit.setVisibility(View.GONE);

            InputMethodManager imm =
                (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
          }
          break;

        default:
          if ((context instanceof SDLActivity)
              && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
            Log.e(TAG, "error handling message, command is " + msg.arg1);
          }
      }
    }
  private void adjustFirstCellsAndScroll() {
    int values[];

    //		values = adjustFirstCellsAndScroll(scrollX, firstColumn, widths);
    //		scrollX = values[0];
    //		firstColumn = values[1];
    // 切换应用导致重新布局时横向滚到最前端
    scrollX = 0;
    firstColumn = 0;
    sumX = 0;

    values = adjustFirstCellsAndScroll(scrollY, firstRow, heights);
    scrollY = values[0];
    firstRow = values[1];

    if (lineView != null) {
      int maxY = lineView.getBottom() - height + lineView.getTop();
      // data变化后maxY发生变化,而之前存的sumY也失效了,滑动时以现在的maxY为准
      if (maxY < 0) {
        maxY = 0;
      }
      sumY = Math.min(maxY, sumY);
      lineView.scrollBy(0, sumY);
    }
  }
Ejemplo n.º 3
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
 @Override
 public void onClick(View inButton) {
   boolean isErr = false;
   if (mTitle.getText().toString().length() == 0) {
     mTitle.setError("Required");
     mTitle.setEms(10);
     isErr = true;
   }
   if (mDesc.getText().toString().length() == 0) {
     mDesc.setActivated(true);
     mDesc.setError("Required");
     isErr = true;
   }
   if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE);
   else if (inButton.getId() == mAvail.getId())
     startActivity(new Intent(this, CheckActivity.class));
   else if (inButton.getId() == mBack.getId()) finish();
   else if (inButton.getId() == mSub.getId()) {
     AlertDialog.Builder al = new AlertDialog.Builder(this);
     if (isErr) return;
     else
       al.setTitle("Continue?")
           .setIcon(R.drawable.ornament)
           .setMessage("Your listing is going to be submitted to your chosen category.")
           .setPositiveButton(
               "OK",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {
                   payment = new ArrayList<String>();
                   if (mCard.isChecked()) payment.add("Card");
                   if (mCheck.isChecked()) payment.add("Check");
                   if (mOnline.isChecked()) payment.add("Online");
                   if (mCash.isChecked()) payment.add("Cash");
                   //			Toast.makeText(getApplicationContext(), payment.toString(),
                   // Toast.LENGTH_LONG).show();
                   Intent intent = new Intent(getApplicationContext(), StartActivity.class);
                   intent.putExtra("Payment", payment);
                   intent.putExtra("Category", mChosenCategory);
                   intent.putExtra("Title", mTitle.getText().toString());
                   intent.putExtra("Price", mPrice.getText().toString());
                   intent.putExtra("Description", mDesc.getText().toString());
                   intent.putExtra("Location", mLocation.getText().toString());
                   intent.putExtra("Photo", jpegData);
                   startActivity(intent);
                 }
               })
           .setNegativeButton(
               "Cancel",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {}
               })
           .show();
   } else
     startActivityForResult(
         new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ);
 }
Ejemplo n.º 5
0
 @Override
 public boolean onTouch(View view, MotionEvent event) {
   String str = null;
   int i = 0;
   str =
       "x="
           + event.getX(i) / view.getMeasuredWidth()
           + ",y="
           + event.getY(i) / view.getMeasuredHeight();
   textView.setText(str);
   return false;
 }
Ejemplo n.º 6
0
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   FrameLayout mainView = null;
   mainView = new FrameLayout(this);
   setContentView(mainView);
   View view = null;
   view = new MyView(this);
   view.setLongClickable(true);
   view.setOnTouchListener(this);
   mainView.addView(view);
   textView = new TextView(this);
   mainView.addView(textView);
 }
Ejemplo n.º 7
0
  private void showcaseActionItem(ViewParent p, Class absAbv, int itemType, int actionItemId) {
    try {
      Field mAmpField = absAbv.getDeclaredField("mActionMenuPresenter");
      mAmpField.setAccessible(true);
      Object mAmp = mAmpField.get(p);
      if (itemType == ITEM_ACTION_OVERFLOW) {
        // Finds the overflow button associated with the ActionMenuPresenter
        Field mObField = mAmp.getClass().getDeclaredField("mOverflowButton");
        mObField.setAccessible(true);
        View mOb = (View) mObField.get(mAmp);
        if (mOb != null) setShowcaseView(mOb);
      } else {
        // Want an ActionItem, so find it
        Field mAmvField = mAmp.getClass().getSuperclass().getDeclaredField("mMenuView");
        mAmvField.setAccessible(true);
        Object mAmv = mAmvField.get(mAmp);

        Field mChField;
        if (mAmv.getClass().toString().contains("com.actionbarsherlock")) {
          // There are thousands of superclasses to traverse up
          // Have to get superclasses because mChildren is private
          mChField =
              mAmv.getClass()
                  .getSuperclass()
                  .getSuperclass()
                  .getSuperclass()
                  .getSuperclass()
                  .getDeclaredField("mChildren");
        } else
          mChField = mAmv.getClass().getSuperclass().getSuperclass().getDeclaredField("mChildren");
        mChField.setAccessible(true);
        Object[] mChs = (Object[]) mChField.get(mAmv);
        for (Object mCh : mChs) {
          if (mCh != null) {
            View v = (View) mCh;
            if (v.getId() == actionItemId) setShowcaseView(v);
          }
        }
      }
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (NoSuchFieldException e) {
      e.printStackTrace();
    } catch (NullPointerException npe) {
      throw new RuntimeException(
          "insertShowcaseViewWithType() must be called "
              + "after or during onCreateOptionsMenu() of the host Activity");
    }
  }
Ejemplo n.º 8
0
  /**
   * 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();
          }
        });
  }
 private void addLineView(int l, int t, int r, int b) {
   if (adapter.hasLineView()) {
     lineView = adapter.getView(-2, -2, null, this);
     lineView.layout(l, t, r, b);
     addView(lineView, 0);
   }
 }
 private View makeView(int row, int column, int w, int h) {
   final int itemViewType = adapter.getItemViewType(row, column);
   final View recycledView;
   if (itemViewType == TableAdapter.IGNORE_ITEM_VIEW_TYPE) {
     recycledView = null;
   } else {
     recycledView = recycler.getRecycledView(itemViewType);
   }
   final View view = adapter.getView(row, column, recycledView, this);
   view.setTag(R.id.tag_type_view, itemViewType);
   view.setTag(R.id.tag_row, row);
   view.setTag(R.id.tag_column, column);
   view.measure(
       MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY),
       MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY));
   addTableView(view, row, column);
   return view;
 }
  @Override
  public void removeView(View view) {
    super.removeView(view);

    final int typeView = (Integer) view.getTag(R.id.tag_type_view);
    if (typeView != TableAdapter.IGNORE_ITEM_VIEW_TYPE) {
      recycler.addRecycledView(view, typeView);
    }
  }
Ejemplo n.º 12
0
  public void showDetails(Equipment equipment) {
    equip = equipment;
    View view;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      view = getActivity().findViewById(R.id.detail_frag);
    } else {
      view = getActivity().findViewById(R.id.main_frame);
      Button button = (Button) view.findViewById(R.id.closeButton);
      button.setVisibility(View.VISIBLE);
    }

    TextView textIt_no = (TextView) view.findViewById(R.id.it_no2);
    TextView textType = (TextView) view.findViewById(R.id.type2);
    TextView textBrand = (TextView) view.findViewById(R.id.brand2);
    TextView textModel = (TextView) view.findViewById(R.id.model2);
    TextView textE_id = (TextView) view.findViewById(R.id.e_id);
    TextView textDescription = (TextView) view.findViewById(R.id.description);
    TextView textAquired = (TextView) view.findViewById(R.id.aquired);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
    } else {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
    }
    textIt_no.setText("Item nr: \t\t\t\t" + equipment.getIt_no());
    textType.setText("Type: \t\t\t\t\t" + equipment.getType());
    textBrand.setText("Brand: \t\t\t\t" + equipment.getBrand());
    textModel.setText("Model: \t\t\t\t" + equipment.getModel());
    textE_id.setText("Equipment ID: \t" + equipment.getE_id());
    textDescription.setText("Description: \t" + equipment.getDescription());
    textAquired.setText("Aquired: \t\t\t" + equipment.getAquired());

    downloadImageThread();

    ImageView image = (ImageView) view.findViewById(R.id.equipment_image);
    image.setImageBitmap(bitmap);
  }
Ejemplo n.º 13
0
 public boolean onTouchEvent(MotionEvent event) {
   super.onTouchEvent(event);
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     x += 15;
     y += 15;
     invalidate();
     return true;
   }
   return false;
 }
Ejemplo n.º 14
0
    @Override
    public void handleMessage(Message msg) {
      Context context = getContext();
      if (context == null) {
        Log.e(TAG, "error handling message, getContext() returned null");
        return;
      }
      switch (msg.arg1) {
        case COMMAND_CHANGE_TITLE:
          if (context instanceof Activity) {
            ((Activity) context).setTitle((String) msg.obj);
          } else {
            Log.e(TAG, "error handling message, getContext() returned no Activity");
          }
          break;
        case COMMAND_TEXTEDIT_HIDE:
          if (mTextEdit != null) {
            mTextEdit.setVisibility(View.GONE);

            InputMethodManager imm =
                (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
          }
          break;
        case COMMAND_SET_KEEP_SCREEN_ON:
          {
            Window window = ((Activity) context).getWindow();
            if (window != null) {
              if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
                window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
              } else {
                window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
              }
            }
            break;
          }
        default:
          if ((context instanceof SDLActivity)
              && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
            Log.e(TAG, "error handling message, command is " + msg.arg1);
          }
      }
    }
Ejemplo n.º 15
0
 @Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
   super.onSizeChanged(w, h, oldw, oldh);
   getAnimationProvider().terminate();
   if (myScreenIsTouched) {
     final ZLView view = ZLApplication.Instance().getCurrentView();
     myScreenIsTouched = false;
     view.onScrollingFinished(ZLView.PageIndex.current);
   }
 }
Ejemplo n.º 16
0
    @Override
    public void run() {
      AbsoluteLayout.LayoutParams params =
          new AbsoluteLayout.LayoutParams(w, h + HEIGHT_PADDING, x, y);

      if (mTextEdit == null) {
        mTextEdit = new DummyEdit(getContext());

        mLayout.addView(mTextEdit, params);
      } else {
        mTextEdit.setLayoutParams(params);
      }

      mTextEdit.setVisibility(View.VISIBLE);
      mTextEdit.requestFocus();

      InputMethodManager imm =
          (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.showSoftInput(mTextEdit, 0);
    }
Ejemplo n.º 17
0
  protected void onDraw(Canvas cs) {
    super.onDraw(cs);

    // 描画方法の設定
    Paint p = new Paint();
    p.setColor(Color.BLACK);
    p.setStyle(Paint.Style.FILL);
    p.setStrokeWidth(8);

    // 円の描画
    cs.drawCircle(x, y, 50, p);
  }
  private void repositionViews() {
    int left, top, right, bottom, i;

    left = widths[0] - scrollX;
    i = firstColumn;
    for (View view : rowViewList) {
      right = left + widths[++i];
      view.layout(left, 0, right, heights[0]);
      left = right;
    }

    top = heights[0] - scrollY;
    i = firstRow;
    for (View view : columnViewList) {
      bottom = top + heights[++i];
      view.layout(0, top, widths[0], bottom);
      top = bottom;
    }

    top = heights[0] - scrollY;
    i = firstRow;
    for (List<View> list : bodyViewTable) {
      bottom = top + heights[++i];
      left = widths[0] - scrollX;
      int j = firstColumn;
      for (View view : list) {
        right = left + widths[++j];
        view.layout(left, top, right, bottom);
        left = right;
      }
      top = bottom;
    }
    invalidate();
  }
Ejemplo n.º 19
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.row, null);
   }
   Message m = items.get(position);
   // if (m != null) {
   m.createColorFromString(m.from);
   TextView tt = (TextView) v.findViewById(R.id.username);
   TextView bt = (TextView) v.findViewById(R.id.message);
   if (isMonospaced) {
     tt.setTypeface(Typeface.MONOSPACE);
     bt.setTypeface(Typeface.MONOSPACE);
   }
   tt.setText(m.getFrom());
   tt.setTextColor(m.color);
   bt.setText(m.getMessage());
   // }
   return v;
 }
  @Override
  protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    final boolean ret;

    final Integer row = (Integer) child.getTag(R.id.tag_row);
    final Integer column = (Integer) child.getTag(R.id.tag_column);
    // row == null => Shadow view
    if (row == null || (row == -1 && column == -1)) {
      ret = super.drawChild(canvas, child, drawingTime);
    } else {
      canvas.save();
      if (row == -1) {
        canvas.clipRect(widths[0], 0, canvas.getWidth(), canvas.getHeight());
      } else if (column == -1) {
        canvas.clipRect(0, heights[0], canvas.getWidth(), canvas.getHeight());
      } else {
        canvas.clipRect(widths[0], heights[0], canvas.getWidth(), canvas.getHeight());
      }

      ret = super.drawChild(canvas, child, drawingTime);
      canvas.restore();
    }
    return ret;
  }
Ejemplo n.º 21
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    float xpad = (float) (getPaddingLeft() + getPaddingRight());
    float ypad = (float) (getPaddingTop() + getPaddingBottom());

    float ww = (float) w - xpad - axisYSpacing;
    float hh = (float) h - ypad - axisXSpacing;

    // Figure out how big we can make the pie.
    mPlotBounds = new RectF(0f, 0f, ww, hh);
    mPlotBounds.offsetTo(getPaddingLeft() + axisYSpacing, getPaddingTop());

    onDataChanged();
  }
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   if (paint == null) {
     paint = new Paint();
     luar =
         new LinearGradient(
             0.f, 0.f, 0.f, this.getMeasuredHeight(), 0xffffffff, 0xff000000, TileMode.CLAMP);
   }
   int rgb = Color.HSVToColor(color);
   Shader dalam =
       new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, 0xffffffff, rgb, TileMode.CLAMP);
   ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY);
   paint.setShader(shader);
   canvas.drawRect(0.f, 0.f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint);
 }
Ejemplo n.º 23
0
  @Override
  protected void onDraw(final Canvas canvas) {
    final Context context = getContext();
    if (context instanceof FBReader) {
      ((FBReader) context).createWakeLock();
    } else {
      System.err.println("A surprise: view's context is not an FBReader");
    }
    super.onDraw(canvas);

    //		final int w = getWidth();
    //		final int h = getMainAreaHeight();

    if (getAnimationProvider().inProgress()) {
      onDrawInScrolling(canvas);
    } else {
      onDrawStatic(canvas);
      ZLApplication.Instance().onRepaintFinished();
    }
  }
Ejemplo n.º 24
0
 @Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   Intent intent;
   String parentPN; // 蹂댄샇���꾪솕踰덊샇
   /** 媛�踰꾪듉蹂꾨줈 �댁빞���쇱쓣 梨꾩썙�k뒗�� */
   switch (v.getId()) {
     case R.id.mystatbtn:
       intent = new Intent(Menus.this, Mystat.class);
       startActivity(intent);
       break;
     case R.id.noticebtn:
       intent = new Intent(Menus.this, Notice.class);
       startActivity(intent);
       break;
     case R.id.requestbtn:
       intent = new Intent(Menus.this, RequestTalk.class);
       startActivity(intent);
       break;
     case R.id.hospitalinfobtn:
       intent = new Intent(Menus.this, Hospitalinfo.class);
       startActivity(intent);
       break;
     case R.id.qrreadbtn:
       intent = new Intent(Menus.this, QRread.class);
       startActivity(intent);
       break;
     case R.id.parentcallbtn:
       parentPN = "01193699621"; // 蹂댄샇���꾪솕踰덊샇 DB�먯꽌 媛�졇��빞 ��
       intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + parentPN));
       startActivity(intent);
       break;
     case R.id.emergencybtn:
       // 蹂묒썝��湲닿툒肄�
       ((Button) findViewById(R.id.emergencybtn)).setBackgroundColor(Color.GREEN);
       ((Button) findViewById(R.id.emergencybtn)).setText("�좉퀬 �꾨즺");
       break;
   }
 }
Ejemplo n.º 25
0
    @Override
    protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);

      if (Build.VERSION.SDK_INT < 11) {
        mTransform.set(canvas.getMatrix());
        mTransform.preRotate(mRotation, mPivot.x, mPivot.y);
        canvas.setMatrix(mTransform);
      }

      for (Item it : mData) {
        mPiePaint.setShader(it.mItemShader);
        cSlicePaint.setShader(it.cSliceShader);
        //                Log.d(TAG, "mBounds: " +mBounds);
        canvas.drawArc(mBounds, 360 - it.mEndAngle, it.mEndAngle - it.mStartAngle, true, mPiePaint);
        Log.d(TAG, "Item Being Built: " + it.mLabel);
        Log.d(TAG, "RectF: " + it.cSliceBounds);
        Log.d(TAG, "StartAngle> " + it.mStartAngle + " EndAngle> " + it.mEndAngle);
        canvas.drawArc(
            it.cSliceBounds, 360 - it.mEndAngle, it.mEndAngle - it.mStartAngle, true, cSlicePaint);
        //                Log.d(TAG, "StartAngle> "+it.mStartAngle+" EndAngle> "+it.mEndAngle);
      }
    }
Ejemplo n.º 26
0
 public boolean onKeyDown(int KeyCode, KeyEvent event) {
   super.onKeyDown(KeyCode, event);
   if (event.getAction() == KeyEvent.ACTION_DOWN) {
     switch (KeyCode) {
       case KeyEvent.KEYCODE_DPAD_LEFT:
         x -= 15;
         invalidate();
         return true;
       case KeyEvent.KEYCODE_DPAD_RIGHT:
         x += 15;
         invalidate();
         return true;
       case KeyEvent.KEYCODE_DPAD_UP:
         y -= 15;
         invalidate();
         return true;
       case KeyEvent.KEYCODE_DPAD_DOWN:
         y += 15;
         invalidate();
         return true;
     }
   }
   return false;
 }
 private View makeAndSetup(int row, int column, int left, int top, int right, int bottom) {
   final View view = makeView(row, column, right - left, bottom - top);
   view.layout(left, top, right, bottom);
   return view;
 }
Ejemplo n.º 28
0
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      // detector.onTouchEvent(event);
      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          startX = event.getX();
          downX = event.getX();
          break;
        case MotionEvent.ACTION_UP:
          v.performClick();
          break;
        case MotionEvent.ACTION_MOVE:
          // 是否已滚动到无法继续滑动
          boolean isEnable = false;
          // 手指move的像素值超过系统判定判定滚动的最小临界值,避免手指抖动造成chart图抖动
          if (Math.abs(event.getX() - downX)
              > ViewConfiguration.get(context).getScaledTouchSlop()) {
            int transValue = (int) (event.getX() - startX);
            if (axesData.size() > 1) {
              int max = axesData.get(axesData.size() - 1).X;
              int min = axesData.get(0).X;
              int maxLimit = width - rightPadding - POINT_PADDING;
              int minLimit = leftPadding + yTextWidth + POINT_PADDING;
              if (min + transValue > minLimit) { // 滑动以后左边界判断
                if (min < minLimit) {
                  transValue = minLimit - min;
                  isEnable = true;
                } else {
                  transValue = 0;
                  if (loadMore != null) {
                    loadMore.onLoad();
                  }
                }
              } else {
                isEnable = true;
              }
              if (max + transValue < maxLimit) { // 滑动后右边界判断
                if (max > maxLimit) {
                  transValue = maxLimit - max;
                  isEnable = true;
                } else {
                  transValue = 0;
                }
              } else {
                isEnable = true;
              }
              Log.d("min", min + "");
              Log.d("minLimit", minLimit + "");
              Log.d("transValue", transValue + "");
              if (isEnable) {
                startX = event.getX();
                refreshChart(transValue);
              }
            }
          }
          break;

        default:
          break;
      }
      return true;
    }
Ejemplo n.º 29
0
 public static String visualize(View view) {
   Canvas canvas = new Canvas();
   view.draw(canvas);
   return shadowOf(canvas).getDescription();
 }
  @Override
  public void scrollBy(int x, int y) {
    scrollX += x;
    scrollY += y;

    if (needRelayout) {
      return;
    }

    if (lineView != null) {
      int maxX = lineView.getRight() - width + lineView.getLeft();
      int maxY = lineView.getBottom() - height + lineView.getTop();
      int dX = x;
      int dY = y;
      sumX += x;
      sumY += y;
      if (maxY < 0) {
        maxY = 0;
      }
      if (sumX <= 0) {
        dX = x - sumX;
        sumX = 0;
      } else if (sumX >= maxX) {
        dX = maxX - sumX + x;
        sumX = maxX;
      }
      if (sumY <= 0) {
        dY = y - sumY;
        sumY = 0;
      } else if (sumY >= maxY) {
        dY = maxY - sumY + y;
        sumY = maxY;
      }

      lineView.scrollBy(dX, 0);
      lineView.scrollBy(0, dY);
    }

    scrollBounds();

    /*
     * TODO Improve the algorithm. Think big diagonal movements. If we are
     * in the top left corner and scrollBy to the opposite corner. We will
     * have created the views from the top right corner on the X part and we
     * will have eliminated to generate the right at the Y.
     */
    if (scrollX == 0) {
      // no op
    } else if (scrollX > 0) {
      while (widths[firstColumn + 1] < scrollX) {
        if (!rowViewList.isEmpty()) {
          removeLeft();
        }
        scrollX -= widths[firstColumn + 1];
        firstColumn++;
      }
      while (getFilledWidth() < width) {
        addRight();
      }
    } else {
      while (!rowViewList.isEmpty()
          && getFilledWidth() - widths[firstColumn + rowViewList.size()] >= width) {
        removeRight();
      }
      if (rowViewList.isEmpty()) {
        while (scrollX < 0) {
          firstColumn--;
          scrollX += widths[firstColumn + 1];
        }
        while (getFilledWidth() < width) {
          addRight();
        }
      } else {
        while (0 > scrollX) {
          addLeft();
          firstColumn--;
          scrollX += widths[firstColumn + 1];
        }
      }
    }

    if (scrollY == 0) {
      // no op
    } else if (scrollY > 0) {
      while (heights[firstRow + 1] < scrollY) {
        if (!columnViewList.isEmpty()) {
          removeTop();
        }
        scrollY -= heights[firstRow + 1];
        firstRow++;
      }
      while (getFilledHeight() < height) {
        addBottom();
      }
    } else {
      while (!columnViewList.isEmpty()
          && getFilledHeight() - heights[firstRow + columnViewList.size()] >= height) {
        removeBottom();
      }
      if (columnViewList.isEmpty()) {
        while (scrollY < 0) {
          firstRow--;
          scrollY += heights[firstRow + 1];
        }
        while (getFilledHeight() < height) {
          addBottom();
        }
      } else {
        while (0 > scrollY) {
          addTop();
          firstRow--;
          scrollY += heights[firstRow + 1];
        }
      }
    }

    repositionViews();

    shadowsVisibility();

    if (delegateTable != null && positiveScroll) {
      delegateTable.setPositiveScroll(false);
      delegateTable.scrollBy(x, 0);
    }
  }