public void showConfirmationField() {
   if (!firstIsShown) {
     return;
   }
   flipper.setInAnimation(pushLeftIn);
   flipper.setOutAnimation(pushLeftOut);
   flip();
 }
 public void showNewPasswordField() {
   if (firstIsShown) {
     return;
   }
   flipper.setInAnimation(pushRightIn);
   flipper.setOutAnimation(pushRightOut);
   flip();
 }
 private void flip() {
   if (firstIsShown) {
     firstIsShown = false;
     container2.removeAllViews();
     container2.addView(secondView);
   } else {
     firstIsShown = true;
     container1.removeAllViews();
     container1.addView(firstView);
   }
   flipper.showNext();
 }
Ejemplo n.º 4
0
  /** @Method: initCompenents @Description: ��ʼ����������ͱ��� */
  private void initCompenents() throws Exception {

    titleButtonReturn = (ImageButton) findViewById(R.id.upfilpperbutton1);
    titleButtonShare = (ImageButton) findViewById(R.id.upfilpperbutton3);
    titleButtonDelete = (ImageButton) findViewById(R.id.upfilpperbutton2);
    titleButtonDelete.setBackgroundColor(Color.TRANSPARENT);
    titleTextView = (TextView) findViewById(R.id.upfilppertextview);
    titleTextView.setText(PhotoAlbumActivity.AlbumsFloderTitle.get(AlbumName).get(currentNum));
    titleParent = (FrameLayout) findViewById(R.id.upfilpperparent);
    titleParent.setVisibility(View.INVISIBLE);

    // ������һ��Activity
    titleButtonReturn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    // ɾ��ǰ��Ƭ
    titleButtonDelete.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            sureToDelete();
          }
        });

    // ���?ǰ��Ƭ
    titleButtonShare.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            shareToWeiBo(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum));
          }
        });

    photoCount = PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).size();
    middleView = 1;
    lastView = 2;
    firstView = 0;

    BitmapList = new Bitmap[3];

    ImageViewList = new ArrayList<ImageView>();
    for (int i = 0; i < 3; i++) ImageViewList.add(new ImageView(this));

    BitmapList[0] =
        decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum), 400);
    ImageViewList.get(0).setImageBitmap(BitmapList[0]);

    if (currentNum == photoCount - 1)
      BitmapList[1] = decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
    else
      BitmapList[1] =
          decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum + 1), 400);
    ImageViewList.get(1).setImageBitmap(BitmapList[1]);

    if (currentNum == 0)
      BitmapList[2] =
          decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(photoCount - 1), 400);
    else
      BitmapList[2] =
          decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum - 1), 400);
    ImageViewList.get(2).setImageBitmap(BitmapList[2]);

    flipper.addView(ImageViewList.get(0));
    flipper.addView(ImageViewList.get(1));
    flipper.addView(ImageViewList.get(2));

    System.gc();
    VMRuntime.getRuntime().setTargetHeapUtilization(0.75f);

    handler = new Handler();
  }
Ejemplo n.º 5
0
  /**
   * (�� Javadoc,��д�ķ���) @Title: onFling @Description: �����л�ͼ
   *
   * @param e1
   * @param e2
   * @param velocityX
   * @param velocityY
   * @return
   * @see android.view.GestureDetector.OnGestureListener#onFling(android.view.MotionEvent,
   *     android.view.MotionEvent, float, float)
   */
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    if (!touchEnable) return false;
    touchEnable = false;
    handler.postDelayed(runnable, 500);

    try {
      if (e1.getX() - e2.getX() > 120) {
        // ��һ�β�ִ�У��Ժ�ÿ�ζ�ִ��
        if (!once) {
          if (BitmapList[middleView].isRecycled() == false) // ���û�л���
          BitmapList[middleView].recycle();
          System.gc();

          // �ϴ������󻬶�
          if (LeftIsTrue) {
            if (currentNum == photoCount - 1)
              BitmapList[middleView] =
                  decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
            else
              BitmapList[middleView] =
                  decodeBitmap(
                      PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum + 1), 400);

          }
          // �ϴ����һ���
          else {
            if (currentNum == 0)
              BitmapList[middleView] =
                  decodeBitmap(
                      PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(photoCount - 1), 400);
            else
              BitmapList[middleView] =
                  decodeBitmap(
                      PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum - 1), 400);
          }
          ImageViewList.get(middleView).destroyDrawingCache();
          ImageViewList.get(middleView).setImageBitmap(BitmapList[middleView]);
        }

        // ���������¼��ǰ״̬
        if (firstView == 2) firstView = 0;
        else firstView++;

        if (middleView == 2) middleView = 0;
        else middleView++;

        if (lastView == 2) lastView = 0;
        else lastView++;

        if (currentNum == photoCount - 1) currentNum = 0;
        else currentNum++;

        once = false;
        LeftIsTrue = true;

        flipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));
        flipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_out));
        flipper.showNext();

      } else if (e1.getX() - e2.getX() < -120) {
        if (!once) {
          if (BitmapList[lastView].isRecycled() == false) // ���û�л���
          BitmapList[lastView].recycle();
          System.gc();

          if (LeftIsTrue) {
            if (currentNum == photoCount - 1)
              BitmapList[lastView] =
                  decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
            else
              BitmapList[lastView] =
                  decodeBitmap(
                      PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum + 1), 400);

          } else {
            if (currentNum == 0)
              BitmapList[lastView] =
                  decodeBitmap(
                      PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(photoCount - 1), 400);
            else
              BitmapList[lastView] =
                  decodeBitmap(
                      PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum - 1), 400);
          }

          ImageViewList.get(lastView).destroyDrawingCache();
          ImageViewList.get(lastView).setImageBitmap(BitmapList[lastView]);
        }

        if (firstView == 0) firstView = 2;
        else firstView--;

        if (middleView == 0) middleView = 2;
        else middleView--;

        if (lastView == 0) lastView = 2;
        else lastView--;

        if (currentNum == 0) currentNum = photoCount - 1;
        else currentNum--;

        LeftIsTrue = false;
        once = false;

        flipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_right_in));
        flipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_right_out));
        flipper.showPrevious();
      }

      titleTextView.setText(PhotoAlbumActivity.AlbumsFloderTitle.get(AlbumName).get(currentNum));
    } catch (Exception e) {
      e.printStackTrace();
    }

    return false;
  }