mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-07-01 05:14:17 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,386 @@
|
|||
package com.adins.mss.coll.dashboardcollection.view;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.todolist.form.PriorityTabFragment;
|
||||
import com.adins.mss.base.todolist.form.TaskListFragment_new;
|
||||
import com.adins.mss.base.todolist.form.TaskList_Fragment;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.dashboardcollection.DashboardCollDataSource;
|
||||
import com.adins.mss.coll.dashboardcollection.DashboardCollectionContract;
|
||||
import com.adins.mss.coll.dashboardcollection.model.CollResultDetail;
|
||||
import com.adins.mss.coll.dashboardcollection.model.DashboardData;
|
||||
import com.adins.mss.coll.dashboardcollection.presenter.DashboardCollPresenter;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.UserHelp.Bean.Dummy.UserHelpViewDummy;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class DashboardCollectionView extends Fragment implements TabLayout.BaseOnTabSelectedListener, DashboardCollectionContract.View {
|
||||
|
||||
//android widget
|
||||
private ConstraintLayout contentLayout;
|
||||
private ProgressBar targetProgress;
|
||||
private TextView outstandingTv, collectAmountProgress, percentageTv, outstandingAmountTv;
|
||||
private PieChart collResultPie;
|
||||
private TabLayout tabLayout;
|
||||
private ViewPager viewPager;
|
||||
private ValueFormatter valueFormatter;
|
||||
|
||||
private DashboardCollectionContract.Presenter presenter;
|
||||
private android.app.ProgressDialog progressDialog;
|
||||
//data holder
|
||||
private int collNum, ptpNum, failNum;
|
||||
private List<CollResultDetail> collectDetails;
|
||||
private List<CollResultDetail> ptpDetails;
|
||||
private List<CollResultDetail> failedDetails;
|
||||
private CollResultPagerAdapter tabAdapter;
|
||||
|
||||
//dialog builder
|
||||
private NiftyDialogBuilder dialogBuilder;
|
||||
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
public DashboardCollectionView() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_dashboard_collection_view, container, false);
|
||||
contentLayout = view.findViewById(R.id.dashContentLayout);
|
||||
targetProgress = view.findViewById(R.id.dashTargetProgress);
|
||||
collResultPie = view.findViewById(R.id.dashCollResultPie);
|
||||
tabLayout = view.findViewById(R.id.dashDetailTab);
|
||||
viewPager = view.findViewById(R.id.dashViewPager);
|
||||
collectAmountProgress = view.findViewById(R.id.dashProgressValue);
|
||||
percentageTv = view.findViewById(R.id.dashProgressPercent);
|
||||
outstandingTv = view.findViewById(R.id.dashOutstandingValue);
|
||||
outstandingAmountTv = view.findViewById(R.id.dashOutstandingAmount);
|
||||
|
||||
screenName = FirebaseAnalytics.getInstance(getActivity());
|
||||
|
||||
outstandingTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
for (int i = 0; i < getActivity().getSupportFragmentManager().getBackStackEntryCount(); i++)
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
|
||||
Fragment fragment;
|
||||
if (Global.PLAN_TASK_ENABLED) {
|
||||
fragment = new TaskListFragment_new();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(TaskList_Fragment.BUND_KEY_PAGE, 1);
|
||||
fragment.setArguments(bundle);
|
||||
} else {
|
||||
fragment = new PriorityTabFragment();
|
||||
}
|
||||
FragmentTransaction transaction = getFragmentManager().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.commit();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
getActivity().setTitle(getString(R.string.collector_dashboard));
|
||||
Global.positionStack.push(1);
|
||||
|
||||
//init presenter and datasource
|
||||
presenter = new DashboardCollPresenter(this, new DashboardCollDataSource(getActivity().getApplication()));
|
||||
|
||||
//set data for tabs
|
||||
tabLayout.addTab(tabLayout.newTab().setText("Collected"));
|
||||
tabLayout.addTab(tabLayout.newTab().setText("PTP"));
|
||||
tabLayout.addTab(tabLayout.newTab().setText("Failed"));
|
||||
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
||||
|
||||
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
|
||||
tabAdapter = new CollResultPagerAdapter(fragmentManager, tabLayout.getTabCount());
|
||||
viewPager.setAdapter(tabAdapter);
|
||||
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(this);
|
||||
|
||||
//load data
|
||||
if(needShowUserHelp()){
|
||||
showUserhelp();
|
||||
}
|
||||
else {
|
||||
initData();
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
progressDialog = android.app.ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.please_wait_dialog), true);
|
||||
presenter.requestDashboardData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(getActivity(), getString(R.string.screen_name_dashboard_coll), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(final Menu menu) {
|
||||
if (Global.ENABLE_USER_HELP &&
|
||||
(Global.userHelpGuide.get(DummyDashboardCollView.class.getSimpleName()) != null) ||
|
||||
Global.userHelpDummyGuide.get(DummyDashboardCollView.class.getSimpleName()) != null) {
|
||||
menu.findItem(R.id.mnGuide).setVisible(true);
|
||||
}
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == com.adins.mss.base.R.id.mnGuide) {
|
||||
if (!Global.BACKPRESS_RESTRICTION) {
|
||||
UserHelp.reloadUserHelp(getActivity(), DummyDashboardCollView.class.getSimpleName());
|
||||
if (needShowUserHelp()) {
|
||||
showUserhelp();
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void drawCollResultChart() {
|
||||
//init value formatter
|
||||
valueFormatter = new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return value == 0 ? "" : (int) value + "";
|
||||
}
|
||||
};
|
||||
|
||||
List<PieEntry> pieEntries = new ArrayList<>();
|
||||
|
||||
PieData pieData;
|
||||
if (ptpNum == 0 && failNum == 0 && collNum == 0) {
|
||||
pieEntries.add(new PieEntry(1, ""));
|
||||
PieDataSet dataSet = new PieDataSet(pieEntries, "");
|
||||
dataSet.setColors(Color.parseColor("#A9A9AA"));
|
||||
dataSet.setDrawValues(false);
|
||||
pieData = new PieData(dataSet);
|
||||
} else {
|
||||
PieEntry pieEntry1 = new PieEntry(ptpNum, "PTP");
|
||||
pieEntries.add(pieEntry1);
|
||||
|
||||
PieEntry pieEntry2 = new PieEntry(collNum, "Collected");
|
||||
pieEntries.add(pieEntry2);
|
||||
|
||||
PieEntry pieEntry3 = new PieEntry(failNum, "Failed");
|
||||
pieEntries.add(pieEntry3);
|
||||
|
||||
PieDataSet dataSet = new PieDataSet(pieEntries, "");
|
||||
int[] colors = {Color.parseColor("#221E66"), Color.parseColor("#1D6304"), Color.parseColor("#C61E00")};
|
||||
dataSet.setColors(colors);
|
||||
dataSet.setValueTextColor(Color.WHITE);
|
||||
dataSet.setValueTextSize(12f);
|
||||
dataSet.setValueFormatter(valueFormatter);
|
||||
pieData = new PieData(dataSet);
|
||||
}
|
||||
|
||||
collResultPie.getLegend().setEnabled(false);
|
||||
collResultPie.setDrawEntryLabels(false);
|
||||
collResultPie.setDrawHoleEnabled(true);
|
||||
collResultPie.setHoleColor(Color.parseColor("#00000000"));
|
||||
collResultPie.setTransparentCircleAlpha(0);
|
||||
collResultPie.setDescription(null);
|
||||
collResultPie.setHoleRadius(40f);
|
||||
collResultPie.setData(pieData);
|
||||
collResultPie.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
viewPager.setCurrentItem(tab.getPosition());
|
||||
//send data coll result details
|
||||
int idx = tab.getPosition();
|
||||
switch (idx) {
|
||||
case 0:
|
||||
tabAdapter.setDataToPage(tab.getPosition(), collectDetails);
|
||||
break;
|
||||
case 1:
|
||||
tabAdapter.setDataToPage(tab.getPosition(), ptpDetails);
|
||||
break;
|
||||
case 2:
|
||||
tabAdapter.setDataToPage(tab.getPosition(), failedDetails);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
//no need to be implemented for now
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
//no need to be implemented for now
|
||||
}
|
||||
|
||||
//dashboard related UI callback
|
||||
private void setTotalOutstandingTask(int outstandingTask) {
|
||||
outstandingTv.setText(outstandingTask + "");
|
||||
}
|
||||
|
||||
private void setOutstandingAmount(double outstandingAmount) {
|
||||
String finToCollectAmount = Tool.formatToCurrency(outstandingAmount);
|
||||
outstandingAmountTv.setText(finToCollectAmount + " IDR");
|
||||
}
|
||||
|
||||
private void setProgressBarValue(double collectedAmount, double targetAmount) {
|
||||
//set percentage from target
|
||||
double percentage = collectedAmount / targetAmount;
|
||||
int finPercentage = (int) (percentage * 100);
|
||||
targetProgress.setProgress(finPercentage);
|
||||
targetProgress.setMax(100);
|
||||
|
||||
if (percentage >= 100f) {
|
||||
Drawable drawable = targetProgress.getIndeterminateDrawable().mutate();
|
||||
drawable.setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
|
||||
targetProgress.setIndeterminateDrawable(drawable);
|
||||
percentageTv.setTextColor(Color.GREEN);
|
||||
}
|
||||
|
||||
percentageTv.setText(finPercentage + " %");
|
||||
|
||||
String finCollectAmount, finTargetAmount;
|
||||
finCollectAmount = Tool.formatToCurrency(collectedAmount);
|
||||
finTargetAmount = Tool.formatToCurrency(targetAmount);
|
||||
collectAmountProgress.setText(finCollectAmount + " / " + finTargetAmount + " IDR");
|
||||
}
|
||||
|
||||
private void setTaskCollectedNum(int collectedNum) {
|
||||
this.collNum = collectedNum;
|
||||
}
|
||||
|
||||
private void setTaskPTPNum(int ptpNum) {
|
||||
this.ptpNum = ptpNum;
|
||||
}
|
||||
|
||||
private void setTaskFailedNum(int failedNum) {
|
||||
this.failNum = failedNum;
|
||||
}
|
||||
|
||||
private void setTaskCollectedDetails(List<CollResultDetail> resultList) {
|
||||
this.collectDetails = resultList;
|
||||
}
|
||||
|
||||
private void setTaskPTPDetails(List<CollResultDetail> resultList) {
|
||||
this.ptpDetails = resultList;
|
||||
}
|
||||
|
||||
public void setTaskFailedDetails(List<CollResultDetail> resultList) {
|
||||
this.failedDetails = resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDashboardDataReceived(DashboardData dashboardData) {
|
||||
if (progressDialog.isShowing()){
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
if (dashboardData == null) {
|
||||
//hide all layout and show dialog
|
||||
showErrorInfo("No Data Available");
|
||||
return;
|
||||
}
|
||||
|
||||
//setup data to view widget
|
||||
setProgressBarValue(dashboardData.getCollectedAmount(), dashboardData.getTargetAmount());
|
||||
setTotalOutstandingTask(dashboardData.getOutstandingNum());
|
||||
setOutstandingAmount(dashboardData.getOutstandingAmount());
|
||||
setTaskCollectedNum(dashboardData.getCollectDetails().size());
|
||||
setTaskPTPNum(dashboardData.getPtpDetails().size());
|
||||
setTaskFailedNum(dashboardData.getFailedDetails().size());
|
||||
setTaskCollectedDetails(dashboardData.getCollectDetails());
|
||||
setTaskPTPDetails(dashboardData.getPtpDetails());
|
||||
setTaskFailedDetails(dashboardData.getFailedDetails());
|
||||
|
||||
//finish setup data, draw chart
|
||||
drawCollResultChart();
|
||||
//trigger listener for first tab
|
||||
onTabSelected(tabLayout.getTabAt(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showErrorInfo(String errorMessage) {
|
||||
if (progressDialog.isShowing()){
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
if (dialogBuilder == null) {
|
||||
dialogBuilder = NiftyDialogBuilder.getInstance(getActivity());
|
||||
}
|
||||
contentLayout.setVisibility(View.GONE);
|
||||
dialogBuilder.withTitle(getString(R.string.error))
|
||||
.withMessage(errorMessage);
|
||||
dialogBuilder.show();
|
||||
}
|
||||
|
||||
private boolean needShowUserHelp() {
|
||||
List<UserHelpViewDummy> userHelpViews = Global.userHelpDummyGuide.get(DummyDashboardCollView.class.getSimpleName());
|
||||
return Global.ENABLE_USER_HELP && userHelpViews != null && userHelpViews.size() > 0;
|
||||
}
|
||||
|
||||
private void showUserhelp() {
|
||||
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
|
||||
Fragment dummyDashboard = new DummyDashboardCollView();
|
||||
transaction.replace(R.id.content_frame, dummyDashboard);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package com.adins.mss.base.tasklog;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.commons.TaskListener;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.depositreport.TaskLogHelper;
|
||||
import com.adins.mss.base.errorhandler.ErrorMessageHandler;
|
||||
import com.adins.mss.base.errorhandler.IShowError;
|
||||
import com.adins.mss.base.log.Log;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
import com.adins.mss.foundation.dialog.DialogManager;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TaskLogImpl extends Log implements TaskLogInterface, IShowError {
|
||||
private static Context context;
|
||||
private static List<TaskH> listTask;
|
||||
private GetOnlineLog onlineLog;
|
||||
protected ErrorMessageHandler errorMessageHandler;
|
||||
//private static String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
|
||||
public TaskLogImpl(Context context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
errorMessageHandler = new ErrorMessageHandler(this);
|
||||
}
|
||||
|
||||
public static long getCounterLog(Context context) {
|
||||
long counter = 0;
|
||||
try {
|
||||
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
counter = TaskHDataAccess.getSentTaskCounter(context, uuidUser);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
// TODO: handle exception
|
||||
}
|
||||
int MAXIMUM_DATA_KEEP = GlobalData.getSharedGlobalData().getMaxDataInLog();
|
||||
if (counter > MAXIMUM_DATA_KEEP && MAXIMUM_DATA_KEEP != 0) counter = MAXIMUM_DATA_KEEP;
|
||||
return counter;
|
||||
}
|
||||
|
||||
public List<TaskH> getListTaskLog() {
|
||||
listTask = getAllSentTaskWithLimited();
|
||||
Global.setListOfSentTask(listTask);
|
||||
return listTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callOnlineLog(TaskListener listener) {
|
||||
cancelOnlineLog();
|
||||
onlineLog = new GetOnlineLog(listener);
|
||||
onlineLog.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelOnlineLog() {
|
||||
if (onlineLog != null) {
|
||||
onlineLog.cancel(true);
|
||||
onlineLog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String errorSubject, String errorMsg, int notifType) {
|
||||
if(GlobalData.isRequireRelogin()){
|
||||
return;
|
||||
}
|
||||
if(notifType == ErrorMessageHandler.DIALOG_TYPE){
|
||||
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(context);
|
||||
dialogBuilder.withTitle(errorSubject)
|
||||
.withMessage(errorMsg)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
public class GetOnlineLog extends AsyncTask<Void, Void, List<TaskH>> {
|
||||
private ProgressDialog progressDialog;
|
||||
private TaskListener listener;
|
||||
private String errMessage = null;
|
||||
|
||||
public GetOnlineLog(TaskListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = ProgressDialog.show(context, "", context.getString(R.string.progressWait), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TaskH> doInBackground(Void... params) {
|
||||
List<TaskH> result = null;
|
||||
if (GlobalData.getSharedGlobalData().getApplication().equals(Global.APPLICATION_COLLECTION)) {
|
||||
try {
|
||||
TaskLogImpl log = new TaskLogImpl(context);
|
||||
result = log.getListTaskLog();
|
||||
if (Tool.isInternetconnected(context)) {
|
||||
List<TaskH> onlineLog = TaskLogHelper.getTaskLog(context);
|
||||
if (onlineLog != null) {
|
||||
if (result == null) result = new ArrayList<>();
|
||||
List<String> uuidListTaskH = new ArrayList<>();
|
||||
|
||||
for (TaskH taskH : result) {
|
||||
uuidListTaskH.add(taskH.getUuid_task_h());
|
||||
}
|
||||
|
||||
Iterator<TaskH> iterator = onlineLog.iterator();
|
||||
List<TaskH> listTaskHWithFlag = new ArrayList<>();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
TaskH taskH = iterator.next();
|
||||
|
||||
if (uuidListTaskH.contains(taskH.getUuid_task_h())) {
|
||||
try {
|
||||
TaskH taskHWithFlag = TaskHDataAccess.getOneHeader(context, taskH.getUuid_task_h());
|
||||
taskHWithFlag.setFlag(taskH.getFlag());
|
||||
listTaskHWithFlag.add(taskHWithFlag);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
|
||||
}
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
}
|
||||
if (listTaskHWithFlag.size() > 0) {
|
||||
TaskHDataAccess.addOrReplace(context, listTaskHWithFlag);
|
||||
}
|
||||
|
||||
if (onlineLog.size() > 0) {
|
||||
for (TaskH taskH : onlineLog) {
|
||||
if (uuidListTaskH.contains(taskH.getUuid_task_h())) {
|
||||
|
||||
} else {
|
||||
taskH.setUuid_user(GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
taskH.setStatus(TaskHDataAccess.STATUS_SEND_SENT);
|
||||
}
|
||||
TaskHDataAccess.addOrReplace(context, taskH);
|
||||
result.add(taskH);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = context.getString(R.string.no_internet_connection);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<TaskH> taskHs) {
|
||||
super.onPostExecute(taskHs);
|
||||
if (context != null) {
|
||||
if (progressDialog.isShowing()) {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
if (errMessage != null) {
|
||||
errorMessageHandler.processError(context.getString(R.string.info_capital)
|
||||
,errMessage,ErrorMessageHandler.DIALOG_TYPE);
|
||||
/* NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(context);
|
||||
dialogBuilder.withTitle(context.getString(R.string.info_capital))
|
||||
.withMessage(errMessage)
|
||||
.show();*/
|
||||
} else {
|
||||
if (GlobalData.isRequireRelogin()) {
|
||||
|
||||
} else if (taskHs == null || taskHs.size() == 0) {
|
||||
errorMessageHandler.processError(context.getString(R.string.info_capital)
|
||||
,context.getString(R.string.msgNoSent)
|
||||
,ErrorMessageHandler.DIALOG_TYPE);
|
||||
/*NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(context);
|
||||
dialogBuilder.withTitle(context.getString(R.string.info_capital))
|
||||
.withMessage(context.getString(R.string.msgNoSent))
|
||||
.show();*/
|
||||
}
|
||||
}
|
||||
listener.onCompleteTask(taskHs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.adins.mss.base.avatar;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Created by intishar.fa on 02/10/2018.
|
||||
*/
|
||||
|
||||
public class AvatarUploadRequestJson extends MssRequestType {
|
||||
@SerializedName("uuid_user")
|
||||
private String uuid_user;
|
||||
@SerializedName("image")
|
||||
private String base64Img;
|
||||
|
||||
public String getUuid_user() {
|
||||
return uuid_user;
|
||||
}
|
||||
|
||||
public void setUuid_user(String uuid_user) {
|
||||
this.uuid_user = uuid_user;
|
||||
}
|
||||
|
||||
public String getBase64Img() {
|
||||
return base64Img;
|
||||
}
|
||||
|
||||
public void setBase64Img(String base64Img) {
|
||||
this.base64Img = base64Img;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.manuelpeinado.fadingactionbar.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
|
||||
|
||||
public class RootLayout extends FrameLayout {
|
||||
|
||||
private View mHeaderContainer;
|
||||
private View mListViewBackground;
|
||||
private boolean mInitialized = false;
|
||||
|
||||
public RootLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RootLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RootLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
//at first find headerViewContainer and listViewBackground
|
||||
if (mHeaderContainer == null)
|
||||
mHeaderContainer = findViewById(R.id.fab__header_container);
|
||||
if (mListViewBackground == null)
|
||||
mListViewBackground = findViewById(R.id.fab__listview_background);
|
||||
|
||||
//if there's no headerViewContainer then fallback to standard FrameLayout
|
||||
if (mHeaderContainer == null) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mInitialized) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
//if mListViewBackground not exists or mListViewBackground exists
|
||||
//and its top is at headercontainer height then view is initialized
|
||||
if (mListViewBackground == null || mListViewBackground.getTop() == mHeaderContainer.getHeight())
|
||||
mInitialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
//get last header and listViewBackground position
|
||||
int headerTopPrevious = mHeaderContainer.getTop();
|
||||
int listViewBackgroundTopPrevious = mListViewBackground != null ? mListViewBackground.getTop() : 0;
|
||||
|
||||
//relayout
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
//revert header top position
|
||||
int headerTopCurrent = mHeaderContainer.getTop();
|
||||
if (headerTopCurrent != headerTopPrevious) {
|
||||
mHeaderContainer.offsetTopAndBottom(headerTopPrevious - headerTopCurrent);
|
||||
}
|
||||
//revert listViewBackground top position
|
||||
int listViewBackgroundTopCurrent = mListViewBackground != null ? mListViewBackground.getTop() : 0;
|
||||
if (listViewBackgroundTopCurrent != listViewBackgroundTopPrevious) {
|
||||
mListViewBackground.offsetTopAndBottom(listViewBackgroundTopPrevious - listViewBackgroundTopCurrent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?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:layout_margin="3dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/dropdown_background">
|
||||
<TextView
|
||||
android:id="@+id/txtDate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Date"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_date_color"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtStatus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Status"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_info"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtNotes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Notes"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_notes"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/txtId"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="TaskID"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_form_color"
|
||||
android:drawablePadding="5dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bgColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listClosingTask"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/btnClosingTask">
|
||||
</ListView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnClosingTask"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:text="@string/title_mn_closing_task"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/fontColorWhite" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,26 @@
|
|||
<?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">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="5dp"
|
||||
app:cardElevation="5dp"
|
||||
android:layout_margin="3dp"
|
||||
app:cardBackgroundColor="@color/fontColorWhite">
|
||||
<TextView
|
||||
android:id="@+id/txtProduct"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:text="Product"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_product"
|
||||
android:drawablePadding="5dp" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,51 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:fcf="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout
|
||||
android:id="@+id/question_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:headerDividersEnabled="true"
|
||||
android:footerDividersEnabled="true"
|
||||
android:scrollbarSize="1dp"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="5dp"/>
|
||||
</uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:weightSum="1"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnApprove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight=".5"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btnApprove"
|
||||
android:textColor="@color/tv_white"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnReject"
|
||||
android:layout_weight=".5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@+id/btnNext"
|
||||
android:text="@string/btnReject"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,146 @@
|
|||
package com.services;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.commons.BackupManager;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.timeline.TimelineManager;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.camerainapp.helper.Logger;
|
||||
import com.adins.mss.foundation.notification.Notification;
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
|
||||
import com.adins.mss.svy.MSMainMenuActivity;
|
||||
import com.adins.mss.svy.NewMSMainActivity;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.Thread.NORM_PRIORITY;
|
||||
|
||||
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||
super.onMessageReceived(remoteMessage);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
NotificationChannel channel = new NotificationChannel("messaging", "Notification", NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription("Application Notification Message");
|
||||
mNotificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
// TODO(developer): Handle FCM messages here.
|
||||
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
|
||||
Logger.d("FirebaseMessagingServ", "From: " + remoteMessage.getFrom());
|
||||
|
||||
// Check if message contains a data payload.
|
||||
if (remoteMessage.getData().size() > 0) {
|
||||
Logger.d("FirebaseMessagingServ", "Message data payload: " + remoteMessage.getData());
|
||||
|
||||
//Nendi: 2019-01-18 | Add event listener
|
||||
Map<String, String> extras = remoteMessage.getData();
|
||||
if (extras.containsKey("event")) {
|
||||
String eventType = extras.get("event");
|
||||
if (eventType == null)
|
||||
return;
|
||||
|
||||
switch (eventType) {
|
||||
case "backup":
|
||||
String entity = extras.get("entity");
|
||||
String constraint = null;
|
||||
if (extras.containsKey("constraint")) {
|
||||
constraint = extras.get("constraint");
|
||||
BackupManager backupManager = new BackupManager(getApplicationContext());
|
||||
backupManager.backup(entity, constraint);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if message contains a notification payload.
|
||||
if (remoteMessage.getNotification() != null) {
|
||||
Logger.d("FirebaseMessagingServ", "Message Notification Body: " + remoteMessage.getNotification().getBody());
|
||||
}
|
||||
String notif = null;
|
||||
try {
|
||||
notif = remoteMessage.getData().get("message");
|
||||
if (notif == null || notif.equals("")) {
|
||||
notif = remoteMessage.getNotification().getBody();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(getApplicationContext(),
|
||||
"GlobalData", Context.MODE_PRIVATE);
|
||||
boolean hasLogged = sharedPref.getBoolean("HAS_LOGGED", false);
|
||||
User user = GlobalData.getSharedGlobalData().getUser();
|
||||
if (null != user && hasLogged){
|
||||
showNotif("" + notif);
|
||||
TimelineManager.insertTimelinePushNotification(getBaseContext(), "" + notif);
|
||||
}
|
||||
}
|
||||
|
||||
// public static String MAINMENU_NOTIFICATION_KEY = "MAINMENU_NOTIFICATION_KEY";
|
||||
|
||||
public void showNotif(String notif) {
|
||||
String notifTitle = getApplicationContext().getString(com.adins.mss.base.R.string.push_notification);
|
||||
// String message = getApplicationContext().getString(com.adins.mss.base.R.string.push_notification_info);
|
||||
// TODO munculkan notifikasi di sini
|
||||
|
||||
Intent intent = new Intent(getApplicationContext(), NewMSMainActivity.class);
|
||||
ComponentName cn = intent.getComponent();
|
||||
intent.makeMainActivity(cn);
|
||||
intent.setAction(Global.MAINMENU_NOTIFICATION_KEY);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent
|
||||
.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
Notification.getSharedNotification().setDefaultIcon(
|
||||
com.adins.mss.base.R.drawable.icon_notif_new);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), "messaging");
|
||||
builder.setSmallIcon(getNotificationIcon());
|
||||
builder.setContentTitle(notifTitle);
|
||||
builder.setContentText(notif);
|
||||
builder.setPriority(NORM_PRIORITY);
|
||||
NotificationCompat.BigTextStyle inboxStyle =
|
||||
new NotificationCompat.BigTextStyle();
|
||||
// Sets a title for the Inbox in expanded layout
|
||||
inboxStyle.setBigContentTitle(notifTitle);
|
||||
inboxStyle.bigText(notif);
|
||||
inboxStyle.setSummaryText(getApplicationContext().getString(com.adins.mss.base.R.string.click_to_open));
|
||||
|
||||
|
||||
builder.setDefaults(android.app.Notification.DEFAULT_ALL);
|
||||
builder.setStyle(inboxStyle);
|
||||
builder.setAutoCancel(true);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.notify(1, builder.build());
|
||||
|
||||
}
|
||||
|
||||
public static int getNotificationIcon() {
|
||||
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
|
||||
return useWhiteIcon ? com.adins.mss.base.R.drawable.icon_notif_new_white : com.adins.mss.base.R.drawable.icon_notif_new;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue