mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-07-01 05:14:17 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,115 @@
|
|||
package com.adins.mss.base.loyalti.mypointdashboard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Base64;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
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.perf.FirebasePerformance;
|
||||
import com.google.firebase.perf.metrics.HttpMetric;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
public class GetLogoKompetisi extends AsyncTask<Void, Void, String> {
|
||||
private Context context;
|
||||
String errMsg = "";
|
||||
public GetLogoKompetisiResponse logoKompetisiResponse;
|
||||
String memberCode;
|
||||
ImageView imageLogo;
|
||||
|
||||
|
||||
public GetLogoKompetisi(Context mContext, String membership_program_code, ImageView logoKompetisi) {
|
||||
context = mContext;
|
||||
memberCode = membership_program_code;
|
||||
imageLogo = logoKompetisi;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... voids) {
|
||||
if (Tool.isInternetconnected(context)) {
|
||||
|
||||
Gson gson = new GsonBuilder().setDateFormat("ddMMyyyyHHmmss").registerTypeHierarchyAdapter(byte[].class,
|
||||
new GsonHelper.ByteArrayToBase64TypeAdapter()).create();
|
||||
String result;
|
||||
GetLogoRequest requestType = new GetLogoRequest();
|
||||
// ArrayList<String> data = null;
|
||||
// data = new ArrayList<>();
|
||||
// for(int i = 0 ; i < dataKompetisireq.size() ; i++){
|
||||
// data.add(dataKompetisireq.get(i).getMembershipProgramCode());
|
||||
// }
|
||||
requestType.setMEMBERSHIP_PROGRAM_CODE(memberCode);
|
||||
requestType.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
// requestType.addItemToUnstructured(new KeyValue("imei", GlobalData.getSharedGlobalData().getImei()), false);
|
||||
|
||||
String json = GsonHelper.toJson(requestType);
|
||||
String url = GlobalData.getSharedGlobalData().getURL_GET_LOGOKOMPETISI();
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, 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) {
|
||||
e.printStackTrace();
|
||||
errMsg = e.getMessage();
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
if(serverResult != null && serverResult.getStatusCode() == 200){
|
||||
try {
|
||||
logoKompetisiResponse = gson.fromJson(serverResult.getResult(), GetLogoKompetisiResponse.class);
|
||||
} catch (Exception e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}else {
|
||||
errMsg = context.getString(R.string.failed_get_data_try_again);
|
||||
}
|
||||
|
||||
return errMsg;
|
||||
} else {
|
||||
errMsg = context.getString(R.string.no_internet_connection);
|
||||
return errMsg;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String s) {
|
||||
super.onPostExecute(s);
|
||||
if (errMsg.length() > 0) {
|
||||
Toast.makeText(context, errMsg, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String base64Logo = logoKompetisiResponse.getLOGO();
|
||||
if(base64Logo != null && !base64Logo.equals("")){
|
||||
byte[] decodedString = Base64.decode(base64Logo, Base64.DEFAULT );
|
||||
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
|
||||
imageLogo.setImageBitmap(decodedByte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package com.adins.mss.svy.tool;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
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.TaskD;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
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.image.JsonResponseImage;
|
||||
import com.adins.mss.svy.R;
|
||||
import com.adins.mss.svy.assignment.OrderAssignmentResult;
|
||||
import com.adins.mss.svy.reassignment.JsonRequestImage;
|
||||
import com.google.firebase.perf.FirebasePerformance;
|
||||
import com.google.firebase.perf.metrics.HttpMetric;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
public class getImageTask extends AsyncTask<Void, Void, byte[]> {
|
||||
private ProgressDialog progressDialog;
|
||||
private String errMessage = null;
|
||||
private WeakReference<Activity> activity;
|
||||
static byte[] imagebyte =null;
|
||||
List<NameValuePair> params;
|
||||
|
||||
public getImageTask(Activity activity, List<NameValuePair> params){
|
||||
this.activity = new WeakReference<Activity>(activity);
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = ProgressDialog.show(activity.get(),
|
||||
"", activity.get().getString(R.string.progressWait), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] doInBackground(Void... arg0) {
|
||||
byte[] imageResult =null;
|
||||
JsonRequestImage request = new JsonRequestImage();
|
||||
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
request.setUuid_task_h(params.get(0).getValue());
|
||||
request.setQuestion_id(params.get(1).getValue());
|
||||
|
||||
String json = GsonHelper.toJson(request);
|
||||
String url = GlobalData.getSharedGlobalData().getURL_GET_IMAGE();
|
||||
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity.get(), encrypt, decrypt);
|
||||
HttpConnectionResult serverResult = null;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
String result = serverResult.getResult();
|
||||
|
||||
JsonResponseImage resultServer = null;
|
||||
try {
|
||||
resultServer = GsonHelper.fromJson(result, JsonResponseImage.class);
|
||||
if(resultServer.getStatus().getCode()==0){
|
||||
List<TaskD> taskDs = resultServer.getImg();
|
||||
TaskD d = taskDs.get(0);
|
||||
imageResult = d.getImage();
|
||||
}else{
|
||||
errMessage = resultServer.getStatus().getMessage();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
errMessage = e.getMessage();
|
||||
}
|
||||
|
||||
return imageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(byte[] result){
|
||||
if (progressDialog.isShowing()){
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
if(errMessage!=null){
|
||||
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(activity.get());
|
||||
dialogBuilder.withTitle(activity.get().getString(R.string.error_capital))
|
||||
.withMessage(errMessage)
|
||||
.show();
|
||||
}else{
|
||||
if(null==result){
|
||||
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(activity.get());
|
||||
dialogBuilder.withTitle(activity.get().getString(R.string.info_capital))
|
||||
.withMessage(activity.get().getString(R.string.no_image))
|
||||
.show();
|
||||
}else{
|
||||
try {
|
||||
OrderAssignmentResult.targetThumbnail.setResultImg(result);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.adins.mss.foundation.print.paymentchannel;
|
||||
|
||||
import com.adins.mss.dao.PaymentChannel;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by angga.permadi on 5/10/2016.
|
||||
*/
|
||||
public class SyncChannelResponse extends MssResponseType {
|
||||
@SerializedName("errorMessage")
|
||||
private String errorMessage;
|
||||
@SerializedName("listPaymentChannel")
|
||||
private List<PaymentChannel> listPaymentChannel;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public List<PaymentChannel> getListPaymentChannel() {
|
||||
return listPaymentChannel;
|
||||
}
|
||||
|
||||
public void setListPaymentChannelr(List<PaymentChannel> listPaymentChannel) {
|
||||
this.listPaymentChannel = listPaymentChannel;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -0,0 +1,118 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.ExcludeFromGson;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SurveyHeaderBean extends TaskH implements Serializable, Cloneable {
|
||||
@ExcludeFromGson
|
||||
private FormBean form;
|
||||
@ExcludeFromGson
|
||||
private int imageLeft;
|
||||
|
||||
public SurveyHeaderBean() {
|
||||
}
|
||||
|
||||
public SurveyHeaderBean(TaskH taskH) {
|
||||
if (taskH == null)
|
||||
throw new IllegalArgumentException("taskH is null!");
|
||||
setUuid_task_h(taskH.getUuid_task_h());
|
||||
setTask_id(taskH.getTask_id());
|
||||
setStatus(taskH.getStatus());
|
||||
setIs_printable(taskH.getIs_printable());
|
||||
setCustomer_name(taskH.getCustomer_name());
|
||||
setCustomer_phone(taskH.getCustomer_phone());
|
||||
setCustomer_address(taskH.getCustomer_address());
|
||||
setNotes(taskH.getNotes());
|
||||
setSubmit_date(taskH.getSubmit_date());
|
||||
setSubmit_duration(taskH.getSubmit_duration());
|
||||
setSubmit_size(taskH.getSubmit_size());
|
||||
setSubmit_result(taskH.getSubmit_result());
|
||||
setAssignment_date(taskH.getAssignment_date());
|
||||
setPrint_count(taskH.getPrint_count());
|
||||
setDraft_date(taskH.getDraft_date());
|
||||
setUsr_crt(taskH.getUsr_crt());
|
||||
setDtm_crt(taskH.getDtm_crt());
|
||||
setPriority(taskH.getPriority());
|
||||
setLatitude(taskH.getLatitude());
|
||||
setLongitude(taskH.getLongitude());
|
||||
setScheme_last_update(taskH.getScheme_last_update());
|
||||
setIs_verification(taskH.getIs_verification());
|
||||
setIs_preview_server(taskH.getIs_preview_server());
|
||||
setUuid_user(taskH.getUuid_user());
|
||||
setVoice_note(taskH.getVoice_note());
|
||||
setUuid_scheme(taskH.getUuid_scheme());
|
||||
setZip_code(taskH.getZip_code());
|
||||
setScheme(taskH.getScheme());
|
||||
setStart_date(taskH.getStart_date());
|
||||
setOpen_date(taskH.getOpen_date());
|
||||
setLast_saved_question(taskH.getLast_saved_question());
|
||||
setAppl_no(taskH.getAppl_no());
|
||||
setIs_prepocessed(taskH.getIs_prepocessed());
|
||||
setIs_reconciled(taskH.getIs_reconciled());
|
||||
setPts_date(taskH.getPts_date());
|
||||
setAccess_mode(taskH.getAccess_mode());
|
||||
setRv_number(taskH.getRv_number());
|
||||
setStatus_rv(taskH.getStatus_rv());
|
||||
setFlag(taskH.getFlag());
|
||||
setForm_version(taskH.getForm_version());
|
||||
setAmt_due(taskH.getAmt_due());
|
||||
setOd(taskH.getOd());
|
||||
setInst_no(taskH.getInst_no());
|
||||
setSurvey_location(taskH.getSurvey_location());
|
||||
String schemeIsPrintable = Global.FALSE_STRING;
|
||||
try {
|
||||
schemeIsPrintable = taskH.getIs_printable();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
String schemeId = taskH.getUuid_scheme();
|
||||
this.form = new FormBean(schemeId, getScheme_last_update(), schemeIsPrintable);
|
||||
|
||||
try {
|
||||
String previewServer = taskH.getIs_preview_server();
|
||||
if (getForm() != null) {
|
||||
getForm().setPreviewServer(previewServer);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
String previewServer = Global.FALSE_STRING;
|
||||
if (getForm() != null) {
|
||||
getForm().setPreviewServer(previewServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
public TaskH getTaskH() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FormBean getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
public void setForm(FormBean form) {
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
public void setImageLeft(int imageLeft) {
|
||||
this.imageLeft = imageLeft;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package com.adins.mss.foundation.questiongenerator.form;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.dynamicform.QuestionGroup;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class QuestionView extends LinearLayout {
|
||||
|
||||
protected QuestionBean questionBean;
|
||||
protected QuestionGroup questionGroup;
|
||||
protected QuestionViewListener listener;
|
||||
protected TextView label;
|
||||
//Glen 10 Oct 2014
|
||||
protected LayoutParams defLayout = new LayoutParams(
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
protected String QuestionId;
|
||||
protected HashMap<String, Object> hashMap;
|
||||
protected int sequence = 0;
|
||||
protected boolean isChanged = false;
|
||||
//ini dikarenakan kasus :
|
||||
//saat buat onselecttecItem, listener sudah kepanggil pada saat dropdown kebentuk
|
||||
//padahal seharusnya belum boleh
|
||||
//segingga di kasih flag dulu
|
||||
//bangkit 15 des 14
|
||||
protected int isCanSetFlag = 0;
|
||||
protected boolean titleOnly;
|
||||
protected boolean expanded;
|
||||
|
||||
public QuestionView(Context context) {
|
||||
super(context);
|
||||
// setExpanded(true);
|
||||
}
|
||||
|
||||
public QuestionView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public QuestionView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public QuestionView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
//Glen 14 Oct 2014, enforce to initiate with bean
|
||||
//bangkit 16 des temporary not used, concern to memory usage
|
||||
public QuestionView(Context context, QuestionBean bean) {
|
||||
super(context);
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
|
||||
//moved from subclass
|
||||
label = new TextView(context);
|
||||
// label.setTextColor(Color.parseColor("#0b5d66"));
|
||||
this.addView(label, defLayout);
|
||||
|
||||
this.questionBean = bean;
|
||||
// setExpanded(true);
|
||||
}
|
||||
|
||||
public QuestionGroup getQuestionGroup() {
|
||||
return questionGroup;
|
||||
}
|
||||
|
||||
public void setQuestionGroup(QuestionGroup questionGroup) {
|
||||
this.questionGroup = questionGroup;
|
||||
}
|
||||
|
||||
public boolean isTitleOnly() {
|
||||
return titleOnly;
|
||||
}
|
||||
|
||||
public void setTitleOnly(boolean titleOnly) {
|
||||
this.titleOnly = titleOnly;
|
||||
}
|
||||
|
||||
public TextView getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(TextView label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getQuestionId() {
|
||||
return QuestionId;
|
||||
}
|
||||
|
||||
public void setQuestionId(String questionId) {
|
||||
QuestionId = questionId;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getHashMap() {
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public void setHashMap(HashMap<String, Object> hashMap) {
|
||||
this.hashMap = hashMap;
|
||||
}
|
||||
|
||||
public int getSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public void setSequence(int sequence) {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public boolean isChanged() {
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
public void setChanged(boolean isChanged) {
|
||||
if (isCanSetFlag >= 1) {
|
||||
this.isChanged = isChanged;
|
||||
} else {
|
||||
isCanSetFlag++;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIsCanSetFlag() {
|
||||
return isCanSetFlag;
|
||||
}
|
||||
|
||||
public void setIsCanSetFlag(int isCanSetFlag) {
|
||||
this.isCanSetFlag = isCanSetFlag;
|
||||
}
|
||||
|
||||
//=== Getter & Setter ===//
|
||||
|
||||
public QuestionBean getQuestionBean() {
|
||||
return questionBean;
|
||||
}
|
||||
|
||||
public void setQuestionBean(QuestionBean questionBean) {
|
||||
this.questionBean = questionBean;
|
||||
}
|
||||
|
||||
public QuestionViewListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
public void setListener(QuestionViewListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public String getLabelText() {
|
||||
return label.getText().toString();
|
||||
}
|
||||
|
||||
public void setLabelText(String text) {
|
||||
label.setText(text);
|
||||
}
|
||||
|
||||
//Use this method to change visibility, as it usually needed in QuestionViewGenerator
|
||||
//not to confuse with View.setVisibility. this.setVisible(true) is the same as setVisibility(VISIBLE), and false as GONE
|
||||
public void setVisible(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
this.setVisibility(VISIBLE);
|
||||
} else {
|
||||
this.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
public void setExpanded(boolean expanded) {
|
||||
this.expanded = expanded;
|
||||
}
|
||||
|
||||
interface QuestionViewListener {
|
||||
void onFinishEdit(QuestionView questionView, QuestionBean questionBean);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.github.jjobes.slidedatetimepicker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.NumberPicker;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.foundation.camerainapp.helper.Logger;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* A subclass of {@link DatePicker} that uses
|
||||
* reflection to allow for customization of the default blue
|
||||
* dividers.
|
||||
*
|
||||
* @author jjobes
|
||||
*/
|
||||
public class CustomDatePicker extends DatePicker {
|
||||
private static final String TAG = "CustomDatePicker";
|
||||
|
||||
public CustomDatePicker(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
Class<?> idClass = null;
|
||||
Class<?> numberPickerClass = null;
|
||||
Field selectionDividerField = null;
|
||||
Field monthField = null;
|
||||
Field dayField = null;
|
||||
Field yearField = null;
|
||||
NumberPicker monthNumberPicker = null;
|
||||
NumberPicker dayNumberPicker = null;
|
||||
NumberPicker yearNumberPicker = null;
|
||||
|
||||
try {
|
||||
// Create an instance of the id class
|
||||
idClass = Class.forName("com.android.internal.R$id");
|
||||
|
||||
// Get the fields that store the resource IDs for the month, day and year NumberPickers
|
||||
monthField = idClass.getField("month");
|
||||
dayField = idClass.getField("day");
|
||||
yearField = idClass.getField("year");
|
||||
|
||||
// Use the resource IDs to get references to the month, day and year NumberPickers
|
||||
monthNumberPicker = (NumberPicker) findViewById(monthField.getInt(null));
|
||||
dayNumberPicker = (NumberPicker) findViewById(dayField.getInt(null));
|
||||
yearNumberPicker = (NumberPicker) findViewById(yearField.getInt(null));
|
||||
|
||||
numberPickerClass = Class.forName("android.widget.NumberPicker");
|
||||
|
||||
// Set the value of the mSelectionDivider field in the month, day and year NumberPickers
|
||||
// to refer to our custom drawables
|
||||
selectionDividerField = numberPickerClass.getDeclaredField("mSelectionDivider");
|
||||
selectionDividerField.setAccessible(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
selectionDividerField.set(monthNumberPicker, getResources().getDrawable(R.drawable.selection_divider, getContext().getTheme()));
|
||||
selectionDividerField.set(dayNumberPicker, getResources().getDrawable(R.drawable.selection_divider, getContext().getTheme()));
|
||||
selectionDividerField.set(yearNumberPicker, getResources().getDrawable(R.drawable.selection_divider, getContext().getTheme()));
|
||||
} else {
|
||||
selectionDividerField.set(monthNumberPicker, getResources().getDrawable(R.drawable.selection_divider));
|
||||
selectionDividerField.set(dayNumberPicker, getResources().getDrawable(R.drawable.selection_divider));
|
||||
selectionDividerField.set(yearNumberPicker, getResources().getDrawable(R.drawable.selection_divider));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
Logger.e(TAG, "ClassNotFoundException in CustomDatePicker", e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Logger.e(TAG, "NoSuchFieldException in CustomDatePicker", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Logger.e(TAG, "IllegalAccessException in CustomDatePicker", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Logger.e(TAG, "IllegalArgumentException in CustomDatePicker", e);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,308 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions.viewholder;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.questiongenerator.OptionAnswerBean;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
import com.adins.mss.foundation.questiongenerator.form.QuestionView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 01/09/2016.
|
||||
*/
|
||||
public class MultipleQuestionViewHolder extends RecyclerView.ViewHolder implements TextWatcher {
|
||||
public QuestionView mView;
|
||||
public TextView mQuestionLabel;
|
||||
public TextView mMultipleEmpty;
|
||||
public LinearLayout mMultipleLayout;
|
||||
public EditText mDescription;
|
||||
public QuestionBean bean;
|
||||
public FragmentActivity mActivity;
|
||||
protected List<OptionAnswerBean> options;
|
||||
protected LinearLayout.LayoutParams defLayout = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
private List<CheckBox> listCheckBox;
|
||||
private List<EditText> listDescription;
|
||||
private List<OptionAnswerBean> selectedOptionAnswers;
|
||||
|
||||
@Deprecated
|
||||
public MultipleQuestionViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionMultipleLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionMultipleLabel);
|
||||
mMultipleEmpty = (TextView) itemView.findViewById(R.id.questionMultipleEmpty);
|
||||
mMultipleLayout = (LinearLayout) itemView.findViewById(R.id.multipleQuestionListLayout);
|
||||
mDescription = (EditText) itemView.findViewById(R.id.questionMultipleDescription);
|
||||
listCheckBox = new ArrayList<>();
|
||||
listDescription = new ArrayList<>();
|
||||
selectedOptionAnswers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public MultipleQuestionViewHolder(View itemView, FragmentActivity activity) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionMultipleLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionMultipleLabel);
|
||||
mMultipleEmpty = (TextView) itemView.findViewById(R.id.questionMultipleEmpty);
|
||||
mMultipleLayout = (LinearLayout) itemView.findViewById(R.id.multipleQuestionListLayout);
|
||||
mDescription = (EditText) itemView.findViewById(R.id.questionMultipleDescription);
|
||||
mActivity = activity;
|
||||
listCheckBox = new ArrayList<>();
|
||||
listDescription = new ArrayList<>();
|
||||
selectedOptionAnswers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void bind(final QuestionBean item, int number) {
|
||||
selectedOptionAnswers = new ArrayList<>();
|
||||
bean = item;
|
||||
options = bean.getOptionAnswers();
|
||||
String answerType = bean.getAnswer_type();
|
||||
|
||||
boolean withDescription = false;
|
||||
boolean withOneDescription = false;
|
||||
if (Global.AT_MULTIPLE_W_DESCRIPTION.equals(answerType)) {
|
||||
withDescription = true;
|
||||
}
|
||||
|
||||
if (Global.AT_MULTIPLE_ONE_DESCRIPTION.equals(answerType)) {
|
||||
withOneDescription = true;
|
||||
}
|
||||
|
||||
String qLabel = number + ". " + bean.getQuestion_label();
|
||||
mQuestionLabel.setText(qLabel);
|
||||
mMultipleLayout.removeAllViews();
|
||||
listCheckBox.clear();
|
||||
listDescription.clear();
|
||||
|
||||
int i = 0;
|
||||
String[] arrSelectedAnswer = null;
|
||||
List<OptionAnswerBean> optSelectedBean = null;
|
||||
try {
|
||||
arrSelectedAnswer= Tool.split(bean.getAnswer(), Global.DELIMETER_DATA);
|
||||
optSelectedBean=bean.getSelectedOptionAnswers();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
arrSelectedAnswer = new String[0];
|
||||
optSelectedBean = new ArrayList<>();
|
||||
}
|
||||
if (options != null && !options.isEmpty()) {
|
||||
for (OptionAnswerBean optBean : options) {
|
||||
CheckBox chk = new CheckBox(mActivity);
|
||||
chk.setText(optBean.getValue());
|
||||
chk.setChecked(optBean.isSelected());
|
||||
mMultipleLayout.addView(chk);
|
||||
listCheckBox.add(chk);
|
||||
if (bean.isReadOnly()) {
|
||||
chk.setClickable(false);
|
||||
chk.setEnabled(false);
|
||||
} else {
|
||||
chk.setClickable(true);
|
||||
chk.setEnabled(true);
|
||||
}
|
||||
String optBeanId = optBean.getUuid_lookup();
|
||||
if (withDescription) {
|
||||
mDescription.setEnabled(false);
|
||||
EditText desc = new EditText(mActivity);
|
||||
if (null != bean.getMax_length() ) {
|
||||
InputFilter[] inputFilters = {new InputFilter.LengthFilter(
|
||||
bean.getMax_length() == 0 ? Global.DEFAULT_MAX_LENGTH : bean.getMax_length())};
|
||||
desc.setFilters(inputFilters);
|
||||
}
|
||||
qloop:
|
||||
for (OptionAnswerBean nOptBean : optSelectedBean) {
|
||||
String nOptBeanId = nOptBean.getUuid_lookup();
|
||||
if (optBeanId.equals(nOptBeanId) && nOptBean.isSelected()) {
|
||||
if (i < arrSelectedAnswer.length)
|
||||
desc.setText(arrSelectedAnswer[i]);
|
||||
i++;
|
||||
break qloop;
|
||||
}
|
||||
}
|
||||
desc.addTextChangedListener(this);
|
||||
mMultipleLayout.addView(desc, defLayout);
|
||||
listDescription.add(desc);
|
||||
}
|
||||
chk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
saveSelectedOptionToBean();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (withOneDescription) {
|
||||
enableDescription(true);
|
||||
try {
|
||||
mDescription.setText(bean.getAnswer());
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
mDescription.setText("");
|
||||
}
|
||||
mDescription.addTextChangedListener(this);
|
||||
} else {
|
||||
enableDescription(false);
|
||||
}
|
||||
mMultipleEmpty.setVisibility(View.GONE);
|
||||
} else {
|
||||
mMultipleEmpty.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
selectSavedOptionsFromBeans();
|
||||
}
|
||||
|
||||
private void selectSavedOptionsFromBeans() {
|
||||
List<OptionAnswerBean> beans = new ArrayList<>();
|
||||
for (int i = 0; i < bean.getSelectedOptionAnswers().size(); i++) {
|
||||
beans.add(bean.getSelectedOptionAnswers().get(i));
|
||||
}
|
||||
|
||||
try {
|
||||
for (OptionAnswerBean optAnsBean : beans) {
|
||||
String lovCode = optAnsBean.getCode();
|
||||
String description = null;
|
||||
if (Global.AT_MULTIPLE_W_DESCRIPTION.equals(bean.getAnswer_type()) ||
|
||||
Global.AT_MULTIPLE_ONE_DESCRIPTION.equals(bean.getAnswer_type())) {
|
||||
description = bean.getAnswer();
|
||||
}
|
||||
selectOption(lovCode, description);
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void selectOption(String lovCode, String description) {
|
||||
int indexOfOption = -1;
|
||||
int i = 0;
|
||||
for (OptionAnswerBean optAnsBean : options) {
|
||||
if (lovCode.equals(optAnsBean.getCode())) {
|
||||
indexOfOption = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (indexOfOption > -1) {
|
||||
if (listCheckBox != null && listCheckBox.size() > i) {
|
||||
listCheckBox.get(i).setChecked(true);
|
||||
}
|
||||
if (description != null) {
|
||||
if (Global.AT_MULTIPLE_W_DESCRIPTION.equals(bean.getAnswer_type())
|
||||
|| Global.AT_MULTIPLE_ONE_DESCRIPTION.equals(bean.getAnswer_type())) {
|
||||
enableDescription(true);
|
||||
mDescription.setText(description);
|
||||
} else {
|
||||
enableDescription(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//added from danu
|
||||
saveSelectedOptionToBean();
|
||||
}
|
||||
|
||||
public void enableDescription(boolean enable) {
|
||||
if (enable) {
|
||||
if (null != bean.getMax_length() ) {
|
||||
if (bean.getAnswer_type().equals(Global.AT_MULTIPLE_W_DESCRIPTION)) {
|
||||
InputFilter[] inputFilters = {new InputFilter.LengthFilter(
|
||||
bean.getMax_length() == 0 ? Global.DEFAULT_MAX_LENGTH :
|
||||
(bean.getMax_length() * options.size()) + bean.getMax_length())};
|
||||
mDescription.setFilters(inputFilters);
|
||||
} else {
|
||||
InputFilter[] inputFilters = {new InputFilter.LengthFilter(
|
||||
bean.getMax_length() == 0 ? Global.DEFAULT_MAX_LENGTH : bean.getMax_length())};
|
||||
mDescription.setFilters(inputFilters);
|
||||
}
|
||||
}
|
||||
mDescription.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSelectedOptionToBean() {
|
||||
selectedOptionAnswers.clear();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean withDescription = false;
|
||||
boolean withOneDescription = false;
|
||||
if (Global.AT_MULTIPLE_W_DESCRIPTION.equals(bean.getAnswer_type())) {
|
||||
withDescription = true;
|
||||
}
|
||||
|
||||
if (Global.AT_MULTIPLE_ONE_DESCRIPTION.equals(bean.getAnswer_type())) {
|
||||
withOneDescription = true;
|
||||
}
|
||||
for (int i = 0; i < listCheckBox.size(); i++) {
|
||||
CheckBox chk = listCheckBox.get(i);
|
||||
if (chk.isChecked()) {
|
||||
OptionAnswerBean optAnsBean = options.get(i); //assume checkbox is the same order as options
|
||||
|
||||
if (sb.length() > 0) {
|
||||
sb.append(Global.DELIMETER_DATA);
|
||||
}
|
||||
|
||||
if (withDescription) {
|
||||
EditText txtDescription = listDescription.get(i);
|
||||
String description = txtDescription.getText().toString();
|
||||
if (description.isEmpty()) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(description);
|
||||
}
|
||||
|
||||
optAnsBean.setSelected(true);
|
||||
|
||||
selectedOptionAnswers.add(optAnsBean);
|
||||
|
||||
} else {
|
||||
options.get(i).setSelected(false);
|
||||
}
|
||||
}
|
||||
bean.setAnswer(sb.toString());
|
||||
|
||||
if (Global.AT_MULTIPLE_W_DESCRIPTION.equals(bean.getAnswer_type())) {
|
||||
//added by danu
|
||||
enableDescription(true);
|
||||
mDescription.setText(sb.toString());
|
||||
}
|
||||
|
||||
if (withOneDescription) {
|
||||
String description = mDescription.getText().toString().trim();
|
||||
bean.setAnswer(description);
|
||||
}
|
||||
|
||||
bean.setLovCode(sb.toString());
|
||||
bean.setSelectedOptionAnswers(selectedOptionAnswers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
saveSelectedOptionToBean();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue