public void testAllowDecoding() {
   DecodeThread t = new DecodeThread();
   mBitmapManager.cancelThreadDecoding(t);
   mBitmapManager.allowThreadDecoding(t);
   try {
     t.start();
     t.join();
   } catch (InterruptedException ex) {
   } finally {
     assertNotNull(t.getBitmap());
   }
 }
  public void testCanThreadDecoding() {
    Thread t = new DecodeThread();

    // By default all threads can decode.
    assertTrue(mBitmapManager.canThreadDecoding(t));

    // Disallow thread t to decode.
    mBitmapManager.cancelThreadDecoding(t);
    assertFalse(mBitmapManager.canThreadDecoding(t));

    // Allow thread t to decode again.
    mBitmapManager.allowThreadDecoding(t);
    assertTrue(mBitmapManager.canThreadDecoding(t));
  }
Beispiel #3
0
  private void onDrawInScrolling(Canvas canvas) {
    final ZLView view = ZLApplication.Instance().getCurrentView();

    //		final int w = getWidth();
    //		final int h = getMainAreaHeight();

    final AnimationProvider animator = getAnimationProvider();
    final AnimationProvider.Mode oldMode = animator.getMode();
    animator.doStep();
    if (animator.inProgress()) {
      animator.draw(canvas);
      if (animator.getMode().Auto) {
        postInvalidate();
      }
      drawFooter(canvas);
    } else {
      switch (oldMode) {
        case AnimatedScrollingForward:
          {
            final ZLView.PageIndex index = animator.getPageToScrollTo();
            myBitmapManager.shift(index == ZLView.PageIndex.next);
            view.onScrollingFinished(index);
            ZLApplication.Instance().onRepaintFinished();
            break;
          }
        case AnimatedScrollingBackward:
          view.onScrollingFinished(ZLView.PageIndex.current);
          break;
      }
      onDrawStatic(canvas);
    }
  }
Beispiel #4
0
 private void onDrawStatic(final Canvas canvas) {
   myBitmapManager.setSize(getWidth(), getMainAreaHeight());
   canvas.drawBitmap(myBitmapManager.getBitmap(ZLView.PageIndex.current), 0, 0, myPaint);
   drawFooter(canvas);
   new Thread() {
     @Override
     public void run() {
       final ZLView view = ZLApplication.Instance().getCurrentView();
       final ZLAndroidPaintContext context =
           new ZLAndroidPaintContext(
               canvas,
               getWidth(),
               getMainAreaHeight(),
               view.isScrollbarShown() ? getVerticalScrollbarWidth() : 0);
       view.preparePage(context, ZLView.PageIndex.next);
     }
   }.start();
 }
  public void testThreadDecoding() {
    DecodeThread t1 = new DecodeThread();
    DecodeThread t2 = new DecodeThread();
    mBitmapManager.allowThreadDecoding(t1);
    mBitmapManager.cancelThreadDecoding(t2);
    t1.start();
    t2.start();

    try {
      t1.join();
      t2.join();
    } catch (InterruptedException ex) {
    } finally {
      assertTrue(mBitmapManager.canThreadDecoding(t1));
      assertNotNull(t1.getBitmap());
      assertFalse(mBitmapManager.canThreadDecoding(t2));
      assertNull(t2.getBitmap());
    }
  }
Beispiel #6
0
 private BitmapFactory.Options snifBitmapOptions() {
   ParcelFileDescriptor input = getPFD();
   if (input == null) return null;
   try {
     BitmapFactory.Options options = new BitmapFactory.Options();
     options.inJustDecodeBounds = true;
     BitmapManager.instance().decodeFileDescriptor(input.getFileDescriptor(), options);
     return options;
   } finally {
     Util.closeSilently(input);
   }
 }
 @Override
 public void setUp() {
   mContext = getContext();
   mBitmapManager = BitmapManager.instance();
   mImageList =
       ImageManager.makeImageList(
           mContext.getContentResolver(),
           ImageManager.DataLocation.ALL,
           ImageManager.INCLUDE_IMAGES,
           ImageManager.SORT_DESCENDING,
           null);
   mImage = mImageList.getImageAt(0);
 }
 public void stop() {
     synchronized (mQueue) {
         mDone = true;
         mQueue.notifyAll();
     }
     if (mDecodeThread != null) {
         try {
             Thread t = mDecodeThread;
             BitmapManager.instance().cancelThreadDecoding(t);
             MediaStore.Images.Thumbnails.cancelThumbnailRequest(mCr, -1);
             t.join();
             mDecodeThread = null;
         } catch (InterruptedException ex) {
             // so now what?
         }
     }
 }
Beispiel #9
0
 @Override
 public void reset() {
   myBitmapManager.reset();
 }
 public void testSingleton() {
   BitmapManager manager = BitmapManager.instance();
   assertNotNull(manager);
   assertNotNull(mBitmapManager);
   assertSame(manager, mBitmapManager);
 }
Beispiel #11
0
  @Override
  protected void onPause() {

    super.onPause();
    BitmapManager.instance().cancelThreadDecoding(mDecodingThreads);
  }