random click and gesture for android 7.0+!!!

This commit is contained in:
hyb1996
2017-05-16 21:40:23 +08:00
parent ec98d75d3b
commit c4ec951a10
42 changed files with 757 additions and 564 deletions

View File

@@ -0,0 +1,46 @@
package com.stardust.concurrent;
/**
* Created by Stardust on 2017/5/8.
*/
public class VolatileBox<T> {
private volatile T mValue;
public VolatileBox() {
}
public VolatileBox(T value) {
set(value);
}
public T get() {
return mValue;
}
public void set(T value) {
mValue = value;
}
public void setAndNotify(T value) {
mValue = value;
synchronized (this) {
notify();
}
}
public T blockedGet() {
synchronized (this) {
try {
this.wait();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
return mValue;
}
}

View File

@@ -3,33 +3,60 @@ package com.stardust.util;
import android.app.Activity;
import android.util.DisplayMetrics;
import com.stardust.pio.PFile;
/**
* Created by Stardust on 2017/4/26.
*/
public class ScreenMetrics {
private static int screenHeight;
private static int screenWidth;
private static int deviceScreenHeight;
private static int deviceScreenWidth;
private static boolean initialized = false;
public static void initIfNeeded(Activity activity) {
if (!initialized) {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenHeight = metrics.heightPixels;
screenWidth = metrics.widthPixels;
deviceScreenHeight = metrics.heightPixels;
deviceScreenWidth = metrics.widthPixels;
initialized = true;
}
}
public static int getScreenHeight() {
return screenHeight;
public static int getDeviceScreenHeight() {
return deviceScreenHeight;
}
public static int getScreenWidth() {
return screenWidth;
public static int getDeviceScreenWidth() {
return deviceScreenWidth;
}
private int mScreenWidth;
private int mScreenHeight;
public void setScreenWidth(int screenWidth) {
mScreenWidth = screenWidth;
}
public void setScreenHeight(int screenHeight) {
mScreenHeight = screenHeight;
}
public int scaleX(int x) {
if (mScreenWidth == 0 || !initialized)
return x;
return x * deviceScreenWidth / mScreenWidth;
}
public int scaleY(int y) {
if (mScreenHeight == 0 || !initialized)
return y;
return y * deviceScreenHeight / mScreenHeight;
}
public void setScreenMetrics(int width, int height) {
mScreenWidth = width;
mScreenHeight = height;
}
}