Exemplo n.º 1
2
  // Setup
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Log.v("SDL", "onCreate()");
    super.onCreate(savedInstanceState);

    // So we can call stuff from static callbacks
    mSingleton = this;

    // Set up the surface
    mSurface = new SDLSurface(getApplication());

    // Make sure this variable is initialized here!
    mExitCalledFromJava = false;

    if (Build.VERSION.SDK_INT >= 12) {
      mJoystickHandler = new SDLJoystickHandler_API12();
    } else {
      mJoystickHandler = new SDLJoystickHandler();
    }

    mLayout = new AbsoluteLayout(this);
    mLayout.addView(mSurface);

    setContentView(mLayout);
  }
Exemplo n.º 2
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Draw the shadow
    canvas.drawOval(mShadowBounds, mShadowPaint);

    // TODO 0 Slices
    String label = "";
    //        if(mData.size() > 0)
    label = mData.get(mCurrentItem).mLabel;
    //        else
    //        	label = NO_DATA_SLICE;

    // Draw the label text
    if (getShowText()) {
      canvas.drawText(label, mTextX, mTextY, mTextPaint);
    }

    // If the API level is less than 11, we can't rely on the view animation system to
    // do the scrolling animation. Need to tick it here and call postInvalidate() until the
    // scrolling is done.
    if (Build.VERSION.SDK_INT < 11) {
      tickScrollAnimation();
      if (!mScroller.isFinished()) {
        postInvalidate();
      }
    }
  }
  @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);
    }
  }
Exemplo n.º 4
0
  // Setup
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Log.v("SDL", "onCreate()");
    super.onCreate(savedInstanceState);

    // So we can call stuff from static callbacks
    mSingleton = this;

    // Set up the surface
    mSurface = new SDLSurface(getApplication());

    mLayout = new AbsoluteLayout(this);
    mLayout.addView(mSurface);

    setContentView(mLayout);
  }
Exemplo n.º 5
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);
    }
 // ==============================================================================
 @Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
   super.onSizeChanged(w, h, oldw, oldh);
   viewSizeChanged();
 }
 @Override
 public void draw(Canvas canvas) {
   super.draw(canvas);
   handlePaint(canvas);
 }
  public final void deleteView(ComponentPeerView view) {
    ViewGroup group = (ViewGroup) (view.getParent());

    if (group != null) group.removeView(view);
  }
Exemplo n.º 9
0
  // Setup
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.v("SDL", "Device: " + android.os.Build.DEVICE);
    Log.v("SDL", "Model: " + android.os.Build.MODEL);
    Log.v("SDL", "onCreate():" + mSingleton);
    super.onCreate(savedInstanceState);

    SDLActivity.initialize();
    // So we can call stuff from static callbacks
    mSingleton = this;

    // Load shared libraries
    String errorMsgBrokenLib = "";
    try {
      loadLibraries();
    } catch (UnsatisfiedLinkError e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    } catch (Exception e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    }

    if (mBrokenLibraries) {
      AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
      dlgAlert.setMessage(
          "An error occurred while trying to start the application. Please try again and/or reinstall."
              + System.getProperty("line.separator")
              + System.getProperty("line.separator")
              + "Error: "
              + errorMsgBrokenLib);
      dlgAlert.setTitle("SDL Error");
      dlgAlert.setPositiveButton(
          "Exit",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
              // if this button is clicked, close current activity
              SDLActivity.mSingleton.finish();
            }
          });
      dlgAlert.setCancelable(false);
      dlgAlert.create().show();

      return;
    }

    // Set up the surface
    mSurface = new SDLSurface(getApplication());

    if (Build.VERSION.SDK_INT >= 12) {
      mJoystickHandler = new SDLJoystickHandler_API12();
    } else {
      mJoystickHandler = new SDLJoystickHandler();
    }

    mLayout = new AbsoluteLayout(this);
    mLayout.addView(mSurface);

    setContentView(mLayout);
  }
Exemplo n.º 10
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    Log.d(TAG, "Slice Count: " + mData.size());
    if (mData.size() > 0) {
      //
      // Set dimensions for text, pie chart, etc
      //
      // Account for padding
      float xpad = (float) (getPaddingLeft() + getPaddingRight());
      float ypad = (float) (getPaddingTop() + getPaddingBottom());

      // Account for the label
      if (mShowText) xpad += mTextWidth;

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

      // Figure out how big we can make the pie.
      float diameter = Math.min(ww, hh);
      mPieBounds = new RectF(0.0f, 0.0f, diameter, diameter);
      mPieBounds.offsetTo(getPaddingLeft(), getPaddingTop());
      //	        Log.d(TAG, "mPieBounds>> "+mPieBounds);

      mPointerY = mTextY - (mTextHeight / 2.0f);
      float pointerOffset = mPieBounds.centerY() - mPointerY;

      // Make adjustments based on text position
      if (mTextPos == TEXTPOS_LEFT) {
        mTextPaint.setTextAlign(Paint.Align.RIGHT);
        if (mShowText) mPieBounds.offset(mTextWidth, 0.0f);
        mTextX = mPieBounds.left;

        if (pointerOffset < 0) {
          pointerOffset = -pointerOffset;
          mCurrentItemAngle = 225;
        } else {
          mCurrentItemAngle = 135;
        }
        mPointerX = mPieBounds.centerX() - pointerOffset;
      } else {
        mTextPaint.setTextAlign(Paint.Align.LEFT);
        mTextX = mPieBounds.right;

        if (pointerOffset < 0) {
          pointerOffset = -pointerOffset;
          mCurrentItemAngle = 315;
        } else {
          mCurrentItemAngle = 45;
        }
        mPointerX = mPieBounds.centerX() + pointerOffset;
      }

      mShadowBounds =
          new RectF(
              mPieBounds.left + 10,
              mPieBounds.bottom + 10,
              mPieBounds.right - 10,
              mPieBounds.bottom + 20);

      // Lay out the child view that actually draws the pie.
      mPieView.layout(
          (int) mPieBounds.left,
          (int) mPieBounds.top,
          (int) mPieBounds.right,
          (int) mPieBounds.bottom);
      mPieView.setPivot(mPieBounds.width() / 2, mPieBounds.height() / 2);

      mPointerView.layout(0, 0, w, h);
      onDataChanged();
    }
  }
Exemplo n.º 11
0
  public final void deleteOpenGLView(OpenGLView view) {
    ViewGroup group = (ViewGroup) (view.getParent());

    if (group != null) group.removeView(view);
  }