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,66 @@
<?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">
<com.github.jjobes.slidedatetimepicker.SlidingTabLayout
android:id="@+id/slidingTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.github.jjobes.slidedatetimepicker.CustomViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<!--
The horizontal separator that runs across the top of
the button bar
-->
<View
android:id="@+id/buttonHorizontalDivider"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/gray_holo_dark" />
<!-- Footer button bar -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/cancelButton"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/cancel" />
<!-- The vertical divider line between the two buttons -->
<View
android:id="@+id/buttonVerticalDivider"
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="@color/gray_holo_dark" />
<Button
android:id="@+id/okButton"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/ok" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_frame"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_grayscale"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Guideline &amp; FAQ"
android:textStyle="bold"
android:textSize="@dimen/textSizeLarge_openSource"
android:padding="5dp"
android:layout_marginBottom="10dp"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/guidelineRV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"/>
</LinearLayout>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<com.manuelpeinado.fadingactionbar.view.RootLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/fab__header_container" />
</com.manuelpeinado.fadingactionbar.view.RootLayout>

View file

@ -0,0 +1,295 @@
package fr.castorflex.android.smoothprogressbar;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ProgressBar;
import com.adins.mss.base.R;
/**
* Created by castorflex on 11/10/13.
*/
@SuppressLint("NewApi")
public class SmoothProgressBar extends ProgressBar {
private static final int INTERPOLATOR_ACCELERATE = 0;
private static final int INTERPOLATOR_LINEAR = 1;
private static final int INTERPOLATOR_ACCELERATEDECELERATE = 2;
private static final int INTERPOLATOR_DECELERATE = 3;
public SmoothProgressBar(Context context) {
this(context, null);
}
public SmoothProgressBar(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.spbStyle);
}
public SmoothProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) {
setIndeterminateDrawable(new SmoothProgressDrawable.Builder(context).build());
return;
}
Resources res = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SmoothProgressBar, defStyle, 0);
final int color = a.getColor(R.styleable.SmoothProgressBar_spb_color, res.getColor(R.color.spb_default_color, getContext().getTheme()));
final int sectionsCount = a.getInteger(R.styleable.SmoothProgressBar_spb_sections_count, res.getInteger(R.integer.spb_default_sections_count));
final int separatorLength = a.getDimensionPixelSize(R.styleable.SmoothProgressBar_spb_stroke_separator_length, res.getDimensionPixelSize(R.dimen.spb_default_stroke_separator_length));
final float strokeWidth = a.getDimension(R.styleable.SmoothProgressBar_spb_stroke_width, res.getDimension(R.dimen.spb_default_stroke_width));
final float speed = a.getFloat(R.styleable.SmoothProgressBar_spb_speed, Float.parseFloat(res.getString(R.string.spb_default_speed)));
final float speedProgressiveStart = a.getFloat(R.styleable.SmoothProgressBar_spb_progressiveStart_speed, speed);
final float speedProgressiveStop = a.getFloat(R.styleable.SmoothProgressBar_spb_progressiveStop_speed, speed);
final int iInterpolator = a.getInteger(R.styleable.SmoothProgressBar_spb_interpolator, -1);
final boolean reversed = a.getBoolean(R.styleable.SmoothProgressBar_spb_reversed, res.getBoolean(R.bool.spb_default_reversed));
final boolean mirrorMode = a.getBoolean(R.styleable.SmoothProgressBar_spb_mirror_mode, res.getBoolean(R.bool.spb_default_mirror_mode));
final int colorsId = a.getResourceId(R.styleable.SmoothProgressBar_spb_colors, 0);
final boolean progressiveStartActivated = a.getBoolean(R.styleable.SmoothProgressBar_spb_progressiveStart_activated, res.getBoolean(R.bool.spb_default_progressiveStart_activated));
final Drawable backgroundDrawable = a.getDrawable(R.styleable.SmoothProgressBar_spb_background);
final boolean generateBackgroundWithColors = a.getBoolean(R.styleable.SmoothProgressBar_spb_generate_background_with_colors, false);
final boolean gradients = a.getBoolean(R.styleable.SmoothProgressBar_spb_gradients, false);
a.recycle();
//interpolator
Interpolator interpolator = null;
if (iInterpolator == -1) {
interpolator = getInterpolator();
}
if (interpolator == null) {
switch (iInterpolator) {
case INTERPOLATOR_ACCELERATEDECELERATE:
interpolator = new AccelerateDecelerateInterpolator();
break;
case INTERPOLATOR_DECELERATE:
interpolator = new DecelerateInterpolator();
break;
case INTERPOLATOR_LINEAR:
interpolator = new LinearInterpolator();
break;
case INTERPOLATOR_ACCELERATE:
default:
interpolator = new AccelerateInterpolator();
}
}
int[] colors = null;
//colors
if (colorsId != 0) {
colors = res.getIntArray(colorsId);
}
SmoothProgressDrawable.Builder builder = new SmoothProgressDrawable.Builder(context)
.speed(speed)
.progressiveStartSpeed(speedProgressiveStart)
.progressiveStopSpeed(speedProgressiveStop)
.interpolator(interpolator)
.sectionsCount(sectionsCount)
.separatorLength(separatorLength)
.strokeWidth(strokeWidth)
.reversed(reversed)
.mirrorMode(mirrorMode)
.progressiveStart(progressiveStartActivated)
.gradients(gradients);
if (backgroundDrawable != null) {
builder.backgroundDrawable(backgroundDrawable);
}
if (generateBackgroundWithColors) {
builder.generateBackgroundUsingColors();
}
if (colors != null && colors.length > 0)
builder.colors(colors);
else
builder.color(color);
SmoothProgressDrawable d = builder.build();
setIndeterminateDrawable(d);
}
public void applyStyle(int styleResId) {
TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SmoothProgressBar, 0, styleResId);
if (a.hasValue(R.styleable.SmoothProgressBar_spb_color)) {
setSmoothProgressDrawableColor(a.getColor(R.styleable.SmoothProgressBar_spb_color, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_colors)) {
int colorsId = a.getResourceId(R.styleable.SmoothProgressBar_spb_colors, 0);
if (colorsId != 0) {
int[] colors = getResources().getIntArray(colorsId);
if (colors != null && colors.length > 0)
setSmoothProgressDrawableColors(colors);
}
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_sections_count)) {
setSmoothProgressDrawableSectionsCount(a.getInteger(R.styleable.SmoothProgressBar_spb_sections_count, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_stroke_separator_length)) {
setSmoothProgressDrawableSeparatorLength(a.getDimensionPixelSize(R.styleable.SmoothProgressBar_spb_stroke_separator_length, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_stroke_width)) {
setSmoothProgressDrawableStrokeWidth(a.getDimension(R.styleable.SmoothProgressBar_spb_stroke_width, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_speed)) {
setSmoothProgressDrawableSpeed(a.getFloat(R.styleable.SmoothProgressBar_spb_speed, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStart_speed)) {
setSmoothProgressDrawableProgressiveStartSpeed(a.getFloat(R.styleable.SmoothProgressBar_spb_progressiveStart_speed, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStop_speed)) {
setSmoothProgressDrawableProgressiveStopSpeed(a.getFloat(R.styleable.SmoothProgressBar_spb_progressiveStop_speed, 0));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_reversed)) {
setSmoothProgressDrawableReversed(a.getBoolean(R.styleable.SmoothProgressBar_spb_reversed, false));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_mirror_mode)) {
setSmoothProgressDrawableMirrorMode(a.getBoolean(R.styleable.SmoothProgressBar_spb_mirror_mode, false));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStart_activated)) {
setProgressiveStartActivated(a.getBoolean(R.styleable.SmoothProgressBar_spb_progressiveStart_activated, false));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStart_activated)) {
setProgressiveStartActivated(a.getBoolean(R.styleable.SmoothProgressBar_spb_progressiveStart_activated, false));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_gradients)) {
setSmoothProgressDrawableUseGradients(a.getBoolean(R.styleable.SmoothProgressBar_spb_gradients, false));
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_generate_background_with_colors)) {
if (a.getBoolean(R.styleable.SmoothProgressBar_spb_generate_background_with_colors, false)) {
setSmoothProgressDrawableBackgroundDrawable(
SmoothProgressBarUtils.generateDrawableWithColors(checkIndeterminateDrawable().getColors(), checkIndeterminateDrawable().getStrokeWidth()));
}
}
if (a.hasValue(R.styleable.SmoothProgressBar_spb_interpolator)) {
int iInterpolator = a.getInteger(R.styleable.SmoothProgressBar_spb_interpolator, -1);
Interpolator interpolator;
switch (iInterpolator) {
case INTERPOLATOR_ACCELERATEDECELERATE:
interpolator = new AccelerateDecelerateInterpolator();
break;
case INTERPOLATOR_DECELERATE:
interpolator = new DecelerateInterpolator();
break;
case INTERPOLATOR_LINEAR:
interpolator = new LinearInterpolator();
break;
case INTERPOLATOR_ACCELERATE:
interpolator = new AccelerateInterpolator();
break;
default:
interpolator = null;
}
if (interpolator != null) {
setInterpolator(interpolator);
}
}
a.recycle();
}
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isIndeterminate() && getIndeterminateDrawable() instanceof SmoothProgressDrawable &&
!((SmoothProgressDrawable) getIndeterminateDrawable()).isRunning()) {
getIndeterminateDrawable().draw(canvas);
}
}
private SmoothProgressDrawable checkIndeterminateDrawable() {
Drawable ret = getIndeterminateDrawable();
if (ret == null || !(ret instanceof SmoothProgressDrawable))
throw new RuntimeException("The drawable is not a SmoothProgressDrawable");
return (SmoothProgressDrawable) ret;
}
@Override
public void setInterpolator(Interpolator interpolator) {
super.setInterpolator(interpolator);
Drawable ret = getIndeterminateDrawable();
if (ret != null && (ret instanceof SmoothProgressDrawable))
((SmoothProgressDrawable) ret).setInterpolator(interpolator);
}
public void setSmoothProgressDrawableInterpolator(Interpolator interpolator) {
checkIndeterminateDrawable().setInterpolator(interpolator);
}
public void setSmoothProgressDrawableColors(int[] colors) {
checkIndeterminateDrawable().setColors(colors);
}
public void setSmoothProgressDrawableColor(int color) {
checkIndeterminateDrawable().setColor(color);
}
public void setSmoothProgressDrawableSpeed(float speed) {
checkIndeterminateDrawable().setSpeed(speed);
}
public void setSmoothProgressDrawableProgressiveStartSpeed(float speed) {
checkIndeterminateDrawable().setProgressiveStartSpeed(speed);
}
public void setSmoothProgressDrawableProgressiveStopSpeed(float speed) {
checkIndeterminateDrawable().setProgressiveStopSpeed(speed);
}
public void setSmoothProgressDrawableSectionsCount(int sectionsCount) {
checkIndeterminateDrawable().setSectionsCount(sectionsCount);
}
public void setSmoothProgressDrawableSeparatorLength(int separatorLength) {
checkIndeterminateDrawable().setSeparatorLength(separatorLength);
}
public void setSmoothProgressDrawableStrokeWidth(float strokeWidth) {
checkIndeterminateDrawable().setStrokeWidth(strokeWidth);
}
public void setSmoothProgressDrawableReversed(boolean reversed) {
checkIndeterminateDrawable().setReversed(reversed);
}
public void setSmoothProgressDrawableMirrorMode(boolean mirrorMode) {
checkIndeterminateDrawable().setMirrorMode(mirrorMode);
}
public void setProgressiveStartActivated(boolean progressiveStartActivated) {
checkIndeterminateDrawable().setProgressiveStartActivated(progressiveStartActivated);
}
public void setSmoothProgressDrawableCallbacks(SmoothProgressDrawable.Callbacks listener) {
checkIndeterminateDrawable().setCallbacks(listener);
}
public void setSmoothProgressDrawableBackgroundDrawable(Drawable drawable) {
checkIndeterminateDrawable().setBackgroundDrawable(drawable);
}
public void setSmoothProgressDrawableUseGradients(boolean useGradients) {
checkIndeterminateDrawable().setUseGradients(useGradients);
}
public void progressiveStart() {
checkIndeterminateDrawable().progressiveStart();
}
public void progressiveStop() {
checkIndeterminateDrawable().progressiveStop();
}
}

View file

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/timelineContainer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:id="@+id/timelineItem">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<ImageView
android:id="@+id/timelineIcon"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:src="@drawable/task_highpriority"
android:padding="2dp"
android:layout_marginTop="10dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:id="@+id/taskHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="5dp"
app:cardBackgroundColor="@color/fontColorWhite"
app:cardElevation="@dimen/card_shadow"
android:layout_margin="@dimen/card_margin">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/taskName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:layout_weight="0.8"
android:text="Sample Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_person_color"
android:drawablePadding="5dp"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:id="@+id/taskTime"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="right"
android:text="Time"
android:textSize="10dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<TextView
android:id="@+id/taskAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/container"
android:paddingBottom="5dp"
android:text="Sample Address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_location_color"
android:drawablePadding="5dp"/>
<TextView
android:id="@+id/taskCollResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/taskAddress"
android:paddingBottom="5dp"
android:text="@string/collection_result"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_coll_result"
android:drawablePadding="5dp"
android:visibility="gone"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:id="@+id/taskStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:id="@+id/taskStatusItem1"
android:visibility="visible">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<ImageView
android:id="@+id/taskStatusIcon1"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/task_draft"
android:padding="3dp"/>
</RelativeLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="10dp"
app:cardElevation="@dimen/card_shadow"
android:layout_margin="@dimen/card_margin"
app:cardBackgroundColor="@color/fontColorWhite">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtStatus1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/txtTime1"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView
android:id="@+id/txtDesc1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtStatus1"
android:text="Description"
android:textSize="11dp"
android:visibility="gone"/>
<TextView
android:id="@+id/txtTime1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="10dp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/timelineLine" />
</LinearLayout>

View file

@ -0,0 +1,161 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.PrintItem;
import com.adins.mss.dao.PrintItemDao;
import com.adins.mss.foundation.db.DaoOpenHelper;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
public class PrintItemDataAccess {
private PrintItemDataAccess() {
}
/**
* 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 printItem dao and you can access the DB
*
* @param context
* @return
*/
protected static PrintItemDao getPrintItemDao(Context context) {
return getDaoSession(context).getPrintItemDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
DaoOpenHelper.closeAll();
}
/**
* add printItem as entity
*
* @param context
* @param printItem
*/
public static void add(Context context, PrintItem printItem) {
getPrintItemDao(context).insertInTx(printItem);
getDaoSession(context).clear();
}
/**
* add printItem as list entity
*
* @param context
* @param printItemList
*/
public static void add(Context context, List<PrintItem> printItemList) {
getPrintItemDao(context).insertInTx(printItemList);
getDaoSession(context).clear();
}
/**
* addOrReplace printItem as entity
*
* @param context
* @param printItem
*/
public static void addOrReplace(Context context, PrintItem printItem) {
getPrintItemDao(context).insertOrReplaceInTx(printItem);
getDaoSession(context).clear();
}
/**
* addOrReplace printItem as list entity
*
* @param context
* @param printItemList
*/
public static void addOrReplace(Context context, List<PrintItem> printItemList) {
getPrintItemDao(context).insertOrReplaceInTx(printItemList);
getDaoSession(context).clear();
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getPrintItemDao(context).deleteAll();
getDaoSession(context).clear();
}
/**
* @param printItem
* @param context
*/
public static void delete(Context context, PrintItem printItem) {
getPrintItemDao(context).delete(printItem);
getDaoSession(context).clear();
}
/**
* delete all record by keyScheme
*
* @param context
*/
public static void delete(Context context, String keyScheme) {
QueryBuilder<PrintItem> qb = getPrintItemDao(context).queryBuilder();
qb.where(PrintItemDao.Properties.Uuid_scheme.eq(keyScheme));
qb.build();
getPrintItemDao(context).deleteInTx(qb.list());
getDaoSession(context).clear();
}
/**
* @param printItem
* @param context
*/
public static void update(Context context, PrintItem printItem) {
getPrintItemDao(context).update(printItem);
getDaoSession(context).clear();
}
/**
* select * from table where uuid_scheme = param
*
* @param context
* @param keyScheme
* @return
*/
public static List<PrintItem> getAll(Context context, String keyScheme) {
QueryBuilder<PrintItem> qb = getPrintItemDao(context).queryBuilder();
qb.where(PrintItemDao.Properties.Uuid_scheme.eq(keyScheme));
qb.build();
return qb.list();
}
/**
* select * from table where uuid_print_item = param
*
* @param context
* @param uuidPrintItem
* @return
*/
public static PrintItem getOne(Context context, String uuidPrintItem) {
QueryBuilder<PrintItem> qb = getPrintItemDao(context).queryBuilder();
qb.where(PrintItemDao.Properties.Uuid_print_item.eq(uuidPrintItem));
qb.build();
if (!qb.list().isEmpty()) {
return qb.list().get(0);
} else {
return null;
}
}
}

View file

@ -0,0 +1,194 @@
package com.adins.mss.base.todo.form;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.NewMainActivity;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.errorhandler.ErrorMessageHandler;
import com.adins.mss.base.errorhandler.IShowError;
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.PrintItem;
import com.adins.mss.dao.Scheme;
import com.adins.mss.foundation.db.dataaccess.PrintItemDataAccess;
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
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 java.lang.ref.WeakReference;
import java.util.List;
public class GetSchemeTask extends AsyncTask<Void, Void, Boolean> {
private WeakReference<FragmentActivity> activity;
FragmentManager fragmentManager;
DialogFragment fragment;
boolean isNewTask = false;
private ProgressDialog progressDialog;
private String errMsg = null;
private ErrorMessageHandler errorMessageHandler;
NiftyDialogBuilder dialogBuilder;
public GetSchemeTask(final FragmentActivity activity, DialogFragment newTaskActivity, boolean isNewTask) {
this.activity = new WeakReference<>(activity);
fragmentManager = activity.getSupportFragmentManager();
fragment = newTaskActivity;
this.isNewTask = isNewTask;
errorMessageHandler = new ErrorMessageHandler(new IShowError() {
@Override
public void showError(String errorSubject, String errorMsg, int notifType) {
if(notifType == ErrorMessageHandler.DIALOG_TYPE){
dialogBuilder = NiftyDialogBuilder.getInstance(activity);
dialogBuilder.withTitle(errorSubject)
.withMessage(errorMsg)
.show();
}
}
});
}
@Override
protected void onPreExecute() {
if (isNewTask) {
this.progressDialog = ProgressDialog.show(activity.get(), "", activity.get().getString(R.string.progressWait), true);
}
}
@Override
protected Boolean doInBackground(Void... arg0) {
JsonRequestScheme requestScheme = new JsonRequestScheme();
requestScheme.setAudit(GlobalData.getSharedGlobalData().getAuditData());
requestScheme.setUuid_user(GlobalData.getSharedGlobalData().getUser().getUuid_user());
requestScheme.setTask(Global.TASK_GETLIST);
String json = GsonHelper.toJson(requestScheme);
String url = GlobalData.getSharedGlobalData().getURL_GET_SCHEME();
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();
errMsg = e.getMessage();
}
if (null != serverResult && serverResult.isOK()) {
try {
String result = serverResult.getResult();
JsonResponseScheme responseScheme = GsonHelper.fromJson(result, JsonResponseScheme.class);
List<Scheme> schemes = responseScheme.getListScheme();
List<PrintItem> printItems = responseScheme.getListPrintItems();
//bong 19 may 15 - delete scheme dulu baru di add dari server
if (!schemes.isEmpty()) {
SchemeDataAccess.clean(activity.get());
}
for (Scheme scheme : schemes) {
Scheme scheme2 = null;
try {
scheme2 = SchemeDataAccess.getOneByLastUpdate(activity.get(), scheme.getUuid_scheme(), scheme.getScheme_last_update());
} catch (Exception e) {
FireCrash.log(e);
}
if (scheme2 == null) {
if (scheme.getUuid_scheme() != null) {
SchemeDataAccess.addOrReplace(activity.get(), scheme);
}
} else {
if (scheme.getScheme_last_update().after(scheme2.getScheme_last_update()) && scheme.getUuid_scheme() != null) {
SchemeDataAccess.addOrReplace(activity.get(), scheme);
}
}
}
for (PrintItem printItem : printItems) {
Scheme scheme = SchemeDataAccess.getOne(activity.get(), printItem.getUuid_scheme());
printItem.setScheme(scheme);
PrintItemDataAccess.addOrReplace(activity.get(), printItem);
}
} catch (Exception e) {
FireCrash.log(e);
errMsg = e.getMessage();
}
} else {
try {
errMsg = serverResult.getResult();
} catch (NullPointerException e) {
Log.w("NULL_POINTER_EXCEPTION","Server result is empty on : " + getClass().getSimpleName());
errMsg = activity.get().getString(R.string.something_went_wrong);
}
}
return serverResult.isOK();
}
@Override
protected void onPostExecute(Boolean result) {
if (isNewTask) {
if (progressDialog.isShowing()) {
try {
progressDialog.dismiss();
} catch (Exception e) {
FireCrash.log(e);
}
}
if (result) {
if (errMsg != null) {
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
if (application.equalsIgnoreCase(Global.APPLICATION_SURVEY)) {
if (SchemeDataAccess.getAllSurveyScheme(activity.get()) != null ||
!SchemeDataAccess.getAllSurveyScheme(activity.get()).isEmpty()) {
if(!GlobalData.isRequireRelogin())
fragment.show(fragmentManager, "New Task");
} else {
errorMessageHandler.processError(activity.get().getString(R.string.error_capital)
, errMsg
, ErrorMessageHandler.DIALOG_TYPE);
}
} else if (application.equalsIgnoreCase(Global.APPLICATION_ORDER)) {
if (SchemeDataAccess.getAllOrderScheme(activity.get()) != null ||
!SchemeDataAccess.getAllOrderScheme(activity.get()).isEmpty()) {
if(!GlobalData.isRequireRelogin()){
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
} else {
errorMessageHandler.processError(activity.get().getString(R.string.error_capital)
, errMsg
, ErrorMessageHandler.DIALOG_TYPE);
}
}
} else {
if(!GlobalData.isRequireRelogin())
fragment.show(fragmentManager, "New Task");
}
} else {
Toast.makeText(activity.get(), errMsg, Toast.LENGTH_SHORT).show();
}
}
}
}

View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<RelativeLayout
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<TextView
android:id="@+id/formName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/form_name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/formName"
android:fillViewport="true" >
<TableLayout
android:id="@+id/orderDetailTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:stretchColumns="1" >
</TableLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/Bottomlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<Button
android:id="@+id/btnLookupCMO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:onClick="doLookupCMO"
android:text="@string/btnLookupCMO"/>
<Button
android:id="@+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:onClick="doSubmit"
android:text="@string/btnSubmit"/>
<EditText
android:id="@+id/txtNotes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btnSubmit"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/txtCMO"
android:ems="10"
android:hint="@string/customer_notes_hint"
android:inputType="textMultiLine" />
<TextView
android:id="@+id/txtCMO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btnLookupCMO"
android:visibility="gone"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</LinearLayout>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0" android:toXScale="0.3"
android:fromYScale="1.0" android:toYScale="0.3"
android:pivotX="50%" android:pivotY="100%"
android:duration="@android:integer/config_shortAnimTime"
/>
<alpha
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="@android:integer/config_shortAnimTime"
/>
</set>

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageReviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_medium"
android:background="@color/tv_white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0."
android:paddingRight="@dimen/ptr_progress_bar_stroke_width"
android:layout_alignParentLeft="true"
android:id="@+id/questionNoLabel" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="label"
android:layout_toRightOf="@+id/questionNoLabel"
android:id="@+id/questionImageLabel" />
<LinearLayout
android:id="@+id/imgLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="1"
android:layout_below="@+id/questionImageLabel"
android:layout_toRightOf="@+id/questionNoLabel"
android:layout_toEndOf="@+id/questionNoLabel">
<ImageView
android:id="@+id/imgPhotoAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:gravity="center"
android:scaleType="centerInside"
android:src="@drawable/ic_camera"/>
<ImageView
android:id="@+id/imgLocationAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:scaleType="centerInside"
android:src="@drawable/ic_absent" />
</LinearLayout>
<TextView
android:id="@+id/questionImageAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imgLayout"
android:layout_toRightOf="@+id/questionNoLabel"
android:textAppearance="@android:style/TextAppearance.Small"
android:layout_toEndOf="@+id/questionNoLabel"/>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/line_height"
android:background="@color/tv_gray"
android:layout_below="@+id/questionImageAnswer"/>
</RelativeLayout>