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
Binary file not shown.
After Width: | Height: | Size: 363 B |
|
@ -0,0 +1,201 @@
|
|||
package com.adins.mss.coll;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.NewMainActivity;
|
||||
import com.adins.mss.coll.services.EmergencyService;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Emergency;
|
||||
import com.adins.mss.dao.GeneralParameter;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.EmergencyDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
|
||||
public class EmergencyLockActivity extends AppCompatActivity {
|
||||
|
||||
CircleImageView emAnimateSuccess;
|
||||
CircleImageView emPending, emAnimatePending;
|
||||
ImageView emSuccess;
|
||||
TextView textSuccess, textPending, textSuccessDescription;
|
||||
Button btnCancel;
|
||||
|
||||
public static EmergencyHandler emergencyHandler;
|
||||
public static ReleaseEmergencyHandler releaseEmergencyHandler;
|
||||
private Handler waitCancelHandler;
|
||||
private Runnable waitCancelRunnable;
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
screenName = FirebaseAnalytics.getInstance(this);
|
||||
setContentView(R.layout.activity_emergency_lock);
|
||||
|
||||
emAnimatePending = findViewById(R.id.animate_pending);
|
||||
emPending = findViewById(R.id.image_pending);
|
||||
emAnimateSuccess = findViewById(R.id.animate_success);
|
||||
emSuccess = findViewById(R.id.image_success);
|
||||
textSuccess = findViewById(R.id.text_success);
|
||||
textSuccessDescription = findViewById(R.id.text_success_description);
|
||||
textPending = findViewById(R.id.text_pending);
|
||||
btnCancel = findViewById(R.id.btn_cancel);
|
||||
|
||||
emAnimatePending.setVisibility(View.VISIBLE);
|
||||
emPending.setVisibility(View.VISIBLE);
|
||||
emAnimatePending.setAnimation(loadAnimation(R.anim.wave));
|
||||
|
||||
try {
|
||||
textPending.setText(GeneralParameterDataAccess.getOne(getApplicationContext(), GlobalData.getSharedGlobalData().getUser().getUuid_user(),
|
||||
Global.GS_TEXT_EMERGENCY_MC).getGs_value());
|
||||
} catch (Exception e){
|
||||
textPending.setText(Global.DEFAULT_EMERGENCY_PENDING_TEXT);
|
||||
}
|
||||
|
||||
emergencyHandler = new EmergencyHandler();
|
||||
releaseEmergencyHandler = new ReleaseEmergencyHandler();
|
||||
long waitTime = Global.DEFAULT_EMERGENCY_CANCEL_SEND;
|
||||
try {
|
||||
waitTime = Long.parseLong(GeneralParameterDataAccess.getOne(getApplicationContext(),GlobalData.getSharedGlobalData().getUser().getUuid_user(),
|
||||
Global.GS_CANCEL_EMERGENCY_MC).getGs_value()) * Global.SECOND;
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
String emergencyState = GlobalData.getSharedGlobalData().getUser().getIs_emergency();
|
||||
if(emergencyState.equalsIgnoreCase(Global.NO_EMERGENCY)||
|
||||
emergencyState.equalsIgnoreCase(Global.EMERGENCY_SEND_PENDING)){
|
||||
GlobalData.getSharedGlobalData().getUser().setIs_emergency(Global.EMERGENCY_SEND_PENDING);
|
||||
waitCancelHandler = new Handler();
|
||||
waitCancelRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
btnCancel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
};
|
||||
waitCancelHandler.postDelayed(waitCancelRunnable,waitTime);
|
||||
Intent service = new Intent(this, EmergencyService.class);
|
||||
startService(service);
|
||||
} else if(emergencyState.equalsIgnoreCase(Global.EMERGENCY_SEND_SUCCESS)){
|
||||
emergencySentLayout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
screenName.setCurrentScreen(this, getString(R.string.screen_name_emergency_lock), null);
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
protected void emergencySentLayout(){
|
||||
emSuccess.setImageResource(R.drawable.em_check_with_animation);
|
||||
emSuccess.setVisibility(View.VISIBLE);
|
||||
emAnimateSuccess.setVisibility(View.VISIBLE);
|
||||
textSuccess.setVisibility(View.VISIBLE);
|
||||
textSuccessDescription.setVisibility(View.VISIBLE);
|
||||
btnCancel.setVisibility(View.GONE);
|
||||
textSuccess.setAnimation(loadAnimation(R.anim.fade_in));
|
||||
textSuccessDescription.setAnimation(loadAnimation(R.anim.fade_in));
|
||||
if(emSuccess.getDrawable() instanceof AnimatedVectorDrawableCompat){
|
||||
((AnimatedVectorDrawableCompat) emSuccess.getDrawable()).start();
|
||||
} else if( emSuccess.getDrawable() instanceof AnimatedVectorDrawable){
|
||||
((AnimatedVectorDrawable) emSuccess.getDrawable()).start();
|
||||
}
|
||||
emAnimatePending.setVisibility(View.GONE);
|
||||
textPending.setVisibility(View.GONE);
|
||||
emPending.setVisibility(View.GONE);
|
||||
emAnimatePending.setAnimation(null);
|
||||
}
|
||||
|
||||
private Animation loadAnimation(int id){
|
||||
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), id);
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
return;
|
||||
}
|
||||
|
||||
public void doCancel(View view) {
|
||||
GlobalData.getSharedGlobalData().getUser().setIs_emergency(Global.NO_EMERGENCY);
|
||||
UserDataAccess.addOrReplace(getApplicationContext(),GlobalData.getSharedGlobalData().getUser());
|
||||
|
||||
List<Emergency> emergencies= EmergencyDataAccess.getByUser(getApplicationContext(), GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
if(emergencies.size() > 0){
|
||||
EmergencyDataAccess.clean(getApplicationContext());
|
||||
}
|
||||
Intent service = new Intent(this, EmergencyService.class);
|
||||
stopService(service);
|
||||
finish();
|
||||
}
|
||||
|
||||
public class EmergencyHandler extends Handler{
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
emergencySentLayout();
|
||||
waitCancelHandler.removeCallbacks(waitCancelRunnable);
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ReleaseEmergencyHandler extends Handler{
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
if (NewMainActivity.AutoSendLocationHistoryService != null)
|
||||
getApplicationContext().stopService(NewMainActivity.AutoSendLocationHistoryService);
|
||||
User user = GlobalData.getSharedGlobalData().getUser();
|
||||
String uuid_user = user.getUuid_user();
|
||||
GeneralParameter gp = GeneralParameterDataAccess.getOne(getApplicationContext(),
|
||||
GlobalData.getSharedGlobalData().getUser().getUuid_user(),
|
||||
Global.GS_ENABLE_EMERGENCY_MC);
|
||||
if(null != gp) {
|
||||
gp.setGs_value(msg.obj + "");
|
||||
GeneralParameterDataAccess.addOrReplace(getApplicationContext(), gp);
|
||||
}
|
||||
EmergencyDataAccess.delete(getApplicationContext(), uuid_user);
|
||||
user.setIs_emergency(Global.NO_EMERGENCY);
|
||||
UserDataAccess.addOrReplace(getApplicationContext(),user);
|
||||
Intent intent = new Intent(getApplicationContext(), NewMCMainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Intent service = new Intent(this, EmergencyService.class);
|
||||
stopService(service);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.adins.mss.foundation.location;
|
||||
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
|
||||
public class UpdateMenuIcon {
|
||||
public boolean updateGPSIcon(Menu mainMenu) {
|
||||
if (null != mainMenu) {
|
||||
MenuItem existingItem = mainMenu.findItem(R.id.mnGPS);
|
||||
if (existingItem != null) {
|
||||
if (LocationTrackingManager.getLocationStatus() == 2) {
|
||||
existingItem.setIcon(
|
||||
R.drawable.location_on);
|
||||
} else if (LocationTrackingManager.getLocationStatus() == 1) {
|
||||
existingItem.setIcon(
|
||||
R.drawable.location_far);
|
||||
} else {
|
||||
existingItem.setIcon(
|
||||
R.drawable.location_off);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1,530 @@
|
|||
package com.adins.mss.base.review;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.dynamicform.QuestionGroup;
|
||||
import com.adins.mss.base.timeline.MapsViewer;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.formatter.Formatter;
|
||||
import com.adins.mss.foundation.formatter.Reader;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author gigin.ginanjar
|
||||
*/
|
||||
@SuppressLint("ResourceAsColor")
|
||||
public class QuestionReviewGenerator {
|
||||
public static final int TYPE_DATE = 1;
|
||||
public static final int TYPE_TIME = 2;
|
||||
public static final int TYPE_DATE_TIME = 3;
|
||||
|
||||
|
||||
public final LayoutParams defLayout = new LayoutParams(
|
||||
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
//------------------------------------------------
|
||||
//Gigin 5/10/014
|
||||
//method untuk ngambil data buat di review
|
||||
public QuestionView generateQuestionGroupTitle(Activity activity, QuestionGroup questionGroup) {
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
container.setOrientation(LinearLayout.HORIZONTAL);
|
||||
container.setBackgroundResource(R.color.tv_dark);
|
||||
container.setPadding(8, 10, 8, 10);
|
||||
mainContainer.setQuestionGroup(questionGroup);
|
||||
container.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL);
|
||||
|
||||
LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
textLayout.weight = 0.8f;
|
||||
|
||||
TextView label = new TextView(activity);
|
||||
label.setText(questionGroup.getQuestion_group_name().toUpperCase());
|
||||
label.setTextColor(Color.WHITE);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
label.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL);
|
||||
container.addView(label, textLayout);
|
||||
|
||||
RelativeLayout.LayoutParams viewLayout = new RelativeLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
viewLayout.width = Global.TRIANGLE_SIZE;
|
||||
viewLayout.height = Global.TRIANGLE_SIZE;
|
||||
viewLayout.bottomMargin = 10;
|
||||
viewLayout.topMargin = 10;
|
||||
viewLayout.leftMargin = 10;
|
||||
viewLayout.rightMargin = 10;
|
||||
|
||||
RelativeLayout.LayoutParams relLayout = new RelativeLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
RelativeLayout relativeLayout = new RelativeLayout(activity);
|
||||
relativeLayout.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
|
||||
|
||||
View view = new View(activity);
|
||||
view.setBackgroundResource(R.drawable.triangle);
|
||||
view.setRotation(mainContainer.isExpanded() ? 0f : 180f);
|
||||
|
||||
relativeLayout.addView(view, viewLayout);
|
||||
container.addView(relativeLayout, relLayout);
|
||||
|
||||
mainContainer.addView(container);
|
||||
mainContainer.setTitleOnly(true);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
public QuestionView generateTextAnswer(Activity activity,
|
||||
QuestionBean bean) {
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
mainContainer.setQuestionBean(bean);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(8, 8, 8, 8);
|
||||
container.setBackgroundColor(Color.parseColor("#cccccc"));
|
||||
TextView label = new TextView(activity);
|
||||
label.setTextSize(18);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
label.setText(bean.getQuestion_label() + " :");
|
||||
|
||||
String question = bean.getQuestion_label();
|
||||
String answer = bean.getAnswer();
|
||||
|
||||
|
||||
String answerType = bean.getAnswer_type();
|
||||
String regex = "(dalam ribuan)";
|
||||
|
||||
if (question.indexOf(regex) != -1) {
|
||||
|
||||
int firstIdx = regex.length();
|
||||
int lastIdx = question.length();
|
||||
int indexAkhir = lastIdx - firstIdx;
|
||||
|
||||
String newQuestion = question.substring(0, indexAkhir);
|
||||
question = newQuestion;
|
||||
String answerTemp = Reader.getThousandDigit(answer);
|
||||
answer = answerTemp;
|
||||
|
||||
label.setText(question + " :");
|
||||
}
|
||||
|
||||
if (Global.AT_DECIMAL.equals(answerType)) {
|
||||
String answerTemp = Reader.getCurrencyDigit(answer);
|
||||
answer = answerTemp;
|
||||
}
|
||||
|
||||
if (Global.AT_CURRENCY.equals(bean.getAnswer_type())) {
|
||||
String answerTemp = Tool.separateThousand(answer);
|
||||
if (answerTemp == null) answerTemp = "";
|
||||
answer = answerTemp;
|
||||
}
|
||||
TextView text = new TextView(activity);
|
||||
text.setText(answer);
|
||||
text.setTextSize(16);
|
||||
text.setTypeface(null, Typeface.NORMAL);
|
||||
container.addView(label, defLayout);
|
||||
container.addView(text, defLayout);
|
||||
mainContainer.addView(container);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
public QuestionView generateLocationAnswer(Activity activity,
|
||||
QuestionBean bean) {
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
mainContainer.setQuestionBean(bean);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(8, 8, 8, 8);
|
||||
container.setBackgroundColor(Color.parseColor("#cccccc"));
|
||||
TextView label = new TextView(activity);
|
||||
label.setTextSize(18);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
label.setText(bean.getQuestion_label() + " :");
|
||||
|
||||
TextView text = new TextView(activity);
|
||||
text.setText(bean.getAnswer());
|
||||
text.setTextSize(16);
|
||||
text.setTypeface(null, Typeface.NORMAL);
|
||||
text.setTextColor(Color.BLACK);
|
||||
|
||||
container.addView(label, defLayout);
|
||||
container.addView(text, defLayout);
|
||||
|
||||
mainContainer.addView(container);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
public QuestionView generateDateTimeAnswer(final Activity activity,
|
||||
QuestionBean bean, int type) throws Exception {
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
mainContainer.setQuestionBean(bean);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(8, 8, 8, 8);
|
||||
container.setBackgroundColor(Color.parseColor("#cccccc"));
|
||||
TextView label = new TextView(activity);
|
||||
label.setTextSize(18);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
label.setText(bean.getQuestion_label() + " :");
|
||||
|
||||
String format = null;
|
||||
TextView text = new TextView(activity);
|
||||
text.setTextSize(16);
|
||||
text.setTypeface(null, Typeface.NORMAL);
|
||||
switch (type) {
|
||||
case TYPE_DATE:
|
||||
format = Global.DATE_STR_FORMAT;
|
||||
break;
|
||||
case TYPE_TIME:
|
||||
format = Global.TIME_STR_FORMAT;
|
||||
break;
|
||||
case TYPE_DATE_TIME:
|
||||
format = Global.DATE_TIME_STR_FORMAT;
|
||||
break;
|
||||
default:
|
||||
format = Global.DATE_STR_FORMAT;
|
||||
break;
|
||||
}
|
||||
|
||||
String answer = bean.getAnswer();
|
||||
try {
|
||||
Date date = null;
|
||||
if (type == TYPE_TIME) {
|
||||
date = Formatter.parseDate(answer, Global.TIME_STR_FORMAT2);
|
||||
} else {
|
||||
date = Formatter.parseDate(answer, Global.DATE_STR_FORMAT_GSON);
|
||||
}
|
||||
answer = Formatter.formatDate(date, format);
|
||||
text.setText(answer);
|
||||
} catch (Exception ex) {
|
||||
text.setText(format);
|
||||
if (answer != null && answer.length() > 0) {
|
||||
long dtLong = Formatter.stringToDate(answer);
|
||||
Date date = new Date(dtLong);
|
||||
answer = Formatter.formatDate(date, format);
|
||||
|
||||
if (answer.length() > 0) {
|
||||
text.setText(answer);
|
||||
} else {
|
||||
text.setText(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
container.addView(label, defLayout);
|
||||
container.addView(text);
|
||||
mainContainer.addView(container);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
public QuestionView generateOptionsAnswer(Activity activity,
|
||||
QuestionBean bean) {
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
mainContainer.setQuestionBean(bean);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(8, 8, 8, 8);
|
||||
container.setBackgroundColor(Color.parseColor("#cccccc"));
|
||||
List<OptionAnswerBean> listOptions = bean.getSelectedOptionAnswers();
|
||||
TextView label = new TextView(activity);
|
||||
label.setTextSize(18);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
label.setText(bean.getQuestion_label() + " :");
|
||||
container.addView(label, defLayout);
|
||||
int i = 0;
|
||||
String[] arrSelectedAnswer = null;
|
||||
try {
|
||||
arrSelectedAnswer = Tool.split(bean.getAnswer(), Global.DELIMETER_DATA);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
arrSelectedAnswer = new String[0];
|
||||
}
|
||||
for (OptionAnswerBean optBean : listOptions) {
|
||||
if (optBean.isSelected()) {
|
||||
|
||||
TextView txt = new TextView(activity);
|
||||
txt.setTextSize(16);
|
||||
txt.setTypeface(null, Typeface.NORMAL);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (Tool.isOptionsWithDescription(bean.getAnswer_type())) {
|
||||
|
||||
sb.append(optBean.getCode() + " - " + arrSelectedAnswer[i]);
|
||||
} else {
|
||||
sb.append(optBean.getValue());
|
||||
}
|
||||
|
||||
if ((Global.AT_MULTIPLE_ONE_DESCRIPTION.equals(bean.getAnswer_type())
|
||||
|| Global.AT_DROPDOWN_W_DESCRIPTION.equals(bean.getAnswer_type())) && i == listOptions.size() - 1) {
|
||||
sb.append("\nDesc : " + bean.getAnswer());
|
||||
}
|
||||
txt.setText(sb.toString());
|
||||
|
||||
container.addView(txt);
|
||||
} else {
|
||||
TextView txt = new TextView(activity);
|
||||
txt.setTextSize(16);
|
||||
txt.setTypeface(null, Typeface.NORMAL);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(activity.getString(R.string.no_selected_field));
|
||||
txt.setText(sb.toString());
|
||||
|
||||
container.addView(txt);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (listOptions == null || listOptions.isEmpty()) {
|
||||
TextView txt = new TextView(activity);
|
||||
txt.setTextSize(16);
|
||||
txt.setTypeface(null, Typeface.NORMAL);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(activity.getString(R.string.no_selected_field));
|
||||
txt.setText(sb.toString());
|
||||
container.addView(txt);
|
||||
}
|
||||
mainContainer.addView(container);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
public QuestionView generateImageAnswer(final Activity activity, final QuestionBean bean,
|
||||
final Class<?> ViewImageActivity) {
|
||||
Utility.freeMemory();
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
mainContainer.setQuestionBean(bean);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(8, 8, 8, 8);
|
||||
container.setBackgroundColor(Color.parseColor("#cccccc"));
|
||||
TextView label = new TextView(activity);
|
||||
label.setText(bean.getQuestion_label() + " :");
|
||||
label.setTextSize(18);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
byte[] img = bean.getImgAnswer();
|
||||
|
||||
LinearLayout imgContainer = new QuestionView(activity);
|
||||
imgContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||
imgContainer.setGravity(Gravity.LEFT);
|
||||
imgContainer.setPadding(5, 0, 5, 0);
|
||||
|
||||
final ImageView thumb = new ImageView(activity);
|
||||
final ImageView thumbLct = new ImageView(activity);
|
||||
thumbLct.setPadding(15, 0, 0, 0);
|
||||
|
||||
|
||||
if (img != null && img.length > 0) {
|
||||
final float scale = 0;
|
||||
|
||||
int w = Tool.dpToPixel(scale, Global.THUMBNAIL_WIDTH);
|
||||
int h = Tool.dpToPixel(scale, Global.THUMBNAIL_HEIGHT);
|
||||
ViewGroup.LayoutParams imgLayout = new LayoutParams(w, h);
|
||||
thumb.setLayoutParams(imgLayout);
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(img, 0, img.length);
|
||||
int[] res = Tool.getThumbnailResolution(bm.getWidth(), bm.getHeight());
|
||||
Bitmap thumbnail = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
|
||||
thumb.setImageBitmap(thumbnail);
|
||||
thumb.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Global.getSharedGlobal().setIsViewer(true);
|
||||
Bundle extras = new Bundle();
|
||||
extras.putByteArray(Global.BUND_KEY_IMAGE_BYTE, bean.getImgAnswer());
|
||||
Intent intent = new Intent(activity, ViewImageActivity);
|
||||
intent.putExtras(extras);
|
||||
activity.startActivity(intent);
|
||||
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bm.recycle();
|
||||
thumbLct.setLayoutParams(imgLayout);
|
||||
thumbLct.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (bean.getLocationInfo() != null) {
|
||||
try {
|
||||
String lat = bean.getLocationInfo().getLatitude();
|
||||
String lng = bean.getLocationInfo().getLongitude();
|
||||
int accuracy = bean.getLocationInfo().getAccuracy();
|
||||
Intent intent = new Intent(activity, MapsViewer.class);
|
||||
intent.putExtra("latitude", lat);
|
||||
intent.putExtra("longitude", lng);
|
||||
intent.putExtra("accuracy", accuracy);
|
||||
activity.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
String lat = bean.getLatitude();
|
||||
String lng = bean.getLongitude();
|
||||
Intent intent = new Intent(activity, MapsViewer.class);
|
||||
intent.putExtra("latitude", lat);
|
||||
intent.putExtra("longitude", lng);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(activity, activity.getString(R.string.msgUnavaibleLocation),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Tool.isHaveLocation(bean.getAnswer_type())) {
|
||||
thumbLct.setImageResource(R.drawable.ic_absent);
|
||||
}
|
||||
} else {
|
||||
thumb.setImageResource(android.R.drawable.ic_menu_gallery);
|
||||
}
|
||||
container.addView(label, defLayout);
|
||||
|
||||
imgContainer.addView(thumb, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
imgContainer.addView(thumbLct, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
container.addView(imgContainer, defLayout);
|
||||
mainContainer.addView(container);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
public QuestionView generateLookupAnswer(final Activity activity, final QuestionBean bean) {
|
||||
QuestionView mainContainer = new QuestionView(activity);
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setPadding(5, 5, 5, 5);
|
||||
|
||||
QuestionView container = new QuestionView(activity);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
mainContainer.setQuestionBean(bean);
|
||||
container.setPadding(8, 8, 8, 8);
|
||||
container.setBackgroundColor(Color.parseColor("#cccccc"));
|
||||
TextView label = new TextView(activity);
|
||||
label.setTextSize(18);
|
||||
label.setTypeface(null, Typeface.BOLD);
|
||||
label.setText(bean.getQuestion_label() + " :");
|
||||
|
||||
String key = bean.getLovId();
|
||||
if (!Tool.isEmptyString(key)) {
|
||||
TextView txt = new TextView(activity);
|
||||
txt.setTextSize(16);
|
||||
txt.setTypeface(null, Typeface.NORMAL);
|
||||
String value = bean.getAnswer();
|
||||
|
||||
if (value == null || "".equals(value.trim())) {
|
||||
value = "(name)";
|
||||
}
|
||||
txt.setText(value);
|
||||
|
||||
container.addView(label, defLayout);
|
||||
container.addView(txt, defLayout);
|
||||
}
|
||||
mainContainer.addView(container);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout for Review by Answer type
|
||||
*
|
||||
* @param activity - Activity
|
||||
* @param bean - QuestionBean
|
||||
* @param ViewImageActivity - Class of ViewImageActivity
|
||||
* @return Layout Container
|
||||
* @throws Exception
|
||||
*/
|
||||
public QuestionView generateReviewQuestion(Activity activity,
|
||||
QuestionBean bean, final Class<?> ViewImageActivity, QuestionGroup group) throws Exception {
|
||||
QuestionView linear = new QuestionView(activity);
|
||||
linear.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
if (group != null) {
|
||||
return this.generateQuestionGroupTitle(activity, group);
|
||||
}
|
||||
String answerType = bean.getAnswer_type();
|
||||
if (Global.AT_TEXT.equals(answerType)) {
|
||||
return this.generateTextAnswer(activity, bean);
|
||||
} else if (Global.AT_TEXT_MULTILINE.equals(answerType)) {
|
||||
return this.generateTextAnswer(activity, bean);
|
||||
} else if (Global.AT_TEXT_WITH_SUGGESTION.equals(answerType)) {
|
||||
return this.generateTextAnswer(activity, bean);
|
||||
} else if (Global.AT_CURRENCY.equals(answerType)) {
|
||||
return this.generateTextAnswer(activity, bean);
|
||||
} else if (Global.AT_NUMERIC.equals(answerType)) {
|
||||
return this.generateTextAnswer(activity, bean);
|
||||
} else if (Global.AT_DECIMAL.equals(answerType)) {
|
||||
return this.generateTextAnswer(activity, bean);
|
||||
} else if (Global.AT_GPS.equals(answerType)) {
|
||||
return this.generateLocationAnswer(activity, bean);
|
||||
} else if (Global.AT_GPS_N_LBS.equals(answerType)) {
|
||||
return this.generateLocationAnswer(activity, bean);
|
||||
} else if (Global.AT_MULTIPLE.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_MULTIPLE_ONE_DESCRIPTION.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_MULTIPLE_W_DESCRIPTION.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_RADIO.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_RADIO_W_DESCRIPTION.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_DROPDOWN.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_DROPDOWN_W_DESCRIPTION.equals(answerType)) {
|
||||
return this.generateOptionsAnswer(activity, bean);
|
||||
} else if (Global.AT_DATE.equals(answerType)) {
|
||||
return this.generateDateTimeAnswer(activity, bean, TYPE_DATE);
|
||||
} else if (Global.AT_TIME.equals(answerType)) {
|
||||
return this.generateDateTimeAnswer(activity, bean, TYPE_TIME);
|
||||
} else if (Global.AT_DATE_TIME.equals(answerType)) {
|
||||
return this.generateDateTimeAnswer(activity, bean, TYPE_DATE_TIME);
|
||||
} else if (Tool.isImage(answerType)) {
|
||||
return this.generateImageAnswer(activity, bean, ViewImageActivity);
|
||||
}
|
||||
else if (Global.AT_LOCATION.equals(answerType)) {
|
||||
return this.generateLocationAnswer(activity, bean);
|
||||
} else if (Global.AT_LOV.equals(answerType)) {
|
||||
return this.generateLookupAnswer(activity, bean);
|
||||
} else if (Global.AT_LOV_W_FILTER.equals(answerType)) {
|
||||
return this.generateLookupAnswer(activity, bean);
|
||||
} else if (Global.AT_DRAWING.equals(answerType)) {
|
||||
return this.generateImageAnswer(activity, bean, ViewImageActivity);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.adins.mss.base.commons;
|
||||
|
||||
import android.view.Menu;
|
||||
|
||||
/**
|
||||
* Created by kusnendi.muhamad on 28/07/2017.
|
||||
*/
|
||||
|
||||
public interface ViewInterface {
|
||||
public void publish();
|
||||
|
||||
public void onCreate();
|
||||
|
||||
public void onResume();
|
||||
|
||||
public void onDestroy();
|
||||
|
||||
public void onCreateOptionsMenu(Menu menu);
|
||||
|
||||
public void onOptionsItemSelected(int id);
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
package com.adins.mss.base;
|
||||
|
||||
import com.adins.mss.base.loyalti.sla.LoyaltiSlaTimeHandler;
|
||||
import com.adins.mss.constant.Global;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class LoyaltySLATimeTest {
|
||||
|
||||
private int slaTime = 3;
|
||||
private int[] trackingDays;
|
||||
private int[] startTimeDigit;
|
||||
private int[] endTimeDigit;
|
||||
private boolean enableTracking;
|
||||
|
||||
private LoyaltiSlaTimeHandler generateHandler(){
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = new LoyaltiSlaTimeHandler();//use default constructor
|
||||
slaTimeHandler.enableTracking(enableTracking);
|
||||
slaTimeHandler.setSlaTime((long) slaTime * Global.HOUR);
|
||||
slaTimeHandler.setTrackingDays(trackingDays);
|
||||
slaTimeHandler.setStartTimeDigit(startTimeDigit);
|
||||
slaTimeHandler.setEndTimeDigit(endTimeDigit);
|
||||
return slaTimeHandler;
|
||||
}
|
||||
|
||||
private Date parseDate(String strDate){
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(Global.DATE_TIME_STR_FORMAT, Locale.getDefault());
|
||||
Date result = null;
|
||||
try {
|
||||
result = dateFormat.parse(strDate);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario1(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{0,1,2,3,4,5,6};
|
||||
startTimeDigit = new int[]{9,0};
|
||||
endTimeDigit = new int[]{22,0};
|
||||
String assignDateStr = "14/10/2020 10:30";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 1 assertion: ","14/10/2020 13:30",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario2(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{1,2,3,4,5};
|
||||
startTimeDigit = new int[]{9,0};
|
||||
endTimeDigit = new int[]{22,0};
|
||||
String assignDateStr = "17/10/2020 10:30";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 2 assertion: ","19/10/2020 12:00",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario3(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{1,2,3,4,5};
|
||||
startTimeDigit = new int[]{9,0};
|
||||
endTimeDigit = new int[]{22,0};
|
||||
String assignDateStr = "16/10/2020 21:45";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 3 assertion: ","19/10/2020 11:45",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario4(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{2,3,4,5};
|
||||
startTimeDigit = new int[]{9,0};
|
||||
endTimeDigit = new int[]{17,0};
|
||||
String assignDateStr = "16/10/2020 17:30";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 4 assertion: ","20/10/2020 12:00",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario5(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{2,3,4,5};
|
||||
startTimeDigit = new int[]{9,0};
|
||||
endTimeDigit = new int[]{17,0};
|
||||
String assignDateStr = "17/10/2020 12:53";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 5 assertion: ","20/10/2020 12:00",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario6(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{2,3,4,5,6};
|
||||
startTimeDigit = new int[]{8,0};
|
||||
endTimeDigit = new int[]{21,0};
|
||||
String assignDateStr = "17/10/2020 20:00";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 6 assertion: ","20/10/2020 10:00",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario7(){
|
||||
slaTime = 3;
|
||||
enableTracking = false;
|
||||
trackingDays = new int[]{2,3,4,5};
|
||||
startTimeDigit = new int[]{9,0};
|
||||
endTimeDigit = new int[]{17,0};
|
||||
String assignDateStr = "17/10/2020 12:53";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 7 assertion: ","17/10/2020 15:53",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario8(){
|
||||
slaTime = 3;
|
||||
enableTracking = false;
|
||||
trackingDays = new int[]{0,1,2,3,6};
|
||||
startTimeDigit = new int[]{16,0};
|
||||
endTimeDigit = new int[]{23,59};
|
||||
String assignDateStr = "26/10/2020 12:53";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 8 assertion: ","26/10/2020 19:00",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario9(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{0,1,2,3,6};
|
||||
startTimeDigit = new int[]{16,0};
|
||||
endTimeDigit = new int[]{23,59};
|
||||
String assignDateStr = "26/10/2020 23:59";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 9 assertion: ","27/10/2020 19:00",slaTimeResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScenario10(){
|
||||
slaTime = 3;
|
||||
enableTracking = true;
|
||||
trackingDays = new int[]{2,3};
|
||||
startTimeDigit = new int[]{16,0};
|
||||
endTimeDigit = new int[]{23,59};
|
||||
String assignDateStr = "01/11/2020 12:59";
|
||||
|
||||
LoyaltiSlaTimeHandler slaTimeHandler = generateHandler();
|
||||
Date assignDate = parseDate(assignDateStr);
|
||||
if(assignDate == null)
|
||||
throw new NullPointerException();
|
||||
String slaTimeResult = slaTimeHandler.calculateSLATime(assignDate,Global.DATE_TIME_STR_FORMAT);
|
||||
Assert.assertEquals("Scenario 9 assertion: ","03/11/2020 19:00",slaTimeResult);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/AITMSS-v2.5.0.0_NEW_UI.iml" filepath="$PROJECT_DIR$/AITMSS-v2.5.0.0_NEW_UI.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/databasegenerator/databasegenerator.iml" filepath="$PROJECT_DIR$/databasegenerator/databasegenerator.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/for-testing-only/for-testing-only.iml" filepath="$PROJECT_DIR$/for-testing-only/for-testing-only.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/google-play-services/google-play-services.iml" filepath="$PROJECT_DIR$/google-play-services/google-play-services.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/mssbase/mssbase.iml" filepath="$PROJECT_DIR$/mssbase/mssbase.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/msscoll/msscoll.iml" filepath="$PROJECT_DIR$/msscoll/msscoll.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/mssodr/mssodr.iml" filepath="$PROJECT_DIR$/mssodr/mssodr.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/msssvy/msssvy.iml" filepath="$PROJECT_DIR$/msssvy/msssvy.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package com.adins.mss.svy.models;
|
||||
|
||||
/**
|
||||
* Created by Aditya Purwa on 1/28/2015.
|
||||
*/
|
||||
public class ResponseStatus {
|
||||
private int code;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/listTitle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="35dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@android:color/black" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Add table
Add a link
Reference in a new issue