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,133 @@
package com.adins.mss.base.todolist.form;
import android.content.Context;
import android.graphics.Color;
import androidx.core.view.MotionEventCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.adins.mss.base.R;
import com.adins.mss.base.todolist.form.helper.ItemTouchHelperAdapter;
import com.adins.mss.base.todolist.form.helper.ItemTouchHelperViewHolder;
import com.adins.mss.base.todolist.form.helper.OnStartDragListener;
import com.adins.mss.dao.TaskH;
import java.util.Collections;
import java.util.List;
/**
* Created by ACER 471 on 3/22/2017.
*/
public class SurveyListAdapter extends RecyclerView.Adapter<SurveyListAdapter.ItemViewHolder>
implements ItemTouchHelperAdapter {
private final OnStartDragListener mDragStartListener;
private Context mContext;
private List<TaskH> listTaskH;
public SurveyListAdapter(Context mContext, OnStartDragListener dragStartListener, List<TaskH> listTaskH) {
mDragStartListener = dragStartListener;
this.listTaskH = listTaskH;
this.mContext = mContext;
}
@Override
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.survey_plan_item, parent, false);
ItemViewHolder itemViewHolder = new ItemViewHolder(view);
return itemViewHolder;
}
@Override
public void onBindViewHolder(final ItemViewHolder holder, int position) {
TaskH taskH = listTaskH.get(position);
holder.txtPriority.setText(taskH.getPriority());
holder.txtCustName.setText(taskH.getCustomer_name());
holder.txtCustAddress.setText(taskH.getCustomer_address());
holder.txtCustPhone.setText(taskH.getCustomer_phone());
holder.txtNotes.setText(taskH.getNotes());
// Start a drag whenever the handle view it touched
holder.handleView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
mDragStartListener.onStartDrag(holder);
}
return false;
}
});
}
@Override
public void onItemDismiss(int position) {
// lis.remove(position);
// notifyItemRemoved(position);
}
@Override
public boolean onItemMove(int fromPosition, int toPosition) {
Collections.swap(listTaskH, fromPosition, toPosition);
notifyItemMoved(fromPosition, toPosition);
// TaskHSequenceDataAccess.clean(mContext);
// TaskHSequenceDataAccess.insertAllNewTaskHSeq(mContext, listTaskH);
// Toast.makeText(mContext, "Berhasil Memindah Task", Toast.LENGTH_SHORT).show();
return true;
}
@Override
public int getItemCount() {
return listTaskH.size();
}
public List<TaskH> getListTaskH() {
return listTaskH;
}
/**
* Simple example of a view holder that implements {@link ItemTouchHelperViewHolder} and has a
* "handle" view that initiates a drag event when touched.
*/
public static class ItemViewHolder extends RecyclerView.ViewHolder implements
ItemTouchHelperViewHolder {
public final TextView txtPriority;
public final TextView txtCustName;
public final TextView txtCustAddress;
public final TextView txtCustPhone;
public final TextView txtNotes;
// public final TextView textView;
public ImageView handleView;
public ItemViewHolder(View itemView) {
super(itemView);
txtPriority = (TextView) itemView.findViewById(R.id.txtPriority);
txtCustName = (TextView) itemView.findViewById(R.id.txtCustName);
txtCustAddress = (TextView) itemView.findViewById(R.id.txtCustAddress);
txtCustPhone = (TextView) itemView.findViewById(R.id.txtCustPhone);
txtNotes = (TextView) itemView.findViewById(R.id.txtNotes);
handleView = (ImageView) itemView.findViewById(R.id.dragableIcon);
}
@Override
public void onItemSelected() {
itemView.setBackgroundColor(Color.LTGRAY);
}
@Override
public void onItemClear() {
itemView.setBackgroundColor(Color.LTGRAY);
}
}
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gradient_end"
android:pathData="M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM14,6h-4L10,4h4v2z"/>
</vector>

View file

@ -0,0 +1,70 @@
package com.adins.mss.odr.model;
import com.adins.mss.foundation.http.MssRequestType;
import com.google.gson.annotations.SerializedName;
public class JsonRequestDetailOrder extends MssRequestType {
/**
* Property flag
*/
@SerializedName("flag")
String flag;
/**
* Property nomor_order
*/
@SerializedName("nomor_order")
String nomor_order;
@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 flag
*/
public String getFlag() {
return this.flag;
}
/**
* Sets the flag
*/
public void setFlag(String value) {
this.flag = value;
}
/**
* Gets the nomor_order
*/
public String getNomor_order() {
return this.nomor_order;
}
/**
* Sets the nomor_order
*/
public void setNomor_order(String value) {
this.nomor_order = value;
}
}

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<com.adins.mss.foundation.questiongenerator.form.QuestionView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/questionDropdownLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0. label"
android:id="@+id/questionDropdownLabel" />
<TextView
android:id="@+id/questionDropdownEmpty"
android:layout_width="match_parent"
android:text="@string/lookup_not_found"
android:visibility="gone"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/spinnerQuestionList"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/img1"
android:layout_width="@dimen/exr_iconSize"
android:layout_height="@dimen/exr_iconSize"
android:layout_gravity="center_vertical"
android:tint="@color/tv_white"
android:src="@drawable/ic_expand_more_24dp"
android:layout_marginRight="@dimen/padding_medium"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/spinnerQuestionList"
android:layout_alignParentTop="true" />
</RelativeLayout>
<EditText
android:id="@+id/questionDropdownDescription"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content" />
</com.adins.mss.foundation.questiongenerator.form.QuestionView>

View file

@ -0,0 +1,38 @@
package com.adins.mss.base.timeline;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import com.adins.mss.dao.Timeline;
import java.util.List;
/**
* Created by kusnendi.muhamad on 26/07/2017.
*/
public interface TimelineInterface {
public AsyncTask<Void, Void, List<Timeline>> refreshBackgroundTask();
public AsyncTask<Void, Void, Bitmap> refreshImageBitmap(int viewId, int defaultDrawable, byte[] byteImage);
public List<Timeline> getTimelines();
public void setCashOnHand();
public boolean isCOHAktif();
public double getLimit();
public double getCashOnHand();
public String getsCOH();
public String getsLimit();
public String getCoh();
public String getCashLimit();
public Bitmap getBitmap();
}

View file

@ -0,0 +1,133 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.Message;
import com.adins.mss.dao.MessageDao;
import com.adins.mss.foundation.db.DaoOpenHelper;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
public class MessageDataAccess {
// private static DaoOpenHelper daoOpenHelper;
/**
* use to generate dao session that you can access modelDao
*
* @param context --> context from activity
* @return
*/
protected static DaoSession getDaoSession(Context context) {
/*if(daoOpenHelper==null){
// if(daoOpenHelper.getDaoSession()==null)
daoOpenHelper = new DaoOpenHelper(context);
}
DaoSession daoSeesion = daoOpenHelper.getDaoSession();
return daoSeesion;*/
return DaoOpenHelper.getDaoSession(context);
}
/**
* get message dao and you can access the DB
*
* @param context
* @return
*/
protected static MessageDao getMessageDao(Context context) {
return getDaoSession(context).getMessageDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
/*if(daoOpenHelper!=null){
daoOpenHelper.closeAll();
daoOpenHelper = null;
}*/
DaoOpenHelper.closeAll();
}
/**
* add message as entity
*
* @param context
* @param message
*/
public static void add(Context context, Message message) {
getMessageDao(context).insert(message);
}
/**
* add message as list entity
*
* @param context
* @param messageList
*/
public static void add(Context context, List<Message> messageList) {
getMessageDao(context).insertInTx(messageList);
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getMessageDao(context).deleteAll();
}
/**
* @param context
* @param message
*/
public static void delete(Context context, Message message) {
getMessageDao(context).delete(message);
}
/**
* delete all record by user
*
* @param context
* @param uuidUser
*/
public static void delete(Context context, String uuidUser) {
QueryBuilder<Message> qb = getMessageDao(context).queryBuilder();
qb.where(MessageDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
getMessageDao(context).deleteInTx(qb.list());
}
/**
* @param context
* @param message
*/
public static void updateMessage(Context context, Message message) {
getMessageDao(context).update(message);
}
/**
* select * from table where uuid_user = param
*
* @param context
* @param uuidUser
* @return
*/
public static List<Message> getAll(Context context, String uuidUser) {
QueryBuilder<Message> qb = getMessageDao(context).queryBuilder();
qb.where(MessageDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
return qb.list();
}
/**
* select message per
*
* @param context
* @return
*/
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

View file

@ -0,0 +1,22 @@
package com.adins.mss.coll.models;
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 DepositReportReconcileResponse extends MssResponseType {
@SerializedName("taskId")
private List<String> taskId;
public List<String> getTaskId() {
return taskId;
}
public void setTaskId(List<String> taskId) {
this.taskId = taskId;
}
}

View file

@ -0,0 +1,19 @@
package com.adins.mss.svy.tool;
import com.adins.mss.dao.TaskD;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class JsonTaskD extends MssResponseType {
@SerializedName("listTaskD")
List<TaskD> listTaskD;
public List<TaskD> getListTaskD(){
return listTaskD;
}
public void setListTaskD (List<TaskD> listTaskD){
this.listTaskD = listTaskD;
}
}

View file

@ -0,0 +1,54 @@
package com.adins.mss.foundation.http;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
//import javax.xml.bind.annotation.XmlRootElement;
//@XmlRootElement(name="result")
public class MssResponseType implements Serializable {
@SerializedName("unstructured")
protected KeyValue[] unstructured;
@SerializedName("status")
protected MssResponseType.Status status;
public KeyValue[] getUnstructured() {
return unstructured;
}
public void setUnstructured(KeyValue[] unstructured) {
this.unstructured = unstructured;
}
public Status getStatus() {
return status;
}
public void setStatus(MssResponseType.Status status) {
this.status = status;
}
public static class Status implements Serializable {
@SerializedName("code")
protected int code;
@SerializedName("message")
protected String message;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
}

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/legendColorRect"
android:layout_width="30dp"
android:layout_height="10dp"
android:src="@drawable/legend_color_rect"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/legendText"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/legendColorRect"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/hello_blank_fragment"
android:textSize="12sp"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,132 @@
package com.adins.mss.base;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.adins.mss.base.api.ChangePasswordApi;
import com.adins.mss.base.api.ChangePasswordApiCallback;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.login.DefaultLoginModel;
import com.adins.mss.base.models.ChangePasswordRequestModel;
import com.adins.mss.base.syncfile.FileSyncHelper;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.User;
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
import com.google.firebase.analytics.FirebaseAnalytics;
public class NewChangePasswordActivity extends AppCompatActivity {
private EditText currentPassword;
private EditText newPassword;
private EditText retypePassword;
private Button changePassword;
private FirebaseAnalytics screenName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
screenName = FirebaseAnalytics.getInstance(this);
setContentView(R.layout.new_change_password_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitleTextColor(getResources().getColor(R.color.fontColorWhite));
toolbar.setTitle(getResources().getString(R.string.title_mn_resetpassword));
setSupportActionBar(toolbar);
String pwdExp = this.getIntent().getStringExtra(DefaultLoginModel.PWD_EXP);
try {
if (pwdExp.equals("1")) {
Toast.makeText(NewChangePasswordActivity.this, getString(R.string.password_expired),
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
FireCrash.log(e);
// TODO: handle exception
}
currentPassword = (EditText) findViewById(R.id.currentPassword);
newPassword = (EditText) findViewById(R.id.newPassword);
retypePassword = (EditText) findViewById(R.id.retypePassword);
changePassword = (Button) findViewById(R.id.changePassword);
changePassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (newPassword.getText() == null ||
newPassword.getText().toString().equals("")) {
newPassword.setError(getString(R.string.new_password_mandatory));
return;
}
if (!newPassword.getText().toString().equals(retypePassword.getText().toString())) {
Toast.makeText(NewChangePasswordActivity.this, getString(R.string.new_password_equal), Toast.LENGTH_SHORT).show();
return;
}
ChangePasswordRequestModel request = new ChangePasswordRequestModel();
request.setUuid_user(GlobalData.getSharedGlobalData().getUser().getUuid_user());
request.setOld_password(currentPassword.getText().toString());
request.setNew_password(newPassword.getText().toString());
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
ChangePasswordApi api = new ChangePasswordApi(NewChangePasswordActivity.this);
api.setCallback(new ChangePasswordApiCallback() {
@Override
public void onFailed(String message) {
try {
Toast.makeText(NewChangePasswordActivity.this, getString(R.string.warning_capital) + ": " + message, Toast.LENGTH_LONG).show();
} catch (Exception e) {
FireCrash.log(e);
Toast.makeText(NewChangePasswordActivity.this, "Change Password Error", Toast.LENGTH_LONG).show();
}
}
@Override
public void onSuccess() {
Toast.makeText(NewChangePasswordActivity.this, getString(R.string.password_changed), Toast.LENGTH_LONG).show();
User user = GlobalData.getSharedGlobalData().getUser();
user.setPassword(newPassword.getText().toString());
UserDataAccess.addOrReplace(NewChangePasswordActivity.this, user);
// goToSynchronize();
Global.syncIntent = null;
finish();
clear();
}
});
api.execute(request);
}
});
}
@Override
protected void onResume() {
super.onResume();
screenName.setCurrentScreen(this, getString(R.string.screen_name_change_password), null);
}
private void clear() {
currentPassword.setText("");
newPassword.setText("");
retypePassword.setText("");
}
@Override
public void onBackPressed() {
//
}
private void goToSynchronize() {
if (Global.syncIntent != null) {
Intent syncIntent = Global.syncIntent;
startActivity(syncIntent);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View file

@ -0,0 +1,243 @@
package com.adins.mss.base.todolist;
import android.content.Context;
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.QuestionSet;
import com.adins.mss.dao.Scheme;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.dao.User;
import com.adins.mss.foundation.db.dataaccess.QuestionSetDataAccess;
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
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 java.util.List;
public class DoList {
private static Context context;
private static List<Scheme> listScheme;
private static List<QuestionSet> listQuestionSet;
private TaskH taskH;
private List<TaskD> listTaskD;
private User user;
public DoList(Context context) {
DoList.context = context;
user = GlobalData.getSharedGlobalData().getUser();
}
/**
* For the first call, this method will download scheme list and all question set of each scheme from server and store them to local storage.
* For the next call, this method will return a list from local storage.
*
* @return
*/
public List<Scheme> getListScheme() {
listScheme = SchemeDataAccess.getAll(context);
if (listScheme == null)
listScheme = getListSchemeFromServer();
for (Scheme scheme : listScheme) {
getQuestionSetFromServer(scheme);
}
return listScheme;
}
/**
* it will return null if not be initialzed first
*
* @return
*/
public TaskH getTaskH() {
return taskH;
}
/**
* This method will download list scheme from server and store it to local storage
*
* @return
*/
public List<Scheme> getListSchemeFromServer() {
MssRequestType mrt = new MssRequestType();
mrt.setAudit(GlobalData.getSharedGlobalData().getAuditData());
mrt.addImeiAndroidIdToUnstructured();
// to JSON
String json = GsonHelper.toJson(mrt);
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult result = null;
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(GlobalData.getSharedGlobalData().getURL_GET_SCHEME(), FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
result = httpConn.requestToServer(GlobalData.getSharedGlobalData().getURL_GET_SCHEME(), json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, result);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
if(result == null){
return listScheme;
}
JsonGetScheme jgs = GsonHelper.fromJson(result.getResult(), JsonGetScheme.class);
listScheme = jgs.getListScheme();
for (Scheme scheme : listScheme) {
if (scheme.getUuid_scheme() == null) {
listScheme.remove(scheme);
}
}
//bong 19 may 15 - delete scheme dulu baru di add dari server
if (!listScheme.isEmpty()) {
SchemeDataAccess.clean(context);
}
SchemeDataAccess.addOrReplace(context, listScheme);
return listScheme;
}
/**
* It will initiate a new object for TaskH data type
*
* @param scheme
* @return
*/
public TaskH getNewTaskH(Scheme scheme) {
taskH = null;
taskH = new TaskH();
taskH.setUser(user);
taskH.setScheme(scheme);
return taskH;
}
/**
* It will return all Task Detail for a taskId
*
* @param taskId
* @param withImage
* @return
*/
public List<TaskD> getListTaskD(String taskId, int withImage) {
listTaskD = null;
listTaskD = TaskDDataAccess.getAllByTaskId(context, user.getUuid_user(), taskId, withImage);
return listTaskD;
}
// need of getQuestionSet
/**
* It will return all question set for a scheme from local
*
* @param scheme
* @return
*/
public List<QuestionSet> getQuestionSet(Scheme scheme) {
List<QuestionSet> listQuestionSet = QuestionSetDataAccess.getAll(context, scheme.getUuid_scheme());
if (listQuestionSet.isEmpty())
return getQuestionSetFromServer(scheme);
else return listQuestionSet;
}
/**
* It will return all question set for a scheme from server
*
* @param scheme
* @return
*/
public List<QuestionSet> getQuestionSetFromServer(Scheme scheme) {
RequestQuestionSetBean rqsb = new RequestQuestionSetBean();
rqsb.setFormId(scheme.getForm_id());
rqsb.setAudit(GlobalData.getSharedGlobalData().getAuditData());
rqsb.addImeiAndroidIdToUnstructured();
// to JSON
String json = GsonHelper.toJson(rqsb);
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult result = null;
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(GlobalData.getSharedGlobalData().getURL_GET_QUESTIONSET(), FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
result = httpConn.requestToServer(GlobalData.getSharedGlobalData().getURL_GET_QUESTIONSET(), json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, result);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
if(result == null){
return listQuestionSet;
}
JsonQuestionSet jqs = GsonHelper.fromJson(result.getResult(), JsonQuestionSet.class);
listQuestionSet = jqs.getListQuestionSet();
QuestionSetDataAccess.addOrReplace(context, scheme.getUuid_scheme(), listQuestionSet);
return listQuestionSet;
}
/**
* This method will redownload scheme list and all question set of each scheme from server, then store them to local storage
*/
public void doRefresh() {
listScheme = getListSchemeFromServer();
for (Scheme scheme : listScheme) {
getQuestionSetFromServer(scheme);
}
}
/**
* Gets List Scheme for LeadIn
*
* @return Scheme List
* @author gigin.ginanjar
*/
public List<Scheme> getOrderListScheme() {
return SchemeDataAccess.getAllOrderScheme(context);
}
/**
* Gets List Scheme for Mobile Survey
*
* @return Scheme List
* @author gigin.ginanjar
*/
public List<Scheme> getSurveyListScheme() {
return SchemeDataAccess.getAllSurveyScheme(context);
}
/**
* Gets List Scheme for Mobile Survey
*
* @return Scheme List
* @author gigin.ginanjar
*/
public List<Scheme> getCollListScheme() {
return SchemeDataAccess.getAllCollectionScheme(context);
}
public List<Scheme> getMarketingListScheme() {
return SchemeDataAccess.getAllMarketingScheme(context);
}
}

View file

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="19.565218"
android:viewportHeight="19.565218"
android:tint="#FFFFFF">
<group android:translateX="-2.2173913"
android:translateY="-2.2173913">
<path
android:fillColor="#FF000000"
android:pathData="M15.73,3L8.27,3L3,8.27v7.46L8.27,21h7.46L21,15.73L21,8.27L15.73,3zM12,17.3c-0.72,0 -1.3,-0.58 -1.3,-1.3 0,-0.72 0.58,-1.3 1.3,-1.3 0.72,0 1.3,0.58 1.3,1.3 0,0.72 -0.58,1.3 -1.3,1.3zM13,13h-2L11,7h2v6z"/>
</group>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1,215 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.MobileContentH;
import com.adins.mss.dao.MobileContentHDao;
import com.adins.mss.foundation.db.DaoOpenHelper;
import com.adins.mss.foundation.formatter.Tool;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
public class MobileContentHDataAccess {
private MobileContentHDataAccess() {
}
/**
* 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 mobileContentH dao and you can access the DB
*
* @param context
* @return
*/
protected static MobileContentHDao getMobileContentHDao(Context context) {
return getDaoSession(context).getMobileContentHDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
DaoOpenHelper.closeAll();
}
public static void addOrReplace(Context context, MobileContentH mobileContentH) {
getMobileContentHDao(context).insertOrReplaceInTx(mobileContentH);
getDaoSession(context).clear();
}
public static void addOrReplace(Context context, List<MobileContentH> mobileContentHList) {
getMobileContentHDao(context).insertOrReplaceInTx(mobileContentHList);
getDaoSession(context).clear();
}
/**
* add mobileContentH as entity
*
* @param context
* @param mobileContentH
*/
public static void add(Context context, MobileContentH mobileContentH) {
getMobileContentHDao(context).insertInTx(mobileContentH);
getDaoSession(context).clear();
}
/**
* add mobileContentH as list entity
*
* @param context
* @param mobileContentHList
*/
public static void add(Context context, List<MobileContentH> mobileContentHList) {
getMobileContentHDao(context).insertInTx(mobileContentHList);
getDaoSession(context).clear();
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getMobileContentHDao(context).deleteAll();
getDaoSession(context).clear();
}
/**
* @param context
* @param mobileContentH
*/
public static void delete(Context context, MobileContentH mobileContentH) {
getMobileContentHDao(context).deleteInTx(mobileContentH);
getDaoSession(context).clear();
}
/**
* delete all record by user
*
* @param context
* @param uuidUser
*/
public static void delete(Context context, String uuidUser) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
getMobileContentHDao(context).deleteInTx(qb.list());
getDaoSession(context).clear();
}
/**
* @param context
* @param mobileContentH
*/
public static void update(Context context, MobileContentH mobileContentH) {
getMobileContentHDao(context).updateInTx(mobileContentH);
getDaoSession(context).clear();
}
/**
* get one mobileContentH
*
* @param context
* @param keyMobileContentH
* @return
*/
public static MobileContentH getOne(Context context, String keyMobileContentH) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_mobile_content_h.eq(keyMobileContentH));
qb.build();
if (!qb.list().isEmpty())
return qb.list().get(0);
else return null;
}
/**
* select * from table where uuid_user = param
*
* @param context
* @param uuidUser
* @return
*/
public static List<MobileContentH> getAll(Context context, String uuidUser) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser));
qb.build();
return qb.list();
}
/**
* select * from table where uuid_parent_content = param
*
* @param context
* @param uuidUser
* @param keyParentContent
* @return
*/
public static List<MobileContentH> getAll(Context context, String uuidUser, String keyParentContent) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser),
MobileContentHDao.Properties.Uuid_parent_content.eq(keyParentContent)
, MobileContentHDao.Properties.Start_date.lt(Tool.getSystemDateTime())
, MobileContentHDao.Properties.End_date.gt(Tool.getSystemDateTime()));
qb.build();
return qb.list();
}
public static List<MobileContentH> getAllWithoutDate(Context context, String uuidUser, String keyParentContent) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser),
MobileContentHDao.Properties.Uuid_parent_content.eq(keyParentContent));
qb.build();
return qb.list();
}
/**
* select * from table where uuid_parent_content = null
*
* @param context
* @param uuidUser
* @return
*/
public static List<MobileContentH> getAllParent(Context context, String uuidUser) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser),
MobileContentHDao.Properties.Uuid_parent_content.eq("0")
, MobileContentHDao.Properties.Start_date.lt(Tool.getSystemDateTime())
, MobileContentHDao.Properties.End_date.gt(Tool.getSystemDateTime())
);
qb.build();
return qb.list();
}
public static long getParentCounter(Context context, String uuidUser) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser),
MobileContentHDao.Properties.Uuid_parent_content.isNull());
qb.build();
return qb.count();
}
/**
* @param context
* @param uuidUser
* @param uuid_mobile_content_h
* @return
*/
public static List<MobileContentH> getContent(Context context, String uuidUser, String uuid_mobile_content_h) {
QueryBuilder<MobileContentH> qb = getMobileContentHDao(context).queryBuilder();
qb.where(MobileContentHDao.Properties.Uuid_user.eq(uuidUser),
MobileContentHDao.Properties.Uuid_mobile_content_h.eq(uuid_mobile_content_h));
qb.build();
return qb.list();
}
}

View file

@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>