Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pathNode = (PathNode) getApplication();
    paintView = (PaintView) findViewById(R.id.paint);
    paintView.setIsRecordPath(true, pathNode);
    paintView.setOnPathListener(
        new OnPathListener() {
          @Override
          public void AddNodeToPath(float x, float y, int event, boolean IsPaint) {
            PathNode.Node tempnode = pathNode.new Node();
            tempnode.x = paintView.px2dip(x);
            tempnode.y = paintView.px2dip(y);
            if (IsPaint) {
              tempnode.PenColor = UserInfo.PaintColor;
              tempnode.PenWidth = UserInfo.PaintWidth;
            } else {
              tempnode.EraserWidth = UserInfo.EraserWidth;
            }
            tempnode.IsPaint = IsPaint;
            Log.e(
                tempnode.PenColor + ":" + tempnode.PenWidth + ":" + tempnode.EraserWidth,
                tempnode.IsPaint + "");
            tempnode.TouchEvent = event;
            tempnode.time = System.currentTimeMillis();
            pathNode.AddNode(tempnode);
          }
        });

    Init_View();
  }
Esempio n. 2
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   switch (keyCode) {
     case KeyEvent.KEYCODE_HOME:
       moveTaskToBack(true);
       break;
     case KeyEvent.KEYCODE_MENU:
       if (!OPEN) {
         if (VISIBLE) {
           rightLowerButton.setVisibility(View.INVISIBLE);
         } else {
           rightLowerButton.setVisibility(View.VISIBLE);
         }
         paintView.isFocusable();
         VISIBLE = !VISIBLE;
       }
       break;
     case KeyEvent.KEYCODE_VOLUME_UP:
       paintView.ReDoORUndo(true);
       break;
     case KeyEvent.KEYCODE_VOLUME_DOWN:
       paintView.ReDoORUndo(false);
       break;
   }
   return true;
 }
Esempio n. 3
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == RESULT_OK) {
     switch (requestCode) {
       case SELECT_PICTURE:
         paintView.setmBitmap(data.getData());
         break;
       case SELECT_FILE:
         paintView.JsonToPathNodeToHandle(data.getData());
         break;
     }
   }
 }
Esempio n. 4
0
 @Override
 public void onColorSelected(int dialogId, int color) {
   switch (dialogId) {
     case PREFERENCE_DIALOG_ID:
       ((ColorPickerDialogFragment.ColorPickerDialogListener) this)
           .onColorSelected(dialogId, color);
       break;
     case DIALOG_ID:
       paintView.setColor(color);
       UserInfo.PaintColor = color;
       break;
   }
 }