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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -0,0 +1,46 @@
package fr.castorflex.android.smoothprogressbar;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.shapes.Shape;
/**
* Created by castorflex on 3/5/14.
*/
public class ColorsShape extends Shape {
private float mStrokeWidth;
private int[] mColors;
public ColorsShape(float strokeWidth, int[] colors) {
mStrokeWidth = strokeWidth;
mColors = colors;
}
public float getStrokeWidth() {
return mStrokeWidth;
}
public void setStrokeWidth(float strokeWidth) {
mStrokeWidth = strokeWidth;
}
public int[] getColors() {
return mColors;
}
public void setColors(int[] colors) {
mColors = colors;
}
@Override
public void draw(Canvas canvas, Paint paint) {
float ratio = 1f / mColors.length;
int i = 0;
paint.setStrokeWidth(mStrokeWidth);
for (int color : mColors) {
paint.setColor(color);
canvas.drawLine(i * ratio * getWidth(), getHeight() / 2, ++i * ratio * getWidth(), getHeight() / 2, paint);
}
}
}

View file

@ -0,0 +1,50 @@
package com.adins.mss.coll.closingtask.models;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.SerializedName;
/**
* Created by angga.permadi on 6/6/2016.
*/
public class ClosingTaskEntity {
@SerializedName("noKontrak")
private String noKontrak;
@SerializedName("customerName")
private String customerName;
@SerializedName("noLkp")
private String noLkp;
public ClosingTaskEntity() {
}
public String getNoKontrak() {
return noKontrak;
}
public void setNoKontrak(String noKontrak) {
this.noKontrak = noKontrak;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getNoLkp() {
return noLkp;
}
public void setNoLkp(String noLkp) {
this.noLkp = noLkp;
}
}

View file

@ -0,0 +1,397 @@
package com.adins.mss.base.commons;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
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.form.questions.QuestionsValidator;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.dialog.DialogManager;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.AuditDataType;
import com.adins.mss.foundation.http.AuditDataTypeGenerator;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import java.io.File;
import java.text.DateFormat;
import java.text.DecimalFormat;
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;
/**
* Created by kusnendi.muhamad on 26/07/2017.
*/
public class CommonImpl extends Tool implements Common {
static final int REQUEST_CODE_RECOVER_PLAY_SERVICES = 1001;
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 static ThreadLocal dateFormatPool = new ThreadLocal();
public static boolean findBinary(String binaryName) {
boolean found = false;
String[] places = {"/sbin/", "/system/bin/", "/system/xbin/",
"/data/local/xbin/", "/data/local/bin/",
"/system/sd/xbin/", "/system/bin/failsafe/", "/data/local/"};
for (String where : places) {
if (new File(where + binaryName).exists()) {
found = true;
break;
}
}
return found;
}
public static boolean dateIsToday(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date tempDate = null;
try {
tempDate = sdf.parse(sdf.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
Date today = Tool.getSystemDate();
return today.equals(tempDate);
}
public static Date resetDate() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.HOUR_OF_DAY, 0);
return cal.getTime();
}
@Override
public void checkGPS(boolean value) {
//EMPTY
}
@Override
public void askForDownload(Activity activity, int code) {
DialogManager.showAskForDownloadDialog(activity);
}
@Override
public boolean checkPlayServices(Activity activity) {
int status = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity.getApplicationContext());
if (status != ConnectionResult.SUCCESS) {
if (GoogleApiAvailability.getInstance().isUserResolvableError(status)) {
showErrorDialog(activity, status);
} else {
Toast.makeText(activity.getApplicationContext(), activity.getString(R.string.device_not_supported),
Toast.LENGTH_LONG).show();
activity.finish();
}
return false;
}
return true;
}
@Override
public void setAuditData() {
AuditDataType tempAudit = AuditDataTypeGenerator.generateActiveUserAuditData();
GlobalData.getSharedGlobalData().setAuditData(tempAudit);
}
@Override
public boolean isInternetConnected(Context context) {
return isInternetconnected(context);
}
void showErrorDialog(Activity activity, int code) {
Dialog googlePlayDialog = GoogleApiAvailability.getInstance().getErrorDialog(activity, code,
REQUEST_CODE_RECOVER_PLAY_SERVICES);
googlePlayDialog.setCancelable(false);
googlePlayDialog.setCanceledOnTouchOutside(false);
googlePlayDialog.show();
}
public void showGPSAlert(Activity activity) {
try {
DialogManager.showGPSAlert(activity);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
}
public boolean isAlphaNum(String text, int length) {
String regex = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$";
String answer = text.trim();
boolean result = false;
if (!answer.isEmpty() && QuestionsValidator.regexIsMatch(answer, regex)) {
result = true;
}
return result;
}
@Override
public boolean checkIsRooted() {
return findBinary("su");
}
public 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 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 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 Date parseDate(String dateStr, String format) throws ParseException {
return getDateFormat(format).parse(dateStr);
}
public 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();
}
return convertedDate;
}
/**
* Parse specified String dateStr using formatter to java.util.Date
*
* @param dateStr String
* @param formatter DateFormat
* @return Date
* @throws ParseException
*/
public 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 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;
}
//mengubah format long ke time "dd/MM/yyyy" --> bangkit 2011-10-26
/**
* change format Long Date to "dd/MM/yyyy"
*
* @param date
* @return
*/
public 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 "HH:mm" --> bangkit 2011-10-26
/**
* change format Long Date to HH:mm
*
* @param date
* @return
*/
public 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:ss" --> bangkit 2011-10-26
/**
* change format Long Date to HH:mm:ss
*
* @param date
* @return
*/
public 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);
}
public String dateTimeToString(long date) {
return dateToString(date) + " " + timeToString(date);
}
public String dateTimeSecToString(long date) {
return dateToString(date) + " " + timeSecToString(date);
}
// 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
/**
* 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 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();
}
/**
* @param object
* @return
*/
public String getJsonFromObject(Object object) {
return GsonHelper.toJson(object);
}
public 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 Boolean stringToBoolean(String stringBoolean) {
boolean b = false;
if (stringBoolean.equals("0")) b = false;
else b = stringBoolean.equals("1");
return b;
}
public String booleanToString(boolean b) {
String stringBoolean;
if (b) stringBoolean = "1";
else stringBoolean = "0";
return stringBoolean;
}
@Override
public void hideKeyboard(Activity activity) {
try {
InputMethodManager keyboard = (InputMethodManager)
activity.getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV)
e.printStackTrace();
}
}
public static void clearFormatter(){
dateFormatPool.remove();
}
}

View file

@ -0,0 +1,64 @@
package com.adins.mss.coll.tool;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.image.Utils;
import com.adins.mss.coll.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
public class ImageThumbnail extends LinearLayout{
ImageView imgView;
TextView detailText;
private Bitmap thumbnail = null;
byte[] resultImg = null;
public ImageThumbnail(Context context, int width, int height) {
super(context);
//Init container
this.setOrientation(LinearLayout.VERTICAL);
this.setGravity(Gravity.LEFT);
//Init image thumbnail
imgView = new ImageView(context);
ViewGroup.LayoutParams imgLayout = new LayoutParams(width, height);
imgView.setLayoutParams(imgLayout);
imgView.setImageResource(R.drawable.ic_image);
//Init detail text
detailText = new TextView(context);
detailText.setTextColor(Color.BLACK);
this.addView(imgView);
// this.addView(detailText);
}
public byte[] getResultImg() {
return resultImg;
}
public void setResultImg(byte[] resultImg) throws Exception{
this.resultImg = resultImg;
try{
Bitmap bm = Utils.byteToBitmap(resultImg);
int[] res = Tool.getThumbnailResolution(bm.getWidth(), bm.getHeight());
Bitmap thumbnail = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
imgView.setImageBitmap(thumbnail);
detailText.setText(" "+bm.getWidth()+" x " +bm.getHeight()+". Size "+ resultImg.length +" Bytes");
}
catch(Exception e){
throw e;
}
}
}

View file

@ -0,0 +1,442 @@
package com.adins.mss.base.todolist.form;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.loyalti.sla.LoyaltiSlaTimeHandler;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.Scheme;
import com.adins.mss.dao.TaskH;
import com.adins.mss.dao.Timeline;
import com.adins.mss.dao.TimelineType;
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.db.dataaccess.TimelineTypeDataAccess;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.formatter.Tool;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* {@link RecyclerView.Adapter} that can display a {@link TaskH} and makes a call to the
* specified {@link OnTaskListClickListener}.
*/
public class PriorityViewAdapter extends RecyclerView.Adapter<PriorityViewAdapter.ViewHolder> {
public static final String PRIORITY_HIGH = "HIGH";
public static final String PRIORITY_REMINDER = "REMINDER";
public static final String PRIORITY_MEDIUM = "MEDIUM";
public static final String PRIORITY_NORMAL = "NORMAL";
public static final String PRIORITY_LOW = "LOW";
protected static String param;
protected final OnTaskListClickListener mListener;
protected final Context mContext;
protected List<TaskH> mValues = new ArrayList<>();
protected List<TaskH> taskPriority = new ArrayList<>();
private LoyaltiSlaTimeHandler loyaltiSlaHandler;
@Override
public int getItemViewType(int position) {
return 1;
}
public PriorityViewAdapter(Context context, List<TaskH> items, OnTaskListClickListener listener, String param) {
mContext = context;
// olivia : urutan task di timeline: task pending/uploading/draft order by dtm_crt lalu baru task yg belum dikerjakan order by priority
setThenSortTask(items);
mListener = listener;
PriorityViewAdapter.param = param;
if (isNeedApplyLoyaltySla()) {
int slaTime = Integer
.parseInt(GeneralParameterDataAccess.getOne(mContext, GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_SLA_TIME).getGs_value());
loyaltiSlaHandler = new LoyaltiSlaTimeHandler(slaTime);
}
}
private boolean isNeedApplyLoyaltySla() {
String userJob = GlobalData.getSharedGlobalData().getUser().getFlag_job();
boolean isSlaJob = false;
if (null != Global.SLA_LOYALTI_JOB) {
for (int i = 0; i < Global.SLA_LOYALTI_JOB.length; i++) {
if (userJob.equalsIgnoreCase(Global.SLA_LOYALTI_JOB[i])) {
isSlaJob = true;
break;
}
}
}
return Global.LOYALTI_ENABLED && isSlaJob && GlobalData.getSharedGlobalData().getApplication().equalsIgnoreCase(Global.APPLICATION_SURVEY);
}
public List<TaskH> getListTaskh() {
return mValues;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_task_list_item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) {
if (mValues.isEmpty()) {
holder.noData.setVisibility(View.VISIBLE);
holder.taskItem.setVisibility(View.GONE);
} else {
final TaskH taskH = mValues.get(position);
holder.noData.setVisibility(View.GONE);
holder.taskItem.setVisibility(View.VISIBLE);
holder.mItem = taskH;
holder.bind(taskH);
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onItemClickListener(taskH, position);
}
}
});
holder.mView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onItemLongClickListener(taskH, position);
}
return true;
}
});
}
}
public void changeDataset(List<TaskH> taskHList) {
setThenSortTask(taskHList);
notifyDataSetChanged();
}
public void delete(int position) {
mValues.remove(position);
notifyDataSetChanged();
}
public void deleteMany(List<TaskH> taskhToDeleted) {
for (TaskH task : taskhToDeleted) {
mValues.remove(task);
}
notifyDataSetChanged();
}
@Override
public int getItemCount() {
return mValues != null && !mValues.isEmpty() ? mValues.size() : 0;
}
public class ViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public final ImageView imgStatus;
public final TextView txtName;
public final TextView txtScheme;
public final TextView txtAddress;
public final TextView txtPhone;
public final TextView txtAgreement;
public final TextView txtAmount;
public final TextView txtOverdue;
public final TextView txtInstallment;
public final TextView slaTime;
public final TextView draftDate;
public final CardView taskHeader;
public final LinearLayout collInfo;
public TaskH mItem;
public final CardView noData;
public final LinearLayout taskItem;
public ViewHolder(View view) {
super(view);
mView = view;
taskItem = (LinearLayout) view.findViewById(R.id.taskItem);
imgStatus = (ImageView) view.findViewById(R.id.timelineIcon);
txtName = (TextView) view.findViewById(R.id.taskName);
txtAddress = (TextView) view.findViewById(R.id.taskAddress);
txtPhone = (TextView) view.findViewById(R.id.taskPhone);
txtScheme = (TextView) view.findViewById(R.id.taskForm);
txtAgreement = (TextView) view.findViewById(R.id.taskAgreement);
txtAmount = (TextView) view.findViewById(R.id.taskAmount);
txtOverdue = (TextView) view.findViewById(R.id.taskOverdue);
txtInstallment = (TextView) view.findViewById(R.id.taskInst);
slaTime = (TextView) view.findViewById(R.id.txtslatime);
draftDate = (TextView) view.findViewById(R.id.txtSaveDate);
taskHeader = (CardView) view.findViewById(R.id.taskHeader);
collInfo = (LinearLayout) view.findViewById(R.id.collectionInfo);
noData = (CardView) view.findViewById(R.id.noData);
}
public void bind(TaskH taskH) {
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
draftDate.setVisibility(View.GONE);
mItem = taskH;
txtName.setText(taskH.getCustomer_name());
txtAddress.setText(taskH.getCustomer_address());
txtPhone.setText(taskH.getCustomer_phone());
txtName.setSelected(true);
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
collInfo.setVisibility(View.VISIBLE);
txtScheme.setVisibility(View.GONE);
txtAgreement.setText(taskH.getAppl_no());
if (taskH.getAmt_due() == null || "".equals(taskH.getAmt_due())) {
txtAmount.setText("-");
} else {
txtAmount.setText(Tool.separateThousand(taskH.getAmt_due()));
}
if (taskH.getOd() == null || "".equals(taskH.getOd())) {
txtOverdue.setText("-");
} else {
String od = taskH.getOd() + " " + mContext.getString(R.string.txtDay);
txtOverdue.setText(od);
}
if (taskH.getInst_no() == null || "".equals(taskH.getInst_no())) {
txtInstallment.setText("-");
} else {
txtInstallment.setText(taskH.getInst_no());
}
} else if (Global.APPLICATION_SURVEY.equalsIgnoreCase(application)) {
collInfo.setVisibility(View.GONE);
txtScheme.setVisibility(View.VISIBLE);
Scheme scheme = taskH.getScheme();
if (scheme == null) {
scheme = SchemeDataAccess.getOne(mContext, taskH.getUuid_scheme());
}
if (scheme != null) {
txtScheme.setText(scheme.getForm_id());
}
Date assignDate = taskH.getAssignment_date();
Date today = Tool.getSystemDate();
Date now = Tool.getSystemDateTime();
Date dSlaTime;
String slaDate = "";
if (assignDate != null) {
slaTime.setVisibility(View.VISIBLE);
if (loyaltiSlaHandler == null) {
int SLA_time = Integer
.parseInt(GeneralParameterDataAccess.getOne(mContext, GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_SLA_TIME).getGs_value());
if (assignDate.before(today)) {
slaDate = Formatter.formatDate(assignDate, Global.DATE_TIMESEC_TIMELINE_FORMAT_OLD);
slaTime.setBackgroundResource(R.drawable.sla_shape_red);
} else if (assignDate.after(today)) {
if (assignDate.compareTo(Tool.getIncrementDate(1)) == 0) {
Long tempTime = assignDate.getTime();
Date time = new Date(tempTime);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
slaDate = "TOM " + sdf.format(time);
slaTime.setBackgroundResource(R.drawable.sla_shape_green);
} else if (assignDate.compareTo(Tool.getIncrementDate(1)) > 0) {
slaDate = Formatter.formatDate(assignDate, Global.DATE_TIMESEC_TIMELINE_FORMAT_OLD);
slaTime.setBackgroundResource(R.drawable.sla_shape_green);
} else {
Long assDateMs = assignDate.getTime();
Long nowMs = now.getTime();
Long SLAMs = SLA_time * Long.valueOf(Global.HOUR);
Long sla_late = assDateMs + SLAMs;
dSlaTime = new Date(sla_late);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
slaDate = sdf.format(dSlaTime);
if (nowMs > sla_late) {
slaTime.setBackgroundResource(R.drawable.sla_shape_red);
} else {
slaTime.setBackgroundResource(R.drawable.sla_shape_green);
}
}
}
} else {
dSlaTime = loyaltiSlaHandler.calculateSLATime(assignDate);
if (dSlaTime.before(now)) {
slaTime.setBackgroundResource(R.drawable.sla_shape_red);
} else {
slaTime.setBackgroundResource(R.drawable.sla_shape_green);
}
slaDate = formatSlaTime(dSlaTime);
}
slaTime.setText(slaDate);
} else {
slaTime.setVisibility(View.GONE);
}
} else {
collInfo.setVisibility(View.GONE);
txtScheme.setVisibility(View.VISIBLE);
Scheme scheme = taskH.getScheme();
if (scheme == null) {
scheme = SchemeDataAccess.getOne(mContext, taskH.getUuid_scheme());
}
if (scheme != null) {
txtScheme.setText(scheme.getForm_id());
}
}
String priority = taskH.getPriority();
if (taskH.getStatus().equalsIgnoreCase(TaskHDataAccess.STATUS_SEND_INIT) || taskH.getStatus().equalsIgnoreCase(TaskHDataAccess.STATUS_SEND_DOWNLOAD)) {
if (priority != null) {
if (PRIORITY_HIGH.equalsIgnoreCase(priority)) {
imgStatus.setImageResource(R.drawable.task_highpriority);
} else if (PRIORITY_MEDIUM.equalsIgnoreCase(priority)) {
imgStatus.setImageResource(R.drawable.task_normalpriority);
} else if (PRIORITY_NORMAL.equalsIgnoreCase(priority)) {
imgStatus.setImageResource(R.drawable.task_normalpriority);
} else if (PRIORITY_LOW.equalsIgnoreCase(priority)) {
imgStatus.setImageResource(R.drawable.task_lowpriority);
} else if (PRIORITY_REMINDER.equalsIgnoreCase(priority)) {
imgStatus.setImageResource(R.drawable.task_highpriority);
}
}
// olivia : jika task belum terdownload warna backgroundnya abu
if (TaskHDataAccess.STATUS_SEND_INIT.equalsIgnoreCase(taskH.getStatus())) {
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.timelineLine));
taskHeader.setCardElevation(0);
} else {
taskHeader.setCardBackgroundColor(mContext.getResources().getColor(R.color.fontColorWhite));
}
} else if (TaskHDataAccess.STATUS_SEND_PENDING.equalsIgnoreCase(taskH.getStatus())) {
imgStatus.setImageResource(R.drawable.task_pending);
} else if (TaskHDataAccess.STATUS_SEND_UPLOADING.equalsIgnoreCase(taskH.getStatus())) {
imgStatus.setImageResource(R.drawable.task_uploading);
} else if (TaskHDataAccess.STATUS_SEND_SAVEDRAFT.equalsIgnoreCase(taskH.getStatus())) {
TimelineType typeFailedDraft = TimelineTypeDataAccess.getTimelineTypebyType(mContext, Global.TIMELINE_TYPE_FAILEDDRAFT);
List<Timeline> timelineList = taskH.getTimelineList();
TimelineType taskHLastTimelineType = null;
if (!timelineList.isEmpty()) {
taskHLastTimelineType = timelineList.get(timelineList.size() - 1).getTimelineType();
}
if (taskHLastTimelineType != null && taskHLastTimelineType.getUuid_timeline_type().equals(typeFailedDraft.getUuid_timeline_type())) {
imgStatus.setImageResource(R.drawable.task_failed_draft);
} else {
imgStatus.setImageResource(R.drawable.task_draft);
}
draftDate.setVisibility(View.VISIBLE);
if (null != taskH.getDraft_date() && !"".equals(taskH.getDraft_date())) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy - HH:mm");
draftDate.setText(sdf.format(taskH.getDraft_date()));
}
}
}
private String formatSlaTime(Date slaTime) {
Calendar slaTimeCal = Calendar.getInstance();
slaTimeCal.setTime(slaTime);
String result = null;
SimpleDateFormat simpleDateFormat;
if (DateUtils.isToday(slaTimeCal.getTimeInMillis())) {
simpleDateFormat = new SimpleDateFormat(Global.TIME_STR_FORMAT, Locale.getDefault());
} else {
simpleDateFormat = new SimpleDateFormat(Global.DATE_TIME_STR_FORMAT, Locale.getDefault());
}
result = simpleDateFormat.format(slaTime);
return result;
}
@Override
public String toString() {
return super.toString() + " '" + mItem.getCustomer_name() + "'";
}
}
private void setThenSortTask(List<TaskH> items){
//Bersihkan data nya terlebih dahulu agar tidak double
taskPriority = new ArrayList<>();
mValues = new ArrayList<>();
if (!items.isEmpty()) {
for (TaskH task : items) {
if (null != task) {
if (null != task.getStatus() && (TaskHDataAccess.STATUS_SEND_INIT.equalsIgnoreCase(task.getStatus()) ||
TaskHDataAccess.STATUS_SEND_DOWNLOAD.equalsIgnoreCase(task.getStatus()))) {
taskPriority.add(task);
} else {
mValues.add(task);
}
}
}
try {
if (!taskPriority.isEmpty()) {
for (TaskH taskH : taskPriority) {
if (PRIORITY_LOW.equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority("1");
} else if (PRIORITY_NORMAL.equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority("2");
} else if (PRIORITY_MEDIUM.equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority("3");
} else if (PRIORITY_HIGH.equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority("4");
}
}
Collections.sort(taskPriority, new Comparator<TaskH>() {
@Override
public int compare(TaskH taskH, TaskH t1) {
return t1.getPriority().compareTo(taskH.getPriority());
}
});
for (TaskH taskH : taskPriority) {
if ("1".equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority(PRIORITY_LOW);
} else if ("2".equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority(PRIORITY_NORMAL);
} else if ("3".equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority(PRIORITY_MEDIUM);
} else if ("4".equalsIgnoreCase(taskH.getPriority())) {
taskH.setPriority(PRIORITY_HIGH);
}
}
}
} catch (NullPointerException e) {
Log.w("SORT","There is something wrong with sort in class : " + PriorityViewAdapter.class.getSimpleName());
}
}
if (null != taskPriority) {
mValues.addAll(taskPriority);
}
}
}

View file

@ -0,0 +1,25 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/newTaskLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_grayscale" >
<View
android:id="@+id/actionbar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/actionbar_background" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/actionbar"
android:divider="@android:color/transparent"
android:dividerHeight="5dp"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true" >
</ListView>
</RelativeLayout>

View file

@ -0,0 +1,97 @@
package com.adins.mss.foundation.image;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
/**
* @author gigin.ginanjar
*/
public class ImageManipulation {
public static Bitmap resizeBitmap(Bitmap image, int maxWidth, int maxHeight) {
if (maxHeight > 0 && maxWidth > 0) {
int width = image.getWidth();
int height = image.getHeight();
float ratioBitmap = (float) width / (float) height;
float ratioMax = (float) maxWidth / (float) maxHeight;
int finalWidth = maxWidth;
int finalHeight = maxHeight;
if (ratioMax > 1) {
finalWidth = (int) ((float) maxHeight * ratioBitmap);
} else {
finalHeight = (int) ((float) maxWidth / ratioBitmap);
}
image = Bitmap.createScaledBitmap(image, finalWidth, finalHeight, true);
return image;
} else {
return image;
}
}
/**
* Create Watermark on Left Bottom Of Bitmap
*
* @param src - Bitmap
* @param watermark - watermark String
* @param color - int color
* @param alpha - int
* @param size - font size
* @param underline - Boolean
* @return Bitmap
*/
public static Bitmap waterMark(Bitmap src, String watermark, int color, int alpha, int size, boolean underline) {
//get source image width and height
int w = src.getWidth();
int h = src.getHeight();
//set position watermark (Left-Bottom)
int x = 10;
int y = h - 10;
Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());
//create canvas object
Canvas canvas = new Canvas(result);
//draw bitmap on canvas
canvas.drawBitmap(src, 0, 0, null);
//create paint object
Paint paint = new Paint();
//apply color
paint.setColor(color);
//set transparency
paint.setAlpha(alpha);
//set text size
paint.setTextSize(size);
paint.setAntiAlias(true);
//set should be underlined or not
paint.setUnderlineText(underline);
//draw text on given location
canvas.drawText(watermark, x, y, paint);
return result;
}
/**
* Rotate Image
*
* @param src - Bitmap
* @param degree - degree
* @return Bitmap
*/
public static Bitmap rotateImage(Bitmap src, int degree) {
//get source image width and height
int w = src.getWidth();
int h = src.getHeight();
//create canvas object
Matrix matrix = new Matrix();
matrix.postRotate(degree);
Bitmap result = Bitmap.createBitmap(src, 0, 0, w, h, matrix, true);
return result;
}
}

View file

@ -0,0 +1,230 @@
package com.adins.mss.odr.followup;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.todolist.form.TaskListTask;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.GroupTask;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.odr.R;
import com.adins.mss.odr.followup.api.DoFollowUpRequest;
import com.adins.mss.odr.followup.api.DoFollowUpResponse;
import java.util.ArrayList;
import java.util.List;
/**
* Created by olivia.dg on 11/24/2017.
*/
public class FragmentFollowUpResult extends Fragment implements OnCheckedListener {
private Context context;
private List<GroupTask> groupTasks;
private RecyclerView list;
private RecyclerView.LayoutManager layoutManager;
private FollowUpAdapter adapter;
private Button btnRequest;
private List<String> groupTaskId;
public List<String> getGroupTaskId() {
return groupTaskId;
}
public void setGroupTaskId(List<String> groupTaskId) {
this.groupTaskId = groupTaskId;
}
public FragmentFollowUpResult(Context context, List<GroupTask> groupTasks) {
this.context = context;
this.groupTasks = groupTasks;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_followup_result, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
list = (RecyclerView) view.findViewById(R.id.list);
layoutManager = new LinearLayoutManager(getActivity());
list.setLayoutManager(layoutManager);
adapter = new FollowUpAdapter(context, FragmentFollowUpResult.this, groupTasks);
list.setAdapter(adapter);
btnRequest = (Button) view.findViewById(R.id.btnRequest);
btnRequest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getGroupTaskId() != null && getGroupTaskId().size() != 0)
doFollowUp(getGroupTaskId());
else {
NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(getActivity());
builder.withTitle("INFO")
.withMessage(getString(R.string.msgNoneSelected))
.show();
}
}
});
groupTaskId = new ArrayList<>();
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle(getString(com.adins.mss.base.R.string.title_mn_followup));
}
@Override
public void onDestroy() {
super.onDestroy();
Utility.freeMemory();
}
public void doFollowUp(final List<String> groupTaskId) {
new AsyncTask<Void, Void, String>() {
final ProgressDialog progress = new ProgressDialog(getActivity());
String errMessage;
String result;
@Override
protected void onPreExecute() {
super.onPreExecute();
progress.setMessage(getActivity().getString(R.string.contact_server));
progress.show();
}
@Override
protected String doInBackground(Void... params) {
DoFollowUpRequest request = new DoFollowUpRequest();
request.setGroupTaskId(groupTaskId);
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
String json = GsonHelper.toJson(request);
String url = GlobalData.getSharedGlobalData().getURL_DO_FOLLOWUP();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(getActivity(), encrypt, decrypt);
HttpConnectionResult serverResult = null;
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
} catch (Exception e) {
e.printStackTrace();
}
DoFollowUpResponse response = null;
if (serverResult != null && serverResult.isOK()) {
try {
String responseBody = serverResult.getResult();
response = GsonHelper.fromJson(responseBody, DoFollowUpResponse.class);
} catch (Exception e) {
if(Global.IS_DEV) {
e.printStackTrace();
errMessage=e.getMessage();
}
}
result = response.getResult();
if (result == null) {
errMessage = getActivity().getString(R.string.no_result_from_server);
} else {
if (result.equalsIgnoreCase("success")) {
result = "success";
} else {
errMessage = getActivity().getString(R.string.msgFollowupFailed);
}
}
} else {
errMessage = getActivity().getString(R.string.server_down);
}
return result;
}
@Override
protected void onPostExecute(String result) {
if (getActivity() != null) {
if (progress != null && progress.isShowing()) {
progress.dismiss();
}
if (errMessage != null) {
if (errMessage.equals(getActivity().getString(R.string.no_data_from_server))) {
NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(getActivity());
builder.withTitle("INFO")
.withMessage(errMessage)
.show();
} else {
Toast.makeText(getActivity(), errMessage, Toast.LENGTH_SHORT).show();
}
} else {
if (result.equalsIgnoreCase("success")) {
try {
final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(getActivity());
dialogBuilder.withTitle(getActivity().getString(R.string.title_mn_followup))
.withMessage(getActivity().getString(R.string.requestSent))
.withButton1Text(getActivity().getString(R.string.btnOk))
.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
dialogBuilder.dismiss();
// Fragment fragment1 = new PriorityTabFragment();
// FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
// transaction.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, com.adins.mss.base.R.anim.activity_close_scale, com.adins.mss.base.R.anim.activity_open_scale, com.adins.mss.base.R.anim.activity_close_translate);
// transaction.replace(com.adins.mss.base.R.id.content_frame, fragment1);
// transaction.addToBackStack(null);
// transaction.commitAllowingStateLoss();
TaskListTask task = new TaskListTask(getActivity(), getActivity().getString(R.string.progressWait),
getActivity().getString(R.string.msgNoTaskList), R.id.content_frame);
task.execute();
}
})
.show();
} catch (Exception e) {
e.printStackTrace();
}
} else {
errMessage = getActivity().getString(R.string.msgFollowupFailed);
}
}
}
}
}.execute();
}
@Override
public void onChecked(String groupTask) {
groupTaskId = getGroupTaskId();
groupTaskId.add(groupTask);
setGroupTaskId(groupTaskId);
}
@Override
public void onUnchecked(String groupTask) {
groupTaskId = getGroupTaskId();
groupTaskId.remove(groupTask);
setGroupTaskId(groupTaskId);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB