mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
package com.adins.mss.foundation.sync.api;
|
||||
|
||||
import com.adins.mss.dao.Holiday;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SynchronizeResponseHoliday extends MssResponseType {
|
||||
@SerializedName("listSync")
|
||||
private List<Holiday> listSync;
|
||||
|
||||
public List<Holiday> getListSync() {
|
||||
return listSync;
|
||||
}
|
||||
|
||||
public void setListSync(List<Holiday> listSync) {
|
||||
this.listSync = listSync;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.adins.mss.coll.models;
|
||||
|
||||
import com.adins.mss.dao.DepositReportD;
|
||||
import com.adins.mss.dao.DepositReportH;
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Aditya Purwa on 3/4/2015.
|
||||
*/
|
||||
public class DepositReportRequest extends MssRequestType {
|
||||
@SerializedName("reportHeader")
|
||||
private DepositReportH reportHeader;
|
||||
@SerializedName("listReportDetail")
|
||||
private List<DepositReportD> listReportDetail;
|
||||
|
||||
public DepositReportH getReportHeader() {
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
public void setReportHeader(DepositReportH reportHeader) {
|
||||
this.reportHeader = reportHeader;
|
||||
}
|
||||
|
||||
public List<DepositReportD> getListReportDetail() {
|
||||
return listReportDetail;
|
||||
}
|
||||
|
||||
public void setListReportDetail(List<DepositReportD> listReportDetail) {
|
||||
this.listReportDetail = listReportDetail;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
<files-path name="files" path="."/>
|
||||
</paths>
|
|
@ -0,0 +1,9 @@
|
|||
package com.adins.mss.coll.interfaces.callback;
|
||||
|
||||
/**
|
||||
* Created by kusnendi.muhamad on 31/07/2017.
|
||||
*/
|
||||
|
||||
public interface TaskReportCallback {
|
||||
public void OnDisplayLocalData(Object o);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.adins.mss.base.todolist.todayplanrepository;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequestStartVisit extends MssRequestType {
|
||||
@SerializedName("is_start_visit")
|
||||
private String isStartVisit;
|
||||
@SerializedName("activity_list")
|
||||
private List<PlanTaskSequence> activityList;
|
||||
|
||||
public List<PlanTaskSequence> getActivityList() {
|
||||
return activityList;
|
||||
}
|
||||
|
||||
public void setActivityList(List<PlanTaskSequence> activityList) {
|
||||
this.activityList = activityList;
|
||||
}
|
||||
|
||||
public String getIsStartVisit() {
|
||||
return isStartVisit;
|
||||
}
|
||||
|
||||
public void setIsStartVisit(boolean isStartVisit) {
|
||||
this.isStartVisit = isStartVisit?"1":"0";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,343 @@
|
|||
package com.adins.mss.foundation.questiongenerator.form;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.dynamicform.DynamicFormActivity;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FingerDrawingActivity extends Activity implements OnClickListener {
|
||||
public static final int IMG_SAVE_QUALITY = 80;
|
||||
private static final int PAINT_MENU_ID = Menu.FIRST;
|
||||
private static final int ERASE_MENU_ID = Menu.FIRST + 1;
|
||||
private static final int CLEAR_MENU_ID = Menu.FIRST + 2;
|
||||
private static final int SAVE_MENU_ID = Menu.FIRST + 3;
|
||||
private static final int BACK_MENU_ID = Menu.FIRST + 4;
|
||||
private DrawCanvas mView;
|
||||
private int colorbg = Color.BLACK;
|
||||
private int colorpen = Color.WHITE;
|
||||
private LinearLayout canvasLayout;
|
||||
private Button btnClear;
|
||||
private Button btnEdit;
|
||||
private Button btnErase;
|
||||
private Button btnSave;
|
||||
private Paint mPaint;
|
||||
private QuestionBean bean;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.drawing_layout);
|
||||
mView = new DrawCanvas(this);
|
||||
canvasLayout = (LinearLayout) findViewById(R.id.canvasLayout);
|
||||
canvasLayout.addView(mView);
|
||||
btnClear = (Button) findViewById(R.id.btnClear);
|
||||
btnEdit = (Button) findViewById(R.id.btnEdit);
|
||||
btnErase = (Button) findViewById(R.id.btnErase);
|
||||
btnSave = (Button) findViewById(R.id.btnSave);
|
||||
btnClear.setOnClickListener(this);
|
||||
btnEdit.setOnClickListener(this);
|
||||
btnErase.setOnClickListener(this);
|
||||
btnSave.setOnClickListener(this);
|
||||
// setContentView(mView);
|
||||
|
||||
mPaint = new Paint();
|
||||
defaultPaint();
|
||||
|
||||
//---change to portrait mode---
|
||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
|
||||
Toast.makeText(this, getString(R.string.infoDraw), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
|
||||
super.onPause();
|
||||
Global.haveLogin = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
Context context = newBase;
|
||||
Locale locale;
|
||||
try{
|
||||
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} catch (Exception e) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} finally {
|
||||
super.attachBaseContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void defaultPaint() {
|
||||
btnEdit.setBackgroundResource(R.drawable.mediumpriority_background);
|
||||
btnErase.setBackgroundResource(R.drawable.button_background);
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setDither(true);
|
||||
mPaint.setColor(colorpen);
|
||||
mPaint.setStyle(Paint.Style.STROKE);
|
||||
mPaint.setStrokeJoin(Paint.Join.ROUND);
|
||||
mPaint.setStrokeCap(Paint.Cap.ROUND);
|
||||
mPaint.setStrokeWidth(10);
|
||||
}
|
||||
|
||||
public void setColorPen(int color) {
|
||||
mPaint.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
/*menu.add(0, PAINT_MENU_ID, 0, getString(R.string.mnPaint)).setShortcut('1', 'p');
|
||||
menu.add(0, ERASE_MENU_ID, 0, getString(R.string.mnErase)).setShortcut('2', 'e');
|
||||
menu.add(0, CLEAR_MENU_ID, 0, getString(R.string.mnClear)).setShortcut('3', 'c');
|
||||
menu.add(0, SAVE_MENU_ID, 0, getString(R.string.mnSave)).setShortcut('4', 's');
|
||||
menu.add(0, BACK_MENU_ID, 0, getString(R.string.btnBack)).setShortcut('5', 'x');*/
|
||||
|
||||
/****
|
||||
* Is this the mechanism to extend with filter effects? Intent intent =
|
||||
* new Intent(null, getIntent().getData());
|
||||
* intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
|
||||
* menu.addIntentOptions( Menu.ALTERNATIVE, 0, new ComponentName(this,
|
||||
* NotesList.class), null, intent, 0, null);
|
||||
*****/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
mPaint.setXfermode(null);
|
||||
mPaint.setAlpha(0xFF);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case PAINT_MENU_ID:
|
||||
defaultPaint();
|
||||
return true;
|
||||
case ERASE_MENU_ID:
|
||||
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
mPaint.setStrokeJoin(Paint.Join.ROUND);
|
||||
mPaint.setStrokeCap(Paint.Cap.SQUARE);
|
||||
mPaint.setStrokeWidth(30);
|
||||
return true;
|
||||
case CLEAR_MENU_ID:
|
||||
mView.clear();
|
||||
defaultPaint();
|
||||
return true;
|
||||
case SAVE_MENU_ID:
|
||||
byte[] b = mView.getByteBitmap();
|
||||
|
||||
DynamicFormActivity.saveImage(b);
|
||||
|
||||
// set thumbnail
|
||||
if (DynamicFormActivity.getThumbInFocus() != null) {
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(b, 0, b.length);
|
||||
|
||||
int[] res = Tool.getThumbnailResolution(bm.getWidth(), bm.getHeight());
|
||||
Bitmap thumbnail = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
|
||||
DynamicFormActivity.setThumbInFocusImage(thumbnail);
|
||||
}
|
||||
|
||||
FingerDrawingActivity.this.finish();
|
||||
return true;
|
||||
case BACK_MENU_ID:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mPaint.setXfermode(null);
|
||||
mPaint.setAlpha(0xFF);
|
||||
int id = v.getId();
|
||||
if (id == R.id.btnClear) {
|
||||
mView.clear();
|
||||
defaultPaint();
|
||||
} else if (id == R.id.btnErase) {
|
||||
btnErase.setBackgroundResource(R.drawable.mediumpriority_background);
|
||||
btnEdit.setBackgroundResource(R.drawable.button_background);
|
||||
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
// mPaint.setColor(colorbg);
|
||||
mPaint.setStrokeJoin(Paint.Join.ROUND);
|
||||
mPaint.setStrokeCap(Paint.Cap.SQUARE);
|
||||
mPaint.setStrokeWidth(30);
|
||||
} else if (id == R.id.btnSave) {
|
||||
try {
|
||||
byte[] b = mView.getByteBitmap();
|
||||
DynamicFormActivity.saveImage(b);
|
||||
// set thumbnail
|
||||
if (DynamicFormActivity.getThumbInFocus() != null) {
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(b, 0, b.length);
|
||||
|
||||
int[] res = Tool.getThumbnailResolution(bm.getWidth(), bm.getHeight());
|
||||
Bitmap thumbnail = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
|
||||
DynamicFormActivity.setThumbInFocusImage(thumbnail);
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
Toast.makeText(getApplicationContext(), "Processing failed, Out of memory", Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
FingerDrawingActivity.this.finish();
|
||||
} else if (id == R.id.btnEdit) {
|
||||
defaultPaint();
|
||||
}
|
||||
}
|
||||
|
||||
public class DrawCanvas extends View {
|
||||
private static final float TOUCH_TOLERANCE = 4;
|
||||
private Bitmap mBitmap;
|
||||
private Canvas mCanvas;
|
||||
private Path mPath;
|
||||
private Paint mBitmapPaint;
|
||||
private float mX, mY;
|
||||
|
||||
public DrawCanvas(Context c) {
|
||||
super(c);
|
||||
// --
|
||||
DisplayMetrics displaymetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
||||
int height = displaymetrics.heightPixels;
|
||||
int widht = displaymetrics.widthPixels;
|
||||
|
||||
try {
|
||||
mBitmap = Bitmap.createBitmap(widht, height, Bitmap.Config.RGB_565);
|
||||
mCanvas = new Canvas(mBitmap);
|
||||
mPath = new Path();
|
||||
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
|
||||
|
||||
byte[] savedImage = null;
|
||||
try {
|
||||
savedImage = DynamicFormActivity.getQuestionInFocus().getImgAnswer();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
|
||||
}
|
||||
|
||||
if (savedImage != null && savedImage.length > 0) {
|
||||
Bitmap source = BitmapFactory.decodeByteArray(savedImage, 0, savedImage.length);
|
||||
mCanvas.drawBitmap(source, 0, 0, mBitmapPaint);
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.drawColor(colorbg);
|
||||
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
}
|
||||
|
||||
private void touch_start(float x, float y) {
|
||||
mPath.reset();
|
||||
mPath.moveTo(x, y);
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
|
||||
private void touch_move(float x, float y) {
|
||||
float dx = Math.abs(x - mX);
|
||||
float dy = Math.abs(y - mY);
|
||||
if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
|
||||
mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
}
|
||||
|
||||
private void touch_up() {
|
||||
mPath.lineTo(mX, mY);
|
||||
// commit the path to our offscreen
|
||||
mCanvas.drawPath(mPath, mPaint);
|
||||
// kill this so we don't double draw
|
||||
mPath.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
touch_start(x, y);
|
||||
invalidate();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
touch_move(x, y);
|
||||
invalidate();
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
touch_up();
|
||||
invalidate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----
|
||||
public void clear() {
|
||||
if (mCanvas != null) {
|
||||
mCanvas.drawColor(colorbg);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getByteBitmap() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
mBitmap.compress(Bitmap.CompressFormat.JPEG, IMG_SAVE_QUALITY, baos);
|
||||
byte[] b = baos.toByteArray();
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.adins.mss.foundation.sync;
|
||||
|
||||
import com.adins.mss.base.BaseCommunicationModel;
|
||||
|
||||
/**
|
||||
* JSON for Synchronize process
|
||||
*
|
||||
* @author glen.iglesias
|
||||
* @deprecated as of 17 Dec 2014, as BaseCommunicationModel
|
||||
*/
|
||||
public class SynchronizeRequestModel extends BaseCommunicationModel {
|
||||
|
||||
private String action;
|
||||
private String lastupdate;
|
||||
|
||||
public SynchronizeRequestModel() {
|
||||
}
|
||||
|
||||
public SynchronizeRequestModel(boolean useDefault, String table, String lastupdate) {
|
||||
super(useDefault);
|
||||
this.action = table;
|
||||
this.lastupdate = lastupdate;
|
||||
}
|
||||
|
||||
public String getTable() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setTable(String table) {
|
||||
this.action = table;
|
||||
}
|
||||
|
||||
public String getLastupdate() {
|
||||
return lastupdate;
|
||||
}
|
||||
|
||||
public void setLastupdate(String lastupdate) {
|
||||
this.lastupdate = lastupdate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright 2013, Edmodo, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License.
|
||||
* You may obtain a copy of the License in the LICENSE file, or at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
|
||||
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.edmodo.cropper.cropwindow.handle;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.edmodo.cropper.cropwindow.edge.Edge;
|
||||
import com.edmodo.cropper.cropwindow.edge.EdgePair;
|
||||
import com.edmodo.cropper.util.AspectRatioUtil;
|
||||
|
||||
/**
|
||||
* Abstract helper class to handle operations on a crop window Handle.
|
||||
*/
|
||||
abstract class HandleHelper {
|
||||
|
||||
// Member Variables ////////////////////////////////////////////////////////
|
||||
|
||||
private static final float UNFIXED_ASPECT_RATIO_CONSTANT = 1;
|
||||
private Edge mHorizontalEdge;
|
||||
private Edge mVerticalEdge;
|
||||
|
||||
// Save the Pair object as a member variable to avoid having to instantiate
|
||||
// a new Object every time getActiveEdges() is called.
|
||||
private EdgePair mActiveEdges;
|
||||
|
||||
// Constructor /////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param horizontalEdge the horizontal edge associated with this handle;
|
||||
* may be null
|
||||
* @param verticalEdge the vertical edge associated with this handle; may be
|
||||
* null
|
||||
*/
|
||||
HandleHelper(Edge horizontalEdge, Edge verticalEdge) {
|
||||
mHorizontalEdge = horizontalEdge;
|
||||
mVerticalEdge = verticalEdge;
|
||||
mActiveEdges = new EdgePair(mHorizontalEdge, mVerticalEdge);
|
||||
}
|
||||
|
||||
// Package-Private Methods /////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Updates the crop window by directly setting the Edge coordinates.
|
||||
*
|
||||
* @param x the new x-coordinate of this handle
|
||||
* @param y the new y-coordinate of this handle
|
||||
* @param imageRect the bounding rectangle of the image
|
||||
* @param parentView the parent View containing the image
|
||||
* @param snapRadius the maximum distance (in pixels) at which the crop
|
||||
* window should snap to the image
|
||||
*/
|
||||
void updateCropWindow(float x,
|
||||
float y,
|
||||
Rect imageRect,
|
||||
float snapRadius) {
|
||||
|
||||
final EdgePair activeEdges = getActiveEdges();
|
||||
final Edge primaryEdge = activeEdges.primary;
|
||||
final Edge secondaryEdge = activeEdges.secondary;
|
||||
|
||||
if (primaryEdge != null)
|
||||
primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
|
||||
|
||||
if (secondaryEdge != null)
|
||||
secondaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the crop window by directly setting the Edge coordinates; this
|
||||
* method maintains a given aspect ratio.
|
||||
*
|
||||
* @param x the new x-coordinate of this handle
|
||||
* @param y the new y-coordinate of this handle
|
||||
* @param targetAspectRatio the aspect ratio to maintain
|
||||
* @param imageRect the bounding rectangle of the image
|
||||
* @param parentView the parent View containing the image
|
||||
* @param snapRadius the maximum distance (in pixels) at which the crop
|
||||
* window should snap to the image
|
||||
*/
|
||||
abstract void updateCropWindow(float x,
|
||||
float y,
|
||||
float targetAspectRatio,
|
||||
Rect imageRect,
|
||||
float snapRadius);
|
||||
|
||||
/**
|
||||
* Gets the Edges associated with this handle (i.e. the Edges that should be
|
||||
* moved when this handle is dragged). This is used when we are not
|
||||
* maintaining the aspect ratio.
|
||||
*
|
||||
* @return the active edge as a pair (the pair may contain null values for
|
||||
* the <code>primary</code>, <code>secondary</code> or both fields)
|
||||
*/
|
||||
EdgePair getActiveEdges() {
|
||||
return mActiveEdges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Edges associated with this handle as an ordered Pair. The
|
||||
* <code>primary</code> Edge in the pair is the determining side. This
|
||||
* method is used when we need to maintain the aspect ratio.
|
||||
*
|
||||
* @param x the x-coordinate of the touch point
|
||||
* @param y the y-coordinate of the touch point
|
||||
* @param targetAspectRatio the aspect ratio that we are maintaining
|
||||
* @return the active edges as an ordered pair
|
||||
*/
|
||||
EdgePair getActiveEdges(float x, float y, float targetAspectRatio) {
|
||||
|
||||
// Calculate the aspect ratio if this handle were dragged to the given
|
||||
// x-y coordinate.
|
||||
final float potentialAspectRatio = getAspectRatio(x, y);
|
||||
|
||||
// If the touched point is wider than the aspect ratio, then x
|
||||
// is the determining side. Else, y is the determining side.
|
||||
if (potentialAspectRatio > targetAspectRatio) {
|
||||
mActiveEdges.primary = mVerticalEdge;
|
||||
mActiveEdges.secondary = mHorizontalEdge;
|
||||
} else {
|
||||
mActiveEdges.primary = mHorizontalEdge;
|
||||
mActiveEdges.secondary = mVerticalEdge;
|
||||
}
|
||||
return mActiveEdges;
|
||||
}
|
||||
|
||||
// Private Methods /////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Gets the aspect ratio of the resulting crop window if this handle were
|
||||
* dragged to the given point.
|
||||
*
|
||||
* @param x the x-coordinate
|
||||
* @param y the y-coordinate
|
||||
* @return the aspect ratio
|
||||
*/
|
||||
private float getAspectRatio(float x, float y) {
|
||||
|
||||
// Replace the active edge coordinate with the given touch coordinate.
|
||||
final float left = (mVerticalEdge == Edge.LEFT) ? x : Edge.LEFT.getCoordinate();
|
||||
final float top = (mHorizontalEdge == Edge.TOP) ? y : Edge.TOP.getCoordinate();
|
||||
final float right = (mVerticalEdge == Edge.RIGHT) ? x : Edge.RIGHT.getCoordinate();
|
||||
final float bottom = (mHorizontalEdge == Edge.BOTTOM) ? y : Edge.BOTTOM.getCoordinate();
|
||||
|
||||
final float aspectRatio = AspectRatioUtil.calculateAspectRatio(left, top, right, bottom);
|
||||
|
||||
return aspectRatio;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.adins.mss.coll.commons;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
public class SecondWorker extends AsyncTask<Object,Void,Object> {
|
||||
|
||||
private SecondWorkListener listener;
|
||||
|
||||
public SecondWorker(SecondWorkListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object o) {
|
||||
super.onPostExecute(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doInBackground(Object... objects) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface SecondWorkListener {
|
||||
void onPreExecute();
|
||||
Object doWork();
|
||||
void onPostExecute(Object object);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.adins.mss.base.util;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by angga.permadi on 3/8/2016.
|
||||
*/
|
||||
public class EventBusHelper {
|
||||
public static void registerEventBus(Object subcriber) {
|
||||
if (subcriber != null && !EventBus.getDefault().isRegistered(subcriber)) {
|
||||
EventBus.getDefault().register(subcriber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregisterEventBus(Object subcriber) {
|
||||
if (subcriber != null && EventBus.getDefault().isRegistered(subcriber)) {
|
||||
EventBus.getDefault().unregister(subcriber);
|
||||
}
|
||||
}
|
||||
|
||||
public static void post(Object event) {
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue