@Override public void run() { super.run(); // float h2 = (float)myCanvasView.getHeight()/2.0f; // float w2 = (float)myCanvasView.getWidth()/2.0f; // float h2 = clip.height()/2.0f; // float w2 = clip.width()/2.0f; float rotstep = (deg - rotation) / 20.0f; float scalestep = (scl - scale) / 20.0f; for (int i = 0; i < 20; i++) { matrixLock.lock(); matrix.reset(); // linear interpolation // rotation += rotstep; // matrix.setRotate(rotation,w2,h2); scale += scalestep; matrix.postScale(scale, scale); matrixLock.unlock(); myCanvasView.postInvalidate(); try { sleep(30); } catch (InterruptedException e) { Log.i(TAG, "interrupted", e); break; } } }
private boolean tryLoadBitmap(String bmpFilename) throws InterruptedException { try { bmpLock.lock(); bmp = BitmapFactory.decodeStream(assets.open(bmpFilename)); bmpLock.unlock(); if (bmp == null) { AlertDialog a = new AlertDialog.Builder(getContext()).create(); a.setMessage("Cannot load image"); a.show(); return false; } myCanvasView.postInvalidate(); sleep(25); } catch (IOException e) { e.printStackTrace(); } return true; }