Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DisplayActivity extends AppCompatActivity {
private ImageView mDisplayImageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Expand All @@ -30,14 +30,14 @@ protected void onCreate(Bundle savedInstanceState) {
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
public boolean onCreateOptionsMenu(final Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_dislplay, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
public boolean onOptionsItemSelected(final MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MainActivity extends AppCompatActivity {
private RelativeLayout mContentRootView;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContentRootView = (RelativeLayout) findViewById(R.id.rl_content_root);
Expand All @@ -47,14 +47,14 @@ public void onClick(View view) {
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
public boolean onCreateOptionsMenu(final Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
public boolean onOptionsItemSelected(final MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
Expand Down Expand Up @@ -107,7 +107,7 @@ public void onTop(StickerView stickerView) {
/**
* 设置当前处于编辑模式的贴纸
*/
private void setCurrentEdit(StickerView stickerView) {
private void setCurrentEdit(final StickerView stickerView) {
if (mCurrentView != null) {
mCurrentView.setInEdit(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,71 +35,71 @@ public int getHorizonMirror() {
return horizonMirror;
}

public void setHorizonMirror(int horizonMirror) {
public void setHorizonMirror(final int horizonMirror) {
this.horizonMirror = horizonMirror;
}

public String getStickerURL() {
return stickerURL;
}

public void setStickerURL(String stickerURL) {
public void setStickerURL(final String stickerURL) {
this.stickerURL = stickerURL;
}

public long getStickerId() {
return stickerId;
}

public void setStickerId(long stickerId) {
public void setStickerId(final long stickerId) {
this.stickerId = stickerId;
}

public String getText() {
return text;
}

public void setText(String text) {
public void setText(final String text) {
this.text = text;
}

public float getxLocation() {
return xLocation;
}

public void setxLocation(float xLocation) {
public void setxLocation(final float xLocation) {
this.xLocation = xLocation;
}

public float getyLocation() {
return yLocation;
}

public void setyLocation(float yLocation) {
public void setyLocation(final float yLocation) {
this.yLocation = yLocation;
}

public float getDegree() {
return degree;
}

public void setDegree(float degree) {
public void setDegree(final float degree) {
this.degree = degree;
}

public float getScaling() {
return scaling;
}

public void setScaling(float scaling) {
public void setScaling(final float scaling) {
this.scaling = scaling;
}

public int getOrder() {
return order;
}

public void setOrder(int order) {
public void setOrder(final int order) {
this.order = order;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public class DensityUtils {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
public static int dip2px(final Context context, final float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}

/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(Context context, float pxValue) {
public static int px2dip(final Context context, final float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
Expand All @@ -34,15 +34,15 @@ public static int px2dip(Context context, float pxValue) {
* @param context
* @return
*/
public static int getScreenWidth(Context context) {
public static int getScreenWidth(final Context context) {
Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// Point p = new Point();
// display.getSize(p);//need api13
return display.getWidth();
}

public static int getScreenHeight(Context context) {
public static int getScreenHeight(final Context context) {
Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
// Point p = new Point();
Expand All @@ -57,7 +57,7 @@ public static int getScreenHeight(Context context) {
* @param context
* @return
*/
public static int getStatusBarHeight(Context context) {
public static int getStatusBarHeight(final Context context) {
Class<?> c = null;
Object obj = null;
Field field = null;
Expand All @@ -76,7 +76,7 @@ public static int getStatusBarHeight(Context context) {
return sbar;
}

public static int getNavigationBarHeight(Context context) {
public static int getNavigationBarHeight(final Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
Expand All @@ -91,7 +91,7 @@ public static int getNavigationBarHeight(Context context) {
* @param c
* @return
*/
public static long calculateLength(CharSequence c) {
public static long calculateLength(final CharSequence c) {
double len = 0;
for (int i = 0; i < c.length(); i++) {
int tmp = (int) c.charAt(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class FileUtils {

private static final String TEMP_DIR = "Abner/.TEMP";

public static FileUtils getInstance(Context context) {
public static FileUtils getInstance(final Context context) {
if (instance == null) {
synchronized (FileUtils.class) {
if (instance == null) {
Expand All @@ -43,7 +43,7 @@ public static FileUtils getInstance(Context context) {
* @param bm
* @return
*/
public static String saveBitmapToLocal(Bitmap bm, Context context) {
public static String saveBitmapToLocal(final Bitmap bm, final Context context) {
String path = null;
try {
File file = FileUtils.getInstance(context).createTempFile("IMG_", ".jpg");
Expand All @@ -69,7 +69,7 @@ public static String saveBitmapToLocal(Bitmap bm, Context context) {
* @return
* @throws java.io.IOException
*/
public File createTempFile(String prefix, String extension)
public File createTempFile(final String prefix, final String extension)
throws IOException {
File file = new File(getAppDirPath() + ".TEMP/" + prefix
+ System.currentTimeMillis() + extension);
Expand Down Expand Up @@ -130,7 +130,7 @@ private FileUtils() {
*
* @param dirName
*/
public File creatSDDir(String dirName) {
public File creatSDDir(final String dirName) {
File dir = new File(getLocalPath() + dirName);
dir.mkdirs();
return dir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ public class StickerView extends ImageView {
//水平镜像
private boolean isHorizonMirror = false;

public StickerView(Context context, AttributeSet attrs) {
public StickerView(final Context context, final AttributeSet attrs) {
super(context, attrs);
stickerId = 0;
init();
}

public StickerView(Context context) {
public StickerView(final Context context) {
super(context);
stickerId = 0;
init();
}

public StickerView(Context context, AttributeSet attrs, int defStyleAttr) {
public StickerView(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
stickerId = 0;
init();
Expand All @@ -129,7 +129,7 @@ private void init() {
}

@Override
protected void onDraw(Canvas canvas) {
protected void onDraw(final Canvas canvas) {
if (mBitmap != null) {


Expand Down Expand Up @@ -184,11 +184,11 @@ protected void onDraw(Canvas canvas) {
}

@Override
public void setImageResource(int resId) {
public void setImageResource(final int resId) {
setBitmap(BitmapFactory.decodeResource(getResources(), resId));
}

public void setBitmap(Bitmap bitmap) {
public void setBitmap(final Bitmap bitmap) {
matrix.reset();
mBitmap = bitmap;
setDiagonalLength();
Expand Down Expand Up @@ -258,7 +258,7 @@ private void initBitmaps() {
}

@Override
public boolean onTouchEvent(MotionEvent event) {
public boolean onTouchEvent(final MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
boolean handled = true;
switch (action) {
Expand Down Expand Up @@ -374,7 +374,7 @@ public boolean onTouchEvent(MotionEvent event) {
* @param model
* @return
*/
public StickerPropertyModel calculate(StickerPropertyModel model) {
public StickerPropertyModel calculate(final StickerPropertyModel model) {
float[] v = new float[9];
matrix.getValues(v);
// translation is simple
Expand Down Expand Up @@ -420,7 +420,7 @@ public StickerPropertyModel calculate(StickerPropertyModel model) {
*
* @return
*/
private boolean isInBitmap(MotionEvent event) {
private boolean isInBitmap(final MotionEvent event) {
float[] arrayOfFloat1 = new float[9];
this.matrix.getValues(arrayOfFloat1);
//左上角
Expand Down Expand Up @@ -460,7 +460,7 @@ private boolean isInBitmap(MotionEvent event) {
* @param y
* @return
*/
private boolean pointInRect(float[] xRange, float[] yRange, float x, float y) {
private boolean pointInRect(final float[] xRange, final float[] yRange, final float x, final float y) {
//四条边的长度
double a1 = Math.hypot(xRange[0] - xRange[1], yRange[0] - yRange[1]);
double a2 = Math.hypot(xRange[1] - xRange[2], yRange[1] - yRange[2]);
Expand Down Expand Up @@ -511,7 +511,7 @@ private boolean isInButton(MotionEvent event, Rect rect) {
* @param event
* @return
*/
private boolean isInResize(MotionEvent event) {
private boolean isInResize(final MotionEvent event) {
int left = -20 + this.dst_resize.left;
int top = -20 + this.dst_resize.top;
int right = 20 + this.dst_resize.right;
Expand All @@ -524,7 +524,7 @@ private boolean isInResize(MotionEvent event) {
*
* @param event
*/
private void midPointToStartPoint(MotionEvent event) {
private void midPointToStartPoint(final MotionEvent event) {
float[] arrayOfFloat = new float[9];
matrix.getValues(arrayOfFloat);
float f1 = 0.0f * arrayOfFloat[0] + 0.0f * arrayOfFloat[1] + arrayOfFloat[2];
Expand All @@ -539,7 +539,7 @@ private void midPointToStartPoint(MotionEvent event) {
*
* @param paramPointF
*/
private void midDiagonalPoint(PointF paramPointF) {
private void midDiagonalPoint(final PointF paramPointF) {
float[] arrayOfFloat = new float[9];
this.matrix.getValues(arrayOfFloat);
float f1 = 0.0F * arrayOfFloat[0] + 0.0F * arrayOfFloat[1] + arrayOfFloat[2];
Expand All @@ -558,7 +558,7 @@ private void midDiagonalPoint(PointF paramPointF) {
* @param event
* @return
*/
private float rotationToStartPoint(MotionEvent event) {
private float rotationToStartPoint(final MotionEvent event) {

float[] arrayOfFloat = new float[9];
matrix.getValues(arrayOfFloat);
Expand All @@ -574,15 +574,15 @@ private float rotationToStartPoint(MotionEvent event) {
* @param event
* @return
*/
private float diagonalLength(MotionEvent event) {
private float diagonalLength(final MotionEvent event) {
float diagonalLength = (float) Math.hypot(event.getX(0) - mid.x, event.getY(0) - mid.y);
return diagonalLength;
}

/**
* 计算双指之间的距离
*/
private float spacing(MotionEvent event) {
private float spacing(final MotionEvent event) {
if (event.getPointerCount() == 2) {
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
Expand All @@ -600,11 +600,11 @@ public interface OperationListener {
void onTop(StickerView stickerView);
}

public void setOperationListener(OperationListener operationListener) {
public void setOperationListener(final OperationListener operationListener) {
this.operationListener = operationListener;
}

public void setInEdit(boolean isInEdit) {
public void setInEdit(final boolean isInEdit) {
this.isInEdit = isInEdit;
invalidate();
}
Expand Down