コード例 #1
0
  /*
   * method: onCreate
   * purpose: starts the activity
   * @param: savedInstanceState - a Bundle of info about the activity that will be started
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select_ship_positions_ai);

    // set on touch listeners for the ships visible and invisible on startup
    Vship5 = (ImageView) findViewById(R.id.Ship5);
    Vship4 = (ImageView) findViewById(R.id.Ship4);
    Vship3 = (ImageView) findViewById(R.id.Ship3);
    Vship2 = (ImageView) findViewById(R.id.Ship2);
    Vship1 = (ImageView) findViewById(R.id.Ship1);

    Hship5 = (ImageView) findViewById(R.id.HShip5);
    Hship4 = (ImageView) findViewById(R.id.HShip4);
    Hship3 = (ImageView) findViewById(R.id.HShip3);
    Hship2 = (ImageView) findViewById(R.id.HShip2);
    Hship1 = (ImageView) findViewById(R.id.HShip1);

    Vship5.setOnTouchListener(this);
    Vship4.setOnTouchListener(this);
    Vship3.setOnTouchListener(this);
    Vship2.setOnTouchListener(this);
    Vship1.setOnTouchListener(this);

    Hship5.setOnTouchListener(this);
    Hship4.setOnTouchListener(this);
    Hship3.setOnTouchListener(this);
    Hship2.setOnTouchListener(this);
    Hship1.setOnTouchListener(this);

    p1 = (Player) getIntent().getSerializableExtra("Player1");
    p2 = (AI) getIntent().getSerializableExtra("AI2");

    ((RelativeLayout) findViewById(R.id.privacy)).setBackgroundColor(p1.getColorChoiceID());
  }
コード例 #2
0
 private void createSelectionLayer(Context context) {
   final LayoutInflater inflater =
       (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);
   mDragController = new DragController(context);
   mDragController.setDragListener(this);
   mDragController.addDropTarget(mSelectionDragLayer);
   mSelectionDragLayer.setDragController(mDragController);
   mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
   mStartSelectionHandle.setTag(HandleType.START);
   mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
   mEndSelectionHandle.setTag(HandleType.END);
   final OnTouchListener handleTouchListener =
       new OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           boolean handledHere = false;
           if (event.getAction() == MotionEvent.ACTION_DOWN) {
             handledHere = startDrag(v);
             mLastTouchedSelectionHandle = (HandleType) v.getTag();
           }
           return handledHere;
         }
       };
   mStartSelectionHandle.setOnTouchListener(handleTouchListener);
   mEndSelectionHandle.setOnTouchListener(handleTouchListener);
 }
コード例 #3
0
  // Crea il particolare dialog una volta sola
  // Per riconfigurarlo usare onPrepareDialog
  protected Dialog onCreateDialog(int id) {
    final Dialog dialog;
    switch (id) {
      case DIALOG_EXIT_APPLICATION:
        // prepare the custom dialog
        dialog = new Dialog(this); // con l'app context non si aprono
        dialog.setCancelable(false);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.exit_application_dialog);
        // dialog.setTitle("Custom Dialog");
        dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialogbg);

        TextView textExit = (TextView) dialog.findViewById(R.id.textexit);
        textExit.setTypeface(FontFactory.getFont1(getApplicationContext()));

        final ImageView yesButton = (ImageView) dialog.findViewById(R.id.yesButton);
        yesButton.setOnTouchListener(
            new OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                  case MotionEvent.ACTION_UP:
                    yesButton.setEnabled(false);
                    dialog.dismiss();
                    finish();
                    overridePendingTransition(0, 0);
                    break;
                }
                return true;
              }
            });

        final ImageView noButton = (ImageView) dialog.findViewById(R.id.noButton);
        noButton.setOnTouchListener(
            new OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                  case MotionEvent.ACTION_UP:
                    noButton.setEnabled(false);
                    waiting = false;
                    noButton.setEnabled(true);
                    dialog.dismiss();
                    break;
                }
                return true;
              }
            });
        break;
      default:
        dialog = null;
    }
    return dialog;
  }
コード例 #4
0
  public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setOnTouchListener(this);

    mViewTreeObserver = imageView.getViewTreeObserver();
    mViewTreeObserver.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (!imageView.isInEditMode()) {
      // Create Gesture Detectors...
      mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

      mGestureDetector =
          new GestureDetector(
              imageView.getContext(),
              new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                  if (null != mLongClickListener) {
                    mLongClickListener.onLongClick(mImageView.get());
                  }
                }
              });

      mGestureDetector.setOnDoubleTapListener(this);

      // Finally, update the UI so that we're zoomable
      setZoomable(true);
    }
  }
コード例 #5
0
ファイル: MainActivity.java プロジェクト: sn0opy1/HACKATHON
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setAmbientEnabled();

    mContainerView = (BoxInsetLayout) findViewById(R.id.container);
    mImageView = (ImageView) findViewById(R.id.imageView);

    gestureDetector = new GestureDetector(getApplicationContext(), new GameGestureListener());

    mImageView.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
          }
        });

    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    mHeartSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);

    mGoogleApiClient =
        new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    // up vector cal
    mHeadTracker = HeadTracker.createFromContext(getApplicationContext());
    headView = new float[16];
  }
コード例 #6
0
 /** ビューにタッチイベントのリスナーを登録します。 */
 private void setTouchImageListener() {
   for (ImageView dragView : foods) {
     // タッチイベントを登録
     DragViewListener listener = new DragViewListener(dragView);
     dragView.setOnTouchListener(listener);
   }
 }
コード例 #7
0
 /**
  * Конструктор класса.
  *
  * @param imageView контрол для вывода анимации.
  * @param faceHelper менеджер управления лицом.
  */
 public FaceTouchHelper(
     final Context context, final ImageView imageView, final FaceHelper faceHelper) {
   mContext = context;
   mFaceHelper = faceHelper;
   mImageView = imageView;
   imageView.setOnTouchListener(this);
 }
コード例 #8
0
ファイル: VetFragment.java プロジェクト: KitKare/KitKare
  private void attachEventListeners() {
    imageViewVet.setOnTouchListener(
        new OnSwipeTouchListener(context) {
          @Override
          public void onSwipeRight() {
            dashboardActivity.getFragment(
                new DashboardFragment(),
                R.animator.fragment_slide_right,
                R.animator.fragment_slide_left);
          }

          @Override
          public void onSwipeLeft() {
            dashboardActivity.getFragment(new DashboardFragment());
          }
        });

    pickVetNumber.setOnClickListener(this);
    deleteVetNumber.setOnClickListener(this);
    editVetNumber.setOnClickListener(this);
    vetHistory.setOnClickListener(this);

    // http://stackoverflow.com/questions/18911290/perform-both-the-normal-click-and-long-click-at-button
    callVet.setOnLongClickListener(
        new View.OnLongClickListener() {

          @Override
          public boolean onLongClick(View v) {
            callVet();
            return true;
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ImageView iv = (ImageView) findViewById(R.id.image_view);
    iv.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            ImageView iv = (ImageView) v;
            //                AnimationDrawable ad = (AnimationDrawable) iv.getDrawable();
            //                ad.stop();
            //                ad.start();

            //                TranslateAnimation anim =
            //                    new TranslateAnimation(
            //                            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            //                            TranslateAnimation.RELATIVE_TO_SELF, 0.25f,
            //                            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            //                            TranslateAnimation.RELATIVE_TO_SELF, 0.25f);
            //                anim.setDuration(500);
            Animation anim =
                AnimationUtils.loadAnimation(getApplicationContext(), R.anim.simple_set);
            iv.startAnimation(anim);

            return true;
          }
        });
  }
 private void initView() {
   view = LayoutInflater.from(context).inflate(R.layout.floating_layout_list, null);
   RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler);
   recyclerView.setLayoutManager(
       new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
   recyclerView.setItemAnimator(new DefaultItemAnimator());
   setupBackground();
   hideRecycler();
   recyclerView.setAdapter(adapter);
   windowManager.addView(view, rParams);
   if (floatingImage == null) floatingImage = new ImageView(context);
   setupFloatingImage(false);
   floatingImage.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           gestureDetector.onTouchEvent(event);
           return FloatingHorizontalLayout.this.onTouch(v, event);
         }
       });
   windowManager.addView(floatingImage, mParams);
   onMyAppsLoader = new MyPopupAppsLoader(context, this);
   onMyAppsLoader.registerListener(3, onLoadCompleteListener);
   onMyAppsLoader.startLoading();
   animateHidden();
 }
コード例 #11
0
ファイル: UserDetail.java プロジェクト: CrisHu/MyWeiChat
  public UserDetail(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.linearlayout_userdetail, this);
    imageviewbili = (ImageView) findViewById(R.id.littletv);
    imageviewbili.setOnTouchListener(this);
    imageviewbili.setBackgroundResource(R.drawable.bili_up);
    ImageView usericon = (ImageView) findViewById(R.id.usericon);
    TextView textview = (TextView) findViewById(R.id.username);

    RelativeLayout.LayoutParams layoutParamsb =
        (RelativeLayout.LayoutParams) imageviewbili.getLayoutParams();
    layoutParamsb.height = (int) (MainActivity.window_height * 3 / 11 / 1.5);
    layoutParamsb.width = 270 * layoutParamsb.height / 208;
    imageviewbili.setLayoutParams(layoutParamsb);

    StyleController.contextinStyleController = context;
    setusernametextTheme(textview);
    data = getData();
    UserDetailAdapter adapter = new UserDetailAdapter(context);
    lv = (ListView) findViewById(R.id.userlv);
    lv.setAdapter(adapter);
    lv.setDividerHeight(1);
  }
コード例 #12
0
ファイル: Caster.java プロジェクト: lsumag/KingFisher
  /**
   * Initiate the Caster Activity, load the sounds up, set up touch listener, vibrator, sensor
   * manager, and accelerometer sensor
   *
   * @param savedInstanceState
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    setContentView(R.layout.caster);

    castDistance = 0;

    casterBackground = (ImageView) findViewById(R.id.caster_background);
    casterBackground.setOnTouchListener(this);

    audioTask = new AudioTask();

    soundManager = SoundManager.getInstance();

    // TODO: background animation once we get the assets.
    vibrotron = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
    sensorManager =
        (SensorManager) getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
    accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
  }
コード例 #13
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   ImageView view = (ImageView) findViewById(R.id.imageView);
   view.setOnTouchListener(this);
 }
コード例 #14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dynamic_filter);
    resultImage = MessageService.image;

    imageView = (ImageView) findViewById(R.id.basicImage);
    imageView.setImageBitmap(resultImage);
    imageView.setOnTouchListener(this);

    // Shake detection
    shakeDetectionListener = new ShakeDetectionListener(this);
    sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
    sensorMgr.registerListener(
        shakeDetectionListener,
        sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
        SensorManager.SENSOR_DELAY_NORMAL);

    // Gyroscope detection
    movementDetectionListener = new MovementDetectionListener(this);
    sensorMgr.registerListener(
        movementDetectionListener,
        sensorMgr.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR),
        SensorManager.SENSOR_DELAY_NORMAL);

    // Register filter
    filters.add(new ColorFilter());
    filters.add(new GridFilter());
    filters.add(new LightFilter());
    filters.add(new MozFilter());
    filters.add(new BlackAndWhiteFilter());
    filters.add(new InvertFilter());
    filters.add(new BinaryFilter());
    // moved(0, 0, 0);
  }
コード例 #15
0
ファイル: PhotoViewAttacher.java プロジェクト: keqizwl/volley
  /**
   * Clean-up the resources attached to this object. This needs to be called when the ImageView is
   * no longer used. A good example is from {@link android.view.View#onDetachedFromWindow()} or from
   * {@link android.app.Activity#onDestroy()}. This is automatically called if you are using {@link
   * uk.co.senab.photoview.PhotoView}.
   */
  @SuppressWarnings("deprecation")
  public void cleanup() {
    if (null != mImageView) {
      // Remove this as a global layout listener
      ViewTreeObserver observer = mImageView.getViewTreeObserver();
      if (null != observer && observer.isAlive()) {
        observer.removeGlobalOnLayoutListener(this);
      }

      // Remove the ImageView's reference to this
      mImageView.setOnTouchListener(null);

      // make sure a pending fling runnable won't be run
      cancelFling();
    }

    if (null != mGestureDetector) {
      mGestureDetector.setOnDoubleTapListener(null);
    }

    // Clear listeners too
    mMatrixChangeListener = null;
    mPhotoTapListener = null;
    mViewTapListener = null;

    // Finally, clear ImageView
    mImageView = null;
  }
コード例 #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    image_view = (ImageView) findViewById(R.id.image_view);
    image_view.setOnTouchListener(this);
  }
コード例 #17
0
ファイル: BonosActivity.java プロジェクト: vscotti/vscotti
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    colWidths = AccionesBonosConstant.BONOS_COL_WIDTHS;
    colNames = AccionesBonosConstant.BONOS_COL_NAMES;

    parser = new HtmlParser();
    currentAcitvity = this;

    abG = new AccionBonoViewGenerator();
    bonoDao = new BonoDAO(this);
    bonoDao.open();

    indiceId = AccionesBonosConstant.BONOS_NACIONALES_INDICE_ID;
    Indice indice = new Indice();
    indice.setId(indiceId);
    List<Bono> bonos = bonoDao.getAllBonosByInidice(indice);
    List<List<String>> results = new ArrayList<List<String>>();
    Date fechaUltimaActualizacion = new Date();
    for (Bono bono : bonos) {
      List<String> aux = new ArrayList<String>();
      aux.add(bono.getNombre());
      aux.add(bono.getTicket());
      aux.add(bono.getMoneda());
      aux.add(bono.getValor());
      aux.add(bono.getVarPercentage());
      results.add(aux);
      fechaUltimaActualizacion = new Date(bono.getFecha());
    }

    abG.generateView(
        colWidths, colNames, results, currentAcitvity, fechaUltimaActualizacion, true, false);

    TextView title = (TextView) findViewById(R.id.title_index);
    title.setText(indexName);

    ImageView img = (ImageView) findViewById(R.id.imageView1);
    img.setBackgroundResource(R.drawable.spin_animation);
    img.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            frameAnimation.start();

            v.playSoundEffect(SoundEffectConstants.CLICK);
            callAsyncTask();
            return false;
          }
        });
    frameAnimation = (AnimationDrawable) img.getBackground();
    frameAnimation.start();

    callAsyncTask();
  }
コード例 #18
0
ファイル: Login.java プロジェクト: XuJian1252878/Auction
 // 设置监听事件
 private void setEventListeners() {
   moEditUsername.addTextChangedListener(new OnEditUsername());
   moEditPassword.addTextChangedListener(new OnEditPassword());
   moBtnClearUsername.setOnClickListener(new OnClearEditText());
   moBtnClearPassword.setOnClickListener(new OnClearEditText());
   moImgSlider.setOnClickListener(new OnSliderClicked());
   moImgSlider.setOnTouchListener(new OnSliderDragged());
   // moBtnRegister.setOnClickListener(new OnRegister());
   moBtnTraveller.setOnClickListener(new OnTravell());
 }
コード例 #19
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_fex_detail, container, false);

    // show the current exercise
    ImageView imageview = (ImageView) rootView.findViewById(R.id.imageview);

    // set gesture detector
    this.mGestureScanner =
        new GestureDetector(
            this.getActivity(), new ExerciseDetailOnGestureListener(this, imageview, mExercise));

    // Images
    if (!mExercise.getImagePaths().isEmpty()) {
      DataHelper data = new DataHelper(getActivity());
      imageview.setImageDrawable(data.getDrawable(mExercise.getImagePaths().get(0).toString()));
    } else {
      imageview.setImageResource(R.drawable.ic_launcher);
    }

    imageview.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return mGestureScanner.onTouchEvent(event);
          }
        });

    // set adapter
    ListView listView = (ListView) rootView.findViewById(R.id.list);
    final TrainingEntryListAdapter mAdapter =
        new TrainingEntryListAdapter((FragmentActivity) getActivity(), mExercise, mTrainingEntry);
    listView.setAdapter(mAdapter);

    SwipeDismissListViewTouchListener touchListener =
        new SwipeDismissListViewTouchListener(
            listView,
            new SwipeDismissListViewTouchListener.OnDismissCallback() {
              @Override
              public void onDismiss(ListView listView, int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                  mAdapter.remove(position);
                }
                mAdapter.notifyDataSetChanged();
              }
            });
    listView.setOnTouchListener(touchListener);
    // Setting this scroll listener is required to ensure that during
    // ListView scrolling,
    // we don't look for swipes.
    listView.setOnScrollListener(touchListener.makeScrollListener());

    return rootView;
  }
コード例 #20
0
ファイル: Splash.java プロジェクト: crane13/GreenLife-1
  private void initViews() {
    arrViews = new ArrayList<View>();
    baseView = new FrameLayout(context);
    mViewPager = new ViewPager(context);
    llDots = new LinearLayout(context);
    llDots.setOrientation(RadioGroup.HORIZONTAL);

    llDots.setGravity(Gravity.CENTER_HORIZONTAL);
    LinearLayout.LayoutParams paramsGroup =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, (int) (20 * fDensity));
    paramsGroup.gravity = Gravity.CENTER_HORIZONTAL;
    llDots.setLayoutParams(paramsGroup);
    if (resIds == null) return;
    for (int i = 0; i < resIds.length; i++) {
      ImageView iv = new ImageView(context);
      iv.setId(i);
      iv.setTag(i);
      iv.setOnClickListener(mClick);
      iv.setOnTouchListener(onTouch);
      iv.setBackgroundResource(resIds[i]);
      arrViews.add(iv);
      RelativeLayout rl = new RelativeLayout(context);
      android.widget.RelativeLayout.LayoutParams layoutParam =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
      layoutParam.addRule(RelativeLayout.CENTER_VERTICAL);
      ImageView dot = new ImageView(context);
      dot.setId(i);

      if (i == 0) {
        dot.setImageResource(dotResId1);
      } else {
        dot.setImageResource(dotResId2);
      }
      rl.addView(dot, layoutParam);
      rl.setPadding(0, 0, (int) (13 * fDensity), 0);
      llDots.addView(rl);
    }
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    baseView.addView(mViewPager, params);

    pageItemAdapter = new PageItemAdapter(arrViews);
    mViewPager.setAdapter(pageItemAdapter);
    mViewPager.setOnPageChangeListener(mPageChange);

    LayoutParams params2 =
        new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, (int) (20 * fDensity));
    params2.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    params2.bottomMargin = (int) (10 * fDensity);
    baseView.addView(llDots, params2);
    initPage();
    addContentView();
  }
コード例 #21
0
ファイル: Game.java プロジェクト: wjcom/COMFD
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
   // WindowManager.LayoutParams.FLAG_FULLSCREEN);
   setContentView(R.layout.activity_game);
   btn_popWindow = (Button) findViewById(R.id.button3);
   iv_after = (ImageView) findViewById(R.id.iv_after);
   iv_before = (ImageView) findViewById(R.id.iv_before);
   et_size = (EditText) findViewById(R.id.et_size);
   pop = (LinearLayout) findViewById(R.id.pop);
   after = BitmapFactory.decodeResource(getResources(), R.drawable.before);
   // Ö»¶ÁµÄbitmap
   before = BitmapFactory.decodeResource(getResources(), R.drawable.after);
   iv_after.setImageBitmap(after);
   iv_before.setImageBitmap(before);
   // ¿ÉÒÔÐ޸ĵĿհ×bitmap
   alterBitmap = Bitmap.createBitmap(before.getWidth(), before.getHeight(), before.getConfig());
   canvas = new Canvas(alterBitmap);
   paint = new Paint();
   paint.setStrokeWidth(5);
   paint.setColor(Color.BLACK);
   canvas.drawBitmap(before, new Matrix(), paint);
   iv_before.setOnTouchListener(
       new OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           switch (event.getAction()) {
             case MotionEvent.ACTION_MOVE:
               int newX = (int) event.getX();
               int newY = (int) event.getY();
               for (int i = -radio; i < radio; i++) {
                 for (int j = -radio; j < radio; j++) {
                   int x = i + newX;
                   int y = j + newY;
                   // ¼ÆËã°ë¾¶
                   int r = (int) Math.sqrt(i * i + j * j);
                   // ÅжÏËù´¥ÃþµãÔÚͼƬ·¶Î§ÄÚ£¬²¢ÇÒÐ޸IJ¿·ÖΪԲÐÎ
                   if (x > 0
                       && x < iv_before.getWidth()
                       && y > 0
                       && y < iv_before.getHeight()
                       && r <= radio) {
                     alterBitmap.setPixel(x, y, Color.TRANSPARENT);
                   }
                 }
               }
               iv_before.setImageBitmap(alterBitmap);
               break;
           }
           return true;
         }
       });
 }
コード例 #22
0
ファイル: TuiJianActivity.java プロジェクト: niuyi/PPTVTest2
  private ImageView createImageView(int i) {
    ImageView view = new ImageView(this);
    view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    view.setScaleType(ImageView.ScaleType.FIT_START);
    view.setImageResource(images[i]);

    view.setOnTouchListener(gestureListener);
    view.setLongClickable(true);
    view.setTag(new ImageDescriptionHolder(imageDescription[i], i));
    return view;
  }
コード例 #23
0
ファイル: MainActivity.java プロジェクト: yh-kim/EnterPaper
  private void initMenuList() {
    addItemsMenu();

    menu_list = (ListView) findViewById(R.id.menu_list);

    // Adapter 생성
    adapters = new MenuAdapter(this, R.layout.row_menu, dataList);

    // Adapter와 GirdView를 연결
    menu_list.setAdapter(adapters);

    adapters.notifyDataSetChanged();

    // 이미지 터치 못하게
    ImageView imageView99 = (ImageView) findViewById(R.id.imageView99);
    imageView99.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    // menu button 눌렀을 때
    menu_list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
              case 0:
                Intent myInfo = new Intent(getApplicationContext(), MyInfoActivity.class);
                startActivity(myInfo);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
              case 1:
                Intent myBooth = new Intent(getApplicationContext(), MyBoothActivity.class);
                startActivity(myBooth);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
              case 2:
                Intent notice = new Intent(getApplicationContext(), NoticeActivity.class);
                startActivity(notice);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
              case 3:
                Intent setting = new Intent(getApplicationContext(), SettingActivity.class);
                startActivity(setting);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            }
          }
        });
  }
コード例 #24
0
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    if (!mAttached) {
      return false;
    }
    // Ignore future touches
    mScreenshotView.setOnTouchListener(null);

    mPreAnimator.end();
    mCallback.onSendConfirmed();
    return true;
  }
コード例 #25
0
ファイル: CroppingActivity.java プロジェクト: kkor/kanjiapp
 private void enableCropping() {
   mZooming = false;
   mResultImageView.setOnTouchListener(null);
   getActionBar().setSubtitle(R.string.subtitle_activity_cropping);
   getActionBar().setTitle(R.string.title_activity_cropping);
   if (mCropRectangle != null) {
     mCropRectangle.setReportView(mResultImageView, this);
     mCropRectangle.enable();
     mImageResultContainer.addView(mCropRectangle);
   }
   invalidateOptionsMenu();
 }
コード例 #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calibration);
    sp = PreferenceManager.getDefaultSharedPreferences(this);
    bundle = getIntent().getExtras();

    mapId = bundle.getInt("mapId");

    // Link elements from layout
    relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout);
    mapView = (ImageView) findViewById(R.id.map);
    measureButton = (Button) findViewById(R.id.measureButton);
    modeTextView = (TextView) findViewById(R.id.modeTextView);

    // Init measure button
    measureButton.setEnabled(false);
    measureButton.setClickable(false);

    // Init map image
    Bitmap image =
        BitmapFactory.decodeFile(
            Environment.getExternalStorageDirectory()
                + "/calibrationApp/maps/"
                + bundle.getString("image"));
    mapView.setImageBitmap(image);
    bounds = mapView.getDrawable().getBounds();

    viewHeight = getResources().getDisplayMetrics().heightPixels;
    viewWidth = getResources().getDisplayMetrics().widthPixels;

    // Init marker
    marker = new ImageView(this);
    marker.setImageResource(R.drawable.marker);
    marker.setAlpha(TRANSPARENT);
    markerBounds = marker.getDrawable().getBounds();
    relativeLayout.addView(marker);

    new RetrievePointsTask().execute();
    savedPointsVisible = true;

    // Set Passive mode
    mapView.setOnTouchListener(passiveModeListener);

    // Set on click listener on measure button
    measureButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            new AddPointTask().execute();
          }
        });
  }
コード例 #27
0
  /**
   * Creates the selection layer.
   *
   * @param context
   */
  protected void createSelectionLayer(Context context) {

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);

    // Make sure it's filling parent
    mDragController = new DragController(context);
    mDragController.setDragListener(this);
    mDragController.addDropTarget(mSelectionDragLayer);
    mSelectionDragLayer.setDragController(mDragController);

    mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
    mStartSelectionHandle.setTag(new Integer(SELECTION_START_HANDLE));
    mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
    mEndSelectionHandle.setTag(new Integer(SELECTION_END_HANDLE));

    OnTouchListener handleTouchListener =
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {

            boolean handledHere = false;

            final int action = event.getAction();

            // Down event starts drag for handle.
            if (action == MotionEvent.ACTION_DOWN) {
              handledHere = startDrag(v);
              mLastTouchedSelectionHandle = (Integer) v.getTag();
            }

            return handledHere;
          }
        };

    mStartSelectionHandle.setOnTouchListener(handleTouchListener);
    mEndSelectionHandle.setOnTouchListener(handleTouchListener);
  }
コード例 #28
0
  public void AddButtonListeners() {
    final Button EditBtn = (Button) findViewById(R.id.editbutton);
    final Button LogOutBtn = (Button) findViewById(R.id.logoutBtn);
    ImageView TAppIMG = (ImageView) findViewById(R.id.icon_image);
    EditBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String p = (onlineUsersList.get(userEmail)).Permission;
            if ((onlineUsersList.get(userEmail)).Permission.equals("1")) {
              Intent edit = new Intent(MainChatActivity.this, settingActivity.class);
              edit.putExtra("User", userEmail);
              edit.putExtra("perr", "1");
              startActivity(edit);
            } else {
              Intent edit = new Intent(MainChatActivity.this, updateUsersAdmin.class);
              startActivity(edit);
            }
          }
        });
    TAppIMG.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            if (EditButtonImage == false) {
              EditBtn.setVisibility(View.VISIBLE);
              LogOutBtn.setVisibility(View.VISIBLE);
              EditButtonImage = true;

            } else {
              EditBtn.setVisibility(View.GONE);
              LogOutBtn.setVisibility(View.GONE);
              EditButtonImage = false;
            }
            return false;
          }
        });
    LogOutBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            ((TCPClient) (MainActivity.mTcpClient)).serverCommand =
                TCPClient.SERVER_COMMAND_e.STOP_COMM;
            ((TCPClient) (MainActivity.mTcpClient)).msgToServer =
                "DISCONNECT " + userEmail; // append email
            ((TCPClient) (MainActivity.mTcpClient)).DisconnectFromServer();
            Log.e("Disconnect", "Disconnect from server");
            finish();
          }
        });
  }
コード例 #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    imageView = (ImageView) findViewById(R.id.imageview);
    mRrootLayout = (ViewGroup) getWindow().getDecorView().getRootView();
    imageView.setOnTouchListener(this);

    sendAnimation = new PostCardFlipAnimation(this, imageView);
  }
コード例 #30
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    titleHeight = (int) (getResources().getDisplayMetrics().density * (50));
    activityHeight = this.getActivityHeight();

    locImg = (ImageView) findViewById(R.id.misp_img_content); // 获取控件
    // LoadImageUtil.getInstance().loadImage(locImg, imageInfo.getUrl());

    locImg.setOnTouchListener(this); // 设置触屏监听
    dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm); // 获取分辨率
  }