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,230 @@
package com.adins.mss.coll.networks.senders;
import android.app.Activity;
import android.app.ProgressDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import android.view.View;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.NewMainActivity;
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.mainmenu.MainMenuActivity;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.coll.R;
import com.adins.mss.coll.adapters.ClosingTaskAdapter;
import com.adins.mss.coll.fragments.ClosingTaskFragment;
import com.adins.mss.coll.networks.ClosingTaskListener;
import com.adins.mss.coll.networks.entities.ClosingTaskRequest;
import com.adins.mss.coll.networks.responses.ClosingTaskListResponse;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.db.dataaccess.ReceiptVoucherDataAccess;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.JsonParseException;
/**
* Created by angga.permadi on 3/3/2016.
*/
public class ClosingTaskSender<Response extends MssResponseType> extends DataTask<Void, Void, Response> implements IShowError {
private Activity context;
private ProgressDialog progressDialog;
private Class<Response> responseClazz;
private String flag;
private ClosingTaskListener listener;
private boolean isClosingTaskSuccess = false;
NiftyDialogBuilder dialogBuilder;
public ClosingTaskSender(Activity context, ClosingTaskRequest request, Class<Response> responseClazz) {
super(context, request);
this.context = context;
this.flag = request.getFlag();
this.responseClazz = responseClazz;
dialogBuilder = NiftyDialogBuilder.getInstance(context);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(context, "", context.getString(R.string.please_wait), true, false);
}
@Override
protected Response onBackgroundResult(HttpConnectionResult serverResult) {
Response resultBean = null;
if (serverResult != null) {
log(serverResult.getResult());
if (serverResult.isOK()) {
try {
resultBean = GsonHelper.fromJson(serverResult.getResult(), responseClazz);
} catch (JsonParseException e) {
errorMessage = context.getString(R.string.msgErrorParsingJson);
} catch (Exception e) {
FireCrash.log(e);
errorMessage = serverResult.getResult();
}
} else {
errorMessage = serverResult.getResult();
}
}
return resultBean;
}
@Override
protected void onPostExecute(Response response) {
super.onPostExecute(response);
boolean isShowDialog = false;
if (progressDialog != null) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
progressDialog = null;
}
if (errorMessage != null) {
dialogBuilder.withTitle(context.getString(R.string.error_capital))
.withMessage(errorMessage);
isShowDialog = true;
} else if (response == null) {
dialogBuilder.withTitle(context.getString(R.string.error_capital))
.withMessage(context.getString(R.string.empty_data));
isShowDialog = true;
} else {
if (response.getStatus().getCode() == 0) {
if (flag.equals(ClosingTaskRequest.CLOSING_TASK)) {
dialogBuilder.withTitle(context.getString(R.string.info_capital))
.withMessage(response.getStatus().getMessage());
// delete all rv number
ReceiptVoucherDataAccess.clean(context);
if (listener != null) {
listener.onClosingTaskSuccess();
}
//EventBusHelper.post(response);
isShowDialog = true;
isClosingTaskSuccess = true;
} else if (flag.equals(ClosingTaskRequest.CLOSING_TASK_LIST)) {
ClosingTaskListResponse response1 = (ClosingTaskListResponse) response;
if (response1.getTaskList() == null || response1.getTaskList().size() == 0) {
String message = response1.getStatus().getMessage();
if (message == null || message.isEmpty()) {
message = context.getString(R.string.msgNoSurvey);
}
dialogBuilder.withTitle(context.getString(R.string.info_capital)).withMessage(message);
isShowDialog = true;
} else {
/*Bundle bundle = new Bundle();
bundle.putParcelableArrayList(ClosingTaskFragment.CLOSING_TASK_LIST,
(ArrayList<? extends Parcelable>) response1.getTaskList());*/
ClosingTaskAdapter.getInstance().clear();
ClosingTaskAdapter.getInstance().notifyDataSetChanged();
ClosingTaskAdapter.getInstance().processData(response1.getTaskList());
if (!context.isFinishing()) {
Fragment fragment = ClosingTaskFragment.newInstance();
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();
isShowDialog = false;
}
}
}
} else {
dialogBuilder.withTitle(context.getString(R.string.error_capital))
.withMessage(response.getStatus().getMessage());
isShowDialog = true;
}
}
if (flag.equals(ClosingTaskRequest.CLOSING_TASK) || isShowDialog) {
dialogBuilder.isCancelable(false);
dialogBuilder.isCancelableOnTouchOutside(false);
dialogBuilder.withButton1Text(context.getString(R.string.btnClose)).
setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View paramView) {
dialogBuilder.dismiss();
if (isClosingTaskSuccess) {
context.onBackPressed();
UpdateMenuUI();
}
}
});
dialogBuilder.show();
if (flag.equals(ClosingTaskRequest.CLOSING_TASK_LIST)) {
if (context instanceof NewMainActivity) {
try {
Global.positionStack.remove(Global.positionStack.lastElement());
// ((MainMenuActivity) context).mDrawerListLeft.
// setItemChecked(Global.positionStack.lastElement(), true);
NewMainActivity.tempPosition = Global.positionStack.lastElement();
} catch (Exception ex) {
// empty
}
}
}
}
}
private void UpdateMenuUI() {
/*Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
// UI code goes here
try {
if (MainMenuActivity.mnTaskList != null)
MainMenuActivity.mnTaskList.setCounter(String
.valueOf(ToDoList
.getCounterTaskList(context)));
if (MainMenuActivity.mnLog != null)
MainMenuActivity.mnLog
.setCounter(String.valueOf(TaskLogImpl
.getCounterLog(context)));
if (MainMenuActivity.menuAdapter != null)
MainMenuActivity.menuAdapter.notifyDataSetChanged();
} catch (Exception e) { FireCrash.log(e);
// TODO: handle exception
}
}
});*/
try {
// MainMenuActivity.setDrawerCounter();
NewMainActivity.setCounter();
} catch (Exception e) {
FireCrash.log(e);
// TODO: handle exception
}
}
public void setListener(ClosingTaskListener listener) {
this.listener = listener;
}
@Override
protected String getUrl() {
return GlobalData.getSharedGlobalData().getURL_CLOSING_TASK();
}
@Override
public void showError(String errorSubject, String errorMsg, int notifType) {
if(notifType == ErrorMessageHandler.DIALOG_TYPE){
}
}
}

View file

@ -0,0 +1,407 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/card_margin"
app:cardBackgroundColor="#dfdfdf"
app:cardCornerRadius="10dp">
<LinearLayout
android:id="@+id/layoutTask"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Priority"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow9"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Agreement Number"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtAgreementNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Customer Name"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtCustName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Customer Address"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtCustAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="5"
android:text="jalan haji suaib no 34 jakarta barat kebon jeruk"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Customer Phone"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtCustPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableCustJobAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvJobAddressTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Customer Job Address"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/tvJobAddressDivider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/tvJobAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="5"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRowSurveyLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/txtSurveyLocationTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Survey Location"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtSurveyLocationDivider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtSurveyLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notes"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtNotes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Plat"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtLicensePlate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible">
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Rangka"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtChassisNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRow8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible">
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Mesin"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtEngineNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
<TableRow
android:id="@+id/tableRowChassisEngineNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/txtChassisEngineNumberTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Rangka/No Mesin"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtChassisEngineNumberDivider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtChassisEngineNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-"
android:textColor="@android:color/black" />
</TableRow>
</TableLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -0,0 +1,141 @@
package com.adins.mss.foundation.services;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.foundation.camerainapp.helper.Logger;
/**
* @author glen.iglesias
* <p>
* Object to store interval and event to trigger, used by AutoSendThread
* <p>
* example from:
* http://stackoverflow.com/questions/6776327/how-to-pause-resume-thread-in-android
*/
public class ScheduledItem extends Thread {
String scheduleId;
/**
* Interval for which event will be triggered each time
*/
int interval;
ScheduledItemHandler handler;
private Object mPauseLock = new Object();
private boolean mPaused = false;
public ScheduledItem(String id, int interval, ScheduledItemHandler handler) {
super();
this.scheduleId = id;
this.interval = interval;
this.handler = handler;
}
public ScheduledItem(String id, int interval) {
super();
this.scheduleId = id;
this.interval = interval;
}
//=== Thread Method ===//
@Override
public void run() {
while (true) {
try {
handler.onEventTrigger(this);
} catch (Exception e) {
FireCrash.log(e);
Logger.e("ScheduleItem " + scheduleId, "Exception occured");
e.printStackTrace();
}
synchronized (mPauseLock) {
//sleep by interval
try {
mPauseLock.wait(interval);
} catch (InterruptedException e1) {
e1.printStackTrace();
Thread.currentThread().interrupt();
}
//sleep by pause, if paused
while (mPaused) {
try {
mPauseLock.wait();
} catch (InterruptedException e) {
FireCrash.log(e);
Thread.currentThread().interrupt();
}
}
}
}
}
/**
* Call this on pause.
*/
public void pauseSchedule() {
synchronized (mPauseLock) {
mPaused = true;
}
}
/**
* Call this on resume.
*/
public void resumeSchedule() {
synchronized (mPauseLock) {
mPaused = false;
mPauseLock.notifyAll();
}
}
public int getInterval() {
return interval;
}
public void setInterval(int interval) {
this.interval = interval;
}
//=== Getter and Setter ===//
public ScheduledItemHandler getHandler() {
return handler;
}
public void setHandler(ScheduledItemHandler handler) {
this.handler = handler;
}
public String getScheduleId() {
return scheduleId;
}
public void setScheduleId(String scheduleId) {
this.scheduleId = scheduleId;
}
enum State {
PAUSED,
ACTIVE,
INACTIVE
}
/**
* @author glen.iglesias
* <p>
* A Interface for handler to handle event trigger when interval counter reaches zero or below
*/
public interface ScheduledItemHandler {
/**
* Callback when ScheduledItem first started or after a set of interval.
*
* @param schItem
* @return true if should ignore interval and trigger another event just after the previous is done,
* or false if next trigger should wait until next interval
*/
public boolean onEventTrigger(ScheduledItem schItem);
}
}

View file

@ -0,0 +1,17 @@
package com.adins.mss.coll.interfaces;
import android.content.Context;
import com.adins.mss.base.commons.TaskListener;
import com.adins.mss.coll.interfaces.callback.SaveDataInstallmentCallback;
import com.adins.mss.coll.interfaces.callback.TaskReportCallback;
import com.adins.mss.coll.models.InstallmentScheduleResponse;
/**
* Created by kusnendi.muhamad on 31/07/2017.
*/
public interface TasksInterface {
public void saveDataInstallmentSchedule(Context context, InstallmentScheduleResponse installmentSchedResp, String taskId, SaveDataInstallmentCallback callback);
public void getDataInstallmentSchedule(String taskId, TaskListener listener);
}

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#CABBBBBB"/>
<corners android:radius="2dp" />
</shape>
</item>
<item
android:left="0.5dp"
android:right="1dp"
android:top="0dp"
android:bottom="0.5dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="2dp" />
</shape>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/legendText"
android:gravity="center"
android:textSize="12sp"
android:paddingBottom="3dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:text="@string/hello_blank_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/login_color"/>
<!--<gradient-->
<!--android:startColor="@color/gradient_start"-->
<!--android:endColor="@color/gradient_end"-->
<!--android:angle="270" />-->
</shape>

View file

@ -0,0 +1,382 @@
package com.github.jjobes.slidedatetimepicker;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import com.adins.mss.base.R;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* <p>The {@code DialogFragment} that contains the {@link SlidingTabLayout}
* and {@link CustomViewPager}.</p>
* <p>
* <p>The {@code CustomViewPager} contains the {@link DateFragment} and {@link TimeFragment}.</p>
* <p>
* <p>This {@code DialogFragment} is managed by {@link SlideDateTimePicker}.</p>
*
* @author jjobes
*/
public class SlideDateTimeDialogFragment extends DialogFragment implements DateFragment.DateChangedListener,
TimeFragment.TimeChangedListener {
public static final String TAG_SLIDE_DATE_TIME_DIALOG_FRAGMENT = "tagSlideDateTimeDialogFragment";
private static SlideDateTimeListener mListener;
private Context mContext;
private CustomViewPager mViewPager;
private ViewPagerAdapter mViewPagerAdapter;
private SlidingTabLayout mSlidingTabLayout;
private View mButtonHorizontalDivider;
private View mButtonVerticalDivider;
private Button mOkButton;
private Button mCancelButton;
private Date mInitialDate;
private int mTheme;
private int mIndicatorColor;
private Date mMinDate;
private Date mMaxDate;
private boolean mIsClientSpecified24HourTime;
private boolean mIs24HourTime;
private Calendar mCalendar;
private int mDateFlags =
DateUtils.FORMAT_SHOW_WEEKDAY |
DateUtils.FORMAT_SHOW_DATE |
DateUtils.FORMAT_ABBREV_ALL;
public SlideDateTimeDialogFragment() {
// Required empty public constructor
}
/**
* <p>Return a new instance of {@code SlideDateTimeDialogFragment} with its bundle
* filled with the incoming arguments.</p>
* <p>
* <p>Called by {@link SlideDateTimePicker#show()}.</p>
*
* @param listener
* @param initialDate
* @param minDate
* @param maxDate
* @param isClientSpecified24HourTime
* @param is24HourTime
* @param theme
* @param indicatorColor
* @return
*/
public static SlideDateTimeDialogFragment newInstance(SlideDateTimeListener listener,
Date initialDate, Date minDate, Date maxDate, boolean isClientSpecified24HourTime,
boolean is24HourTime, int theme, int indicatorColor) {
mListener = listener;
// Create a new instance of SlideDateTimeDialogFragment
SlideDateTimeDialogFragment dialogFragment = new SlideDateTimeDialogFragment();
// Store the arguments and attach the bundle to the fragment
Bundle bundle = new Bundle();
bundle.putSerializable("initialDate", initialDate);
bundle.putSerializable("minDate", minDate);
bundle.putSerializable("maxDate", maxDate);
bundle.putBoolean("isClientSpecified24HourTime", isClientSpecified24HourTime);
bundle.putBoolean("is24HourTime", is24HourTime);
bundle.putInt("theme", theme);
bundle.putInt("indicatorColor", indicatorColor);
dialogFragment.setArguments(bundle);
// Return the fragment with its bundle
return dialogFragment;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mContext = activity;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
unpackBundle();
mCalendar = Calendar.getInstance();
mCalendar.setTime(mInitialDate);
switch (mTheme) {
case SlideDateTimePicker.HOLO_DARK:
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Dialog_NoActionBar);
break;
case SlideDateTimePicker.HOLO_LIGHT:
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog_NoActionBar);
break;
default: // if no theme was specified, default to holo light
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog_NoActionBar);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.slide_date_time_picker, container);
setupViews(view);
customizeViews();
initViewPager();
initTabs();
initButtons();
return view;
}
@Override
public void onDestroyView() {
// Workaround for a bug in the compatibility library where calling
// setRetainInstance(true) does not retain the instance across
// orientation changes.
if (getDialog() != null && getRetainInstance()) {
getDialog().setDismissMessage(null);
}
super.onDestroyView();
}
private void unpackBundle() {
Bundle args = getArguments();
mInitialDate = (Date) args.getSerializable("initialDate");
mMinDate = (Date) args.getSerializable("minDate");
mMaxDate = (Date) args.getSerializable("maxDate");
mIsClientSpecified24HourTime = args.getBoolean("isClientSpecified24HourTime");
mIs24HourTime = args.getBoolean("is24HourTime");
mTheme = args.getInt("theme");
mIndicatorColor = args.getInt("indicatorColor");
}
private void setupViews(View v) {
mViewPager = (CustomViewPager) v.findViewById(R.id.viewPager);
mSlidingTabLayout = (SlidingTabLayout) v.findViewById(R.id.slidingTabLayout);
mButtonHorizontalDivider = v.findViewById(R.id.buttonHorizontalDivider);
mButtonVerticalDivider = v.findViewById(R.id.buttonVerticalDivider);
mOkButton = (Button) v.findViewById(R.id.okButton);
mCancelButton = (Button) v.findViewById(R.id.cancelButton);
}
private void customizeViews() {
int lineColor = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
lineColor = mTheme == SlideDateTimePicker.HOLO_DARK ?
getResources().getColor(R.color.gray_holo_dark, getContext().getTheme()) :
getResources().getColor(R.color.gray_holo_light, getContext().getTheme());
} else {
lineColor = mTheme == SlideDateTimePicker.HOLO_DARK ?
getResources().getColor(R.color.gray_holo_dark) :
getResources().getColor(R.color.gray_holo_light);
}
// Set the colors of the horizontal and vertical lines for the
// bottom buttons depending on the theme.
switch (mTheme) {
case SlideDateTimePicker.HOLO_LIGHT:
case SlideDateTimePicker.HOLO_DARK:
mButtonHorizontalDivider.setBackgroundColor(lineColor);
mButtonVerticalDivider.setBackgroundColor(lineColor);
break;
default: // if no theme was specified, default to holo light
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mButtonHorizontalDivider.setBackgroundColor(getResources().getColor(R.color.gray_holo_light, getContext().getTheme()));
mButtonVerticalDivider.setBackgroundColor(getResources().getColor(R.color.gray_holo_light, getContext().getTheme()));
} else {
mButtonHorizontalDivider.setBackgroundColor(getResources().getColor(R.color.gray_holo_light));
mButtonVerticalDivider.setBackgroundColor(getResources().getColor(R.color.gray_holo_light));
}
}
// Set the color of the selected tab underline if one was specified.
if (mIndicatorColor != 0)
mSlidingTabLayout.setSelectedIndicatorColors(mIndicatorColor);
}
private void initViewPager() {
mViewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
mViewPager.setAdapter(mViewPagerAdapter);
// Setting this custom layout for each tab ensures that the tabs will
// fill all available horizontal space.
mSlidingTabLayout.setCustomTabView(R.layout.custom_tab, R.id.tabText);
mSlidingTabLayout.setViewPager(mViewPager);
}
private void initTabs() {
// Set intial date on date tab
updateDateTab();
// Set initial time on time tab
updateTimeTab();
}
private void initButtons() {
mOkButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mListener == null) {
throw new NullPointerException(
"Listener no longer exists for mOkButton");
}
mListener.onDateTimeSet(new Date(mCalendar.getTimeInMillis()));
dismiss();
}
});
mCancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mListener == null) {
throw new NullPointerException(
"Listener no longer exists for mCancelButton");
}
mListener.onDateTimeCancel();
dismiss();
}
});
}
/**
* <p>The callback used by the DatePicker to update {@code mCalendar} as
* the user changes the date. Each time this is called, we also update
* the text on the date tab to reflect the date the user has currenly
* selected.</p>
* <p>
* <p>Implements the {@link DateFragment.DateChangedListener}
* interface.</p>
*/
@Override
public void onDateChanged(int year, int month, int day) {
mCalendar.set(year, month, day);
updateDateTab();
}
/**
* <p>The callback used by the TimePicker to update {@code mCalendar} as
* the user changes the time. Each time this is called, we also update
* the text on the time tab to reflect the time the user has currenly
* selected.</p>
* <p>
* <p>Implements the {@link TimeFragment.TimeChangedListener}
* interface.</p>
*/
@Override
public void onTimeChanged(int hour, int minute) {
mCalendar.set(Calendar.HOUR_OF_DAY, hour);
mCalendar.set(Calendar.MINUTE, minute);
updateTimeTab();
}
private void updateDateTab() {
mSlidingTabLayout.setTabText(0, DateUtils.formatDateTime(
mContext, mCalendar.getTimeInMillis(), mDateFlags));
}
@SuppressLint("SimpleDateFormat")
private void updateTimeTab() {
if (mIsClientSpecified24HourTime) {
SimpleDateFormat formatter;
if (mIs24HourTime) {
formatter = new SimpleDateFormat("HH:mm");
mSlidingTabLayout.setTabText(1, formatter.format(mCalendar.getTime()));
} else {
formatter = new SimpleDateFormat("h:mm aa");
mSlidingTabLayout.setTabText(1, formatter.format(mCalendar.getTime()));
}
} else // display time using the device's default 12/24 hour format preference
{
mSlidingTabLayout.setTabText(1, DateFormat.getTimeFormat(
mContext).format(mCalendar.getTimeInMillis()));
}
}
/**
* <p>Called when the user clicks outside the dialog or presses the <b>Back</b>
* button.</p>
* <p>
* <p><b>Note:</b> Actual <b>Cancel</b> button clicks are handled by {@code mCancelButton}'s
* event handler.</p>
*/
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
if (mListener == null) {
throw new NullPointerException(
"Listener no longer exists in onCancel()");
}
mListener.onDateTimeCancel();
}
private class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
DateFragment dateFragment = DateFragment.newInstance(
mTheme,
mCalendar.get(Calendar.YEAR),
mCalendar.get(Calendar.MONTH),
mCalendar.get(Calendar.DAY_OF_MONTH),
mMinDate,
mMaxDate);
// dateFragment.setTargetFragment(SlideDateTimeDialogFragment.this, 100);
return dateFragment;
case 1:
TimeFragment timeFragment = TimeFragment.newInstance(
mTheme,
mCalendar.get(Calendar.HOUR_OF_DAY),
mCalendar.get(Calendar.MINUTE),
mIsClientSpecified24HourTime,
mIs24HourTime);
// timeFragment.setTargetFragment(SlideDateTimeDialogFragment.this, 200);
return timeFragment;
default:
return null;
}
}
@Override
public int getCount() {
return 2;
}
}
}

View file

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bgGridPriority"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="@dimen/line_height"
android:background="@drawable/grid_background" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/ImgSLE"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:src="@drawable/light_red" />
<ImageView
android:id="@+id/imgStsPriority"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:src="@drawable/light_red" />
</LinearLayout>
<ImageView
android:id="@+id/imgPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ImgSLE"
android:src="@drawable/icon_not_priority"
android:layout_centerHorizontal="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txtPriority"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:layout_below="@+id/imgPriority"
android:text="@string/dummy_priority"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<TextView
android:id="@+id/txtTaskID"
android:layout_marginLeft="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dummy_task_id"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<TextView
android:id="@+id/txtName"
android:layout_marginLeft="3dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text="@string/dummy_header_name_2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_white" />
<TextView
android:id="@+id/txtScheme"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="@color/tv_white"
android:text="@string/dummy_scheme_name"
android:textSize="10dp" />
<TextView
android:id="@+id/txtStatusTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_status_task"
android:visibility="gone"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<TextView
android:id="@+id/txtslatime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ImgSLE"
android:text="00:00"
android:layout_marginLeft="5dp"
android:textColor="@color/tv_white"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,256 @@
package com.adins.mss.foundation.image;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.dynamicform.UserClone;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
import com.soundcloud.android.crop.Crop;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class CroppingImage {
private CroppingImage() {
}
/**
* Method for begin Crop from Activity
*
* @param source - Uri Source
* @param activity - Activity
*/
public static void beginCrop(Uri source, Activity activity) {
Uri outputUri = Uri.fromFile(new File(activity.getFilesDir(), "cropped"));
new Crop(source).output(outputUri).asSquare().start(activity);
}
/**
* Method for begin Crop from Activity
*
* @param source - Uri Source
* @param outputSource - Uri Output Source
* @param activity - Activity
*/
public static void beginCropInActivity(Uri source, Uri outputSource, Activity activity) {
new Crop(source).output(outputSource).asSquare().start(activity);
}
/**
* Method for begin Crop from Activity (for Sample)
*
* @param activity
*/
public static void beginCrop(Activity activity) {
Uri outputUri = Uri.fromFile(new File(activity.getFilesDir(), "cropped"));
new Crop(outputUri).output(outputUri).asSquare().start(activity);
}
public static void beginCrop(Activity activity, byte[] byte_image) {
FileOutputStream out = null;
File filename = new File(activity.getFilesDir(), "cropped");
Uri outputUri = Uri.fromFile(filename);
try {
out = new FileOutputStream(filename);
Bitmap bm = BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length);
bm.compress(Bitmap.CompressFormat.JPEG, 80, out);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
new Crop(outputUri).output(outputUri).asSquare().start(activity);
}
/**
* Method for begin Crop from Activity from byte[] data
*
* @param source - Uri source
* @param activity - Activity
* @param byte_image - byte[] byte image
*/
public static void beginCrop(Uri source, Activity activity, byte[] byte_image) {
FileOutputStream out = null;
File filename = new File(activity.getFilesDir(), "cropped");
Uri outputUri = Uri.fromFile(filename);
try {
out = new FileOutputStream(filename);
Bitmap bm = BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length);
bm.compress(Bitmap.CompressFormat.JPEG, 80, out);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
new Crop(source).output(outputUri).asSquare().start(activity);
}
/**
* Method for begin Crop from Fragment
*
* @param source - Uri source
* @param outputSource - Uri output source
* @param context - context
* @param fragment - Fragment
*/
public static void beginCropInFragment(Uri source, Uri outputSource, Context context, Fragment fragment) {
new Crop(source).output(outputSource).asSquare().start(context, fragment);
}
/**
* Method for begin Crop from Fragment for change Profile Picture
*
* @param source
* @param context
* @param fragment
*/
public static void beginCropImgProfile(Uri source, Context context, Fragment fragment) {
new Crop(source).output(source).asSquare().start(context, fragment);
}
/**
* Method for begin Crop from Fragment for change Profile Picture by byte[]
*
* @param context
* @param fragment
* @param byte_image
*/
public static void beginCropImgProfile(Context context, Fragment fragment, byte[] byte_image) {
File filename = new File(context.getFilesDir(), "imgProfile");
FileOutputStream out = null;
try {
out = new FileOutputStream(filename);
Bitmap bm = BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length);
bm.compress(Bitmap.CompressFormat.JPEG, 80, out);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Uri outputUri = Uri.fromFile(filename);
new Crop(outputUri).output(outputUri).asSquare().start(context, fragment);
}
/**
* Method for begin Crop from Fragment for change Header Picture
*
* @param source
* @param context
* @param fragment
*/
public static void beginCropImgHeader(Uri source, Context context, Fragment fragment) {
new Crop(source).output(source).withAspect(16, 10).start(context, fragment);
}
/**
* Method for begin Crop from Fragment for change Header Picture
*
* @param context
* @param fragment
* @param byte_image
*/
public static void beginCropImgHeader(Context context, Fragment fragment, byte[] byte_image) {
File filename = new File(context.getFilesDir(), "imgHeader");
FileOutputStream out = null;
try {
out = new FileOutputStream(filename);
Bitmap bm = BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length);
bm.compress(Bitmap.CompressFormat.JPEG, 80, out);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Uri outputUri = Uri.fromFile(filename);
new Crop(outputUri).output(outputUri).asSquare().start(context, fragment);
}
/**
* Method for handle Croping
*
* @param resultCode
* @param result
* @param activity
* @return
*/
public static Uri handleCrop(int resultCode, Intent result, Activity activity) {
Uri outputUri = null;
if (resultCode == activity.RESULT_OK) {
outputUri = Crop.getOutput(result);
} else if (resultCode == Crop.RESULT_ERROR && Global.IS_DEV) {
Log.i("CropingImage",Crop.getError(result).getMessage());
}
return outputUri;
}
public static void handleCropHeader(int resultCode, Intent result, Activity activity) {
Uri outputUri = null;
if (resultCode == activity.RESULT_OK) {
outputUri = Crop.getOutput(result);
File imgFile = new File(outputUri.getPath());
byte[] byteImage = Utils.pathBitmapToByte(imgFile);
UserClone user = new UserClone(GlobalData.getSharedGlobalData().getUser(), false);
user.setImage_cover(byteImage);
UserDataAccess.addOrReplace(activity.getApplicationContext(), user);
} else if (resultCode == Crop.RESULT_ERROR) {
Toast.makeText(activity, Crop.getError(result).getMessage(), Toast.LENGTH_SHORT).show();
}
}
public static void handleCropProfile(int resultCode, Intent result, Activity activity) {
if (resultCode == activity.RESULT_OK) {
File imgFile = new File(activity.getFilesDir() + "/imgHeader");
byte[] byteImage = Utils.pathBitmapToByte(imgFile);
UserClone user = new UserClone(GlobalData.getSharedGlobalData().getUser(), false);
user.setImage_profile(byteImage);
UserDataAccess.addOrReplace(activity.getApplicationContext(), user);
} else if (resultCode == Crop.RESULT_ERROR) {
Log.i("CropingImage",Crop.getError(result).getMessage());
Toast.makeText(activity, Crop.getError(result).getMessage(), Toast.LENGTH_SHORT).show();
}
}
}