add project adins

This commit is contained in:
Alfrid Sanjaya Leo Putra 2024-07-25 14:44:22 +07:00
commit f8f85d679d
5299 changed files with 625430 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="80%p"
android:toXScale="100%p"
android:fromYScale="80%p"
android:toYScale="100%p"
android:pivotX="50%p"
android:pivotY="50%p"
android:duration="@android:integer/config_shortAnimTime" />
<alpha android:fromAlpha="0.5"
android:toAlpha="1.0"
android:duration="@android:integer/config_shortAnimTime"/>
</set>

View file

@ -0,0 +1,134 @@
package com.adins.mss.coll.services;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.os.SystemClock;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import com.adins.mss.base.GlobalData;
import com.adins.mss.coll.EmergencyLockActivity;
import com.adins.mss.coll.R;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.GeneralParameter;
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
import com.tracking.LocationTrackingService;
public class MCLocationTrackingService extends LocationTrackingService {
public MCLocationTrackingService() {
}
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(getPackageName(), getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("App Service Persistent");
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
}
boolean enableEmergency = false;
GeneralParameter gp = GeneralParameterDataAccess.getOne(getApplicationContext(),
GlobalData.getSharedGlobalData().getUser().getUuid_user(),
Global.GS_ENABLE_EMERGENCY_MC);
if(null != gp){
enableEmergency = "1".equals(gp.getGs_value());
}
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(this,
"GlobalData", Context.MODE_PRIVATE);
if(sharedPref.contains("HAS_LOGGED")) {
if (enableEmergency) {
// Create an Intent for the activity you want to start
Intent resultIntent = new Intent(this, EmergencyLockActivity.class);
// Create the TaskStackBuilder and add the intent, which inflates the back stack
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
// Get the PendingIntent containing the entire back stack
PendingIntent resultPendingIntent =
PendingIntent.getActivity(getApplicationContext(), 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(this, getPackageName())
.setSmallIcon(R.drawable.icon_notif_new)
.setContentTitle(getString(R.string.app_name))
.addAction(R.drawable.ic_sos, "Emergency!", resultPendingIntent)
.setContentText(getString(R.string.application_is_running))
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccent))
.setOngoing(true)
.build();
startForeground(2043, notification);
} else {
Notification notification = new NotificationCompat.Builder(this, getPackageName())
.setSmallIcon(R.drawable.icon_notif_new)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.application_is_running))
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setOngoing(true)
.build();
startForeground(2043, notification);
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
stopSelf();
}
@Override
public void onTaskRemoved(Intent rootIntent){
String manufacture = Build.MANUFACTURER.toLowerCase();
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(getApplicationContext(),
"GlobalData", Context.MODE_PRIVATE);
boolean hasLogged = sharedPref.getBoolean("HAS_LOGGED", false);
if(hasLogged) {
switch (manufacture) {
case "oppo":
case "vivo":
Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
restartServiceIntent.setPackage(getPackageName());
PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmService.set(
AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + 1000,
restartServicePendingIntent);
break;
default:
break;
}
}
super.onTaskRemoved(rootIntent);
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
public static class UserLogoutReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent locationTrackingService = new Intent(context, MCLocationTrackingService.class);
context.stopService(locationTrackingService);
}
}
}

View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mylayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:background="@drawable/crop__texture"
android:focusableInTouchMode="true"
android:orientation="vertical"
tools:context="com.adins.mss.foundation.image.CroppingImageActivity" >
<com.edmodo.cropper.CropImageView
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/CropImageView"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="@+id/linearLayout1"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@color/tv_gray"
android:orientation="horizontal"
android:paddingBottom="@dimen/control_right_margin"
android:paddingLeft="@dimen/control_right_margin"
android:paddingRight="@dimen/control_right_margin"
android:paddingTop="@dimen/control_right_margin"
android:weightSum="1.5" >
<Button
android:id="@+id/Button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/crop__cancel" />
<Button
android:id="@+id/Button_rotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/crop__rotate" />
<Button
android:id="@+id/Button_crop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/crop__done" />
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,60 @@
package com.adins.mss.odr.common;
import android.content.Context;
import java.io.*;
/**
* Created by Aditya Purwa on 3/5/2015.
*/
public class PersistentCounter {
public static int getAndIncrement(Context context, String name) {
File dir = context.getDir("persistentcounter", Context.MODE_PRIVATE);
File file = new File(dir, name);
int base = 0;
if (file.exists()) {
try (BufferedReader reader = new BufferedReader(new FileReader(file));){
String line = reader.readLine();
base = Integer.parseInt(line);
} catch (Exception ex) {
return 0;
}
}
try(BufferedWriter writer = new BufferedWriter(new FileWriter(file));) {
writer.write(String.valueOf(base + 1));
writer.flush();
} catch (Exception e) {
return 0;
}
return base;
}
public static int get(Context context, String name) {
File dir = context.getDir("persistentcounter", Context.MODE_PRIVATE);
File file = new File(dir, name);
BufferedReader reader = null;
int base = 0;
if (file.exists()) {
try {
reader = new BufferedReader(new FileReader(file));
String line = reader.readLine();
base = Integer.parseInt(line);
} catch (Exception ex) {
return 0;
} finally {
try {
reader.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
return base;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View file

@ -0,0 +1,86 @@
package com.adins.mss.base.autosend;
import android.content.Context;
import com.adins.mss.base.GlobalData;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.services.ScheduledConnectionItem;
import com.adins.mss.foundation.services.ScheduledItem.ScheduledItemHandler;
import java.util.ArrayList;
import java.util.List;
//public class AutoSubmitForm extends ScheduledItem implements ScheduledItemHandler{
public class AutoSubmitForm extends ScheduledConnectionItem implements ScheduledItemHandler {
Context context;
private TaskH processedTask;
private List<TaskD> processedQuestions;
private boolean isPartial;
public AutoSubmitForm(Context context, String id, int interval, String url, boolean enc, boolean dec, boolean isPartial) {
super(id, interval, url, enc, dec);
processedQuestions = new ArrayList<TaskD>();
this.context = context;
this.isPartial = isPartial;
setHandler(this);
}
@Override
protected String getData() {
//make sure processedTask and Questions are clear
processedTask = null;
// TODO fetch data from DB, add imei code etc
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
// processedTask = TaskHDataAccess.getAllTaskByStatus(context, uuidUser, TaskHDataAccess.STATUS_SEND_PENDING);
String task_uuid = "";
int withImage;
if (isPartial) {
withImage = TaskDDataAccess.NON_IMAGE_ONLY;
} else {
withImage = TaskDDataAccess.ALL_TASK;
}
processedQuestions = TaskDDataAccess.getAllByTaskId(context, uuidUser, task_uuid, withImage);
//TODO convert to JSON
Object jsonObject = null;
String jsonString = Formatter.getJsonFromObject(jsonObject);
return jsonString;
}
@Override
protected boolean onSuccess(HttpConnectionResult result) {
//Header status
String status;
if (isPartial) {
status = TaskHDataAccess.STATUS_SEND_UPLOADING;
} else {
status = TaskHDataAccess.STATUS_SEND_SENT;
}
TaskHDataAccess.updateStatus(context, processedTask, status);
//Detail status
TaskDDataAccess.changeStatusList(context, processedQuestions, true);
//clear
processedTask = null;
processedQuestions.clear();
return true;
}
@Override
protected boolean onFail(HttpConnectionResult result) {
return false;
}
}

View file

@ -0,0 +1,398 @@
package com.adins.mss.foundation.formatter;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.constant.Global;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.TimeZone;
/**
* Formatter is a helper class for conversion of numeric and date types to/from String type.
* The class internally use ThreadLocal object for returning the same number/date formatter instance
* for the same thread and number/date Sformat <p>
* Example:<br>
* <code><pre>
* DateFormat formatter = Formatter.getDateFormat(Formatter.DFORMAT_DMY); <br>
* for (int i=0; i < xxx; i++) { <br>
* // use 'formatter' <br>
* } <br>
* </pre></code>
* Inner class NumberFormatType is used for specifying number format
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: AdIns</p>
*
* @author Andri Gunardi
* @version 1.0
*/
public class Formatter {
public static final String DFORMAT_YMD = "yyyyMMdd";
public static final String DFORMAT_DMY = "ddMMyyyy";
public static final NumberFormatType NFORMAT_ID_0 = new NumberFormatType('.', ',', 0);
public static final NumberFormatType NFORMAT_ID_2 = new NumberFormatType('.', ',', 2);
public static final NumberFormatType NFORMAT_US_0 = new NumberFormatType(',', '.', 0);
public static final NumberFormatType NFORMAT_US_2 = new NumberFormatType(',', '.', 2);
public static final NumberFormatType NFORMAT_PLAIN = new NumberFormatType(',', '.', 0, false);
private static ThreadLocal numberFormatPool = new ThreadLocal();
private static ThreadLocal dateFormatPool = new ThreadLocal();
private static String gigabyteSuffix = " Gigabytes";
private static String megabyteSuffix = " Megabytes";
private static String kilobyteSuffix = " Kilobytes";
private static String byteSuffix = " Bytes";
private static NumberFormat nf = new DecimalFormat("#,###.##");
/*********************************************************/
/*********************************************************/
private Formatter() {
}
/**
* Returns NumberFormat instance for the specified argument 'type'.
* NumberFormat instance is cache per thread (using ThreadLocal) and per format,
* so the same thread requesting the same formatType will get the same NumberFormat instance.
*
* @param formatType
* @return NumberFormat
*/
public static NumberFormat getNumberFormat(NumberFormatType formatType) {
NumberFormat result = null;
HashMap numberFormats = (HashMap) numberFormatPool.get();
if (numberFormats == null) {
numberFormats = new HashMap<>();
numberFormatPool.set(numberFormats);
} else {
result = (NumberFormat) numberFormats.get(formatType);
}
if (result == null) {
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setGroupingSeparator(formatType.thousandSeparator);
symbols.setDecimalSeparator(formatType.decimalSeparator);
DecimalFormat dFormat = new DecimalFormat("###,###,###,###,###,###.##", symbols);
dFormat.setMinimumFractionDigits(formatType.decimal);
dFormat.setMaximumFractionDigits(formatType.decimal);
dFormat.setGroupingSize(formatType.showThousandSeparator ? 3 : 0);
dFormat.setDecimalSeparatorAlwaysShown(formatType.decimal > 0);
numberFormats.put(formatType, dFormat);
result = dFormat;
}
return result;
}
/**
* Returns (Simple)DateFormat instance for the specified format argument
* DateFormat instance is cache per thread (using ThreadLocal) and per format,
* so the same thread requesting the same date format will get the same DateFormat instance.
*
* @param format String
* @return DateFormat
*/
public static DateFormat getDateFormat(String format) {
DateFormat result = null;
HashMap dateFormats = (HashMap) dateFormatPool.get();
if (dateFormats == null) {
dateFormats = new HashMap<>();
dateFormatPool.set(dateFormats);
} else {
result = (DateFormat) dateFormats.get(format);
}
if (result == null) {
result = new SimpleDateFormat(format);
dateFormats.put(format, result);
}
return result;
}
/**
* Format specified java.util.Date date using format
*
* @param date Date
* @param format String
* @return String
*/
public static String formatDate(Date date, String format) {
return getDateFormat(format).format(date);
}
/**
* Format specified java.util.Date dt using formatter to text String
*
* @param dt Date
* @param formatter DateFormat
* @return String
*/
public static String formatDate(Date dt, DateFormat formatter) {
return formatter.format(dt);
}
/**
* Parse specified String dateStr using format
*
* @param dateStr String
* @param format String
* @return Date
* @throws ParseException
*/
public static java.util.Date parseDate(String dateStr, String format) throws ParseException {
return getDateFormat(format).parse(dateStr);
}
public static java.util.Date parseDate2(String dateStr, String format) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
Date convertedDate = null;
try {
convertedDate = dateFormat.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
convertedDate = null;
}
return convertedDate;
}
/**
* Parse specified String dateStr using formatter to java.util.Date
*
* @param dateStr String
* @param formatter DateFormat
* @return Date
* @throws ParseException
*/
public static Date parseDate(String dateStr, DateFormat formatter) throws ParseException {
return formatter.parse(dateStr);
}
/**
* Converts a byte size into a human-readable string, such as "1.43 MB" or "27 KB".
* The values used are based on powers of 1024, ie 1 KB = 1024 bytes, not 1000 bytes.
*
* @param byteSize the byte size of some item
* @return a human-readable description of the byte size
*/
public static String formatByteSize(long byteSize) {
String result = null;
try {
if (byteSize > Math.pow(1024, 3)) {
// Report gigabytes
result = nf.format(byteSize / Math.pow(1024, 3)) + gigabyteSuffix;
} else if (byteSize > Math.pow(1024, 2)) {
// Report megabytes
result = nf.format(byteSize / Math.pow(1024, 2)) + megabyteSuffix;
} else if (byteSize > 1024) {
// Report kilobytes
result = nf.format(byteSize / Math.pow(1024, 1)) + kilobyteSuffix;
} else if (byteSize >= 0) {
// Report bytes
result = byteSize + byteSuffix;
}
} catch (NumberFormatException e) {
return byteSize + byteSuffix;
}
return result;
}
/**
* change format Long Date to "dd/MM/yyyy"
*
* @param date
* @return
*/
public static String dateToString(long date) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(date));
int y = c.get(Calendar.YEAR);
int m = c.get(Calendar.MONTH) + 1;
int d = c.get(Calendar.DATE);
return (d < 10 ? "0" : "") + d + "/" + (m < 10 ? "0" : "") + m
+ "/" + y;
}
//mengubah format long ke time "dd/MM/yyyy" --> bangkit 2011-10-26
/**
* change format Long Date to HH:mm
*
* @param date
* @return
*/
public static String timeToString(long date) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(date));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m;
}
// mengubah format long ke time "HH:mm" --> bangkit 2011-10-26
/**
* change format Long Date to HH:mm:ss
*
* @param date
* @return
*/
public static String timeSecToString(long date) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(date));
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
int s = c.get(Calendar.SECOND);
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "" + s);
}
// mengubah format long ke time "HH:mm:ss" --> bangkit 2011-10-26
public static String dateTimeToString(long date) {
return dateToString(date) + " " + timeToString(date);
}
public static String dateTimeSecToString(long date) {
return dateToString(date) + " " + timeSecToString(date);
}
/**
* Change format dd/MM/yyyy HH:mm to long Date.
* eg : "09/07/2011 12:45" or "09/07/2011" to Date
*
* @param s
* @return
*/
public static long stringToDate(String s) {
Calendar c = Calendar.getInstance(TimeZone.getDefault());
c.set(Calendar.DAY_OF_MONTH, Integer.parseInt(s.substring(0, 2)));
c.set(Calendar.MONTH, Integer.parseInt(s.substring(3, 5)) - 1);
c.set(Calendar.YEAR, Integer.parseInt(s.substring(06, 10)));
if (s.length() > 10) {
c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(s.substring(11, 13)));
c.set(Calendar.MINUTE, Integer.parseInt(s.substring(14, 16)));
}
return c.getTime().getTime();
}
// mengubah format string tanggal dd/MM/yyyy HH:mm ke date --> bangkit 2011-10-26
// cth format nya "09/07/2011 12:45" atau "09/07/2011"
// mengubah format long ke time "HH:mm:ss" --> bangkit 2011-10-26
/**
* @param object
* @return
*/
public static String getJsonFromObject(Object object) {
return GsonHelper.toJson(object);
}
public static String getDateTimeFormat(String type) {
if (Global.AT_DATE.equals(type)) {
return Global.DATE_STR_FORMAT;
} else if (Global.AT_TIME.equals(type)) {
return Global.TIME_STR_FORMAT;
} else if (Global.AT_DATE_TIME.equals(type)) {
return Global.DATE_TIME_STR_FORMAT;
} else {
return Global.DATE_STR_FORMAT;
}
}
public static Boolean stringToBoolean(String stringBoolean) {
boolean b = false;
if (stringBoolean.equals("0")) b = false;
else b = stringBoolean.equals("1");
return b;
}
public static String booleanToString(boolean b) {
String stringBoolean;
if (b) stringBoolean = "1";
else stringBoolean = "0";
return stringBoolean;
}
/**
* Inner static class for specifying number format
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: AdIns</p>
*
* @author Andri Gunardi
* @version 1.0
*/
public static class NumberFormatType {
private int decimal;
private char thousandSeparator;
private char decimalSeparator;
private boolean showThousandSeparator;
/**
* Create instance of NumberFormatType with specified parameters and displays thousand separator
*
* @param thousandSeparator char
* @param decimalSeparator char
* @param decimal int
*/
public NumberFormatType(char thousandSeparator, char decimalSeparator, int decimal) {
this(thousandSeparator, decimalSeparator, decimal, true);
}
/**
* Create instance of NumberFormatType with specified parameters
*
* @param thousandSeparator char
* @param decimalSeparator char
* @param decimal int
* @param showThousandSeparator boolean
*/
public NumberFormatType(char thousandSeparator, char decimalSeparator, int decimal, boolean showThousandSeparator) {
this.decimal = decimal;
this.thousandSeparator = thousandSeparator;
this.decimalSeparator = decimalSeparator;
this.showThousandSeparator = showThousandSeparator;
}
public boolean equals(Object object) {
if (!(object instanceof NumberFormatType)) {
return false;
}
if (this == object) { // optimization
return true;
}
NumberFormatType other = (NumberFormatType) object;
return other.thousandSeparator == this.thousandSeparator &&
other.decimalSeparator == this.decimalSeparator &&
other.showThousandSeparator == this.showThousandSeparator &&
other.decimal == this.decimal;
}
public int hashCode() {
int result = 5; // arbitrary
result = 7 * result + (int) this.thousandSeparator;
result = 7 * result + (int) this.decimalSeparator;
result = 7 * result + (this.showThousandSeparator ? 1 : 0);
result = 7 * result + this.decimal;
return result;
}
}
public static void clearFormatter(){
numberFormatPool.remove();
dateFormatPool.remove();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -0,0 +1,84 @@
/*
* 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;
/**
* HandleHelper class to handle the center handle.
*/
class CenterHandleHelper extends HandleHelper {
// Constructor /////////////////////////////////////////////////////////////
CenterHandleHelper() {
super(null, null);
}
// HandleHelper Methods ////////////////////////////////////////////////////
@Override
void updateCropWindow(float x,
float y,
Rect imageRect,
float snapRadius) {
float left = Edge.LEFT.getCoordinate();
float top = Edge.TOP.getCoordinate();
float right = Edge.RIGHT.getCoordinate();
float bottom = Edge.BOTTOM.getCoordinate();
final float currentCenterX = (left + right) / 2;
final float currentCenterY = (top + bottom) / 2;
final float offsetX = x - currentCenterX;
final float offsetY = y - currentCenterY;
// Adjust the crop window.
Edge.LEFT.offset(offsetX);
Edge.TOP.offset(offsetY);
Edge.RIGHT.offset(offsetX);
Edge.BOTTOM.offset(offsetY);
// Check if we have gone out of bounds on the sides, and fix.
if (Edge.LEFT.isOutsideMargin(imageRect, snapRadius)) {
final float offset = Edge.LEFT.snapToRect(imageRect);
Edge.RIGHT.offset(offset);
} else if (Edge.RIGHT.isOutsideMargin(imageRect, snapRadius)) {
final float offset = Edge.RIGHT.snapToRect(imageRect);
Edge.LEFT.offset(offset);
}
// Check if we have gone out of bounds on the top or bottom, and fix.
if (Edge.TOP.isOutsideMargin(imageRect, snapRadius)) {
final float offset = Edge.TOP.snapToRect(imageRect);
Edge.BOTTOM.offset(offset);
} else if (Edge.BOTTOM.isOutsideMargin(imageRect, snapRadius)) {
final float offset = Edge.BOTTOM.snapToRect(imageRect);
Edge.TOP.offset(offset);
}
}
@Override
void updateCropWindow(float x,
float y,
float targetAspectRatio,
Rect imageRect,
float snapRadius) {
updateCropWindow(x, y, imageRect, snapRadius);
}
}

View file

@ -0,0 +1,374 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f2f1ed"
android:clipToPadding="false"
tools:context=".loyalti.monthlypointacquisition.MonthlyPointsChartView">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dummyChartHeader"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:visibility="visible"
app:layout_constraintLeft_toRightOf="@id/dummyGuideline1"
app:layout_constraintRight_toLeftOf="@id/dummyGuideline2"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/headerVerticalGuideline"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<androidx.cardview.widget.CardView
android:id="@+id/dummyCardTotalPoin"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="20dp"
android:layout_marginRight="6dp"
android:elevation="6dp"
app:cardCornerRadius="10dp"
app:layout_constraintEnd_toStartOf="@+id/headerVerticalGuideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="15dp"
android:text="@string/total_points"
android:textSize="12sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dummyTotalPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="273"
android:textSize="23sp"
android:textStyle="bold" />
<!--<ImageView-->
<!--android:id="@+id/upDownTotalPoints"-->
<!--android:layout_width="12dp"-->
<!--android:layout_height="12dp"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginStart="10dp"-->
<!--android:src="@drawable/arrowupgreen" />-->
<TextView
android:id="@+id/dummyRataTotalPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:text="+29"
android:textColor="@color/green"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/dummyCardDailyAverage"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="20dp"
android:elevation="6dp"
app:cardCornerRadius="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/headerVerticalGuideline"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="15dp"
android:text="@string/daily_avg_period"
android:textSize="12sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dummyDailyAveragePeriod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textSize="23sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/dummyCardCurrentMonth"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="6dp"
android:layout_marginRight="6dp"
android:elevation="6dp"
app:cardCornerRadius="10dp"
app:layout_constraintEnd_toStartOf="@+id/headerVerticalGuideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/dummyCardTotalPoin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="15dp"
android:text="@string/current_month_point"
android:textSize="12sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dummyCurrentMonthPoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="64"
android:textSize="23sp"
android:textStyle="bold" />
<!--<ImageView-->
<!--android:id="@+id/upDownCurrentMonth"-->
<!--android:layout_width="12dp"-->
<!--android:layout_height="12dp"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginStart="10dp"-->
<!--android:src="@drawable/arrowupgreen" />-->
<TextView
android:id="@+id/dummyRataCurrentMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:text="-26"
android:textColor="@color/blazingRed"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/dummyCardAverageMonth"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="6dp"
android:elevation="6dp"
app:cardCornerRadius="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/headerVerticalGuideline"
app:layout_constraintTop_toBottomOf="@id/dummyCardDailyAverage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="15dp"
android:text="@string/daily_avg_month"
android:textSize="12sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dummyDailyAverageMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="68"
android:textSize="23sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/dummyUpDownAverageMonth"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="bottom"
android:layout_marginStart="10dp"
android:layout_marginBottom="4dp"
android:src="@drawable/arrowupgreen" />
<TextView
android:id="@+id/dummyRataAverageMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="3dp"
android:text="15"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/dummyGuideline1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.05" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/dummyGuideline2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.95" />
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="@dimen/activity_vertical_margin"
app:cardCornerRadius="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/dummyGuideline1"
app:layout_constraintRight_toLeftOf="@id/dummyGuideline2"
app:layout_constraintTop_toBottomOf="@+id/dummyChartHeader">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dummyChartContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/yAxisTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="@string/monthly_points"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/dummyMonthlyChart"
android:layout_width="match_parent"
android:layout_height="400dp"
app:layout_constraintTop_toBottomOf="@id/yAxisTitle"
tools:layout_editor_absoluteX="0dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dummyLegendsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/dummyMonthlyChart">
<com.adins.mss.base.loyalti.barchart.NonScrollListView
android:id="@+id/dummyLegendPoints"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.65" />
<com.adins.mss.base.loyalti.barchart.NonScrollListView
android:id="@+id/dummyLegendRanks"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.35" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -0,0 +1,66 @@
package com.adins.mss.base.dynamicform.form.resolver;
import com.adins.mss.constant.Global;
import com.gadberry.utility.CalendarUtils;
import com.gadberry.utility.expression.Resolver;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by gigin.ginanjar on 15/09/2016.
*/
public class DateTimeResolver implements Resolver {
private final SimpleDateFormat sdf = new SimpleDateFormat(Global.DATE_TIME_STR_FORMAT);
@Override
public boolean canResolve(String path) {
return resolve(path) != null || path.equals("NULL");
}
private Date getDate(String path) {
try {
return sdf.parse(path);
} catch (ParseException e) {
}
return null;
}
private CalendarUtils.Unit getDateUnit(String path) {
if (path.equals("|YEAR|")) {
return CalendarUtils.Unit.YEAR;
} else if (path.equals("|MONTH|")) {
return CalendarUtils.Unit.MONTH;
} else if (path.equals("|DAY|")) {
return CalendarUtils.Unit.DAY;
} else if (path.equals("|HOUR|")) {
return CalendarUtils.Unit.HOUR;
} else if (path.equals("|MINUTE|")) {
return CalendarUtils.Unit.MINUTE;
} else if (path.equals("|SECOND|")) {
return CalendarUtils.Unit.SECOND;
} else if (path.equals("|MILLISECOND|")) {
return CalendarUtils.Unit.MILLISECOND;
}
return null;
}
private boolean isDate(String path) {
return getDate(path) != null;
}
private boolean isDateUnit(String path) {
return getDateUnit(path) != null;
}
@Override
public Object resolve(String path) {
if (isDate(path)) {
return getDate(path);
} else if (isDateUnit(path)) {
return getDateUnit(path);
}
return null;
}
}

View file

@ -0,0 +1,115 @@
package com.adins.mss.dao;
import android.database.Cursor;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;
import com.adins.mss.dao.LogoPrint;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "TR_LOGO_PRINT".
*/
public class LogoPrintDao extends AbstractDao<LogoPrint, String> {
public static final String TABLENAME = "TR_LOGO_PRINT";
/**
* Properties of entity LogoPrint.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Uuid_logo_print = new Property(0, String.class, "uuid_logo_print", true, "UUID_LOGO_PRINT");
public final static Property Tenant = new Property(1, String.class, "tenant", false, "TENANT");
public final static Property Image_bitmap = new Property(2, byte[].class, "image_bitmap", false, "IMAGE_BITMAP");
};
public LogoPrintDao(DaoConfig config) {
super(config);
}
public LogoPrintDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"TR_LOGO_PRINT\" (" + //
"\"UUID_LOGO_PRINT\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_logo_print
"\"TENANT\" TEXT NOT NULL ," + // 1: tenant
"\"IMAGE_BITMAP\" BLOB);"); // 2: image_bitmap
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_LOGO_PRINT\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(DatabaseStatement stmt, LogoPrint entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getUuid_logo_print());
stmt.bindString(2, entity.getTenant());
byte[] image_bitmap = entity.getImage_bitmap();
if (image_bitmap != null) {
stmt.bindBlob(3, image_bitmap);
}
}
/** @inheritdoc */
@Override
public String readKey(Cursor cursor, int offset) {
return cursor.getString(offset + 0);
}
/** @inheritdoc */
@Override
public LogoPrint readEntity(Cursor cursor, int offset) {
LogoPrint entity = new LogoPrint( //
cursor.getString(offset + 0), // uuid_logo_print
cursor.getString(offset + 1), // tenant
cursor.isNull(offset + 2) ? null : cursor.getBlob(offset + 2) // image_bitmap
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, LogoPrint entity, int offset) {
entity.setUuid_logo_print(cursor.getString(offset + 0));
entity.setTenant(cursor.getString(offset + 1));
entity.setImage_bitmap(cursor.isNull(offset + 2) ? null : cursor.getBlob(offset + 2));
}
/** @inheritdoc */
@Override
protected String updateKeyAfterInsert(LogoPrint entity, long rowId) {
return entity.getUuid_logo_print();
}
/** @inheritdoc */
@Override
public String getKey(LogoPrint entity) {
if(entity != null) {
return entity.getUuid_logo_print();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}

View file

@ -0,0 +1,111 @@
package com.adins.mss.coll.api;
import android.content.Context;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.coll.models.PaymentHistoryRequest;
import com.adins.mss.coll.models.PaymentHistoryResponse;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
/**
* Created by adityapurwa on 20/03/15.
*/
public class PaymentHistoryApi {
private final Context context;
public PaymentHistoryApi(Context context) {
this.context = context;
}
public PaymentHistoryResponse request(String taskId) throws Exception {
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
PaymentHistoryRequest request = new PaymentHistoryRequest();
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
request.setTask_id(taskId);
String data = GsonHelper.toJson(request);
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(GlobalData.getSharedGlobalData().getURL_GET_PAYMENTHISTORY(), FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, data);
HttpConnectionResult result = httpConn.requestToServer(
GlobalData.getSharedGlobalData().getURL_GET_PAYMENTHISTORY(),
data, Global.DEFAULTCONNECTIONTIMEOUT);
try {
Utility.metricStop(networkMetric, result);
}catch (Exception e){
e.printStackTrace();
}
String jsonResult = result.getResult();
// bong 21 mei 15 - add or replace to local database
/* PaymentHistoryResponse paymentHistoryResp = gson.fromJson(jsonResult, PaymentHistoryResponse.class);
List<PaymentHistoryHBean> paymentHistoryHList = paymentHistoryResp.getPaymentHistoryHList();
//List<PaymentHistoryH> paymentHistoryHList = paymentHistoryResp.getPaymentHistoryHList();
//List<PaymentHistoryD> paymentHistoryDList = paymentHistoryResp.getPaymentHistoryDList();
List<PaymentHistoryH> paymentHistoryHLocalList = null;
//List<PaymentHistoryD> paymentHistoryDLocalList = null;
if(paymentHistoryHList!=null){
TaskH taskH = TaskHDataAccess.getOneTaskHeader(context, taskId);
for(PaymentHistoryHBean paymentHistoryHBean : paymentHistoryHList){
String agreementNo = paymentHistoryHBean.getPaymentHistoryH().getAgreement_no();;
if(agreementNo!=null && agreementNo.length()>0){
paymentHistoryHLocalList = PaymentHistoryHDataAccess.getAll(context, agreementNo);
//paymentHistoryDLocalList = PaymentHistoryDDataAccess.getAll(context, uuidTaskH);
//if(paymentHistoryDLocalList.size()>0){
// PaymentHistoryDDataAccess.delete(context, uuidTaskH);
//}
taskH.setAppl_no(agreementNo);
TaskHDataAccess.addOrReplace(context, taskH);
if(paymentHistoryHBean.getPaymentHistoryDList()!=null){
if(paymentHistoryHBean.getPaymentHistoryDList().size()>0){
for(PaymentHistoryD paymentHistoryD : paymentHistoryHBean.getPaymentHistoryDList()){
PaymentHistoryDDataAccess.delete(context, paymentHistoryD);
}
PaymentHistoryDDataAccess.delete(context, paymentHistoryHBean.getPaymentHistoryH().getUuid_task_h());
}
}
if(paymentHistoryHLocalList!=null){
if(paymentHistoryHLocalList.size()>0){
PaymentHistoryHDataAccess.delete(context, paymentHistoryHBean.getPaymentHistoryH().getUuid_task_h());
}
}
if(paymentHistoryHBean.getPaymentHistoryH().getUuid_payment_history_h()==null){
paymentHistoryHBean.getPaymentHistoryH().setUuid_payment_history_h(Tool.getUUID());
}
PaymentHistoryHDataAccess.add(context, paymentHistoryHBean.getPaymentHistoryH());
if(paymentHistoryHBean.getPaymentHistoryDList()!=null){
if(paymentHistoryHBean.getPaymentHistoryDList().size()>0){
PaymentHistoryDDataAccess.add(context, paymentHistoryHBean.getPaymentHistoryDList());
}
}
}
}
}*/
// if(paymentHistoryHBean.getPaymentHistoryDList().size()>0){
// //String uuidTaskH = "";
// //List<PaymentHistoryD> paymentHistoryDLocalList = null;
// PaymentHistoryDDataAccess.add(context, paymentHistoryDList);
// }
return GsonHelper.fromJson(jsonResult, PaymentHistoryResponse.class);
}
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gradient_end"
android:pathData="M20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,9.5c0,0.83 -0.67,1.5 -1.5,1.5L9,11v2L7.5,13L7.5,7L10,7c0.83,0 1.5,0.67 1.5,1.5v1zM16.5,11.5c0,0.83 -0.67,1.5 -1.5,1.5h-2.5L12.5,7L15,7c0.83,0 1.5,0.67 1.5,1.5v3zM20.5,8.5L19,8.5v1h1.5L20.5,11L19,11v2h-1.5L17.5,7h3v1.5zM9,9.5h1v-1L9,8.5v1zM4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM14,11.5h1v-3h-1v3z"/>
</vector>

View file

@ -0,0 +1,121 @@
package com.adins.mss.coll.fragments.view;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.adins.mss.coll.R;
import com.adins.mss.coll.fragments.MyDashBoardItemRecyclerViewAdapter;
import com.adins.mss.coll.fragments.TeamMember;
import com.adins.mss.foundation.formatter.Tool;
import java.util.ArrayList;
public class GridDashBoardAdapter extends BaseAdapter {
private Context context;
TextView huruftext;
TextView angkatext;
ImageView imagearrow;
TextView angkastatustext;
ArrayList<TeamMember.DataGroupRank> dataGroupRank = new ArrayList<TeamMember.DataGroupRank>();
// 1
// public GridDashBoardAdapter(MyDashBoardItemRecyclerViewAdapter context, ArrayList<String> books) {
// this.mContext = context;
// this.books = books;
// }
public GridDashBoardAdapter(Context mContext , ArrayList<TeamMember.DataGroupRank> dataGroupRank) {
this.context = mContext;
this.dataGroupRank = dataGroupRank;
}
// 2
@Override
public int getCount() {
return dataGroupRank.size();
}
// 3
@Override
public long getItemId(int position) {
return 0;
}
// 4
@Override
public Object getItem(int position) {
return null;
}
// 5
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
final LayoutInflater layoutInflater = LayoutInflater.from(context);
convertView = layoutInflater.inflate(R.layout.dashboard_gridview, null);
}
huruftext = convertView.findViewById(R.id.huruf);
angkatext = convertView.findViewById(R.id.angka);
final String[] warna = new String[] {
"#FF0000",
"#FFFF00",
"#32CD32",
"#0000FF",
"#00FFFF",
"#FF00FF",
"#800080",
"#808080",
"#C0C0C0",
"#E9967A",
"#FFA07A"};
huruftext.setBackgroundColor(Color.parseColor(warna[position]));
imagearrow = convertView.findViewById(R.id.arrowstatus);
angkastatustext = convertView.findViewById(R.id.angkastatus);
Integer ranknow = Integer.parseInt(dataGroupRank.get(position).getRANK());
Integer rankbefore;
if(dataGroupRank.get(position).getRANK_BEFORE() != null){
rankbefore = Integer.parseInt(dataGroupRank.get(position).getRANK_BEFORE());
}else {
rankbefore = Integer.parseInt(dataGroupRank.get(position).getRANK());
}
double drankbefore = Double.valueOf(rankbefore);
String rankbeforestring = Tool.formatToCurrency(drankbefore);
double dranknow = Double.valueOf(ranknow);
String ranknowstring = Tool.formatToCurrency(dranknow);
if(ranknow < rankbefore){
angkastatustext.setText(rankbeforestring);
imagearrow.setImageDrawable(context.getDrawable(R.drawable.arrowupgreen_64));
}else if(ranknow > rankbefore){
angkastatustext.setText(rankbeforestring);
imagearrow.setImageDrawable(context.getDrawable(R.drawable.arrowdownred_64));
}else {
angkastatustext.setVisibility(View.INVISIBLE);
imagearrow.setVisibility(View.INVISIBLE);
}
String hurufpertamacode = String.valueOf(dataGroupRank.get(position).getLEVEL().charAt(0));
huruftext.setText(hurufpertamacode);
angkatext.setText(ranknowstring);
// TextView dummyTextView = new TextView(context);
// dummyTextView.setText(String.valueOf(position));
return convertView;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:id="@+id/itemBase"
android:background="@color/tv_gray_light">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="horizontal">
<TextView android:layout_width="150dp" android:layout_height="wrap_content"
android:textStyle="bold"
android:id="@+id/itemLabel"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/divider_equals_sign"/>
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textStyle="bold"
android:id="@+id/itemValue"
android:gravity="right"/>
</LinearLayout>
</LinearLayout>