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,816 @@
package com.adins.mss.base.todolist.form;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.GridLayoutManager;
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.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
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.CustomerFragment;
import com.adins.mss.base.dynamicform.SurveyHeaderBean;
import com.adins.mss.base.mainmenu.MainMenuActivity;
import com.adins.mss.base.timeline.TimelineManager;
import com.adins.mss.base.todolist.ToDoList;
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.GeneralParameter;
import com.adins.mss.dao.Scheme;
import com.adins.mss.dao.TaskH;
import com.adins.mss.dao.TaskHSequence;
import com.adins.mss.dao.User;
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.TaskHSequenceDataAccess;
import com.adins.mss.foundation.db.dataaccess.TimelineDataAccess;
import com.adins.mss.foundation.db.dataaccess.TimelineTypeDataAccess;
import com.adins.mss.foundation.dialog.DialogManager;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.http.MssRequestType;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import org.acra.ACRA;
import java.util.ArrayList;
import java.util.List;
/**
* A fragment representing a list of Items.
* <p/>
* Activities containing this fragment MUST implement the {@link OnTaskListClickListener}
* interface.
*/
public class PriorityTabFragmentBackup extends Fragment implements OnTaskListClickListener {
public static final String uuidSchemeDummy = "schemeDummy";
private static final String ARG_COLUMN_COUNT = "column-count";
//ineedthisfor coh
private static final String TASK_OBJ_KEY_CONN = "task_object_key_connection";
private static final String TASK_OBJ_KEY_URL = GlobalData.getSharedGlobalData().getURL_UPDATE_CASH_ON_HAND();
private static final String TASK_OBJ_KEY_JSON = "task_object_key_json";
private static final String TASK_OBJ_KEY_DELEGATE = "task_object_key_delegate";
private static final String TASK_OBJ_KEY_CONTEXT = "task_object_key_context";
private static final String TASK_OBJ_KEY_RESULT = "task_object_key_result";
private static final String TASK_OBJ_KEY_BUILD_NUMBER = "task_object_key_build_number";
private static final String TASK_OBJ_KEY_LOGIN_ID = "task_object_key_login_id";
public static PriorityHandler handler;
private static String param;
public ToDoList toDoList;
public List<TaskH> listTaskH;
public List<TaskH> listTaskHSequenceJoin;
protected Spinner spinnerSearch;
protected Spinner spinnerForm;
double limit = 0;
double cashOnHand = 0;
private TextView cashCounter;
private int mColumnCount = 3;
private GeneralParameter columnList;
private SwipeRefreshLayout mSwipeRefreshLayout;
private PriorityViewAdapter viewAdapter;
private TextView priorityCounter;
private String[] isiSearchBy;
private FormAdapter formAdapter;
private List<Scheme> formListName;
private Scheme selectedScheme;
private RefreshBackgroundTask backgroundTask;
private RecyclerView recyclerView;
private boolean isPriorityOpen = false;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public PriorityTabFragmentBackup() {
//EMPTY
}
@SuppressWarnings("unused")
public static PriorityTabFragmentBackup newInstance(int columnCount) {
PriorityTabFragmentBackup fragment = new PriorityTabFragmentBackup();
Bundle args = new Bundle();
args.putInt(ARG_COLUMN_COUNT, Integer.parseInt(param));
fragment.setArguments(args);
return fragment;
}
private boolean isCOHAktif() {
String parameter = GeneralParameterDataAccess.getOne(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user(),
Global.GS_CASHONHAND).getGs_value();
return parameter != null && parameter.equals(Global.TRUE_STRING);
}
@Override
public void onPause() {
super.onPause();
isPriorityOpen = false;
}
@Override
public void onResume() {
super.onResume();
isPriorityOpen = true;
if (viewAdapter != null && listTaskH != null && selectedScheme != null) {
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
try {
setCashOnHandUI();
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorOnResume", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorOnResume", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Set Cash UI"));
}
}
getSelectedTaskH();
viewAdapter = new PriorityViewAdapter(getActivity(), listTaskH, PriorityTabFragmentBackup.this, param);
recyclerView.setAdapter(viewAdapter);
long counter = listTaskH.size();
priorityCounter.setText(getString(R.string.task_count) + String.valueOf(counter));
}
try {
MainMenuActivity.setDrawerCounter();
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", e.getMessage());
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Drawer Counter"));
}
DialogManager.showTimeProviderAlert(getActivity());
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
if (Global.APPLICATION_SURVEY.equalsIgnoreCase(GlobalData.getSharedGlobalData().getApplication())) {
param = GeneralParameterDataAccess.getOne(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_TASK_LAYOUT_MS).getGs_value();
} else if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(GlobalData.getSharedGlobalData().getApplication())) {
param = GeneralParameterDataAccess.getOne(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_TASK_LAYOUT_MC).getGs_value();
} else if (Global.APPLICATION_ORDER.equalsIgnoreCase(GlobalData.getSharedGlobalData().getApplication())) {
param = GeneralParameterDataAccess.getOne(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_TASK_LAYOUT_MO).getGs_value();
}
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
ACRA.getErrorReporter().putCustomData("ErrorPriorityTabFragment", e.getMessage());
ACRA.getErrorReporter().handleSilentException(new Exception("Error get param Priority Tab Fragment" + e.getMessage()));
}
if (null == param) {
param = "1";
}
toDoList = new ToDoList(getActivity().getApplicationContext());
listTaskH = new ArrayList<>();
try {
listTaskH = toDoList.getListTaskInPriority(ToDoList.SEARCH_BY_ALL, "", uuidSchemeDummy);
List<TaskHSequence> taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
List<TaskH> taskHLists = new ArrayList<>();
TaskHSequenceDataAccess.clean(getContext());
TaskHSequenceDataAccess.insertAllNewTaskHSeq(getContext(), listTaskH);
taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
for (int i = 0; i < taskHSequences.size(); i++) {
taskHLists.add(taskHSequences.get(i).getTaskH());
}
listTaskH = taskHLists;
ViewMapActivity.setListTaskH(listTaskH);
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("ErrorOnCreate", e.getMessage());
ACRA.getErrorReporter().putCustomData("ErrorOnCreate", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set List TaskH"));
if (Global.IS_DEV)
e.printStackTrace();
}
formListName = new ArrayList<>();
formListName.clear();
setAllschemeSpinner();
formListName.addAll(SchemeDataAccess.getAllActivePriorityScheme(getActivity()));
viewAdapter = new PriorityViewAdapter(getActivity(), listTaskH, this, param);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = null;
if (param.equalsIgnoreCase("3")) {
view = inflater.inflate(R.layout.fragment__priority_layout_list, container, false);
} else if (param.equalsIgnoreCase("1")) {
view = inflater.inflate(R.layout.fragment__priority_layout, container, false);
}
// Set the adapter
if (view instanceof RelativeLayout) {
handler = new PriorityHandler();
Context context = view.getContext();
recyclerView = (RecyclerView) view.findViewById(R.id.listPriority);
if (param.equalsIgnoreCase("3")) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
} else if (param.equalsIgnoreCase("1")) {
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
}
recyclerView.setAdapter(viewAdapter);
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.tv_light),
getResources().getColor(R.color.tv_normal),
getResources().getColor(R.color.tv_dark),
getResources().getColor(R.color.tv_darker));
mSwipeRefreshLayout
.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
initiateRefresh(true);
}
});
cashCounter = (TextView) view.findViewById(R.id.cashCounter);
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
cashCounter.setVisibility(View.VISIBLE);
try {
setCashOnHandUI();
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorOnResume", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorOnResume", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Set Cash UI"));
e.printStackTrace();
}
} else {
cashCounter.setVisibility(View.GONE);
}
priorityCounter = (TextView) view.findViewById(R.id.priorityCounter);
spinnerSearch = (Spinner) view.findViewById(R.id.priorityViewBy);
isiSearchBy = this.getResources().getStringArray(R.array.cbPriorityBy);
PriorityAdapter priorityAdapter = new PriorityAdapter(getActivity(), R.layout.spinner_style, isiSearchBy);
spinnerSearch.setAdapter(priorityAdapter);
spinnerForm = (Spinner) view.findViewById(R.id.priorityViewByForm);
formAdapter = new FormAdapter(getActivity(), R.layout.spinner_style, R.id.text_spin, formListName);
formAdapter.setDropDownViewResource(R.layout.spinner_style);
spinnerForm.setAdapter(formAdapter);
spinnerForm.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
selectedScheme = formAdapter.getItem(position);
cancelRefreshTask();
getSelectedTaskH();
viewAdapter = new PriorityViewAdapter(getActivity(), listTaskH, PriorityTabFragmentBackup.this, param);
recyclerView.setAdapter(viewAdapter);
long counter = listTaskH.size();
priorityCounter.setText(getString(R.string.task_count)
+ String.valueOf(counter));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
//EMPTY
}
});
spinnerSearch
.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View v,
int position, long id) {
cancelRefreshTask();
listTaskH = getSelectedTaskH();
viewAdapter = new PriorityViewAdapter(getActivity(), listTaskH, PriorityTabFragmentBackup.this, param);
recyclerView.setAdapter(viewAdapter);
long counter = listTaskH.size();
priorityCounter.setText(getString(R.string.task_count)
+ counter);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
//EMPTY
}
});
}
return view;
}
private void setCashOnHandUI() {
String cashLimit = GlobalData.getSharedGlobalData().getUser().getCash_limit();
limit = cashLimit != null ? Double.parseDouble(cashLimit) : 0.0;
String coh = GlobalData.getSharedGlobalData().getUser().getCash_on_hand();
cashOnHand = coh != null ? Double.parseDouble(coh) : 0.0;
String sLimit = Tool.separateThousand(limit);
String sCOH = Tool.separateThousand(cashOnHand);
if (limit > 0 && isCOHAktif())
cashCounter.setText(getActivity().getString(R.string.lblCashOnHand, sLimit, sCOH));
else
cashCounter.setText(getActivity().getString(R.string.lblCashOnHand_wo_limit, sCOH));
cashCounter.setVisibility(View.GONE);
}
private List<TaskH> getSelectedTaskH() {
listTaskH.clear();
if (spinnerSearch.getSelectedItemPosition() == 0) {
listTaskH.addAll(toDoList.getListTaskInPriority(ToDoList.SEARCH_BY_ALL, "", selectedScheme.getUuid_scheme()));
if (listTaskH.isEmpty()) {
return listTaskH;
}
List<TaskHSequence> taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
List<TaskH> taskHLists = new ArrayList<>();
if (taskHSequences.isEmpty() || taskHSequences.size() != listTaskH.size()) {
TaskHSequenceDataAccess.clean(getContext());
TaskHSequenceDataAccess.insertAllNewTaskHSeq(getContext(), listTaskH);
taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
}
for (int i = 0; i < taskHSequences.size(); i++) {
taskHLists.add(taskHSequences.get(i).getTaskH());
}
listTaskH = taskHLists;
}
if (spinnerSearch.getSelectedItemPosition() == 1) {
listTaskH.addAll(toDoList.getListTaskInHighPriority(selectedScheme.getUuid_scheme()));
if (listTaskH.isEmpty()) {
return listTaskH;
}
List<TaskHSequence> taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
List<TaskH> taskHLists = new ArrayList<>();
if (taskHSequences.isEmpty()) {
TaskHSequenceDataAccess.clean(getContext());
TaskHSequenceDataAccess.insertAllNewTaskHSeq(getContext(), listTaskH);
} else {
for (int i = 0; i < listTaskH.size(); i++) {
TaskHSequence taskHSequence = TaskHSequenceDataAccess.getTaskHSeqByUUIDTaskH(getContext(), listTaskH.get(i).getUuid_task_h());
taskHLists.add(taskHSequence.getTaskH());
}
}
listTaskH = taskHLists;
}
if (spinnerSearch.getSelectedItemPosition() == 2) {
listTaskH.addAll(toDoList.getListTaskInNormalPriority(selectedScheme.getUuid_scheme()));
if (listTaskH.isEmpty()) {
return listTaskH;
}
List<TaskHSequence> taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
List<TaskH> taskHLists = new ArrayList<>();
if (taskHSequences.isEmpty()) {
TaskHSequenceDataAccess.clean(getContext());
TaskHSequenceDataAccess.insertAllNewTaskHSeq(getContext(), listTaskH);
} else {
for (int i = 0; i < listTaskH.size(); i++) {
TaskHSequence taskHSequence = TaskHSequenceDataAccess.getTaskHSeqByUUIDTaskH(getContext(), listTaskH.get(i).getUuid_task_h());
taskHLists.add(taskHSequence.getTaskH());
}
}
listTaskH = taskHLists;
}
if (spinnerSearch.getSelectedItemPosition() == 3) {
listTaskH.addAll(toDoList.getListTaskInLowPriority(selectedScheme.getUuid_scheme()));
if (listTaskH.isEmpty()) {
return listTaskH;
}
List<TaskHSequence> taskHSequences = TaskHSequenceDataAccess.getAllOrderAsc(getContext());
List<TaskH> taskHLists = new ArrayList<>();
if (taskHSequences.isEmpty()) {
TaskHSequenceDataAccess.clean(getContext());
TaskHSequenceDataAccess.insertAllNewTaskHSeq(getContext(), listTaskH);
} else {
for (int i = 0; i < listTaskH.size(); i++) {
TaskHSequence taskHSequence = TaskHSequenceDataAccess.getTaskHSeqByUUIDTaskH(getContext(), listTaskH.get(i).getUuid_task_h());
taskHLists.add(taskHSequence.getTaskH());
}
}
listTaskH = taskHLists;
}
return listTaskH;
}
private void setAllschemeSpinner() {
Scheme schemeDummy = new Scheme();
schemeDummy.setUuid_scheme(uuidSchemeDummy);
schemeDummy.setScheme_description("All");
schemeDummy.setForm_id("schemeDummy");
formListName.add(0, schemeDummy);
}
private void initiateRefresh(boolean getDataFromServer) {
cancelRefreshTask();
backgroundTask = new RefreshBackgroundTask(getDataFromServer);
backgroundTask.execute();
}
private void cancelRefreshTask() {
if (backgroundTask != null) {
backgroundTask.cancel(true);
backgroundTask = null;
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onDestroyView() {
super.onDestroyView();
cancelRefreshTask();
Utility.freeMemory();
}
@Override
public void onItemClickListener(TaskH item, int position) {
try {
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application) && isCOHAktif() && limit > 0 && cashOnHand >= limit) {
DialogManager.showAlertNotif(getActivity(), getActivity().getString(R.string.limit_coh), "Cash On Hand");
} else {
Scheme scheme = null;
scheme = item.getScheme();
if (scheme == null && item.getUuid_scheme() != null) {
scheme = SchemeDataAccess.getOne(getActivity(),
item.getUuid_scheme());
if (scheme != null)
item.setScheme(scheme);
}
if (scheme == null) {
Toast.makeText(getActivity(), getActivity().getString(R.string.task_cant_seen),
Toast.LENGTH_SHORT).show();
} else {
SurveyHeaderBean header = new SurveyHeaderBean(item);
CustomerFragment fragment = CustomerFragment.create(header);
FragmentTransaction transaction = MainMenuActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
}
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorClickListener", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorClickListener", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat click item"));
String message = getActivity().getString(R.string.task_cant_seen2);
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onItemLongClickListener(TaskH item, int position) {
//EMPTY
}
private void onRefreshComplete() {
try {
viewAdapter = new PriorityViewAdapter(getActivity(), listTaskH, PriorityTabFragmentBackup.this, param);
recyclerView.setAdapter(viewAdapter);
viewAdapter.notifyDataSetChanged();
long counter = listTaskH.size();
priorityCounter.setText(getString(R.string.task_count) + String.valueOf(counter));
} catch (UnsupportedOperationException e) {
try {
viewAdapter.notifyDataSetChanged();
} catch (Exception e2) {
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", e.getMessage());
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Notify Data Set Changed"));
}
} catch (Exception e) {
FireCrash.log(e);
try {
viewAdapter.notifyDataSetChanged();
} catch (Exception e2) {
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", e.getMessage());
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Notify Data Set Changed"));
}
}
// Stop the refreshing indicator
if (mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing())
mSwipeRefreshLayout.setRefreshing(false);
}
private String getTaskListFromServer(Context activity) {
String errMsg = "";
if (Tool.isInternetconnected(activity)) {
String result;
User user = GlobalData.getSharedGlobalData().getUser();
MssRequestType requestType = new MssRequestType();
requestType.setAudit(GlobalData.getSharedGlobalData().getAuditData());
requestType.addImeiAndroidIdToUnstructured();
String json = GsonHelper.toJson(requestType);
String url = GlobalData.getSharedGlobalData().getURL_GET_TASKLIST();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity, encrypt, decrypt);
HttpConnectionResult serverResult = null;
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, serverResult);
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorRequestToServer", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorRequestToServer", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat request to server"));
e.printStackTrace();
errMsg = getActivity().getString(R.string.jsonParseFailed);
return errMsg;
}
List<String> listUuidTaskH = new ArrayList<>();
if (serverResult != null) {
if (serverResult.isOK()) {
try {
result = serverResult.getResult();
JsonResponseTaskList taskList = GsonHelper.fromJson(result, JsonResponseTaskList.class);
if (taskList.getStatus().getCode() == 0) {
List<TaskH> listTaskH = taskList.getListTaskList();
if (listTaskH != null && !listTaskH.isEmpty()) {
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
TaskHDataAccess.deleteTaskHByStatus(activity, uuidUser, TaskHDataAccess.STATUS_SEND_INIT);
for (TaskH taskH : listTaskH) {
taskH.setUser(user);
taskH.setIs_verification(Global.TRUE_STRING);
String uuid_scheme = taskH.getUuid_scheme();
listUuidTaskH.add(taskH.getUuid_task_h());
Scheme scheme = SchemeDataAccess.getOne(activity, uuid_scheme);
if (scheme != null) {
taskH.setScheme(scheme);
TaskH h = TaskHDataAccess.getOneHeader(activity, taskH.getUuid_task_h());
String uuid_timelineType = TimelineTypeDataAccess.getTimelineTypebyType(activity, Global.TIMELINE_TYPE_TASK).getUuid_timeline_type();
boolean wasInTimeline = TimelineDataAccess.getOneTimelineByTaskH(activity, user.getUuid_user(), taskH.getUuid_task_h(), uuid_timelineType) != null;
if (h != null && h.getStatus() != null) {
if (!ToDoList.isOldTask(h)) {
taskH.setStatus(TaskHDataAccess.STATUS_SEND_INIT);
TaskHDataAccess.addOrReplace(activity, taskH);
if (!wasInTimeline)
TimelineManager.insertTimeline(activity, taskH);
} else {
if (taskH.getPts_date() != null) {
h.setPts_date(taskH.getPts_date());
TaskHDataAccess.addOrReplace(activity, h);
}
}
} else {
taskH.setStatus(TaskHDataAccess.STATUS_SEND_INIT);
TaskHDataAccess.addOrReplace(activity, taskH);
if (!wasInTimeline)
TimelineManager.insertTimeline(activity, taskH);
}
}
}
List<TaskH> taskHs = TaskHDataAccess.getAllTaskByStatus(activity, GlobalData.getSharedGlobalData().getUser().getUuid_user(), TaskHDataAccess.STATUS_SEND_DOWNLOAD);
for (TaskH h : taskHs) {
String uuid_task_h = h.getUuid_task_h();
boolean isSame = false;
for (String uuid_from_server : listUuidTaskH) {
if (uuid_task_h.equals(uuid_from_server)) {
isSame = true;
break;
}
}
if (!isSame) {
TaskHDataAccess.deleteWithRelation(activity, h);
}
}
}
errMsg = "noError";
return errMsg;
} else {
errMsg = result;
return errMsg;
}
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorGetMessageFromServer", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorGetMessageFromServer", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat convert json dari Server"));
errMsg = getActivity().getString(R.string.jsonParseFailed);
return errMsg;
}
} else {
errMsg = serverResult.getResult();
return errMsg;
}
}
return errMsg;
} else {
return errMsg;
}
}
public class PriorityHandler extends Handler {
@Override
public void handleMessage(Message msg) {
try {
if (isPriorityOpen) {
initiateRefresh(false);
}
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorRefresh", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorRefresh", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat initiate Refresh"));
}
}
}
private class RefreshBackgroundTask extends AsyncTask<Void, Void, List<TaskH>> {
static final int TASK_DURATION = 2 * 1000; // 2 seconds
int pos = 0;
String errMessage = "";
boolean isGetFromServer;
public RefreshBackgroundTask(boolean isGetFromServer) {
try {
this.isGetFromServer = isGetFromServer;
pos = spinnerSearch.getSelectedItemPosition();
} catch (Exception e) {
FireCrash.log(e);
}
}
@Override
protected void onCancelled() {
super.onCancelled();
if (mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing())
mSwipeRefreshLayout.setRefreshing(false);
}
@Override
protected List<TaskH> doInBackground(Void... params) {
// Sleep for a small amount of time to simulate a background-task
try {
if (isGetFromServer)
errMessage = getTaskListFromServer(getActivity());
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("errorGetErrorMessage", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorGetErrorMessage", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat convert taskList in error message"));
e.printStackTrace();
}
// Return a new random list of cheeses
return getSelectedTaskH();
}
@Override
protected void onPostExecute(List<TaskH> result) {
super.onPostExecute(result);
if (!errMessage.isEmpty() && !errMessage.equals("noError")) {
Toast.makeText(getActivity(), errMessage, Toast.LENGTH_SHORT).show();
}
try {
MainMenuActivity.setDrawerCounter();
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", e.getMessage());
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Drawer Counter"));
}
onRefreshComplete();
}
}
public class FormAdapter extends ArrayAdapter<Scheme> {
private Context context;
private List<Scheme> values;
public FormAdapter(Context context, int resource, int textViewResourceId, List<Scheme> objects) {
super(context, resource, textViewResourceId, objects);
this.context = context;
this.values = objects;
}
@Override
public int getCount() {
return values.size();
}
@Override
public Scheme getItem(int position) {
return values.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.spinner_style, parent, false);
TextView label = (TextView) view.findViewById(R.id.text_spin);
label.setText("Form : " + values.get(position).getScheme_description());
return label;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.spinner_style, parent, false);
TextView label = (TextView) view.findViewById(R.id.text_spin);
label.setText(values.get(position).getScheme_description());
return label;
}
}
public class PriorityAdapter extends ArrayAdapter<String> {
private Context context;
private String[] values;
public PriorityAdapter(Context context, int resource, String[] objects) {
super(context, resource, objects);
this.context = context;
this.values = objects;
}
@Override
public int getCount() {
return values.length;
}
@Override
public String getItem(int position) {
return values[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.spinner_style, parent, false);
TextView label = (TextView) view.findViewById(R.id.text_spin);
label.setText("Priority : " + values[position]);
return label;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.spinner_style, parent, false);
TextView label = (TextView) view.findViewById(R.id.text_spin);
label.setText(values[position]);
return label;
}
}
}

View file

@ -0,0 +1,48 @@
package com.services;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import com.adins.mss.base.mainmenu.MainMenuActivity;
import com.adins.mss.svy.MSMainMenuActivity;
public class SurveyApprovalService extends Service {
private SurveyApprovalThread auto;
@Override
public void onDestroy() {
super.onDestroy();
stopSurveyApprovalThread();
}
@Override
public void onCreate() {
super.onCreate();
auto = MSMainMenuActivity.approvalThread;
startSurveyApprovalThread();
}
public synchronized void startSurveyApprovalThread() {
if (auto == null) {
auto = new SurveyApprovalThread(getApplicationContext());
auto.start();
}
else {
auto.start();
}
}
public synchronized void stopSurveyApprovalThread() {
if (auto != null) {
auto.requestStop();
auto = null;
}
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

View file

@ -0,0 +1,388 @@
package com.adins.mss.coll.fragments;
import android.content.Context;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.commons.CommonImpl;
import com.adins.mss.base.util.Utility;
import com.adins.mss.coll.R;
import com.adins.mss.coll.fragments.view.DepositReportSummaryView;
import com.adins.mss.dao.DepositReportD;
import com.adins.mss.dao.DepositReportH;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.dataaccess.DepositReportHDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import org.acra.ACRA;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
/**
* Created by Aditya Purwa on 2/13/2015.
*/
public class DepositReportSummaryFragment extends Fragment {
private DepositReportSummaryView view;
@Override
public void onAttach(Context context) {
super.onAttach(context);
view = new DepositReportSummaryView(getActivity());
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_deposit_report_summary, container, false);
return view.layoutInflater(inflater, container);
}
@Override
public void onViewCreated(View mView, Bundle savedInstanceState) {
super.onViewCreated(mView, savedInstanceState);
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
view.onCreate();
view.publish();
}
@Override
public void onDestroyView() {
super.onDestroyView();
Utility.freeMemory();
}
// private void initialize() {
// populateFields();
// cleanup();
// fillHeader();
// fillDetail();
// }
// private void fillHeader() {
// List<TaskH> h = TaskHDataAccess.getTaskCollToday(getActivity());
// List<TaskH> allSentTask = TaskHDataAccess.getAllSentTask(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user());
// List<TaskH> allSentTaskToday = new ArrayList<TaskH>();
// for(TaskH taskH : allSentTask){
// if(CommonImpl.dateIsToday(taskH.getSubmit_date())){
// allSentTaskToday.add(taskH);
// }
// }
//
// List<TaskH> allCollTask = TaskHDataAccess.getAllTaskCollection(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user());
// List<TaskH> collTaskToday = new ArrayList<TaskH>();
// for(TaskH taskH : allCollTask){
// if(CommonImpl.dateIsToday(taskH.getAssignment_date())){
// collTaskToday.add(taskH);
// }
// }
//
//// int totalTask = TaskHDataAccess.getTotalTaskCollToday(getActivity());
// int totalTask = collTaskToday.size();
//// totalTaskLabel.setText(totalTask + " Tasks");
// /* List<TaskD> totalTaskCollToday = TaskDDataAccess.getTotalTaskCollToday(getActivity());
// int totalTaskValue = 0;
// for (TaskD task : totalTaskCollToday) {
// try {
// totalTaskValue = Integer.parseInt(task.getText_answer());
// } catch (Exception e) { FireCrash.log(e);
// totalTaskValue = 0;
// }
// }*/
// this.totalTaskValue.setText(totalTask + " Tasks");
// int paidTask = TaskDDataAccess.getPaid(getActivity()).size();
// int failTask = TaskDDataAccess.getFail(getActivity()).size();
//
// List<TaskD> paidAllTask = TaskDDataAccess.getAllPaid(getActivity());
// paidTask = 0;
// for(TaskD taskD:paidAllTask){
// for(TaskH taskH :collTaskToday){
// if(taskD.getUuid_task_h().equals(taskH.getUuid_task_h())){
// paidTask++;
// }
// }
// }
//
//// List<TaskD> failAllTask = TaskDDataAccess.getAllFail(getActivity());
// failTask = 0;
// for(TaskH taskH : allSentTaskToday){
// /*List<TaskD> ds = TaskDDataAccess.isTaskPaid(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), taskH.getUuid_task_h());
// for(TaskD d : ds){
// String a = d.getUuid_task_d();
// }*/
// if(!TaskDDataAccess.isTaskPaid(getActivity(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), taskH.getUuid_task_h())){
// failTask++;
// }
//// List<TaskD> alltaskd = taskH.getTaskDList();
//// for(TaskD d : alltaskd){
//// String questionId = d.getQuestion_id();
//// String questionGroupId = d.getQuestion_group_id();
//// QuestionSet questionSet = QuestionSetDataAccess.getOne(getActivity(), taskH.getUuid_scheme(), questionId, questionGroupId);
//// if(questionSet.getTag()!=null && Global.TAG_TOTAL.equals(questionSet.getTag())){
//// tempPaid ++;
//// break;
//// }
//// }
// }
//
//// failTask = allSentTaskToday.size() - paidTask;
//
//
//// for(TaskD taskD:failAllTask){
//// for(TaskH taskH :collTaskToday){
//// if(taskD.getUuid_task_h().equals(taskH.getUuid_task_h())){
//// failTask++;
//// }
//// }
//// }
//
// int visitTask = paidTask + failTask;
//
// totalPaidLabel.setText(paidTask + " Tasks");
// totalFailLabel.setText(failTask + " Tasks");
// totalVisitLabel.setText(visitTask + " Tasks");
// }
//
// private void fillDetail() {
// List<DepositReportH> tempBatches = DepositReportHDataAccess.listOfBacth(getActivity(),GlobalData.getSharedGlobalData().getUser().getUuid_user());
// List<DepositReportH> batches = new ArrayList<DepositReportH>();
// for(DepositReportH reportH : tempBatches){
// if(CommonImpl.dateIsToday(reportH.getDtm_crt())){
// batches.add(reportH);
// }
// }
// HashMap<DepositReportH, List<DepositReportD>> packedListOfBatch = packListOfBatch(batches);
//// listOfBatch.setAdapter(new PackedBatchListAdapter(getActivity(), packedListOfBatch));
// listOfBatch.setAdapter(new PackedBatchListAdapterNew(getActivity(), packedListOfBatch));
// }
//
// private HashMap<DepositReportH, List<DepositReportD>> packListOfBatch(List<DepositReportH> batches) {
// HashMap<DepositReportH, List<DepositReportD>> map = new HashMap<DepositReportH, List<DepositReportD>>();
// for (DepositReportH reportH : batches) {
// map.put(reportH, reportH.getDepositReportDList());
// }
// return map;
// }
//
// private void populateFields() {
// totalTaskLabel = (TextView) getView().findViewById(R.id.totalTask);
// totalTaskValue = (TextView) getView().findViewById(R.id.totalTaskValue);
// totalPaidLabel = (TextView) getView().findViewById(R.id.paidValue);
// totalVisitLabel = (TextView) getView().findViewById(R.id.visitValue);
// totalFailLabel = (TextView) getView().findViewById(R.id.failValue);
// listOfBatch = (ListView) getView().findViewById(R.id.listOfBatch);
// }
//
// private void cleanup() {
// Date today = CommonImpl.resetDate();
// DepositReportHDataAccess.deleteDepositReport(getActivity(), today);
// }
// 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) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// Date today = Tool.getSystemDate();
//
// return today.equals(tempDate);
// }
// private class PackedBatchListAdapter extends BaseAdapter {
//
// private final HashMap<TaskH, List<TaskD>> packedBatches;
// private final List<TaskH> batchesHeaders;
// private final Context context;
//
// public PackedBatchListAdapter(Context context, HashMap<TaskH, List<TaskD>> packedBatches) {
// this.context = context;
// this.packedBatches = packedBatches;
// this.batchesHeaders =
// Arrays.asList(packedBatches.keySet().toArray(new TaskH[packedBatches.keySet().size()]));
// }
//
// @Override
// public int getCount() {
// return packedBatches.size() + 1;
// }
//
// @Override
// public Object getItem(int position) {
// return packedBatches.get(batchesHeaders.get(position));
// }
//
// public int getTaskCount(int position) {
// List<TaskD> tasks = (List<TaskD>) getItem(position);
// return tasks.size();
// }
//
// public int getTaskSum(int position) {
// List<TaskD> tasks = (List<TaskD>) getItem(position);
// int sum = 0;
// for (TaskD task : tasks) {
// try {
// sum += Integer.parseInt(task.getText_answer());
// } catch (Exception e) { FireCrash.log(e);
// sum += 0;
// }
// }
// return sum;
// }
//
// public TaskH getHeader(int position) {
// return batchesHeaders.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// if (convertView == null) {
// if (position % 2 == 0) {
// convertView = LayoutInflater.from(context).inflate(R.layout.item_summary_batch_colored, parent, false);
// } else {
// convertView = LayoutInflater.from(context).inflate(R.layout.item_summary_batch_light, parent, false);
// }
// }
// TextView label = (TextView) convertView.findViewById(R.id.itemLabel);
// TextView value = (TextView) convertView.findViewById(R.id.itemValue);
//
// if (position == getCount() - 1) {
// label.setText("Total");
// value.setText(String.valueOf(getSumAll()));
// return convertView;
// }
//
// TaskH header = getHeader(position);
// int taskCount = getTaskCount(position);
// int taskSum = getTaskSum(position);
//
// label.setText(header.getAppl_no());
// value.setText(taskCount + " Tasks, " + taskSum);
//
// return convertView;
// }
//
// private int getSumAll() {
// int sum = 0;
// for (int i = 0; i < getCount() - 1; i++) {
// sum += getTaskSum(i);
// }
// return sum;
// }
// }
//
// private class PackedBatchListAdapterNew extends BaseAdapter {
//
// private final HashMap<DepositReportH, List<DepositReportD>> packedBatches;
// private final List<DepositReportH> batchesHeaders;
// private final Context context;
//
// public PackedBatchListAdapterNew(Context context, HashMap<DepositReportH, List<DepositReportD>> packedBatches) {
// this.context = context;
// this.packedBatches = packedBatches;
// this.batchesHeaders =
// Arrays.asList(packedBatches.keySet().toArray(new DepositReportH[packedBatches.keySet().size()]));
// }
//
// @Override
// public int getCount() {
// return packedBatches.size() + 1;
// }
//
// @Override
// public Object getItem(int position) {
// return packedBatches.get(batchesHeaders.get(position));
// }
//
// public int getTaskCount(int position) {
// List<DepositReportD> tasks = (List<DepositReportD>) getItem(position);
// return tasks.size();
// }
//
// public double getTaskSum(int position) {
// List<DepositReportD> tasks = (List<DepositReportD>) getItem(position);
// double sum = 0;
// for (DepositReportD task : tasks) {
// try {
// sum += Double.parseDouble(task.getDeposit_amt());
// } catch (Exception e) { FireCrash.log(e);
// sum += 0;
// }
// }
// return sum;
// }
//
// public DepositReportH getHeader(int position) {
// return batchesHeaders.get(position);
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// if (convertView == null) {
// if (position % 2 == 0) {
// convertView = LayoutInflater.from(context).inflate(R.layout.item_summary_batch_colored, parent, false);
// } else {
// convertView = LayoutInflater.from(context).inflate(R.layout.item_summary_batch_light, parent, false);
// }
// }
// TextView label = (TextView) convertView.findViewById(R.id.itemLabel);
// TextView value = (TextView) convertView.findViewById(R.id.itemValue);
//
// if (position == getCount() - 1) {
// label.setText("Total");
// value.setText(Tool.separateThousand(String.valueOf(getSumAll())));
// return convertView;
// }
//
// DepositReportH header = getHeader(position);
// int taskCount = getTaskCount(position);
// double taskSum = getTaskSum(position);
//
// label.setText(header.getBatch_id());
// value.setText(taskCount + " Tasks, " + Tool.separateThousand(taskSum));
//
// return convertView;
// }
//
// private int getSumAll() {
// int sum = 0;
// for (int i = 0; i < getCount() - 1; i++) {
// sum += getTaskSum(i);
// }
// return sum;
// }
// }
}

View file

@ -0,0 +1,247 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.DepositReportH;
import com.adins.mss.dao.DepositReportHDao;
import com.adins.mss.foundation.db.DaoOpenHelper;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import de.greenrobot.dao.query.Query;
import de.greenrobot.dao.query.QueryBuilder;
public class DepositReportHDataAccess {
private DepositReportHDataAccess() {
}
/**
* 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 depositReportH dao and you can access the DB
*
* @param context
* @return
*/
protected static DepositReportHDao getDepositReportHDao(Context context) {
return getDaoSession(context).getDepositReportHDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
DaoOpenHelper.closeAll();
}
/**
* add depositReportH as entity
*
* @param context
* @param depositReportH
*/
public static void add(Context context, DepositReportH depositReportH) {
getDepositReportHDao(context).insertInTx(depositReportH);
getDaoSession(context).clear();
}
/**
* add depositReportH as list entity
*
* @param context
* @param depositReportHList
*/
public static void add(Context context, List<DepositReportH> depositReportHList) {
getDepositReportHDao(context).insertInTx(depositReportHList);
getDaoSession(context).clear();
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getDepositReportHDao(context).deleteAll();
getDaoSession(context).clear();
}
/**
* @param context
* @param depositReprtH
*/
public static void delete(Context context, DepositReportH depositReprtH) {
getDepositReportHDao(context).deleteInTx(depositReprtH);
getDaoSession(context).clear();
}
/**
* delete all record by user
*
* @param context
* @param uuidUser
*/
public static void delete(Context context, String uuidUser) {
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
getDepositReportHDao(context).deleteInTx(qb.list());
getDaoSession(context).clear();
}
public static void deleteDummy(Context context) {
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Batch_id.eq("-"));
qb.build();
deleteListWithRelation(context, qb.list());
}
/**
* @param context
* @param depositReportH
*/
public static void update(Context context, DepositReportH depositReportH) {
getDepositReportHDao(context).update(depositReportH);
getDaoSession(context).clear();
}
/**
* select * from table where uuid_user = param
*
* @param context
* @param uuidUser
* @return
*/
public static List<DepositReportH> getAll(Context context, String uuidUser) {
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
return qb.list();
}
/**
* select * from table where uuid_user = param
*
* @param context
* @param uuidUser
* @return
*/
public static List<String> getAllUuid(Context context, String uuidUser) {
List<String> result = new ArrayList<>();
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
for (int i = 0; i < qb.list().size(); i++) {
result.add(qb.list().get(i).getUuid_deposit_report_h());
}
return result;
}
public static void deleteDepositReport(Context context,
Date today) {
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Transfered_date.lt(today));
qb.build();
deleteListWithRelation(context, qb.list());
}
/**
* delete row and the relation form other table
*
* @param context
* @param depositReportH
*/
public static void deleteWithRelation(Context context,
DepositReportH depositReportH) {
DepositReportDDataAccess.delete(context, depositReportH.getUuid_deposit_report_h());
getDepositReportHDao(context).delete(depositReportH);
getDaoSession(context).clear();
}
/**
* Delete list of DepositReportH with their relation on the other tables
*
* @param context
* @param listDepositReportH
*/
public static void deleteListWithRelation(Context context,
List<DepositReportH> listDepositReportH) {
getDepositReportHDao(context).deleteInTx(listDepositReportH);
getDaoSession(context).clear();
}
/**
* Delete list of DepositReportH with their relation on the other tables
*
* @param context
* @param uuidUser
*/
public static List<DepositReportH> listOfBacth(Context context, String uuidUser) {
Query<DepositReportH> query = getDepositReportHDao(context)
.queryRawCreate(", TR_DEPOSITREPORT_D D WHERE " +
"T.UUID_DEPOSIT_REPORT_H = D.UUID_DEPOSIT_REPORT_H " +
"AND T.UUID_USER=?", uuidUser);
return query.list();
}
public static List<DepositReportH> listOfBacth(Context context){
// QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
// qb.where(DepositReportHDao.Properties.Uuid_user.eq(uuidUser));
//
// qb.build();
Query<DepositReportH> query = getDepositReportHDao(context)
.queryRawCreate(", TR_DEPOSITREPORT_D D WHERE " +
"T.UUID_DEPOSIT_REPORT_H = D.UUID_DEPOSIT_REPORT_H ");
//query.list();
return query.list();
}
public static List<DepositReportH> getAllForAllUser(Context context) {
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Branch_payment.isNull());
qb.where(DepositReportHDao.Properties.Code_channel.isNull());
qb.build();
return qb.list();
}
public static List<DepositReportH> getAllForAllUserAC(Context context){
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Branch_payment.isNotNull());
qb.build();
return qb.list();
}
public static List<DepositReportH> getAllForAllUserPC(Context context){
QueryBuilder<DepositReportH> qb = getDepositReportHDao(context).queryBuilder();
qb.where(DepositReportHDao.Properties.Code_channel.isNotNull());
qb.build();
return qb.list();
}
}

View file

@ -0,0 +1,33 @@
package com.adins.mss.foundation.dialog.gitonway.lib.effects;
import android.view.View;
import com.adins.libs.nineoldandroids.animation.ObjectAnimator;
/*
* Copyright 2014 litao
* https://github.com/sd6352051/NiftyDialogEffects
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License 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.
*/
public class SlideLeft extends BaseEffects {
@Override
protected void setupAnimation(View view) {
getAnimatorSet().playTogether(
ObjectAnimator.ofFloat(view, "translationX", -300, 0).setDuration(mDuration),
ObjectAnimator.ofFloat(view, "alpha", 0, 1).setDuration(mDuration * 3 / 2)
);
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="card_margin">1dp</dimen>
<dimen name="card_shadow">0dp</dimen>
</resources>

View file

@ -0,0 +1,50 @@
package com.adins.mss.base.depositreport;
/**
* Created by Kamil on 11/03/17.
*/
import com.adins.mss.foundation.http.MssRequestType;
import com.google.gson.annotations.SerializedName;
public class JsonRequestImage extends MssRequestType {
/**
* Property uuid_task_h
*/
@SerializedName("uuid_task_h")
String uuid_task_h;
/**
* Property question_id
*/
@SerializedName("question_id")
String question_id;
/**
* Gets the uuid_task_h
*/
public String getUuid_task_h() {
return this.uuid_task_h;
}
/**
* Sets the uuid_task_h
*/
public void setUuid_task_h(String value) {
this.uuid_task_h = value;
}
/**
* Gets the question_id
*/
public String getQuestion_id() {
return this.question_id;
}
/**
* Sets the question_id
*/
public void setQuestion_id(String value) {
this.question_id = value;
}
}

View file

@ -0,0 +1,22 @@
package com.adins.mss.base.depositreport;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by dian.ina on 02/09/2015.
*/
public class DepositReportBatchIdResponse extends MssResponseType {
@SerializedName("listBatchID")
private List<DepositReportBatchIdBean> listBatchID;
public List<DepositReportBatchIdBean> getListBatchID() {
return listBatchID;
}
public void setListBatchID(List<DepositReportBatchIdBean> listBatchID) {
this.listBatchID = listBatchID;
}
}

View file

@ -0,0 +1,215 @@
package com.adins.mss.dao;
import com.adins.mss.dao.DaoSession;
import de.greenrobot.dao.DaoException;
import com.adins.mss.base.util.ExcludeFromGson;
import com.google.gson.annotations.SerializedName;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table "MS_PRINTITEM".
*/
public class PrintItem {
/** Not-null value. */
@SerializedName("uuid_print_item")
private String uuid_print_item;
@SerializedName("print_type_id")
private String print_type_id;
@SerializedName("print_item_label")
private String print_item_label;
@SerializedName("question_group_id")
private String question_group_id;
@SerializedName("question_id")
private String question_id;
@SerializedName("print_item_order")
private Integer print_item_order;
@SerializedName("usr_crt")
private String usr_crt;
@SerializedName("dtm_crt")
private java.util.Date dtm_crt;
@SerializedName("usr_upd")
private String usr_upd;
@SerializedName("dtm_upd")
private java.util.Date dtm_upd;
@SerializedName("uuid_scheme")
private String uuid_scheme;
/** Used to resolve relations */
private transient DaoSession daoSession;
/** Used for active entity operations. */
private transient PrintItemDao myDao;
private Scheme scheme;
private String scheme__resolvedKey;
public PrintItem() {
}
public PrintItem(String uuid_print_item) {
this.uuid_print_item = uuid_print_item;
}
public PrintItem(String uuid_print_item, String print_type_id, String print_item_label, String question_group_id, String question_id, Integer print_item_order, String usr_crt, java.util.Date dtm_crt, String usr_upd, java.util.Date dtm_upd, String uuid_scheme) {
this.uuid_print_item = uuid_print_item;
this.print_type_id = print_type_id;
this.print_item_label = print_item_label;
this.question_group_id = question_group_id;
this.question_id = question_id;
this.print_item_order = print_item_order;
this.usr_crt = usr_crt;
this.dtm_crt = dtm_crt;
this.usr_upd = usr_upd;
this.dtm_upd = dtm_upd;
this.uuid_scheme = uuid_scheme;
}
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getPrintItemDao() : null;
}
/** Not-null value. */
public String getUuid_print_item() {
return uuid_print_item;
}
/** Not-null value; ensure this value is available before it is saved to the database. */
public void setUuid_print_item(String uuid_print_item) {
this.uuid_print_item = uuid_print_item;
}
public String getPrint_type_id() {
return print_type_id;
}
public void setPrint_type_id(String print_type_id) {
this.print_type_id = print_type_id;
}
public String getPrint_item_label() {
return print_item_label;
}
public void setPrint_item_label(String print_item_label) {
this.print_item_label = print_item_label;
}
public String getQuestion_group_id() {
return question_group_id;
}
public void setQuestion_group_id(String question_group_id) {
this.question_group_id = question_group_id;
}
public String getQuestion_id() {
return question_id;
}
public void setQuestion_id(String question_id) {
this.question_id = question_id;
}
public Integer getPrint_item_order() {
return print_item_order;
}
public void setPrint_item_order(Integer print_item_order) {
this.print_item_order = print_item_order;
}
public String getUsr_crt() {
return usr_crt;
}
public void setUsr_crt(String usr_crt) {
this.usr_crt = usr_crt;
}
public java.util.Date getDtm_crt() {
return dtm_crt;
}
public void setDtm_crt(java.util.Date dtm_crt) {
this.dtm_crt = dtm_crt;
}
public String getUsr_upd() {
return usr_upd;
}
public void setUsr_upd(String usr_upd) {
this.usr_upd = usr_upd;
}
public java.util.Date getDtm_upd() {
return dtm_upd;
}
public void setDtm_upd(java.util.Date dtm_upd) {
this.dtm_upd = dtm_upd;
}
public String getUuid_scheme() {
return uuid_scheme;
}
public void setUuid_scheme(String uuid_scheme) {
this.uuid_scheme = uuid_scheme;
}
/** To-one relationship, resolved on first access. */
public Scheme getScheme() {
String __key = this.uuid_scheme;
if (scheme__resolvedKey == null || scheme__resolvedKey != __key) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
SchemeDao targetDao = daoSession.getSchemeDao();
Scheme schemeNew = targetDao.load(__key);
synchronized (this) {
scheme = schemeNew;
scheme__resolvedKey = __key;
}
}
return scheme;
}
public void setScheme(Scheme scheme) {
synchronized (this) {
this.scheme = scheme;
uuid_scheme = scheme == null ? null : scheme.getUuid_scheme();
scheme__resolvedKey = uuid_scheme;
}
}
/** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
}

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillEnabled="true"
android:duration="500">
<translate
android:fromYDelta="5%p"
android:toYDelta="0"/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>

View file

@ -0,0 +1,921 @@
package com.adins.mss.dao;
import java.util.List;
import com.adins.mss.dao.DaoSession;
import de.greenrobot.dao.DaoException;
import com.adins.mss.base.util.ExcludeFromGson;
import com.google.gson.annotations.SerializedName;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table "MS_USER".
*/
public class User {
/** Not-null value. */
@SerializedName("uuid_user")
private String uuid_user;
@SerializedName("flag_job")
private String flag_job;
@ExcludeFromGson
@SerializedName("image_profile")
private byte[] image_profile;
@SerializedName("fullname")
private String fullname;
@SerializedName("branch_id")
private String branch_id;
@SerializedName("branch_name")
private String branch_name;
@SerializedName("is_branch")
private String is_branch;
@SerializedName("password")
private String password;
@SerializedName("task_seq")
private Integer task_seq;
@SerializedName("google_id")
private String google_id;
@SerializedName("facebook_id")
private String facebook_id;
@SerializedName("login_id")
private String login_id;
@SerializedName("fail_count")
private Integer fail_count;
@SerializedName("last_sync")
private java.util.Date last_sync;
@SerializedName("branch_address")
private String branch_address;
@SerializedName("usr_crt")
private String usr_crt;
@SerializedName("dtm_crt")
private java.util.Date dtm_crt;
@SerializedName("usr_upd")
private String usr_upd;
@SerializedName("dtm_upd")
private java.util.Date dtm_upd;
@ExcludeFromGson
@SerializedName("image_cover")
private byte[] image_cover;
@SerializedName("chg_pwd")
private String chg_pwd;
@SerializedName("job_description")
private String job_description;
@SerializedName("pwd_exp")
private String pwd_exp;
@SerializedName("dealer_name")
private String dealer_name;
@SerializedName("cash_limit")
private String cash_limit;
@SerializedName("cash_on_hand")
private String cash_on_hand;
@SerializedName("uuid_branch")
private String uuid_branch;
@SerializedName("uuid_group")
private String uuid_group;
@SerializedName("uuid_dealer")
private String uuid_dealer;
@SerializedName("start_time")
private String start_time;
@SerializedName("end_time")
private String end_time;
@SerializedName("is_tracking")
private String is_tracking;
@SerializedName("tracking_days")
private String tracking_days;
@SerializedName("token_id_fcm")
private String token_id_fcm;
@SerializedName("is_emergency")
private String is_emergency;
@SerializedName("membershipProgramCode")
private String membershipProgramCode;
@SerializedName("membershipProgramName")
private String membershipProgramName;
@SerializedName("membershipProgramPriorityCode")
private String membershipProgramPriorityCode;
@SerializedName("membershipProgramStatus")
private String membershipProgramStatus;
@SerializedName("membershipProgramExpiredDate")
private String membershipProgramExpiredDate;
@SerializedName("membershipProgramStartDate")
private String membershipProgramStartDate;
@SerializedName("gracePeriode")
private String gracePeriode;
@SerializedName("listKompetisi")
private String listKompetisi;
@SerializedName("piloting_branch")
private String piloting_branch;
/** Used to resolve relations */
private transient DaoSession daoSession;
/** Used for active entity operations. */
private transient UserDao myDao;
private List<GeneralParameter> generalParameterList;
private List<GroupUser> groupUserList;
private List<Menu> menuList;
private List<Logger> loggerList;
private List<CollectionHistory> collectionHistoryList;
private List<Kompetisi> kompetisiList;
private List<DepositReportH> depositReportHList;
private List<LocationInfo> locationInfoList;
private List<Message> messageList;
private List<MobileContentH> mobileContentHList;
private List<PrintResult> printResultList;
private List<ReceiptVoucher> receiptVoucherList;
private List<TaskH> taskHList;
private List<ErrorLog> errorLogList;
private List<Timeline> timelineList;
private List<PlanTask> planTaskList;
public User() {
}
public User(String uuid_user) {
this.uuid_user = uuid_user;
}
public User(String uuid_user, String flag_job, byte[] image_profile, String fullname, String branch_id, String branch_name, String is_branch, String password, Integer task_seq, String google_id, String facebook_id, String login_id, Integer fail_count, java.util.Date last_sync, String branch_address, String usr_crt, java.util.Date dtm_crt, String usr_upd, java.util.Date dtm_upd, byte[] image_cover, String chg_pwd, String job_description, String pwd_exp, String dealer_name, String cash_limit, String cash_on_hand, String uuid_branch, String uuid_group, String uuid_dealer, String start_time, String end_time, String is_tracking, String tracking_days, String token_id_fcm, String is_emergency, String membershipProgramCode, String membershipProgramName, String membershipProgramPriorityCode, String membershipProgramStatus, String membershipProgramExpiredDate, String membershipProgramStartDate, String gracePeriode, String listKompetisi, String piloting_branch) {
this.uuid_user = uuid_user;
this.flag_job = flag_job;
this.image_profile = image_profile;
this.fullname = fullname;
this.branch_id = branch_id;
this.branch_name = branch_name;
this.is_branch = is_branch;
this.password = password;
this.task_seq = task_seq;
this.google_id = google_id;
this.facebook_id = facebook_id;
this.login_id = login_id;
this.fail_count = fail_count;
this.last_sync = last_sync;
this.branch_address = branch_address;
this.usr_crt = usr_crt;
this.dtm_crt = dtm_crt;
this.usr_upd = usr_upd;
this.dtm_upd = dtm_upd;
this.image_cover = image_cover;
this.chg_pwd = chg_pwd;
this.job_description = job_description;
this.pwd_exp = pwd_exp;
this.dealer_name = dealer_name;
this.cash_limit = cash_limit;
this.cash_on_hand = cash_on_hand;
this.uuid_branch = uuid_branch;
this.uuid_group = uuid_group;
this.uuid_dealer = uuid_dealer;
this.start_time = start_time;
this.end_time = end_time;
this.is_tracking = is_tracking;
this.tracking_days = tracking_days;
this.token_id_fcm = token_id_fcm;
this.is_emergency = is_emergency;
this.membershipProgramCode = membershipProgramCode;
this.membershipProgramName = membershipProgramName;
this.membershipProgramPriorityCode = membershipProgramPriorityCode;
this.membershipProgramStatus = membershipProgramStatus;
this.membershipProgramExpiredDate = membershipProgramExpiredDate;
this.membershipProgramStartDate = membershipProgramStartDate;
this.gracePeriode = gracePeriode;
this.listKompetisi = listKompetisi;
this.piloting_branch = piloting_branch;
}
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getUserDao() : null;
}
/** Not-null value. */
public String getUuid_user() {
return uuid_user;
}
/** Not-null value; ensure this value is available before it is saved to the database. */
public void setUuid_user(String uuid_user) {
this.uuid_user = uuid_user;
}
public String getFlag_job() {
return flag_job;
}
public void setFlag_job(String flag_job) {
this.flag_job = flag_job;
}
public byte[] getImage_profile() {
return image_profile;
}
public void setImage_profile(byte[] image_profile) {
this.image_profile = image_profile;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getBranch_id() {
return branch_id;
}
public void setBranch_id(String branch_id) {
this.branch_id = branch_id;
}
public String getBranch_name() {
return branch_name;
}
public void setBranch_name(String branch_name) {
this.branch_name = branch_name;
}
public String getIs_branch() {
return is_branch;
}
public void setIs_branch(String is_branch) {
this.is_branch = is_branch;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getTask_seq() {
return task_seq;
}
public void setTask_seq(Integer task_seq) {
this.task_seq = task_seq;
}
public String getGoogle_id() {
return google_id;
}
public void setGoogle_id(String google_id) {
this.google_id = google_id;
}
public String getFacebook_id() {
return facebook_id;
}
public void setFacebook_id(String facebook_id) {
this.facebook_id = facebook_id;
}
public String getLogin_id() {
return login_id;
}
public void setLogin_id(String login_id) {
this.login_id = login_id;
}
public Integer getFail_count() {
return fail_count;
}
public void setFail_count(Integer fail_count) {
this.fail_count = fail_count;
}
public java.util.Date getLast_sync() {
return last_sync;
}
public void setLast_sync(java.util.Date last_sync) {
this.last_sync = last_sync;
}
public String getBranch_address() {
return branch_address;
}
public void setBranch_address(String branch_address) {
this.branch_address = branch_address;
}
public String getUsr_crt() {
return usr_crt;
}
public void setUsr_crt(String usr_crt) {
this.usr_crt = usr_crt;
}
public java.util.Date getDtm_crt() {
return dtm_crt;
}
public void setDtm_crt(java.util.Date dtm_crt) {
this.dtm_crt = dtm_crt;
}
public String getUsr_upd() {
return usr_upd;
}
public void setUsr_upd(String usr_upd) {
this.usr_upd = usr_upd;
}
public java.util.Date getDtm_upd() {
return dtm_upd;
}
public void setDtm_upd(java.util.Date dtm_upd) {
this.dtm_upd = dtm_upd;
}
public byte[] getImage_cover() {
return image_cover;
}
public void setImage_cover(byte[] image_cover) {
this.image_cover = image_cover;
}
public String getChg_pwd() {
return chg_pwd;
}
public void setChg_pwd(String chg_pwd) {
this.chg_pwd = chg_pwd;
}
public String getJob_description() {
return job_description;
}
public void setJob_description(String job_description) {
this.job_description = job_description;
}
public String getPwd_exp() {
return pwd_exp;
}
public void setPwd_exp(String pwd_exp) {
this.pwd_exp = pwd_exp;
}
public String getDealer_name() {
return dealer_name;
}
public void setDealer_name(String dealer_name) {
this.dealer_name = dealer_name;
}
public String getCash_limit() {
return cash_limit;
}
public void setCash_limit(String cash_limit) {
this.cash_limit = cash_limit;
}
public String getCash_on_hand() {
return cash_on_hand;
}
public void setCash_on_hand(String cash_on_hand) {
this.cash_on_hand = cash_on_hand;
}
public String getUuid_branch() {
return uuid_branch;
}
public void setUuid_branch(String uuid_branch) {
this.uuid_branch = uuid_branch;
}
public String getUuid_group() {
return uuid_group;
}
public void setUuid_group(String uuid_group) {
this.uuid_group = uuid_group;
}
public String getUuid_dealer() {
return uuid_dealer;
}
public void setUuid_dealer(String uuid_dealer) {
this.uuid_dealer = uuid_dealer;
}
public String getStart_time() {
return start_time;
}
public void setStart_time(String start_time) {
this.start_time = start_time;
}
public String getEnd_time() {
return end_time;
}
public void setEnd_time(String end_time) {
this.end_time = end_time;
}
public String getIs_tracking() {
return is_tracking;
}
public void setIs_tracking(String is_tracking) {
this.is_tracking = is_tracking;
}
public String getTracking_days() {
return tracking_days;
}
public void setTracking_days(String tracking_days) {
this.tracking_days = tracking_days;
}
public String getToken_id_fcm() {
return token_id_fcm;
}
public void setToken_id_fcm(String token_id_fcm) {
this.token_id_fcm = token_id_fcm;
}
public String getIs_emergency() {
return is_emergency;
}
public void setIs_emergency(String is_emergency) {
this.is_emergency = is_emergency;
}
public String getMembershipProgramCode() {
return membershipProgramCode;
}
public void setMembershipProgramCode(String membershipProgramCode) {
this.membershipProgramCode = membershipProgramCode;
}
public String getMembershipProgramName() {
return membershipProgramName;
}
public void setMembershipProgramName(String membershipProgramName) {
this.membershipProgramName = membershipProgramName;
}
public String getMembershipProgramPriorityCode() {
return membershipProgramPriorityCode;
}
public void setMembershipProgramPriorityCode(String membershipProgramPriorityCode) {
this.membershipProgramPriorityCode = membershipProgramPriorityCode;
}
public String getMembershipProgramStatus() {
return membershipProgramStatus;
}
public void setMembershipProgramStatus(String membershipProgramStatus) {
this.membershipProgramStatus = membershipProgramStatus;
}
public String getMembershipProgramExpiredDate() {
return membershipProgramExpiredDate;
}
public void setMembershipProgramExpiredDate(String membershipProgramExpiredDate) {
this.membershipProgramExpiredDate = membershipProgramExpiredDate;
}
public String getMembershipProgramStartDate() {
return membershipProgramStartDate;
}
public void setMembershipProgramStartDate(String membershipProgramStartDate) {
this.membershipProgramStartDate = membershipProgramStartDate;
}
public String getGracePeriode() {
return gracePeriode;
}
public void setGracePeriode(String gracePeriode) {
this.gracePeriode = gracePeriode;
}
public String getListKompetisi() {
return listKompetisi;
}
public void setListKompetisi(String listKompetisi) {
this.listKompetisi = listKompetisi;
}
public String getPiloting_branch() {
return piloting_branch;
}
public void setPiloting_branch(String piloting_branch) {
this.piloting_branch = piloting_branch;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<GeneralParameter> getGeneralParameterList() {
if (generalParameterList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
GeneralParameterDao targetDao = daoSession.getGeneralParameterDao();
List<GeneralParameter> generalParameterListNew = targetDao._queryUser_GeneralParameterList(uuid_user);
synchronized (this) {
if(generalParameterList == null) {
generalParameterList = generalParameterListNew;
}
}
}
return generalParameterList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetGeneralParameterList() {
generalParameterList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<GroupUser> getGroupUserList() {
if (groupUserList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
GroupUserDao targetDao = daoSession.getGroupUserDao();
List<GroupUser> groupUserListNew = targetDao._queryUser_GroupUserList(uuid_user);
synchronized (this) {
if(groupUserList == null) {
groupUserList = groupUserListNew;
}
}
}
return groupUserList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetGroupUserList() {
groupUserList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<Menu> getMenuList() {
if (menuList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
MenuDao targetDao = daoSession.getMenuDao();
List<Menu> menuListNew = targetDao._queryUser_MenuList(uuid_user);
synchronized (this) {
if(menuList == null) {
menuList = menuListNew;
}
}
}
return menuList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetMenuList() {
menuList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<Logger> getLoggerList() {
if (loggerList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
LoggerDao targetDao = daoSession.getLoggerDao();
List<Logger> loggerListNew = targetDao._queryUser_LoggerList(uuid_user);
synchronized (this) {
if(loggerList == null) {
loggerList = loggerListNew;
}
}
}
return loggerList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetLoggerList() {
loggerList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<CollectionHistory> getCollectionHistoryList() {
if (collectionHistoryList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
CollectionHistoryDao targetDao = daoSession.getCollectionHistoryDao();
List<CollectionHistory> collectionHistoryListNew = targetDao._queryUser_CollectionHistoryList(uuid_user);
synchronized (this) {
if(collectionHistoryList == null) {
collectionHistoryList = collectionHistoryListNew;
}
}
}
return collectionHistoryList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetCollectionHistoryList() {
collectionHistoryList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<Kompetisi> getKompetisiList() {
if (kompetisiList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
KompetisiDao targetDao = daoSession.getKompetisiDao();
List<Kompetisi> kompetisiListNew = targetDao._queryUser_KompetisiList(uuid_user);
synchronized (this) {
if(kompetisiList == null) {
kompetisiList = kompetisiListNew;
}
}
}
return kompetisiList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetKompetisiList() {
kompetisiList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<DepositReportH> getDepositReportHList() {
if (depositReportHList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
DepositReportHDao targetDao = daoSession.getDepositReportHDao();
List<DepositReportH> depositReportHListNew = targetDao._queryUser_DepositReportHList(uuid_user);
synchronized (this) {
if(depositReportHList == null) {
depositReportHList = depositReportHListNew;
}
}
}
return depositReportHList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetDepositReportHList() {
depositReportHList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<LocationInfo> getLocationInfoList() {
if (locationInfoList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
LocationInfoDao targetDao = daoSession.getLocationInfoDao();
List<LocationInfo> locationInfoListNew = targetDao._queryUser_LocationInfoList(uuid_user);
synchronized (this) {
if(locationInfoList == null) {
locationInfoList = locationInfoListNew;
}
}
}
return locationInfoList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetLocationInfoList() {
locationInfoList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<Message> getMessageList() {
if (messageList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
MessageDao targetDao = daoSession.getMessageDao();
List<Message> messageListNew = targetDao._queryUser_MessageList(uuid_user);
synchronized (this) {
if(messageList == null) {
messageList = messageListNew;
}
}
}
return messageList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetMessageList() {
messageList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<MobileContentH> getMobileContentHList() {
if (mobileContentHList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
MobileContentHDao targetDao = daoSession.getMobileContentHDao();
List<MobileContentH> mobileContentHListNew = targetDao._queryUser_MobileContentHList(uuid_user);
synchronized (this) {
if(mobileContentHList == null) {
mobileContentHList = mobileContentHListNew;
}
}
}
return mobileContentHList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetMobileContentHList() {
mobileContentHList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<PrintResult> getPrintResultList() {
if (printResultList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
PrintResultDao targetDao = daoSession.getPrintResultDao();
List<PrintResult> printResultListNew = targetDao._queryUser_PrintResultList(uuid_user);
synchronized (this) {
if(printResultList == null) {
printResultList = printResultListNew;
}
}
}
return printResultList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetPrintResultList() {
printResultList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<ReceiptVoucher> getReceiptVoucherList() {
if (receiptVoucherList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
ReceiptVoucherDao targetDao = daoSession.getReceiptVoucherDao();
List<ReceiptVoucher> receiptVoucherListNew = targetDao._queryUser_ReceiptVoucherList(uuid_user);
synchronized (this) {
if(receiptVoucherList == null) {
receiptVoucherList = receiptVoucherListNew;
}
}
}
return receiptVoucherList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetReceiptVoucherList() {
receiptVoucherList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<TaskH> getTaskHList() {
if (taskHList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
TaskHDao targetDao = daoSession.getTaskHDao();
List<TaskH> taskHListNew = targetDao._queryUser_TaskHList(uuid_user);
synchronized (this) {
if(taskHList == null) {
taskHList = taskHListNew;
}
}
}
return taskHList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetTaskHList() {
taskHList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<ErrorLog> getErrorLogList() {
if (errorLogList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
ErrorLogDao targetDao = daoSession.getErrorLogDao();
List<ErrorLog> errorLogListNew = targetDao._queryUser_ErrorLogList(uuid_user);
synchronized (this) {
if(errorLogList == null) {
errorLogList = errorLogListNew;
}
}
}
return errorLogList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetErrorLogList() {
errorLogList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<Timeline> getTimelineList() {
if (timelineList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
TimelineDao targetDao = daoSession.getTimelineDao();
List<Timeline> timelineListNew = targetDao._queryUser_TimelineList(uuid_user);
synchronized (this) {
if(timelineList == null) {
timelineList = timelineListNew;
}
}
}
return timelineList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetTimelineList() {
timelineList = null;
}
/** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
public List<PlanTask> getPlanTaskList() {
if (planTaskList == null) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
PlanTaskDao targetDao = daoSession.getPlanTaskDao();
List<PlanTask> planTaskListNew = targetDao._queryUser_PlanTaskList(uuid_user);
synchronized (this) {
if(planTaskList == null) {
planTaskList = planTaskListNew;
}
}
}
return planTaskList;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
public synchronized void resetPlanTaskList() {
planTaskList = null;
}
/** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
}

View file

@ -0,0 +1,113 @@
package com.adins.mss.coll.services;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.crashlytics.FireCrash;
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.User;
import com.adins.mss.foundation.camerainapp.helper.Logger;
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import com.services.models.JsonResponseTokenId;
import com.services.models.JsonSendTokenId;
public class RefreshToken extends FirebaseInstanceIdService {
Context context;
public RefreshToken() {
}
public RefreshToken(Context context) {
this.context = context;
}
@Override
public void onTokenRefresh() {
super.onTokenRefresh();
String token = FirebaseInstanceId.getInstance().getToken();
Logger.d("Firebase", " masuk onToken ");
if (null != token) {
Global.Token = token;
registerToken(token);
}
}
private void registerToken(final String token) {
if (null != token && !"".equalsIgnoreCase(token)) {
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
String result = null;
try {
Thread.sleep(5000);
} catch (Exception e) {
FireCrash.log(e);
}
User user = GlobalData.getSharedGlobalData().getUser();
if (null != user && null == user.getToken_id_fcm()) {
if (Tool.isInternetconnected(context)) {
JsonSendTokenId task = new JsonSendTokenId();
task.setAudit(GlobalData.getSharedGlobalData().getAuditData());
task.addImeiAndroidIdToUnstructured();
task.setToken_id(token);
task.setUuid_user(GlobalData.getSharedGlobalData().getUser().getUuid_user());
String json = GsonHelper.toJson(task);
String url = GlobalData.getSharedGlobalData().getURL_UPDATE_FCM();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(getBaseContext(), encrypt, decrypt);
HttpConnectionResult serverResult = null;
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, serverResult);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
if (null != serverResult && serverResult.isOK()){
result = serverResult.getResult();
}
}
}
return result;
}
@Override
protected void onPostExecute(final String message) {
if (null != message) {
JsonResponseTokenId responseTokenId = GsonHelper.fromJson(message, JsonResponseTokenId.class);
if (responseTokenId.getStatus().getCode() == 0){
if (!"".equalsIgnoreCase(responseTokenId.getToken_id())) {
User user = GlobalData.getSharedGlobalData().getUser();
user.setToken_id_fcm(token);
GlobalData.getSharedGlobalData().setUser(user);
UserDataAccess.update(context, user);
}
}
}
}
}.execute();
}
}
}

View file

@ -0,0 +1,372 @@
package com.adins.mss.base.todolist.form;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
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.crashlytics.FireCrash;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.Account;
import com.adins.mss.dao.Product;
import com.adins.mss.dao.Scheme;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.dataaccess.AccountDataAccess;
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
import com.adins.mss.foundation.db.dataaccess.ProductDataAccess;
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by muhammad.aap on 11/12/2018.
*/
public class NewToDoListViewAdapter extends RecyclerView.Adapter<NewToDoListViewAdapter.ViewHolder>{
public static final String PRIORITY_HIGH = "HIGH";
public static final String PRIORITY_MEDIUM = "MEDIUM";
public static final String PRIORITY_NORMAL = "NORMAL";
public static final String PRIORITY_LOW = "LOW";
private List<TaskH> mValues = new ArrayList<>();
private List<TaskH> taskPriority = new ArrayList<>();
private final OnTaskListClickListener mListener;
private final Context mContext;
private static String param;
String initials;
@Override
public int getItemViewType(int position) {
return 1;
}
public NewToDoListViewAdapter(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
if(!items.isEmpty()){
for (TaskH task : items) {
if (task.getStatus().equalsIgnoreCase(TaskHDataAccess.STATUS_SEND_INIT) ||
task.getStatus().equalsIgnoreCase(TaskHDataAccess.STATUS_SEND_DOWNLOAD))
taskPriority.add(task);
else {
mValues.add(task);
}
}
try {
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){
FireCrash.log(e);
}
}
if (taskPriority != null) {
for (TaskH taskH : taskPriority)
mValues.add(taskH);
}
mListener = listener;
NewToDoListViewAdapter.param = param;
}
@Override
public NewToDoListViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_todolist_item, parent, false);
return new NewToDoListViewAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(final NewToDoListViewAdapter.ViewHolder holder, final int position) {
holder.mItem = mValues.get(position);
holder.bind(mValues.get(position));
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(holder.mItem, 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(holder.mItem, position);
}
return true;
}
});
}
@Override
public int getItemCount() {
if (mValues != null)
return mValues.size();
else
return 0;
}
public class ViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public final LinearLayout layout ;
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 TextView accName;
public final TextView lastStatus;
public final TextView prodName;
public final LinearLayout mmaLayout;
public final LinearLayout taskLayout;
public String phoneNumber;
public ViewHolder(View view) {
super(view);
mView = view;
layout = (LinearLayout) view.findViewById(R.id.taskListLayout);
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);
taskLayout = (LinearLayout) view.findViewById(R.id.taskLayout);
mmaLayout = (LinearLayout) view.findViewById(R.id.mmaLayout);
accName = (TextView) view.findViewById(R.id.accountName);
lastStatus = (TextView) view.findViewById(R.id.lastStatus);
prodName = (TextView) view.findViewById(R.id.productName);
}
public void bind(TaskH taskH){
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
if (Global.APPLICATION_ORDER.equals(application)) {
taskLayout.setVisibility(View.GONE);
if (taskH.getStatus_code() != null) {
lastStatus.setText(taskH.getStatus_code());
} else {
TaskD taskd = TaskDDataAccess.getOneFromTaskDWithTag(mContext, taskH.getUuid_task_h(), Global.TAG_STATUS);
if (taskd != null)
lastStatus.setText(taskd.getLov());
else
lastStatus.setText("-");
}
if (taskH.getUuid_account() != null) {
Account account = AccountDataAccess.getOne(mContext, taskH.getUuid_account());
if(account != null) {
initials = "";
initials=initial(account.getAccount_name());
accName.setText(account.getAccount_name());
phoneNumber="";
phoneNumber=taskH.getCustomer_phone();
}
else
accName.setText("-");
} else
accName.setText("-");
if (taskH.getUuid_product() != null) {
Product product = ProductDataAccess.getOne(mContext, taskH.getUuid_product());
if (product != null) {
prodName.setText(product.getProduct_name());
} else {
prodName.setText("-");
}
} else
prodName.setText("-");
} else {
draftDate.setVisibility(View.GONE);
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());
TaskD taskdAmount = TaskDDataAccess.getOneFromTaskDWithTag(mContext, taskH.getUuid_task_h(), Global.TAG_OS_AMOUNT);
TaskD taskdOD = TaskDDataAccess.getOneFromTaskDWithTag(mContext, taskH.getUuid_task_h(), Global.TAG_OD);
TaskD taskdInstallmentNo = TaskDDataAccess.getOneFromTaskDWithTag(mContext, taskH.getUuid_task_h(), Global.TAG_INSTALLMENT_NO);
if (taskdAmount == null) {
txtAmount.setText("-");
} else {
txtAmount.setText(Tool.separateThousand(taskdAmount.getText_answer()));
}
if (taskdOD == null) {
txtOverdue.setText("-");
} else {
txtOverdue.setText(taskdOD.getText_answer());
}
if (taskdInstallmentNo == null) {
txtInstallment.setText("-");
} else {
txtInstallment.setText(taskdInstallmentNo.getText_answer());
}
} 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());
int SLA_time = Integer.parseInt(GeneralParameterDataAccess.getOne(
mContext,
GlobalData.getSharedGlobalData().getUser().getUuid_user(),
Global.GS_SLA_TIME).getGs_value());
Date assignDate = taskH.getAssignment_date();
Date dSlaTime;
if (assignDate != null) {
Long assDateMs = assignDate.getTime();
Date now = Tool.getSystemDateTime();
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");
String slaDate = sdf.format(dSlaTime);
slaTime.setVisibility(View.VISIBLE);
slaTime.setText(slaDate);
if (nowMs > sla_late) {
slaTime.setBackgroundResource(R.color.slaRed);
} else
slaTime.setBackgroundResource(R.color.slaGreen);
}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());
}
}
if (taskH.getStatus().equalsIgnoreCase(TaskHDataAccess.STATUS_SEND_INIT) || taskH.getStatus().equalsIgnoreCase(TaskHDataAccess.STATUS_SEND_DOWNLOAD)) {
// 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_SAVEDRAFT.equalsIgnoreCase(taskH.getStatus())) {
draftDate.setVisibility(View.VISIBLE);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy - HH:mm");
draftDate.setText(sdf.format(taskH.getDraft_date()));
}
}
@Override
public String toString() {
return super.toString() + " '" + mItem.getCustomer_name() + "'";
}
@NonNull
private String initial(String initial) {
Pattern p = Pattern.compile("((^| )[A-Za-z])");
Matcher m = p.matcher(initial);
StringBuilder init = new StringBuilder();
int counter =0;
while (m.find() && counter<2) {
init.append(m.group().trim());
init.append(" ") ;
counter++;
}
return init.toString().toUpperCase();
}
}
}