Ошибка:
12-31 14:10:47.133 3473 3473 D WakeAnimationView: [AnimationView] keyCode:0
12-31 14:10:47.133 3473 3473 D WakeAnimationView: [init] begin
12-31 14:10:47.133 3473 3473 D WakeAnimationView: [startAnimation] begin
12-31 14:10:47.134 3473 3473 D WakeAnimationView: [startAnimation] end
12-31 14:10:47.134 3473 3473 D WakeAnimationView: [init] end
12-31 14:10:47.134 3473 3473 D WakeAnimationView: [AnimationView] end
12-31 14:10:47.134 3473 3473 D WakeMainActivity: [onCreate] end
12-31 14:10:47.135 3473 3489 E AndroidRuntime: FATAL EXCEPTION: Thread-2
12-31 14:10:47.135 3473 3489 E AndroidRuntime: Process: com.wheatek.wakegesture, PID: 3473
12-31 14:10:47.135 3473 3489 E AndroidRuntime: java.lang.IllegalArgumentException: width must be > 0
12-31 14:10:47.135 3473 3489 E AndroidRuntime: at android.graphics.Bitmap.checkWidthHeight(Bitmap.java:410)
12-31 14:10:47.135 3473 3489 E AndroidRuntime: at android.graphics.Bitmap.createBitmap(Bitmap.java:732)
12-31 14:10:47.135 3473 3489 E AndroidRuntime: at com.wheatek.wakegesture.view.AnimationView.run(AnimationView.java:201)
12-31 14:10:47.135 3473 3489 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761)
12-31 14:10:47.137 717 732 W ActivityManager: Force finishing activity com.wheatek.wakegesture/.MainActivity
12-31 14:10:47.142 717 732 W ActivityManager: Force finishing activity com.android.settings/.Settings$GestureSettingsActivity
файлы:
Bitmap.java
AnimationView.java:
package com.wheatek.wakegesture.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import com.wheatek.wakegesture.R;
import com.wheatek.wakegesture.StartApps;
public class AnimationView extends View implements Runnable {
private boolean is_startAnimationTwo = false;
private Bitmap mBitmap = null;
private int mBitmapHeight = 0;
private int mBitmapWidth = 0;
private Context mContext;
private int mHeightLen = 5;
private int mKeyCode = 0;
private int mLeft = 0;
private Paint mPaint = null;
private float mPersent = 0.0f;
private Bitmap mTempBitmap = null;
private int mTop = 0;
private int mWidthLen = 4;
private int sleep_time;
public AnimationView(Context context, int keyCode) {
super(context);
Log.d("WakeAnimationView", "[AnimationView] keyCode:" + keyCode);
this.mContext = context;
this.mKeyCode = keyCode;
setWillNotDraw(false);
this.is_startAnimationTwo = context.getResources().getBoolean(R.bool.is_start_animation_two);
init(context, keyCode);
Log.d("WakeAnimationView", "[AnimationView] end");
}
private void init(Context context, int keyCode) {
Log.d("WakeAnimationView", "[init] begin");
this.mWidthLen = context.getResources().getInteger(R.integer.bitmap_width_length);
this.mHeightLen = context.getResources().getInteger(R.integer.bitmap_height_length);
this.sleep_time = context.getResources().getInteger(R.integer.sleep_time);
this.mPaint = new Paint();
this.mPaint.setAntiAlias(true);
startAnimation(keyCode);
new Thread(this).start();
Log.d("WakeAnimationView", "[init] end");
}
private void startAnimation(int keyCode) {
Log.d("WakeAnimationView", "[startAnimation] begin");
WindowManager wm = (WindowManager) this.mContext.getSystemService("window");
int centerX = wm.getDefaultDisplay().getWidth() / 2;
int centerY = wm.getDefaultDisplay().getHeight() / 2;
Bitmap bitmap;
switch (keyCode) {
case 19:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_up2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_up)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 20:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_down2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_down)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 21:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_left2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_left)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 22:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_right2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_right)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 31:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_c2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_c)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 33:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_e2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_e)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 34:
initDrawable(((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_cusp)).getBitmap(), centerX, centerY);
break;
case 41:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_m2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_m)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 43:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_o2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_o)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 47:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_s2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_s)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 50:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_v2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_v)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 51:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_w2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_w)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
case 54:
if (this.is_startAnimationTwo) {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_z2)).getBitmap();
} else {
bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.gesture_wake_z)).getBitmap();
}
initDrawable(bitmap, centerX, centerY);
break;
}
Log.d("WakeAnimationView", "[startAnimation] end");
}
protected void onDraw(Canvas canvas) {
Log.d("WakeAnimationView", "[onDraw]");
if (!(canvas == null || this.mTempBitmap == null || this.mPaint == null)) {
canvas.drawBitmap(this.mTempBitmap, (float) this.mLeft, (float) this.mTop, this.mPaint);
}
super.onDraw(canvas);
}
private void initDrawable(Bitmap bitmap, int centerX, int centerY) {
Log.d("WakeAnimationView", "[initDrawable] begin");
this.mBitmap = bitmap;
this.mBitmapWidth = bitmap.getWidth();
this.mBitmapHeight = bitmap.getHeight();
this.mPersent = Float.parseFloat(this.mContext.getResources().getString(R.string.persent));
this.mLeft = Math.abs(centerX - ((int) ((this.mPersent * ((float) this.mBitmapWidth)) / ((float) (this.mWidthLen * 2)))));
this.mTop = Math.abs(centerY - ((int) ((this.mPersent * ((float) this.mBitmapHeight)) / ((float) (this.mHeightLen * 2)))));
ScreenOn();
Log.d("WakeAnimationView", "[initDrawable] end");
}
private void ScreenOn() {
Log.d("WakeAnimationView", "[ScreenOn]");
PowerManager pm = (PowerManager) getContext().getSystemService("power");
if (!pm.isScreenOn()) {
pm.wakeUp(SystemClock.uptimeMillis());
}
}
public void run() {
if (this.mContext.getResources().getBoolean(17956895) || !(this.mKeyCode == 21 || this.mKeyCode == 22)) {
for (int i = 0; i < this.mHeightLen; i++) {
for (int j = 0; j < this.mWidthLen; j++) {
try {
Matrix matrix = new Matrix();
matrix.postScale(this.mPersent, this.mPersent);
this.mTempBitmap = Bitmap.createBitmap(this.mBitmap, (this.mBitmapWidth / this.mWidthLen) * j, (this.mBitmapHeight / this.mHeightLen) * i, this.mBitmapWidth / this.mWidthLen, this.mBitmapHeight / this.mHeightLen, matrix, true);
Thread.sleep((long) this.sleep_time);
} catch (InterruptedException e) {
e.printStackTrace();
}
postInvalidate();
}
}
}
Log.d("WakeAnimationView", "[StartApps]:" + this.mKeyCode);
StartApps.startFunction(this.mContext, this.mKeyCode);
}
}
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Виртуальный выделенный сервер (VDS) становится отличным выбором
Есть приложение, которое должно отображать разные изображения в jsp в зависимости от атрибута в сессииКак нужно составить jsp и сам servlet, чтобы...
В качестве упражнения делаю простое приложение по заказу пиццы - выбор размера (влияет на цену) плюс дополнительный топпинг (тоже влияет на цену)
В своем приложении javafx, который я создаю в IDE IntelliJ IDEA, мне нужно добавить картинкиДля заливки фигуры, фон и т