mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-07-01 05:14:17 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
|
@ -0,0 +1,300 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.dao.SchemeDao;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
public class SchemeDataAccess {
|
||||
|
||||
private SchemeDataAccess() {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
/**
|
||||
* use to generate dao session that you can access modelDao
|
||||
*
|
||||
* @param context --> context from activity
|
||||
* @return
|
||||
*/
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get scheme dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static SchemeDao getSchemeDao(Context context) {
|
||||
return getDaoSession(context).getSchemeDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add scheme as entity
|
||||
*
|
||||
* @param context
|
||||
* @param scheme
|
||||
*/
|
||||
public static void add(Context context, Scheme scheme) {
|
||||
getSchemeDao(context).insertInTx(scheme);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add scheme as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param schemeList
|
||||
*/
|
||||
public static void add(Context context, List<Scheme> schemeList) {
|
||||
getSchemeDao(context).insertInTx(schemeList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all content in table.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void clean(Context context) {
|
||||
getSchemeDao(context).deleteAll();
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param scheme
|
||||
*/
|
||||
public static void delete(Context context, Scheme scheme) {
|
||||
getSchemeDao(context).delete(scheme);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by keyScheme
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void delete(Context context, String keyScheme) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Uuid_scheme.eq(keyScheme));
|
||||
qb.build();
|
||||
getSchemeDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param scheme
|
||||
*/
|
||||
public static void update(Context context, Scheme scheme) {
|
||||
getSchemeDao(context).update(scheme);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add scheme as entity
|
||||
*
|
||||
* @param context
|
||||
* @param scheme
|
||||
*/
|
||||
public static void addOrReplace(Context context, Scheme scheme) {
|
||||
getSchemeDao(context).insertOrReplaceInTx(scheme);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add scheme as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param listScheme
|
||||
*/
|
||||
public static void addOrReplace(Context context, List<Scheme> listScheme) {
|
||||
getSchemeDao(context).insertOrReplaceInTx(listScheme);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_scheme = param
|
||||
*
|
||||
* @param context
|
||||
* @param keyScheme
|
||||
* @return
|
||||
*/
|
||||
public static Scheme getOne(Context context, String keyScheme) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Uuid_scheme.eq(keyScheme));
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list().isEmpty())
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_scheme = param
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static List<Scheme> getAll(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Scheme> getAllActiveScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Is_active.eq(Global.TRUE_STRING));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Scheme> getAllActivePriorityScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Is_active.eq(Global.TRUE_STRING));
|
||||
qb.where(SchemeDao.Properties.Form_type.notEq(Global.FORM_TYPE_SIMULASI));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static String getOneSchemeName(Context context, String uuid){
|
||||
List<String> result = new ArrayList<>();
|
||||
String SQL_DISTINCT_ENAME = "SELECT "+ SchemeDao.Properties.Scheme_description.columnName+
|
||||
" FROM "+ SchemeDao.TABLENAME+
|
||||
" WHERE "+ SchemeDao.Properties.Is_active.columnName+"='"+Global.TRUE_STRING+"' "+
|
||||
" AND " + SchemeDao.Properties.Uuid_scheme.columnName+"='"+uuid+"' "+
|
||||
" ORDER BY "+
|
||||
SchemeDao.Properties.Scheme_description.columnName+
|
||||
" ASC";
|
||||
Cursor c = getSchemeDao(context).getDatabase().rawQuery(SQL_DISTINCT_ENAME, null);
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
result.add(c.getString(0));
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
c.close();
|
||||
String resultName = "";
|
||||
if(result != null && result.size()>0){
|
||||
resultName = result.get(0);
|
||||
}
|
||||
return resultName;
|
||||
}
|
||||
|
||||
public static List<String> getAllSchemeName(Context context) {
|
||||
List<String> result = new ArrayList<>();
|
||||
String SQL_DISTINCT_ENAME = "SELECT " + SchemeDao.Properties.Scheme_description.columnName +
|
||||
" FROM " + SchemeDao.TABLENAME +
|
||||
" WHERE " + SchemeDao.Properties.Is_active.columnName + "='" + Global.TRUE_STRING + "' " +
|
||||
" ORDER BY " +
|
||||
SchemeDao.Properties.Scheme_description.columnName +
|
||||
" ASC";
|
||||
Cursor c = getSchemeDao(context).getDatabase().rawQuery(SQL_DISTINCT_ENAME, null);
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
result.add(c.getString(0));
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
c.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* get simulasi scheme
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static List<Scheme> getAllSimulateScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_SIMULASI));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* get Order Scheme
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static List<Scheme> getAllOrderScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.and(qb.or(SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_ORDER),
|
||||
SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_KTP)),
|
||||
SchemeDao.Properties.Is_active.eq(Global.TRUE_STRING));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* get Collection Scheme
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static List<Scheme> getAllCollectionScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_COLL),
|
||||
SchemeDao.Properties.Is_active.eq(Global.TRUE_STRING));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* get Survey scheme
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static List<Scheme> getAllSurveyScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(qb.or(SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_SURVEY),
|
||||
SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_KTP)),
|
||||
SchemeDao.Properties.Is_active.eq(Global.TRUE_STRING));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* select scheme by last update
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static Scheme getOneByLastUpdate(Context context, String keyScheme, java.util.Date scheme_last_update) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Uuid_scheme.eq(keyScheme),
|
||||
SchemeDao.Properties.Scheme_last_update.eq(scheme_last_update));
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list().isEmpty())
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
public static List<Scheme> getAllMarketingScheme(Context context) {
|
||||
QueryBuilder<Scheme> qb = getSchemeDao(context).queryBuilder();
|
||||
qb.where(SchemeDao.Properties.Form_type.eq(Global.FORM_TYPE_MARKETING),
|
||||
SchemeDao.Properties.Is_active.eq(Global.TRUE_STRING));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.adins.mss.base.loyalti.barchart;
|
||||
|
||||
import com.adins.mss.base.loyalti.model.PointDetail;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LoyaltyBarDataSet extends BarDataSet {
|
||||
|
||||
List<PointDetail> pointDetailsDataSet = new ArrayList<>();
|
||||
List<PointDetail> pointCategories = new ArrayList<>();
|
||||
|
||||
public LoyaltyBarDataSet(List<PointDetail> pointDetails, List<PointDetail> pointCategories, List<BarEntry> yVals, String label) {
|
||||
super(yVals, label);
|
||||
pointDetailsDataSet = pointDetails;
|
||||
this.pointCategories = pointCategories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(int index) {
|
||||
if(index >= pointDetailsDataSet.size())
|
||||
return pointCategories.get(0).colorValue;
|
||||
|
||||
PointDetail currentPointDetail = pointDetailsDataSet.get(index);
|
||||
int selectedColor = -1;
|
||||
for (PointDetail category:pointCategories) {
|
||||
if(category.rewardProgram.equals(currentPointDetail.rewardProgram)){
|
||||
selectedColor = category.colorValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return selectedColor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package fr.castorflex.android.smoothprogressbar;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
|
||||
/**
|
||||
* Created by castorflex on 3/5/14.
|
||||
*/
|
||||
public final class SmoothProgressBarUtils {
|
||||
private SmoothProgressBarUtils() {
|
||||
}
|
||||
|
||||
public static Drawable generateDrawableWithColors(int[] colors, float strokeWidth) {
|
||||
if (colors == null || colors.length == 0) return null;
|
||||
|
||||
return new ShapeDrawable(new ColorsShape(strokeWidth, colors));
|
||||
}
|
||||
|
||||
static void checkSpeed(float speed) {
|
||||
if (speed <= 0f)
|
||||
throw new IllegalArgumentException("Speed must be >= 0");
|
||||
}
|
||||
|
||||
static void checkColors(int[] colors) {
|
||||
if (colors == null || colors.length == 0)
|
||||
throw new IllegalArgumentException("You must provide at least 1 color");
|
||||
}
|
||||
|
||||
static void checkAngle(int angle) {
|
||||
if (angle < 0 || angle > 360)
|
||||
throw new IllegalArgumentException(String.format("Illegal angle %d: must be >=0 and <= 360", angle));
|
||||
}
|
||||
|
||||
static void checkPositiveOrZero(float number, String name) {
|
||||
if (number < 0)
|
||||
throw new IllegalArgumentException(String.format("%s %d must be positive", name, number));
|
||||
}
|
||||
|
||||
static void checkPositive(int number, String name) {
|
||||
if (number <= 0)
|
||||
throw new IllegalArgumentException(String.format("%s must not be null", name));
|
||||
}
|
||||
|
||||
static void checkNotNull(Object o, String name) {
|
||||
if (o == null)
|
||||
throw new IllegalArgumentException(String.format("%s must be not null", name));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package com.adins.mss.coll.loyalti.pointacquisitiondaily;
|
||||
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.contracts.ILoyaltyPointsDataSource;
|
||||
import com.adins.mss.coll.models.loyaltymodels.GroupPointData;
|
||||
import com.adins.mss.coll.models.loyaltymodels.LoyaltyPointsRequest;
|
||||
import com.adins.mss.constant.Global;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class DailyPointsLogic {
|
||||
private ILoyaltyPointsDataSource dataSource;
|
||||
private String competitionStartDate;
|
||||
private int displayMonth;
|
||||
private int displayYear;
|
||||
|
||||
public DailyPointsLogic(ILoyaltyPointsDataSource dataSource, String competitionStartDate, int displayMonth, int displayYear) {
|
||||
this.dataSource = dataSource;
|
||||
this.competitionStartDate = competitionStartDate;
|
||||
this.displayMonth = displayMonth;
|
||||
this.displayYear = displayYear;
|
||||
}
|
||||
|
||||
public DailyPointsLogic(ILoyaltyPointsDataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public void getDailyPointsData(LoyaltyPointsRequest reqData, ILoyaltyPointsDataSource.ReqPointsListener listener){
|
||||
dataSource.requestPointsData(reqData,listener);
|
||||
}
|
||||
|
||||
public int getTotalPoints(List<GroupPointData> dataSet){
|
||||
if(dataSet == null)
|
||||
return 0;
|
||||
int totalPoints = 0;
|
||||
int[] totalPerIdx = new int[dataSet.size()];
|
||||
int _sum = 0;
|
||||
for(int i=0; i<totalPerIdx.length; i++){
|
||||
_sum = 0;
|
||||
for (int stack=0; stack<dataSet.get(i).pointDetails.size(); stack++){
|
||||
int point = Integer.valueOf(dataSet.get(i).pointDetails.get(stack).point);
|
||||
_sum += point;
|
||||
}
|
||||
totalPerIdx[i] = _sum;
|
||||
totalPoints += totalPerIdx[i];
|
||||
}
|
||||
|
||||
return totalPoints;
|
||||
}
|
||||
|
||||
public float getAvgPoint(List<GroupPointData> dataSet){
|
||||
if(dataSet == null)
|
||||
return 0;
|
||||
float totalPoints = 0;
|
||||
int avg = 0;
|
||||
int[] totalPerIdx = new int[dataSet.size()];
|
||||
int _sum = 0;
|
||||
for(int i=0; i<totalPerIdx.length; i++){
|
||||
_sum = 0;
|
||||
for (int stack=0; stack<dataSet.get(i).pointDetails.size(); stack++){
|
||||
int point = Integer.valueOf(dataSet.get(i).pointDetails.get(stack).point);
|
||||
_sum += point;
|
||||
}
|
||||
totalPerIdx[i] = _sum;
|
||||
totalPoints += totalPerIdx[i];
|
||||
}
|
||||
|
||||
int divideDays = getTotalDaysMonth();
|
||||
avg = Math.round(totalPoints/divideDays);
|
||||
return avg;
|
||||
}
|
||||
|
||||
private int getTotalDaysMonth(){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
//current date
|
||||
calendar.setTime(new Date());
|
||||
int currMonth = calendar.get(Calendar.MONTH);
|
||||
int currYear = calendar.get(Calendar.YEAR);
|
||||
int currDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
int maxDays = 0;
|
||||
//tentukan tanggal maksimum
|
||||
if(currMonth == displayMonth && currYear == displayYear){
|
||||
//bulan berjalan
|
||||
maxDays = currDay - 1;
|
||||
}else {
|
||||
//sudah lewat
|
||||
calendar.set(Calendar.MONTH,displayMonth);
|
||||
calendar.set(Calendar.YEAR,displayYear);
|
||||
maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
//competition start date
|
||||
DateFormat dateFormat = new SimpleDateFormat(Global.DATE_STR_FORMAT1);
|
||||
Date startCompDate = null;
|
||||
try {
|
||||
startCompDate = dateFormat.parse(competitionStartDate);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(startCompDate == null)
|
||||
return 1;
|
||||
|
||||
calendar.setTime(startCompDate);
|
||||
int cYear = calendar.get(Calendar.YEAR);
|
||||
int cMonth = calendar.get(Calendar.MONTH);
|
||||
int cDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
//hitung tanggal maksimum berdasarkan tanggal kompetisi mulai
|
||||
if(displayYear == cYear && displayMonth == cMonth){
|
||||
maxDays = (maxDays - cDay);
|
||||
}
|
||||
|
||||
return maxDays;
|
||||
}
|
||||
|
||||
public int getMaxPoint(List<GroupPointData> dataSet){
|
||||
if(dataSet == null)
|
||||
return 0;
|
||||
|
||||
int max = 0;
|
||||
int[] totalPerIdx = new int[dataSet.size()];
|
||||
int _sum = 0;
|
||||
for(int i=0; i<totalPerIdx.length; i++){
|
||||
_sum = 0;
|
||||
for (int stack=0; stack<dataSet.get(i).pointDetails.size(); stack++){
|
||||
int point = Integer.valueOf(dataSet.get(i).pointDetails.get(stack).point);
|
||||
_sum += point;
|
||||
}
|
||||
totalPerIdx[i] = _sum;
|
||||
}
|
||||
|
||||
Arrays.sort(totalPerIdx);
|
||||
max = totalPerIdx[totalPerIdx.length -1];
|
||||
return max;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.adins.mss.base.about.activity;
|
||||
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JsonVersionResponse extends MssResponseType {
|
||||
|
||||
@SerializedName("listValue")
|
||||
List<ListValue> listValue;
|
||||
|
||||
public List<ListValue> getListValues() {
|
||||
return this.listValue;
|
||||
}
|
||||
|
||||
public void setListValues(List<ListValue> listValue) {
|
||||
this.listValue = listValue;
|
||||
}
|
||||
|
||||
public class ListValue {
|
||||
@SerializedName("key")
|
||||
String key;
|
||||
@SerializedName("value")
|
||||
String value;
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue