@Override
        public void run() {
          Looper mainLooper = Looper.getMainLooper(); // �õ����߳�loop
          mHandler = new MyHandler(mainLooper); // �������̵߳�handler

          int albumSize = PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).size();
          for (int i = 0; i < albumSize && !Thread.interrupted(); i++) {
            bm = decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(i)); // ȡ��ͼƬ
            sendMessage(bm, i);
          }
        }
  /**
   * (�� Javadoc,��д�ķ���) @Title: onRestart @Description:
   *
   * @see android.app.Activity#onRestart()
   */
  @Override
  protected void onRestart() {

    if (PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).size() == 0) {
      finish();
    }
    super.onRestart();
  }
예제 #3
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();
  }
예제 #4
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;
  }
예제 #5
0
  /** @Method: deleteCurrentPhoto @Description: ɾ��ǰ����Ƭ */
  private void deleteCurrentPhoto() throws Exception {
    // �����ݿ��е�ID�Ż�ȡURI
    Uri uri =
        ContentUris.withAppendedId(
            Media.EXTERNAL_CONTENT_URI,
            PhotoAlbumActivity.AlbumsFloderID.get(AlbumName).get(currentNum));
    // ��URIɾ��ͼƬ
    getContentResolver().delete(uri, null, null);

    // ����adaper
    InLocalSmallPhotoActivity.localGridAdapter.mImageList.remove(currentNum);
    InLocalSmallPhotoActivity.localGridAdapter.notifyDataSetChanged();

    if (photoCount == 1) {;
    } else if (photoCount == 2) {
      if (currentNum == 0) {
        BitmapList[firstView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(1), 400);
        BitmapList[middleView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(1), 400);
        BitmapList[lastView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(1), 400);
      } else {
        BitmapList[firstView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
        BitmapList[middleView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
        BitmapList[lastView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
      }
    } else {
      // ����flipper��������
      if (currentNum == photoCount - 1) {
        BitmapList[firstView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
        BitmapList[middleView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(1), 400);
      } else if (currentNum == photoCount - 2) {
        BitmapList[firstView] =
            decodeBitmap(
                PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum + 1), 400);
        BitmapList[middleView] =
            decodeBitmap(PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(0), 400);
      } else {
        BitmapList[firstView] =
            decodeBitmap(
                PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum + 1), 400);
        BitmapList[middleView] =
            decodeBitmap(
                PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(currentNum + 2), 400);
      }
      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);
    }

    // �����ڴ��е����
    PhotoAlbumActivity.AlbumsFloderID.get(AlbumName).remove(currentNum);
    PhotoAlbumActivity.AlbumsFloderName.get(AlbumName).remove(currentNum);
    PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).remove(currentNum);
    PhotoAlbumActivity.AlbumsFloderTime.get(AlbumName).remove(currentNum);
    PhotoAlbumActivity.AlbumsFloderTitle.get(AlbumName).remove(currentNum);

    // �л�����һ��ͼƬ
    ImageViewList.get(firstView).destroyDrawingCache();
    ImageViewList.get(middleView).destroyDrawingCache();
    ImageViewList.get(firstView).setImageBitmap(BitmapList[firstView]);
    ImageViewList.get(middleView).setImageBitmap(BitmapList[lastView]);

    photoCount--;
    once = true;
    if (photoCount == 0) finish();
    else titleTextView.setText(PhotoAlbumActivity.AlbumsFloderTitle.get(AlbumName).get(currentNum));
  }