mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +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,506 @@
|
|||
package com.adins.mss.coll.loyalti.pointacquisitionmonthly;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.fragments.DashBoardFragment;
|
||||
import com.adins.mss.coll.loyalti.barchart.LoyaltyBarChartRenderer;
|
||||
import com.adins.mss.coll.loyalti.barchart.LoyaltyBarDataSet;
|
||||
import com.adins.mss.coll.loyalti.barchart.LoyaltyXLabelFormatter;
|
||||
import com.adins.mss.coll.loyalti.barchart.NonScrollListView;
|
||||
import com.adins.mss.coll.loyalti.barchart.PointClickMarker;
|
||||
import com.adins.mss.coll.loyalti.barchart.pointlegends.PointLegendsAdapter;
|
||||
import com.adins.mss.coll.loyalti.barchart.ranklegends.RankLegendsAdapter;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitiondaily.DailyPointsChartView;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.contracts.ILoyaltyPointsDataSource;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.contracts.MonthlyPointContract;
|
||||
import com.adins.mss.coll.models.loyaltymodels.GroupPointData;
|
||||
import com.adins.mss.coll.models.loyaltymodels.LoyaltyPointsRequest;
|
||||
import com.adins.mss.coll.models.loyaltymodels.PointDetail;
|
||||
import com.adins.mss.coll.models.loyaltymodels.RankDetail;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.UserHelp.Bean.Dummy.UserHelpViewDummy;
|
||||
import com.adins.mss.foundation.UserHelp.Bean.UserHelpView;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.components.LimitLine;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.listener.ChartTouchListener;
|
||||
import com.github.mikephil.charting.listener.OnChartGestureListener;
|
||||
import com.github.mikephil.charting.utils.MPPointD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class MonthlyPointsChartView extends Fragment implements MonthlyPointContract.View,OnChartGestureListener {
|
||||
|
||||
//android views
|
||||
private ConstraintLayout chartContent;
|
||||
private ConstraintLayout legendContainer;
|
||||
private BarChart barChart;
|
||||
private NonScrollListView rankLegends;
|
||||
private NonScrollListView pointLegends;
|
||||
private TextView totalPointsV;
|
||||
private ProgressDialog progressDialog;
|
||||
private NiftyDialogBuilder dialogBuilder;
|
||||
private NestedScrollView scrollView;
|
||||
|
||||
//presenter
|
||||
private MonthlyPointContract.Presenter presenter;
|
||||
|
||||
//chart data
|
||||
private int averagePoint;
|
||||
private int maxPoint;
|
||||
private int initialIdx;
|
||||
private float[][] pointDataSet;
|
||||
private RankDetail[][] rankDataSet;
|
||||
private List<RankDetail> rankDetails;
|
||||
private List<PointDetail> pointDetailsDataSet;
|
||||
private List<PointDetail> pointDetails;
|
||||
private LoyaltyXLabelFormatter xLabelFormatter;
|
||||
|
||||
//legend colors
|
||||
int[] pointDetailColors = {Color.parseColor("#FBBA72")
|
||||
,Color.parseColor("#F86624"),
|
||||
Color.parseColor("#BA5624") ,
|
||||
Color.parseColor("#8F250C")};
|
||||
|
||||
int[] rankColors = {Color.parseColor("#FF0000"),
|
||||
Color.parseColor("#000000"),
|
||||
Color.parseColor("#32CD32"),
|
||||
Color.parseColor("#0000FF")};
|
||||
private Handler handler;
|
||||
|
||||
public MonthlyPointsChartView() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_point_acquisition, container, false);
|
||||
chartContent = view.findViewById(R.id.chartContent);
|
||||
barChart = view.findViewById(R.id.monthlyChart);
|
||||
rankLegends = view.findViewById(R.id.legendRanks);
|
||||
pointLegends = view.findViewById(R.id.legendPoints);
|
||||
totalPointsV = view.findViewById(R.id.totalPoint);
|
||||
scrollView = view.findViewById(R.id.scrollView);
|
||||
legendContainer = view.findViewById(R.id.legendsContainer);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
String programName = getArguments()!=null?getArguments().getString("MembershipProgramName"):getString(R.string.monthly_point_page_title);
|
||||
String programStartDate = getArguments()!=null?getArguments().getString("ProgramStartDate"):"";
|
||||
getActivity().setTitle(programName);
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
Global.positionStack.push(1);
|
||||
chartContent.setVisibility(View.GONE);
|
||||
|
||||
ILoyaltyPointsDataSource dataSource = new LoyaltyPointsDataSource(getActivity().getApplication());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
MonthlyPointsLogic monthlyPointsLogic = new MonthlyPointsLogic(dataSource,programStartDate,calendar.get(Calendar.YEAR));
|
||||
MonthlyPointsPresenter presenter = new MonthlyPointsPresenter(this,monthlyPointsLogic);
|
||||
setPresenter(presenter);
|
||||
if(needShowUserHelp()){
|
||||
showUserhelp();
|
||||
}
|
||||
else {
|
||||
loadMonthlyPointsData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(final Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
if(checkUserHelpAvailability()){
|
||||
menu.findItem(R.id.mnGuide).setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == com.adins.mss.base.R.id.mnGuide){
|
||||
if(!Global.BACKPRESS_RESTRICTION) {
|
||||
UserHelp.reloadUserHelp(getActivity(), DummyMonthlyPointView.class.getSimpleName());
|
||||
if(needShowUserHelp()){
|
||||
showUserhelp();
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPresenter(MonthlyPointContract.Presenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
//kode request poin bulanan
|
||||
private void loadMonthlyPointsData() {
|
||||
progressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.please_wait_dialog), true);
|
||||
|
||||
//dummy request
|
||||
LoyaltyPointsRequest request = new LoyaltyPointsRequest();
|
||||
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
request.addImeiAndroidIdToUnstructured();
|
||||
String loginid = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
String[] loginIdSplit = loginid.split("@");
|
||||
request.loginId = loginIdSplit[0];
|
||||
String programCode = "";
|
||||
Bundle bundle = getArguments();
|
||||
if(bundle!=null)
|
||||
programCode = bundle.getString("MembershipProgramCode");
|
||||
request.membershipProgramId = programCode;
|
||||
|
||||
presenter.getMonthlyPointsData(request);
|
||||
}
|
||||
|
||||
//callback data poin bulanan
|
||||
@Override
|
||||
public void onDataReceived(float[][] pointDataSet, RankDetail[][] rankDataSet, List<PointDetail> pointDetailsDataSet) {
|
||||
chartContent.setVisibility(View.VISIBLE);
|
||||
if (progressDialog.isShowing()){
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
if(pointDataSet.length < 3){
|
||||
//padding data to avoid large bar width
|
||||
float[][] newDataSet = paddingDataSet(pointDataSet,3-pointDataSet.length);
|
||||
for(int i = pointDataSet.length; i<newDataSet.length; i++){
|
||||
for (int j=0; j<newDataSet[i].length; j++){
|
||||
PointDetail dummyPointDetail = new PointDetail(pointDetailsDataSet.get(0).rewardProgram
|
||||
,"0");
|
||||
pointDetailsDataSet.add(dummyPointDetail);
|
||||
}
|
||||
}
|
||||
pointDataSet = newDataSet;
|
||||
}
|
||||
this.pointDetailsDataSet = pointDetailsDataSet;
|
||||
initView(pointDataSet,rankDataSet);
|
||||
}
|
||||
|
||||
private float[][] paddingDataSet(float[][] pointDataSet,int padNumber){
|
||||
float[][] newDataset = new float[pointDataSet.length+padNumber][];
|
||||
//copy values
|
||||
for (int i=0; i<pointDataSet.length; i++){
|
||||
newDataset[i] = pointDataSet[i];
|
||||
}
|
||||
//pad values
|
||||
for (int j=pointDataSet.length; j<newDataset.length; j++){
|
||||
newDataset[j] = new float[]{0};
|
||||
}
|
||||
|
||||
return newDataset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetDataFailed(String message) {
|
||||
if (progressDialog.isShowing()){
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
|
||||
chartContent.setVisibility(View.GONE);
|
||||
if(dialogBuilder == null){
|
||||
dialogBuilder = NiftyDialogBuilder.getInstance(getActivity());
|
||||
}
|
||||
dialogBuilder.withTitle(getString(R.string.error))
|
||||
.withMessage(message);
|
||||
dialogBuilder.show();
|
||||
}
|
||||
|
||||
//kode untuk chart
|
||||
private void setPointDataSet(float[][] pointDataSet) {
|
||||
this.pointDataSet = pointDataSet;
|
||||
}
|
||||
|
||||
private void setRankDataSet(RankDetail[][] rankDataSet) {
|
||||
this.rankDataSet = rankDataSet;
|
||||
//set rank colors
|
||||
for(int i=0; i<this.rankDataSet.length; i++){
|
||||
for (int j=0; j<this.rankDataSet[i].length; j++)
|
||||
this.rankDataSet[i][j].colorValue = rankColors[j];
|
||||
}
|
||||
}
|
||||
|
||||
private void setTotalPoint(int totalPoint) {
|
||||
totalPointsV.setText("Total: "+totalPoint);
|
||||
}
|
||||
|
||||
private void setAveragePoint(int averagePoint) {
|
||||
this.averagePoint = averagePoint;
|
||||
}
|
||||
|
||||
public void setMaxPoint(int maxPoint) {
|
||||
this.maxPoint = maxPoint;
|
||||
}
|
||||
|
||||
private void setxLabelFormatter(LoyaltyXLabelFormatter xLabelFormatter) {
|
||||
this.xLabelFormatter = xLabelFormatter;
|
||||
}
|
||||
|
||||
private void setRanksLegend(List<RankDetail> rankDetails) {
|
||||
this.rankDetails = rankDetails;
|
||||
}
|
||||
|
||||
private void setPointsLegend(List<PointDetail> pointDetails) {
|
||||
for(int i=0; i<pointDetails.size(); i++){
|
||||
pointDetails.get(i).colorValue = pointDetailColors[i];
|
||||
}
|
||||
this.pointDetails = pointDetails;
|
||||
}
|
||||
|
||||
public void setInitIdx(int initIdx){
|
||||
initialIdx = initIdx;
|
||||
}
|
||||
|
||||
public void initView(float[][] pointDataSet, RankDetail[][] rankDataSet){
|
||||
//set dataset
|
||||
setPointDataSet(pointDataSet);
|
||||
setRankDataSet(rankDataSet);
|
||||
//current month
|
||||
setInitIdx(presenter.getCurrentMonth());
|
||||
//avg
|
||||
setAveragePoint((int)presenter.getAvgPoint());
|
||||
//max point
|
||||
setMaxPoint(presenter.getMaxPoint());
|
||||
//total point
|
||||
setTotalPoint(presenter.getTotalPoints());
|
||||
|
||||
//set months formatter
|
||||
String[] monthLabels = presenter.getMonths();
|
||||
int padData = pointDataSet.length - monthLabels.length;//check different size
|
||||
if(padData > 0){
|
||||
String[] padMonthLabels = new String[monthLabels.length + padData];
|
||||
for(int i=0; i<padMonthLabels.length; i++){
|
||||
padMonthLabels[i] = "";//set default label first
|
||||
if(i < monthLabels.length){
|
||||
padMonthLabels[i] = monthLabels[i];
|
||||
}
|
||||
}
|
||||
monthLabels = padMonthLabels;
|
||||
}
|
||||
LoyaltyXLabelFormatter xLabelFormatter = new LoyaltyXLabelFormatter(monthLabels);
|
||||
|
||||
setxLabelFormatter(xLabelFormatter);
|
||||
//set point details
|
||||
setPointsLegend(presenter.getPointDetails());
|
||||
//set ranks
|
||||
setRanksLegend(presenter.getRanks());
|
||||
//draw chart
|
||||
drawChart();
|
||||
}
|
||||
|
||||
private boolean needShowUserHelp(){
|
||||
List<UserHelpView> userHelpViews = Global.userHelpGuide.get(DummyMonthlyPointView.class.getSimpleName());
|
||||
return Global.ENABLE_USER_HELP && userHelpViews != null && userHelpViews.size() > 0;
|
||||
}
|
||||
|
||||
private void showUserhelp(){
|
||||
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
|
||||
Fragment dummyChart = new DummyMonthlyPointView();
|
||||
transaction.replace(R.id.content_frame,dummyChart);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
private void drawChart(){
|
||||
if(pointDataSet == null || pointDataSet.length == 0)
|
||||
return;
|
||||
|
||||
//set chart pointDataSet
|
||||
List<BarEntry> barEntryList = new ArrayList<>();
|
||||
for(int i = 0; i< pointDataSet.length; i++){
|
||||
barEntryList.add(new BarEntry(i, pointDataSet[i]));
|
||||
}
|
||||
|
||||
int[] stackBarColor = new int[pointDetails.size()];
|
||||
for(int i=0; i<stackBarColor.length; i++){
|
||||
stackBarColor[i] = pointDetails.get(i).colorValue;
|
||||
}
|
||||
BarDataSet barDataSet = new LoyaltyBarDataSet(pointDetailsDataSet,pointDetails,barEntryList,"");
|
||||
barDataSet.setColors(stackBarColor);
|
||||
barDataSet.setDrawValues(false);
|
||||
BarData barData = new BarData(barDataSet);
|
||||
barData.setBarWidth(0.5f);
|
||||
|
||||
XAxis xAxis = barChart.getXAxis();
|
||||
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||
xAxis.setDrawGridLines(false);
|
||||
xAxis.setLabelCount(xLabelFormatter.getLabelCount());
|
||||
xAxis.setGranularity(1f);
|
||||
xAxis.setGranularityEnabled(true);
|
||||
xAxis.setValueFormatter(xLabelFormatter);
|
||||
xAxis.setTextSize(12f);
|
||||
|
||||
//right axis
|
||||
YAxis rYAxis = barChart.getAxisRight();
|
||||
rYAxis.setEnabled(false);
|
||||
rYAxis.setAxisMinimum(0f);
|
||||
rYAxis.setDrawGridLines(false);
|
||||
|
||||
//left axis
|
||||
YAxis lYAxis = barChart.getAxisLeft();
|
||||
lYAxis.setAxisMinimum(0f);
|
||||
lYAxis.setAxisMaximum(maxPoint);
|
||||
|
||||
//use custom legends
|
||||
barChart.getLegend().setEnabled(false);
|
||||
barChart.setDescription(null);
|
||||
RankLegendsAdapter rankLegendsAdapter = new RankLegendsAdapter(getActivity(),rankDetails);
|
||||
rankLegends.setAdapter(rankLegendsAdapter);
|
||||
PointLegendsAdapter pointLegendsAdapter = new PointLegendsAdapter(getActivity(),pointDetails);
|
||||
pointLegends.setAdapter(pointLegendsAdapter);
|
||||
|
||||
//set limit line
|
||||
LimitLine avgLine = new LimitLine(averagePoint,getString(R.string.average_point,averagePoint));
|
||||
avgLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
|
||||
avgLine.enableDashedLine(20f,10f,0f);
|
||||
avgLine.setLineWidth(1f);
|
||||
avgLine.setTextColor(Color.parseColor("#32CD32"));
|
||||
avgLine.setTextSize(12f);
|
||||
avgLine.setLineColor(Color.parseColor("#32CD32"));
|
||||
lYAxis.addLimitLine(avgLine);
|
||||
|
||||
//chart settings
|
||||
//custom render bar
|
||||
LoyaltyBarChartRenderer renderer = new LoyaltyBarChartRenderer(barChart,rankDataSet,0.3f,0);
|
||||
barChart.setRenderer(renderer);
|
||||
|
||||
barChart.setPinchZoom(false);
|
||||
barChart.setDoubleTapToZoomEnabled(false);
|
||||
barChart.setExtraOffsets(0,0,0,10f);
|
||||
barChart.setFitBars(true);
|
||||
barChart.setData(barData);
|
||||
PointClickMarker marker = new PointClickMarker(30f,0);
|
||||
barChart.setMarker(marker);
|
||||
|
||||
//set gesture listener on this
|
||||
barChart.setOnChartGestureListener(this);
|
||||
//chart viewport setting by initial x axis
|
||||
if(initialIdx > pointDataSet.length - 1){
|
||||
initialIdx = 0;
|
||||
}
|
||||
barChart.moveViewToX(initialIdx - 0.7f);
|
||||
//chart viewport range
|
||||
barChart.setVisibleXRangeMaximum(4f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartSingleTapped(MotionEvent me) {
|
||||
float tappedX = me.getX();
|
||||
float tappedY = me.getY();
|
||||
MPPointD point = barChart.getTransformer(YAxis.AxisDependency.LEFT).getValuesByTouchPoint(tappedX, tappedY);
|
||||
if(point.y < 0){
|
||||
int idx = (int)Math.round(point.x);
|
||||
int xLabelSize = barChart.getXAxis().getLabelCount();
|
||||
if(idx < 0 || idx >= xLabelSize)
|
||||
return;
|
||||
|
||||
GroupPointData pointData = presenter.getPointDataAt(idx);
|
||||
if(pointData != null)
|
||||
goToDailyPointsChart(pointData);
|
||||
}
|
||||
}
|
||||
|
||||
private void goToDailyPointsChart(GroupPointData groupPointData){
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("GroupPoint",groupPointData.groupPoint);
|
||||
String programCode = getArguments()!=null?getArguments().getString("MembershipProgramCode"):"";
|
||||
bundle.putString("MembershipProgramCode",programCode);
|
||||
String programName = getArguments()!=null?getArguments().getString("MembershipProgramName"):"";
|
||||
bundle.putString("MembershipProgramName",programName);
|
||||
String programStartDate = getArguments()!=null?getArguments().getString("ProgramStartDate"):"";
|
||||
bundle.putString("ProgramStartDate",programStartDate);
|
||||
|
||||
//fragment transaction
|
||||
DailyPointsChartView dailyPointsChart = new DailyPointsChartView();
|
||||
dailyPointsChart.setArguments(bundle);
|
||||
|
||||
FragmentTransaction transaction = getActivity().getSupportFragmentManager().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, dailyPointsChart);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
//below chart listener implementation not used for now
|
||||
@Override
|
||||
public void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartLongPressed(MotionEvent me) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartDoubleTapped(MotionEvent me) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartScale(MotionEvent me, float scaleX, float scaleY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartTranslate(MotionEvent me, float dX, float dY) {
|
||||
|
||||
}
|
||||
|
||||
private boolean checkUserHelpAvailability() {
|
||||
List<UserHelpView> userHelpViews = Global.userHelpGuide.get(DummyMonthlyPointView.class.getSimpleName());
|
||||
return Global.ENABLE_USER_HELP && userHelpViews != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,311 @@
|
|||
package com.adins.mss.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import android.database.Cursor;
|
||||
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import de.greenrobot.dao.internal.SqlUtils;
|
||||
import de.greenrobot.dao.internal.DaoConfig;
|
||||
import de.greenrobot.dao.database.Database;
|
||||
import de.greenrobot.dao.database.DatabaseStatement;
|
||||
import de.greenrobot.dao.query.Query;
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
import com.adins.mss.dao.MobileContentD;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "TR_MOBILECONTENT_D".
|
||||
*/
|
||||
public class MobileContentDDao extends AbstractDao<MobileContentD, String> {
|
||||
|
||||
public static final String TABLENAME = "TR_MOBILECONTENT_D";
|
||||
|
||||
/**
|
||||
* Properties of entity MobileContentD.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Uuid_mobile_content_d = new Property(0, String.class, "uuid_mobile_content_d", true, "UUID_MOBILE_CONTENT_D");
|
||||
public final static Property Menu_id = new Property(1, String.class, "menu_id", false, "MENU_ID");
|
||||
public final static Property Content = new Property(2, byte[].class, "content", false, "CONTENT");
|
||||
public final static Property Content_type = new Property(3, String.class, "content_type", false, "CONTENT_TYPE");
|
||||
public final static Property Sequence = new Property(4, Integer.class, "sequence", false, "SEQUENCE");
|
||||
public final static Property Usr_crt = new Property(5, String.class, "usr_crt", false, "USR_CRT");
|
||||
public final static Property Dtm_crt = new Property(6, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
|
||||
public final static Property Usr_upd = new Property(7, String.class, "usr_upd", false, "USR_UPD");
|
||||
public final static Property Uuid_mobile_content_h = new Property(8, String.class, "uuid_mobile_content_h", false, "UUID_MOBILE_CONTENT_H");
|
||||
public final static Property Start_date = new Property(9, java.util.Date.class, "start_date", false, "START_DATE");
|
||||
public final static Property End_date = new Property(10, java.util.Date.class, "end_date", false, "END_DATE");
|
||||
};
|
||||
|
||||
private DaoSession daoSession;
|
||||
|
||||
private Query<MobileContentD> mobileContentH_MobileContentDListQuery;
|
||||
|
||||
public MobileContentDDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public MobileContentDDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
this.daoSession = daoSession;
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"TR_MOBILECONTENT_D\" (" + //
|
||||
"\"UUID_MOBILE_CONTENT_D\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_mobile_content_d
|
||||
"\"MENU_ID\" TEXT," + // 1: menu_id
|
||||
"\"CONTENT\" BLOB," + // 2: content
|
||||
"\"CONTENT_TYPE\" TEXT," + // 3: content_type
|
||||
"\"SEQUENCE\" INTEGER," + // 4: sequence
|
||||
"\"USR_CRT\" TEXT," + // 5: usr_crt
|
||||
"\"DTM_CRT\" INTEGER," + // 6: dtm_crt
|
||||
"\"USR_UPD\" TEXT," + // 7: usr_upd
|
||||
"\"UUID_MOBILE_CONTENT_H\" TEXT," + // 8: uuid_mobile_content_h
|
||||
"\"START_DATE\" INTEGER," + // 9: start_date
|
||||
"\"END_DATE\" INTEGER);"); // 10: end_date
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_MOBILECONTENT_D\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected void bindValues(DatabaseStatement stmt, MobileContentD entity) {
|
||||
stmt.clearBindings();
|
||||
stmt.bindString(1, entity.getUuid_mobile_content_d());
|
||||
|
||||
String menu_id = entity.getMenu_id();
|
||||
if (menu_id != null) {
|
||||
stmt.bindString(2, menu_id);
|
||||
}
|
||||
|
||||
byte[] content = entity.getContent();
|
||||
if (content != null) {
|
||||
stmt.bindBlob(3, content);
|
||||
}
|
||||
|
||||
String content_type = entity.getContent_type();
|
||||
if (content_type != null) {
|
||||
stmt.bindString(4, content_type);
|
||||
}
|
||||
|
||||
Integer sequence = entity.getSequence();
|
||||
if (sequence != null) {
|
||||
stmt.bindLong(5, sequence);
|
||||
}
|
||||
|
||||
String usr_crt = entity.getUsr_crt();
|
||||
if (usr_crt != null) {
|
||||
stmt.bindString(6, usr_crt);
|
||||
}
|
||||
|
||||
java.util.Date dtm_crt = entity.getDtm_crt();
|
||||
if (dtm_crt != null) {
|
||||
stmt.bindLong(7, dtm_crt.getTime());
|
||||
}
|
||||
|
||||
String usr_upd = entity.getUsr_upd();
|
||||
if (usr_upd != null) {
|
||||
stmt.bindString(8, usr_upd);
|
||||
}
|
||||
|
||||
String uuid_mobile_content_h = entity.getUuid_mobile_content_h();
|
||||
if (uuid_mobile_content_h != null) {
|
||||
stmt.bindString(9, uuid_mobile_content_h);
|
||||
}
|
||||
|
||||
java.util.Date start_date = entity.getStart_date();
|
||||
if (start_date != null) {
|
||||
stmt.bindLong(10, start_date.getTime());
|
||||
}
|
||||
|
||||
java.util.Date end_date = entity.getEnd_date();
|
||||
if (end_date != null) {
|
||||
stmt.bindLong(11, end_date.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachEntity(MobileContentD entity) {
|
||||
super.attachEntity(entity);
|
||||
entity.__setDaoSession(daoSession);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public MobileContentD readEntity(Cursor cursor, int offset) {
|
||||
MobileContentD entity = new MobileContentD( //
|
||||
cursor.getString(offset + 0), // uuid_mobile_content_d
|
||||
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // menu_id
|
||||
cursor.isNull(offset + 2) ? null : cursor.getBlob(offset + 2), // content
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // content_type
|
||||
cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // sequence
|
||||
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // usr_crt
|
||||
cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)), // dtm_crt
|
||||
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // usr_upd
|
||||
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // uuid_mobile_content_h
|
||||
cursor.isNull(offset + 9) ? null : new java.util.Date(cursor.getLong(offset + 9)), // start_date
|
||||
cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)) // end_date
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, MobileContentD entity, int offset) {
|
||||
entity.setUuid_mobile_content_d(cursor.getString(offset + 0));
|
||||
entity.setMenu_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
|
||||
entity.setContent(cursor.isNull(offset + 2) ? null : cursor.getBlob(offset + 2));
|
||||
entity.setContent_type(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
entity.setSequence(cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4));
|
||||
entity.setUsr_crt(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
|
||||
entity.setDtm_crt(cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)));
|
||||
entity.setUsr_upd(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
|
||||
entity.setUuid_mobile_content_h(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
|
||||
entity.setStart_date(cursor.isNull(offset + 9) ? null : new java.util.Date(cursor.getLong(offset + 9)));
|
||||
entity.setEnd_date(cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected String updateKeyAfterInsert(MobileContentD entity, long rowId) {
|
||||
return entity.getUuid_mobile_content_d();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String getKey(MobileContentD entity) {
|
||||
if(entity != null) {
|
||||
return entity.getUuid_mobile_content_d();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "mobileContentDList" to-many relationship of MobileContentH. */
|
||||
public List<MobileContentD> _queryMobileContentH_MobileContentDList(String uuid_mobile_content_h) {
|
||||
synchronized (this) {
|
||||
if (mobileContentH_MobileContentDListQuery == null) {
|
||||
QueryBuilder<MobileContentD> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Uuid_mobile_content_h.eq(null));
|
||||
mobileContentH_MobileContentDListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<MobileContentD> query = mobileContentH_MobileContentDListQuery.forCurrentThread();
|
||||
query.setParameter(0, uuid_mobile_content_h);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
private String selectDeep;
|
||||
|
||||
protected String getSelectDeep() {
|
||||
if (selectDeep == null) {
|
||||
StringBuilder builder = new StringBuilder("SELECT ");
|
||||
SqlUtils.appendColumns(builder, "T", getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T0", daoSession.getMobileContentHDao().getAllColumns());
|
||||
builder.append(" FROM TR_MOBILECONTENT_D T");
|
||||
builder.append(" LEFT JOIN TR_MOBILECONTENT_H T0 ON T.\"UUID_MOBILE_CONTENT_H\"=T0.\"UUID_MOBILE_CONTENT_H\"");
|
||||
builder.append(' ');
|
||||
selectDeep = builder.toString();
|
||||
}
|
||||
return selectDeep;
|
||||
}
|
||||
|
||||
protected MobileContentD loadCurrentDeep(Cursor cursor, boolean lock) {
|
||||
MobileContentD entity = loadCurrent(cursor, 0, lock);
|
||||
int offset = getAllColumns().length;
|
||||
|
||||
MobileContentH mobileContentH = loadCurrentOther(daoSession.getMobileContentHDao(), cursor, offset);
|
||||
entity.setMobileContentH(mobileContentH);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public MobileContentD loadDeep(Long key) {
|
||||
assertSinglePk();
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(getSelectDeep());
|
||||
builder.append("WHERE ");
|
||||
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
|
||||
String sql = builder.toString();
|
||||
|
||||
String[] keyArray = new String[] { key.toString() };
|
||||
Cursor cursor = db.rawQuery(sql, keyArray);
|
||||
|
||||
try {
|
||||
boolean available = cursor.moveToFirst();
|
||||
if (!available) {
|
||||
return null;
|
||||
} else if (!cursor.isLast()) {
|
||||
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
|
||||
}
|
||||
return loadCurrentDeep(cursor, true);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
|
||||
public List<MobileContentD> loadAllDeepFromCursor(Cursor cursor) {
|
||||
int count = cursor.getCount();
|
||||
List<MobileContentD> list = new ArrayList<MobileContentD>(count);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
if (identityScope != null) {
|
||||
identityScope.lock();
|
||||
identityScope.reserveRoom(count);
|
||||
}
|
||||
try {
|
||||
do {
|
||||
list.add(loadCurrentDeep(cursor, false));
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
if (identityScope != null) {
|
||||
identityScope.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<MobileContentD> loadDeepAllAndCloseCursor(Cursor cursor) {
|
||||
try {
|
||||
return loadAllDeepFromCursor(cursor);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** A raw-style query where you can pass any WHERE clause and arguments. */
|
||||
public List<MobileContentD> queryDeep(String where, String... selectionArg) {
|
||||
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
|
||||
return loadDeepAllAndCloseCursor(cursor);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/gradient_end"
|
||||
android:pathData="M19,8L5,8c-1.66,0 -3,1.34 -3,3v6h4v4h12v-4h4v-6c0,-1.66 -1.34,-3 -3,-3zM16,19L8,19v-5h8v5zM19,12c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM18,3L6,3v4h12L18,3z"/>
|
||||
</vector>
|
|
@ -0,0 +1,257 @@
|
|||
package com.adins.mss.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import android.database.Cursor;
|
||||
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import de.greenrobot.dao.internal.SqlUtils;
|
||||
import de.greenrobot.dao.internal.DaoConfig;
|
||||
import de.greenrobot.dao.database.Database;
|
||||
import de.greenrobot.dao.database.DatabaseStatement;
|
||||
import de.greenrobot.dao.query.Query;
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
import com.adins.mss.dao.Logger;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "TR_APPLICATION_LOG".
|
||||
*/
|
||||
public class LoggerDao extends AbstractDao<Logger, String> {
|
||||
|
||||
public static final String TABLENAME = "TR_APPLICATION_LOG";
|
||||
|
||||
/**
|
||||
* Properties of entity Logger.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Uuid_log = new Property(0, String.class, "uuid_log", true, "UUID_LOG");
|
||||
public final static Property Screen = new Property(1, String.class, "screen", false, "SCREEN");
|
||||
public final static Property Timestamp = new Property(2, java.util.Date.class, "timestamp", false, "TIMESTAMP");
|
||||
public final static Property Detail = new Property(3, String.class, "detail", false, "DETAIL");
|
||||
public final static Property Uuid_user = new Property(4, String.class, "uuid_user", false, "UUID_USER");
|
||||
};
|
||||
|
||||
private DaoSession daoSession;
|
||||
|
||||
private Query<Logger> user_LoggerListQuery;
|
||||
|
||||
public LoggerDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public LoggerDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
this.daoSession = daoSession;
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"TR_APPLICATION_LOG\" (" + //
|
||||
"\"UUID_LOG\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_log
|
||||
"\"SCREEN\" TEXT," + // 1: screen
|
||||
"\"TIMESTAMP\" INTEGER," + // 2: timestamp
|
||||
"\"DETAIL\" TEXT," + // 3: detail
|
||||
"\"UUID_USER\" TEXT);"); // 4: uuid_user
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_APPLICATION_LOG\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected void bindValues(DatabaseStatement stmt, Logger entity) {
|
||||
stmt.clearBindings();
|
||||
stmt.bindString(1, entity.getUuid_log());
|
||||
|
||||
String screen = entity.getScreen();
|
||||
if (screen != null) {
|
||||
stmt.bindString(2, screen);
|
||||
}
|
||||
|
||||
java.util.Date timestamp = entity.getTimestamp();
|
||||
if (timestamp != null) {
|
||||
stmt.bindLong(3, timestamp.getTime());
|
||||
}
|
||||
|
||||
String detail = entity.getDetail();
|
||||
if (detail != null) {
|
||||
stmt.bindString(4, detail);
|
||||
}
|
||||
|
||||
String uuid_user = entity.getUuid_user();
|
||||
if (uuid_user != null) {
|
||||
stmt.bindString(5, uuid_user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachEntity(Logger entity) {
|
||||
super.attachEntity(entity);
|
||||
entity.__setDaoSession(daoSession);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public Logger readEntity(Cursor cursor, int offset) {
|
||||
Logger entity = new Logger( //
|
||||
cursor.getString(offset + 0), // uuid_log
|
||||
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // screen
|
||||
cursor.isNull(offset + 2) ? null : new java.util.Date(cursor.getLong(offset + 2)), // timestamp
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // detail
|
||||
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // uuid_user
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, Logger entity, int offset) {
|
||||
entity.setUuid_log(cursor.getString(offset + 0));
|
||||
entity.setScreen(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
|
||||
entity.setTimestamp(cursor.isNull(offset + 2) ? null : new java.util.Date(cursor.getLong(offset + 2)));
|
||||
entity.setDetail(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
entity.setUuid_user(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected String updateKeyAfterInsert(Logger entity, long rowId) {
|
||||
return entity.getUuid_log();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String getKey(Logger entity) {
|
||||
if(entity != null) {
|
||||
return entity.getUuid_log();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "loggerList" to-many relationship of User. */
|
||||
public List<Logger> _queryUser_LoggerList(String uuid_user) {
|
||||
synchronized (this) {
|
||||
if (user_LoggerListQuery == null) {
|
||||
QueryBuilder<Logger> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Uuid_user.eq(null));
|
||||
user_LoggerListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<Logger> query = user_LoggerListQuery.forCurrentThread();
|
||||
query.setParameter(0, uuid_user);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
private String selectDeep;
|
||||
|
||||
protected String getSelectDeep() {
|
||||
if (selectDeep == null) {
|
||||
StringBuilder builder = new StringBuilder("SELECT ");
|
||||
SqlUtils.appendColumns(builder, "T", getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T0", daoSession.getUserDao().getAllColumns());
|
||||
builder.append(" FROM TR_APPLICATION_LOG T");
|
||||
builder.append(" LEFT JOIN MS_USER T0 ON T.\"UUID_USER\"=T0.\"UUID_USER\"");
|
||||
builder.append(' ');
|
||||
selectDeep = builder.toString();
|
||||
}
|
||||
return selectDeep;
|
||||
}
|
||||
|
||||
protected Logger loadCurrentDeep(Cursor cursor, boolean lock) {
|
||||
Logger entity = loadCurrent(cursor, 0, lock);
|
||||
int offset = getAllColumns().length;
|
||||
|
||||
User user = loadCurrentOther(daoSession.getUserDao(), cursor, offset);
|
||||
entity.setUser(user);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Logger loadDeep(Long key) {
|
||||
assertSinglePk();
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(getSelectDeep());
|
||||
builder.append("WHERE ");
|
||||
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
|
||||
String sql = builder.toString();
|
||||
|
||||
String[] keyArray = new String[] { key.toString() };
|
||||
Cursor cursor = db.rawQuery(sql, keyArray);
|
||||
|
||||
try {
|
||||
boolean available = cursor.moveToFirst();
|
||||
if (!available) {
|
||||
return null;
|
||||
} else if (!cursor.isLast()) {
|
||||
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
|
||||
}
|
||||
return loadCurrentDeep(cursor, true);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
|
||||
public List<Logger> loadAllDeepFromCursor(Cursor cursor) {
|
||||
int count = cursor.getCount();
|
||||
List<Logger> list = new ArrayList<Logger>(count);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
if (identityScope != null) {
|
||||
identityScope.lock();
|
||||
identityScope.reserveRoom(count);
|
||||
}
|
||||
try {
|
||||
do {
|
||||
list.add(loadCurrentDeep(cursor, false));
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
if (identityScope != null) {
|
||||
identityScope.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<Logger> loadDeepAllAndCloseCursor(Cursor cursor) {
|
||||
try {
|
||||
return loadAllDeepFromCursor(cursor);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** A raw-style query where you can pass any WHERE clause and arguments. */
|
||||
public List<Logger> queryDeep(String where, String... selectionArg) {
|
||||
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
|
||||
return loadDeepAllAndCloseCursor(cursor);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
|
@ -0,0 +1,16 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class JsonResponseTextOnline extends MssResponseType {
|
||||
@SerializedName("value") private String answer;
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.adins.mss.base.todolist.todayplanrepository;
|
||||
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
|
||||
public class ResponseChangePlan extends MssResponseType {
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="110dp"
|
||||
android:background="#76000000">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@+id/btn_takepicture"
|
||||
android:layout_toStartOf="@+id/btn_takepicture">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb_camera_mode"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="35dp"
|
||||
android:tag="Rear"
|
||||
android:background="@drawable/selector_camera_mode"
|
||||
android:button="@android:color/transparent"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_takepicture"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:background="@drawable/ic_take_camera"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toRightOf="@+id/btn_takepicture"
|
||||
android:layout_toEndOf="@+id/btn_takepicture">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_flash_mode"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="35dp"
|
||||
android:tag="Off"
|
||||
android:background="@drawable/ic_camera_flash_off"
|
||||
android:layout_centerInParent="true"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,62 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class JsonResponseSubmitTask extends MssResponseType {
|
||||
/**
|
||||
* Property result
|
||||
*/
|
||||
@SerializedName("result")
|
||||
String result;
|
||||
@SerializedName("taskId")
|
||||
String taskId;
|
||||
@SerializedName("cash_on_hand")
|
||||
String cashOnHand;
|
||||
@SerializedName("uuid")
|
||||
String uuidTask;
|
||||
|
||||
public String getUuidTask() {
|
||||
return uuidTask;
|
||||
}
|
||||
|
||||
public void setUuidTask(String uuidTask) {
|
||||
this.uuidTask = uuidTask;
|
||||
}
|
||||
|
||||
public String getCashOnHand() {
|
||||
return cashOnHand;
|
||||
}
|
||||
|
||||
public void setCashOnHand(String cashOnHand) {
|
||||
this.cashOnHand = cashOnHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the result
|
||||
*/
|
||||
public String getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the result
|
||||
*/
|
||||
public void setResult(String value) {
|
||||
this.result = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Task id
|
||||
*/
|
||||
public String getTaskId() {
|
||||
return this.taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Task id
|
||||
*/
|
||||
public void setTaskId(String value) {
|
||||
this.taskId = value;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 570 B |
|
@ -0,0 +1,51 @@
|
|||
package com.adins.mss.base.autosend;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.services.ScheduledConnectionItem;
|
||||
import com.adins.mss.foundation.services.ScheduledItem.ScheduledItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AutoSubmitImage extends ScheduledConnectionItem implements ScheduledItemHandler {
|
||||
|
||||
Context context;
|
||||
/**
|
||||
* stored question which are being sent
|
||||
*/
|
||||
private List<TaskD> imageQuestions;
|
||||
|
||||
public AutoSubmitImage(Context context, String id, int interval, String url, boolean enc, boolean dec) {
|
||||
super(id, interval, url, enc, dec);
|
||||
imageQuestions = new ArrayList<TaskD>();
|
||||
this.context = context;
|
||||
setHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getData() {
|
||||
// TODO fetch pending image
|
||||
imageQuestions = null;
|
||||
|
||||
// TODO convert to JSON
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSuccess(HttpConnectionResult result) {
|
||||
TaskDDataAccess.changeStatusList(context, imageQuestions, true);
|
||||
imageQuestions.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onFail(HttpConnectionResult result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/gradient_end"
|
||||
android:pathData="M7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM1,2v2h2l3.6,7.59 -1.35,2.45c-0.16,0.28 -0.25,0.61 -0.25,0.96 0,1.1 0.9,2 2,2h12v-2L7.42,15c-0.14,0 -0.25,-0.11 -0.25,-0.25l0.03,-0.12 0.9,-1.63h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.58,-6.49c0.08,-0.14 0.12,-0.31 0.12,-0.48 0,-0.55 -0.45,-1 -1,-1L5.21,4l-0.94,-2L1,2zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,73 @@
|
|||
package com.adins.mss.foundation.services;
|
||||
|
||||
import android.app.Service;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.autosend.AutoSubmitForm;
|
||||
import com.adins.mss.base.autosend.AutoSubmitImage;
|
||||
import com.adins.mss.base.tracking.LocationTrackingSchedule;
|
||||
|
||||
/**
|
||||
* A default AutoSendService which will include LocationTracking, AutoSubmitForm, and AutoSubmitImage ScheduledItem
|
||||
* as the service is created.
|
||||
* It save the hassle of accessing this service and manually register said default ScheduledItem
|
||||
* <p>If there is a need to access this service and register more ScheduledItem, might need to check bindService() in http://developer.android.com/guide/components/services.html
|
||||
* <p>Register this service to AndroidManifest and call from StartService() to use
|
||||
* <br>Make sure both GlobalData.intervalTracking and GlobalData.intervalAutoSend or they will use default value
|
||||
*
|
||||
* @author glen.iglesias
|
||||
* @see Service
|
||||
* @see AutoSendTaskService
|
||||
* @see GlobalData
|
||||
*/
|
||||
public class DefaultAutoSendService extends AutoSendSerivce {
|
||||
|
||||
public static final String SCHED_LOC_TRACKING = "schedule_location_tracking";
|
||||
public static final String SCHED_AUTO_SUBMIT = "schedule_auto_submit";
|
||||
public static final String SCHED_AUTO_SUBMIT_IMAGE = "schedule_auto_submit_image";
|
||||
|
||||
public DefaultAutoSendService() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
GlobalData globData = GlobalData.getSharedGlobalData();
|
||||
boolean enc = globData.isEncrypt();
|
||||
boolean dec = globData.isDecrypt();
|
||||
|
||||
//TODO replace userid
|
||||
//get userId from globalData
|
||||
|
||||
//Cancel fetch from database because the process should be to set all from database to GlobalData after login
|
||||
//Fetch from database instead of GlobalData, to enable multi-user saved on database just in case needed
|
||||
// List<GeneralParameter> parameters = GeneralParameterDataAccess.getAll(this, "test");
|
||||
|
||||
//Location Tracking
|
||||
int locTrackSchedInterval = GlobalData.getSharedGlobalData().getIntervalTracking();
|
||||
if (locTrackSchedInterval == -1) locTrackSchedInterval = 10000;
|
||||
String urlTracking = globData.getUrlTracking();
|
||||
LocationTrackingSchedule locTrackSched = new LocationTrackingSchedule(this, SCHED_LOC_TRACKING, locTrackSchedInterval, urlTracking, enc, dec);
|
||||
addScheduledItem(locTrackSched);
|
||||
|
||||
String urlSubmit = globData.getURL_SUBMITTASK();
|
||||
boolean isPartial = globData.isPartialSending();
|
||||
|
||||
//Auto Submit Form
|
||||
int autoSubmitSchedInterval = GlobalData.getSharedGlobalData().getIntervalAutoSend();
|
||||
if (autoSubmitSchedInterval == -1) autoSubmitSchedInterval = 100000;
|
||||
// AutoSubmitForm autoSubmitFormSched = new AutoSubmitForm(this, SCHED_AUTO_SUBMIT, autoSubmitSchedInterval, urlSubmit, enc, dec);
|
||||
AutoSubmitForm autoSubmitFormSched = new AutoSubmitForm(this, SCHED_AUTO_SUBMIT, autoSubmitSchedInterval, urlSubmit, enc, dec, isPartial);
|
||||
addScheduledItem(autoSubmitFormSched);
|
||||
|
||||
//Auto Submit Image
|
||||
int autoSubmitImageSchedInterval = GlobalData.getSharedGlobalData().getIntervalAutoSend();
|
||||
if (autoSubmitImageSchedInterval == -1) autoSubmitImageSchedInterval = 100000;
|
||||
// AutoSubmitImage autoSubmitImageSched = new AutoSubmitImage(this, SCHED_AUTO_SUBMIT_IMAGE, autoSubmitImageSchedInterval, urlSubmit, enc, dec, isPartial);
|
||||
AutoSubmitImage autoSubmitImageSched = new AutoSubmitImage(this, SCHED_AUTO_SUBMIT_IMAGE, autoSubmitImageSchedInterval, urlSubmit, enc, dec);
|
||||
addScheduledItem(autoSubmitImageSched);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue