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,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/previewContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="?android:attr/actionBarSize"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:padding="10dp"
|
||||
android:background="#90000000"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:gravity="bottom" >
|
||||
|
||||
<!-- <Button -->
|
||||
<!-- android:id="@+id/spFlashCam" -->
|
||||
<!-- android:layout_width="48sp" -->
|
||||
<!-- android:layout_height="47sp" -->
|
||||
<!-- android:layout_alignParentRight="true" -->
|
||||
<!-- android:layout_alignParentTop="true" -->
|
||||
<!-- android:background="@drawable/ic_flash_auto_white" /> -->
|
||||
|
||||
<Button
|
||||
android:id="@+id/btCaptureCam"
|
||||
android:layout_width="48sp"
|
||||
android:layout_height="47sp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/ic_camera" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.adins.mss.coll.NewMCMainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!" />
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,22 @@
|
|||
package com.adins.mss.odr.marketingreport;
|
||||
|
||||
import com.adins.mss.foundation.http.KeyValue;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 11/28/2017.
|
||||
*/
|
||||
|
||||
public class MarketingSearchResponse extends MssResponseType {
|
||||
@SerializedName("listKeyValue")
|
||||
private KeyValue[] listKeyValue;
|
||||
|
||||
public KeyValue[] getListKeyValue() {
|
||||
return listKeyValue;
|
||||
}
|
||||
|
||||
public void setListKeyValue(KeyValue[] listKeyValue) {
|
||||
this.listKeyValue = listKeyValue;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
|
@ -0,0 +1,37 @@
|
|||
package com.adins.mss.foundation.formatter;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.adins.mss.constant.Global;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 28/09/2016.
|
||||
*/
|
||||
//kamil (22/03/2018) : don't edit this class, used for JexlContext in fragmentQuestion
|
||||
// context.set("dateformatter", new DateFormatter());
|
||||
public class DateFormatter {
|
||||
@Keep
|
||||
public int age(String birthDate) {
|
||||
Date birth = null;
|
||||
try {
|
||||
birth = Formatter.parseDate(birthDate, Global.DATE_STR_FORMAT_GSON);
|
||||
} catch (ParseException e) {
|
||||
try {
|
||||
birth = Formatter.parseDate(birthDate, Global.DATE_STR_FORMAT);
|
||||
} catch (ParseException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
Date now = new Date();
|
||||
long timeBetween = 0L;
|
||||
if(birth != null) {
|
||||
timeBetween = now.getTime() - birth.getTime();
|
||||
}
|
||||
double yearsBetween = timeBetween / 3.15576e+10;
|
||||
return (int) Math.floor(yearsBetween);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -0,0 +1,70 @@
|
|||
package com.adins.mss.odr.update;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.odr.R;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RejectOrderTask extends AsyncTask<Void, Void, String>{
|
||||
private ProgressDialog progressDialog;
|
||||
private String errMessage = null;
|
||||
private Activity activity;
|
||||
List<NameValuePair> params;
|
||||
public RejectOrderTask (Activity activity, List<NameValuePair> params){
|
||||
this.activity = activity;
|
||||
this.params = params;
|
||||
}
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = ProgressDialog.show(activity,
|
||||
"", activity.getString(R.string.progressWait), true);
|
||||
}
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
//FIXME : Tambahin buat ngirim datanya and nerima balikannya
|
||||
String result="";
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errMessage = activity.getString(R.string.cancel_order_error);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(String result){
|
||||
if (progressDialog.isShowing()){
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
// if(null==result || "".equals(result)){
|
||||
// NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(activity);
|
||||
// dialogBuilder.withTitle("Error")
|
||||
// .withMessage(errMessage)
|
||||
// .show();
|
||||
// }else{
|
||||
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(activity);
|
||||
dialogBuilder.withTitle(activity.getString(R.string.success))
|
||||
.withMessage(activity.getString(R.string.order_rejected))
|
||||
.isCancelable(false)
|
||||
.withButton1Text(activity.getString(R.string.btnOk))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activity.finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,236 @@
|
|||
package com.adins.mss.base.loyalti.userhelpdummy;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.loyalti.barchart.LoyaltyBarChartRenderer;
|
||||
import com.adins.mss.base.loyalti.barchart.NonScrollListView;
|
||||
import com.adins.mss.base.loyalti.barchart.pointlegends.PointLegendsAdapter;
|
||||
import com.adins.mss.base.loyalti.barchart.ranklegends.RankLegendsAdapter;
|
||||
import com.adins.mss.base.loyalti.model.PointDetail;
|
||||
import com.adins.mss.base.loyalti.model.RankDetail;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dummy.userhelp_dummy.UserHelpGeneralDummy;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
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.formatter.IndexAxisValueFormatter;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class DummyMonthlyPointView extends Fragment {
|
||||
|
||||
|
||||
protected BarChart barChart;
|
||||
protected NonScrollListView rankLegends;
|
||||
protected NonScrollListView pointLegends;
|
||||
private View view;
|
||||
private NestedScrollView scrollView;
|
||||
|
||||
private static final String LEVEL_1 = "Level 1";
|
||||
private static final String LEVEL_2 = "Level 2";
|
||||
private static final String LEVEL_3 = "Level 3";
|
||||
|
||||
//chart colors
|
||||
int[] pointDetailColors;
|
||||
int[] rankColors;
|
||||
|
||||
public DummyMonthlyPointView() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == com.adins.mss.base.R.id.mnGuide && !Global.BACKPRESS_RESTRICTION) {
|
||||
showUserHelp();
|
||||
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
protected UserHelp.OnShowSequenceFinish finishCallback = new UserHelp.OnShowSequenceFinish() {
|
||||
@Override
|
||||
public void onSequenceFinish() {
|
||||
Global.positionStack.pop();
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
};
|
||||
|
||||
protected void showUserHelp(){
|
||||
final UserHelpGeneralDummy userHelpSvyDummy = new UserHelpGeneralDummy();
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
userHelpSvyDummy.showChartUserHelp(getActivity(),DummyMonthlyPointView.class.getSimpleName(),view,finishCallback, scrollView);
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
initializeChartColor(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
view = inflater.inflate(R.layout.fragment_dummy_monthly_point, container, false);
|
||||
barChart = view.findViewById(R.id.dummyMonthlyChart);
|
||||
rankLegends = view.findViewById(R.id.dummyLegendRanks);
|
||||
pointLegends = view.findViewById(R.id.dummyLegendPoints);
|
||||
scrollView = view.findViewById(R.id.scrollView);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Global.positionStack.push(1);
|
||||
showDummyChart();
|
||||
showUserHelp();
|
||||
}
|
||||
|
||||
protected void showDummyChart(){
|
||||
List<BarEntry> barEntryList = new ArrayList<>();
|
||||
float[][] dummyDataset = getDummyDataSet();
|
||||
for(int i = 0; i< dummyDataset.length; i++){
|
||||
barEntryList.add(new BarEntry(i, dummyDataset[i]));
|
||||
}
|
||||
|
||||
BarDataSet barDataSet = new BarDataSet(barEntryList,"");
|
||||
barDataSet.setColors(pointDetailColors);
|
||||
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(4);
|
||||
xAxis.setGranularity(1f);
|
||||
xAxis.setGranularityEnabled(true);
|
||||
xAxis.setValueFormatter(getXValueFormatter());
|
||||
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);
|
||||
|
||||
//use custom legends
|
||||
barChart.getLegend().setEnabled(false);
|
||||
barChart.setDescription(null);
|
||||
RankLegendsAdapter rankLegendsAdapter = new RankLegendsAdapter(getActivity(),getDummyRanksLegend());
|
||||
rankLegends.setAdapter(rankLegendsAdapter);
|
||||
PointLegendsAdapter pointLegendsAdapter = new PointLegendsAdapter(getActivity(),getDummyPointCategoriesLegend());
|
||||
pointLegends.setAdapter(pointLegendsAdapter);
|
||||
|
||||
//chart settings
|
||||
//custom render bar
|
||||
RankDetail[][] dummyRankDataSet = getDummyRankDataSet();
|
||||
LoyaltyBarChartRenderer renderer = new LoyaltyBarChartRenderer(barChart,dummyRankDataSet,0.3f,0);
|
||||
barChart.setRenderer(renderer);
|
||||
|
||||
barChart.setPinchZoom(false);
|
||||
barChart.setDoubleTapToZoomEnabled(false);
|
||||
barChart.setExtraOffsets(0,0,0,10f);
|
||||
barChart.setFitBars(true);
|
||||
barChart.setData(barData);
|
||||
}
|
||||
|
||||
protected RankDetail[][] getDummyRankDataSet() {
|
||||
RankDetail[][] dummyRanks = new RankDetail[4][];
|
||||
dummyRanks[0] = new RankDetail[]{new RankDetail(LEVEL_1,"3",rankColors[0])
|
||||
,new RankDetail(LEVEL_2,"12",rankColors[1])
|
||||
,new RankDetail(LEVEL_3,"20",rankColors[2])};
|
||||
dummyRanks[1] = new RankDetail[]{new RankDetail(LEVEL_1,"1",rankColors[0])
|
||||
,new RankDetail(LEVEL_2,"3",rankColors[1])
|
||||
,new RankDetail(LEVEL_3,"5",rankColors[2])};
|
||||
dummyRanks[2] = new RankDetail[]{new RankDetail(LEVEL_1,"5",rankColors[0])
|
||||
,new RankDetail(LEVEL_2,"10",rankColors[1])
|
||||
,new RankDetail(LEVEL_3,"15",rankColors[2])};
|
||||
dummyRanks[3] = new RankDetail[]{new RankDetail(LEVEL_1,"1",rankColors[0])
|
||||
,new RankDetail(LEVEL_2,"1",rankColors[1])
|
||||
,new RankDetail(LEVEL_3,"6",rankColors[2])};
|
||||
|
||||
return dummyRanks;
|
||||
}
|
||||
|
||||
protected float[][] getDummyDataSet() {
|
||||
float[][] dummyPoin = new float[4][];
|
||||
dummyPoin[0] = new float[]{10,40,20,12};
|
||||
dummyPoin[1] = new float[]{5,10,14,8};
|
||||
dummyPoin[2] = new float[]{40,20,20,10};
|
||||
dummyPoin[3] = new float[]{20,25,13,6};
|
||||
return dummyPoin;
|
||||
}
|
||||
|
||||
protected List<RankDetail> getDummyRanksLegend(){
|
||||
List<RankDetail> dummyRankLegend = new ArrayList<>();
|
||||
dummyRankLegend.add(new RankDetail(LEVEL_1,"3",rankColors[0]));
|
||||
dummyRankLegend.add(new RankDetail(LEVEL_2,"12",rankColors[1]));
|
||||
dummyRankLegend.add(new RankDetail(LEVEL_3,"20",rankColors[2]));
|
||||
return dummyRankLegend;
|
||||
}
|
||||
|
||||
protected List<PointDetail> getDummyPointCategoriesLegend(){
|
||||
List<PointDetail> dummyPointLegend = new ArrayList<>();
|
||||
dummyPointLegend.add(new PointDetail("Point Category 1","3",pointDetailColors[0]));
|
||||
dummyPointLegend.add(new PointDetail("Point Category 2","3",pointDetailColors[1]));
|
||||
dummyPointLegend.add(new PointDetail("Point Category 3","3",pointDetailColors[2]));
|
||||
dummyPointLegend.add(new PointDetail("Point Category 4","4",pointDetailColors[3]));
|
||||
return dummyPointLegend;
|
||||
}
|
||||
|
||||
protected ValueFormatter getXValueFormatter(){
|
||||
return new IndexAxisValueFormatter(new String[]{"Jan","Feb","Mar","Apr"});
|
||||
}
|
||||
|
||||
|
||||
private void initializeChartColor(Context mContext){
|
||||
pointDetailColors = new int[] {
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.graphColor1),
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.graphColor2),
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.graphColor3),
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.graphColor4)
|
||||
};
|
||||
|
||||
rankColors = new int[] {
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.rankColor1),
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.rankColor2),
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.rankColor3),
|
||||
androidx.core.content.ContextCompat.getColor(mContext, R.color.rankColor4)
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
|
@ -0,0 +1,34 @@
|
|||
package com.adins.mss.foundation.dialog.gitonway.lib.effects;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.adins.libs.nineoldandroids.animation.ObjectAnimator;
|
||||
|
||||
/*
|
||||
* Copyright 2014 litao
|
||||
* https://github.com/sd6352051/NiftyDialogEffects
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
public class Slit extends BaseEffects {
|
||||
|
||||
@Override
|
||||
protected void setupAnimation(View view) {
|
||||
getAnimatorSet().playTogether(
|
||||
ObjectAnimator.ofFloat(view, "rotationY", 90, 88, 88, 45, 0).setDuration(mDuration),
|
||||
ObjectAnimator.ofFloat(view, "alpha", 0, 0.4f, 0.8f, 1).setDuration(mDuration * 3 / 2),
|
||||
ObjectAnimator.ofFloat(view, "scaleX", 0, 0.5f, 0.9f, 0.9f, 1).setDuration(mDuration),
|
||||
ObjectAnimator.ofFloat(view, "scaleY", 0, 0.5f, 0.9f, 0.9f, 1).setDuration(mDuration)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.adins.mss.base.scheme;
|
||||
|
||||
public class VersionSchemeTaskBean {
|
||||
private String uuidScheme;
|
||||
private String formVersion;
|
||||
|
||||
public String getUuidScheme() {
|
||||
return uuidScheme;
|
||||
}
|
||||
|
||||
public void setUuidScheme(String uuidScheme) {
|
||||
this.uuidScheme = uuidScheme;
|
||||
}
|
||||
|
||||
public String getFormVersion() {
|
||||
return formVersion;
|
||||
}
|
||||
|
||||
public void setFormVersion(String formVersion) {
|
||||
this.formVersion = formVersion;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class JsonRequestTextOnline extends MssRequestType {
|
||||
|
||||
@SerializedName("taskID") private String taskId;
|
||||
|
||||
@SerializedName("refID") private String refId;
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getRefId() {
|
||||
return refId;
|
||||
}
|
||||
|
||||
public void setRefId(String refId) {
|
||||
this.refId = refId;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,512 @@
|
|||
package com.tracking;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.networkmonitor.NetworkMonitorDataUsage;
|
||||
import com.adins.mss.base.tracking.LocationTrackingRequestJson;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.GeneralParameter;
|
||||
import com.adins.mss.dao.LocationInfo;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.LocationInfoDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.http.HttpCryptedConnection;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.adins.mss.foundation.location.LocationTrackingManager;
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
|
||||
import com.adins.mss.logger.Logger;
|
||||
import com.google.firebase.perf.FirebasePerformance;
|
||||
import com.google.firebase.perf.metrics.HttpMetric;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class LocationTrackingService extends Service implements Runnable, LocationListener {
|
||||
private static String TAG = "LocationTrackingService";
|
||||
private static final int LIMITED_TRACKING_FOR_SENT = 100;
|
||||
private static Context context;
|
||||
private static boolean keepRunning;
|
||||
private static boolean keepRunningBefore;
|
||||
Thread thr;
|
||||
NetworkMonitorDataUsage monitorDU = new NetworkMonitorDataUsage();
|
||||
|
||||
//Nendi: 2019.07.01
|
||||
public LocationTrackingManager manager;
|
||||
protected LocationManager mLocation;
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
|
||||
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(context,
|
||||
"GlobalData", Context.MODE_PRIVATE);
|
||||
if (!sharedPref.contains("HAS_LOGGED")) {
|
||||
stopSelf();
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
StartLocationTracking();
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
public static boolean isKeepRunning() {
|
||||
return keepRunning;
|
||||
}
|
||||
|
||||
public static boolean isKeepRunningBefore() {
|
||||
return keepRunningBefore;
|
||||
}
|
||||
|
||||
public static void setKeepRunningBefore(boolean before) {
|
||||
keepRunningBefore = before;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mLocation != null) {
|
||||
mLocation.removeUpdates(this);
|
||||
manager.removeLocationListener();
|
||||
manager = null;
|
||||
mLocation = null;
|
||||
}
|
||||
|
||||
Intent broadcast = new Intent(getString(R.string.intent_action_restart_location_tracking));
|
||||
sendBroadcast(broadcast);
|
||||
|
||||
stopSelf();
|
||||
stopAutoSendLocationTrackingThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
thr = new Thread(null, this, "AutoSendLocationHistory");
|
||||
context = this;
|
||||
startAutoSendLocationTrackingThread();
|
||||
}
|
||||
|
||||
private void startAutoSendLocationTrackingThread() {
|
||||
thr.start();
|
||||
}
|
||||
|
||||
private void stopAutoSendLocationTrackingThread() {
|
||||
if (thr != null) {
|
||||
thr.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getBatteryLevel() {
|
||||
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent batteryStatus = context.registerReceiver(null, ifilter);
|
||||
int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
return (level * 100) / scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String uuid_user = null;
|
||||
try {
|
||||
uuid_user = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
if (uuid_user == null)
|
||||
uuid_user = Global.user.getUuid_user();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
if (Global.user != null)
|
||||
uuid_user = Global.user.getUuid_user();
|
||||
}
|
||||
boolean enableTracking = false;
|
||||
try {
|
||||
if (uuid_user != null) {
|
||||
GeneralParameter gp = GeneralParameterDataAccess.getOne(context, uuid_user, "PRM01_TRCK");
|
||||
if (gp != null && gp.getGs_value().equals("1")) {
|
||||
enableTracking = true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
keepRunning = true;
|
||||
keepRunningBefore = true;
|
||||
|
||||
int interval = 0;
|
||||
try {
|
||||
if (uuid_user != null && context != null)
|
||||
interval = Integer.parseInt(GeneralParameterDataAccess.getOne(context, uuid_user, "PRM02_TRIN").getGs_value());
|
||||
interval *= Global.SECOND;
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
keepRunning = false;
|
||||
}
|
||||
|
||||
MssResponseType mrt = new MssResponseType();
|
||||
String sentStatus = "0";
|
||||
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
synchronized (this) {
|
||||
while (keepRunning) {
|
||||
try {
|
||||
try {
|
||||
String uuidUser = GlobalData.getSharedGlobalData().getUser()
|
||||
.getUuid_user();
|
||||
if (uuidUser != null) {
|
||||
GeneralParameter gp = GeneralParameterDataAccess.getOne(context, uuidUser, Global.GS_INTERVAL_TRACKING);
|
||||
if (gp != null && gp.getGs_value() != null
|
||||
&& !gp.getGs_value()
|
||||
.isEmpty()) {
|
||||
interval = Integer.parseInt(gp.getGs_value()) * Global.SECOND;
|
||||
}
|
||||
GeneralParameter gp2 = GeneralParameterDataAccess.getOne(context, uuidUser, Global.GS_TRACKING);
|
||||
if (gp2 != null) {
|
||||
enableTracking = gp2.getGs_value().equals("1");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
if (enableTracking) {
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
if (!Global.APPLICATION_ORDER.equals(application)) {
|
||||
if (checkFlagTracking()) {
|
||||
|
||||
if (Tool.isInternetconnected(context)) {
|
||||
LocationTrackingRequestJson ltj = new LocationTrackingRequestJson();
|
||||
ltj.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
ltj.addImeiAndroidIdToUnstructured();
|
||||
List<LocationInfo> listLocationInfo = new ArrayList<>();
|
||||
try {
|
||||
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
listLocationInfo = LocationInfoDataAccess.getAllbyTypewithlimited(context, uuidUser, Global.LOCATION_TYPE_TRACKING, LIMITED_TRACKING_FOR_SENT);
|
||||
if (!listLocationInfo.isEmpty()) {
|
||||
for (LocationInfo info : listLocationInfo) {
|
||||
if (info.getUuid_user() != null) {
|
||||
info.setUuid_user(uuidUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
//proses data usage
|
||||
ltj.setDataUsage(String.valueOf(monitorDU.getDataThisDay(context) / 1024)); //dirubah dari byte ke kilobyte
|
||||
//end proses data usage
|
||||
|
||||
ltj.addLocationInfoList(listLocationInfo);
|
||||
ltj.setPrecentageBattery(String.valueOf(getBatteryLevel()));
|
||||
//retrieve from db
|
||||
if (!ltj.getLocationInfoList().isEmpty()) {
|
||||
try {
|
||||
String json = GsonHelper.toJson(ltj);
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
|
||||
HttpConnectionResult serverResult = null;
|
||||
|
||||
//Firebase Performance Trace HTTP Request
|
||||
HttpMetric networkMetric =
|
||||
FirebasePerformance.getInstance().newHttpMetric(GlobalData.getSharedGlobalData().getURL_SUBMIT_TRACK(), FirebasePerformance.HttpMethod.POST);
|
||||
Utility.metricStart(networkMetric, json);
|
||||
|
||||
try {
|
||||
serverResult = httpConn.requestToServer(GlobalData.getSharedGlobalData().getURL_SUBMIT_TRACK(), json, Global.DEFAULTCONNECTIONTIMEOUT);
|
||||
Utility.metricStop(networkMetric, serverResult);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
|
||||
}
|
||||
if (serverResult != null && serverResult.isOK()) {
|
||||
String resultvalue = serverResult.getResult();
|
||||
try {
|
||||
mrt = GsonHelper.fromJson(resultvalue, MssResponseType.class);
|
||||
if (mrt.getStatus().getCode() == 0) {
|
||||
if (Global.IS_DEV)
|
||||
Log.i(TAG, "_____________________Submit Tracking IS SUCCESSFULL");
|
||||
|
||||
LocationInfoDataAccess.deleteList(context, listLocationInfo);
|
||||
List<LocationInfo> lastlocation = LocationInfoDataAccess.getAllbyType(context, GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.LOCATION_TYPE_TRACKING);
|
||||
if (lastlocation != null && !lastlocation.isEmpty()) {
|
||||
|
||||
} else {
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Global.IS_DEV) Log.i(TAG, mrt.toString());
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} catch (IllegalStateException ex) {
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(context,
|
||||
"GlobalData", Context.MODE_PRIVATE);
|
||||
String uuidUser = sharedPref.getString("UUID_USER", "");
|
||||
LocationInfoDataAccess.deleteAllbyType(context, uuidUser, Global.LOCATION_TYPE_TRACKING);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e2) {
|
||||
e2.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// end of thread
|
||||
try {
|
||||
wait(interval);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
FireCrash.log(ex);
|
||||
Logger.e("AUTOSENDLOCTRACKING", Log.getStackTraceString(ex));
|
||||
ex.printStackTrace();
|
||||
keepRunning = false;
|
||||
ACRA.getErrorReporter().handleSilentException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkFlagTracking() {
|
||||
try {
|
||||
User user = GlobalData.getSharedGlobalData().getUser();
|
||||
String hourFromWebStart;
|
||||
String hourFromWeb;
|
||||
Calendar cal;
|
||||
Calendar calStart;
|
||||
String trackingDays;
|
||||
List trackingDaysList;
|
||||
int thisDayInt = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
|
||||
String thisDay;
|
||||
thisDayInt -= 1;
|
||||
thisDay = String.valueOf(thisDayInt);
|
||||
|
||||
|
||||
if (user != null) {
|
||||
if (null != user.getIs_tracking() && "1".equals(user.getIs_tracking())) {
|
||||
trackingDays = user.getTracking_days();
|
||||
if (null != trackingDays && !"".equalsIgnoreCase(trackingDays)) {
|
||||
trackingDaysList = Arrays.asList(trackingDays.split(";"));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
hourFromWebStart = user.getStart_time();
|
||||
calStart = Calendar.getInstance();
|
||||
if (null != hourFromWebStart && !"".equalsIgnoreCase(hourFromWebStart)) {
|
||||
String hourSplitStart[] = hourFromWebStart.split(":");
|
||||
int hourStart = Integer.parseInt(hourSplitStart[0]);
|
||||
int minuteStart = Integer.parseInt(hourSplitStart[1]);
|
||||
|
||||
calStart.set(Calendar.HOUR_OF_DAY, hourStart);
|
||||
calStart.set(Calendar.MINUTE, minuteStart);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
hourFromWeb = user.getEnd_time();
|
||||
cal = Calendar.getInstance();
|
||||
if (null != hourFromWeb && !"".equalsIgnoreCase(hourFromWeb)) {
|
||||
String hourSplit[] = hourFromWeb.split(":");
|
||||
int hour = Integer.parseInt(hourSplit[0]);
|
||||
int minute = Integer.parseInt(hourSplit[1]);
|
||||
|
||||
cal.set(Calendar.HOUR_OF_DAY, hour);
|
||||
cal.set(Calendar.MINUTE, minute);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (trackingDaysList.contains(thisDay)) {
|
||||
if (Calendar.getInstance().after(calStart) && Calendar.getInstance().before(cal)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Log.d("Location Tracking", "Stop Location Service");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
ACRA.getErrorReporter().putCustomData("LocationListenerImpl", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("LocationListenerImpl", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat checkFlagTacking"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void StartLocationTracking() {
|
||||
try {
|
||||
mLocation = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
GeneralParameter gp_distance = GeneralParameterDataAccess.getOne(getApplicationContext(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_DISTANCE_TRACKING);
|
||||
try {
|
||||
if (gp_distance != null) {
|
||||
int distanceTracking = Integer.parseInt(gp_distance.getGs_value());
|
||||
if (distanceTracking != 0) {
|
||||
manager = new LocationTrackingManager(tm, mLocation, this);
|
||||
manager.setMinimalDistanceChangeLocation(Integer.parseInt(GeneralParameterDataAccess.getOne(getApplicationContext(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), "PRM13_DIST").getGs_value()));
|
||||
manager.setMinimalTimeChangeLocation(5);
|
||||
manager.applyLocationListener(context);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
manager = new LocationTrackingManager(tm, mLocation, this);
|
||||
manager.setMinimalDistanceChangeLocation(50);
|
||||
manager.setMinimalTimeChangeLocation(5);
|
||||
manager.applyLocationListener(context);
|
||||
}
|
||||
|
||||
if (Global.LTM == null) {
|
||||
Global.LTM = manager;
|
||||
} else {
|
||||
try {
|
||||
Global.LTM = null;
|
||||
Global.LTM = manager;
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void bindLocationListener() {
|
||||
mLocation = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
} else {
|
||||
if (mLocation.getAllProviders().contains(LocationManager.GPS_PROVIDER))
|
||||
mLocation.requestLocationUpdates(LocationManager.GPS_PROVIDER, (long)(5 * 1000), 10f, this);
|
||||
}
|
||||
} else {
|
||||
if (mLocation.getAllProviders().contains(LocationManager.GPS_PROVIDER))
|
||||
mLocation.requestLocationUpdates(LocationManager.GPS_PROVIDER, (long)(5 * 1000), 10f, this);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.GroupUser;
|
||||
import com.adins.mss.dao.GroupUserDao;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
|
||||
public class GroupUserDataAccess {
|
||||
|
||||
// private static DaoOpenHelper daoOpenHelper;
|
||||
|
||||
/**
|
||||
* use to generate dao session that you can access modelDao
|
||||
*
|
||||
* @param context --> context from activity
|
||||
* @return
|
||||
*/
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
/*if(daoOpenHelper==null){
|
||||
// if(daoOpenHelper.getDaoSession()==null)
|
||||
daoOpenHelper = new DaoOpenHelper(context);
|
||||
}
|
||||
DaoSession daoSeesion = daoOpenHelper.getDaoSession();
|
||||
return daoSeesion;*/
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get groupUser dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static GroupUserDao getGroupUserDao(Context context) {
|
||||
return getDaoSession(context).getGroupUserDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
/*if(daoOpenHelper!=null){
|
||||
daoOpenHelper.closeAll();
|
||||
daoOpenHelper = null;
|
||||
}*/
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add groupUser as entity
|
||||
*
|
||||
* @param context
|
||||
* @param groupUser
|
||||
*/
|
||||
public static void add(Context context, GroupUser groupUser) {
|
||||
getGroupUserDao(context).insert(groupUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* add groupUser as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param groupUserList
|
||||
*/
|
||||
public static void add(Context context, List<GroupUser> groupUserList) {
|
||||
getGroupUserDao(context).insertInTx(groupUserList);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all content in table.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void clean(Context context) {
|
||||
getGroupUserDao(context).deleteAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupUser
|
||||
* @param context
|
||||
*/
|
||||
public static void delete(Context context, GroupUser groupUser) {
|
||||
getGroupUserDao(context).delete(groupUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by user
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
*/
|
||||
public static void delete(Context context, String uuidUser) {
|
||||
QueryBuilder<GroupUser> qb = getGroupUserDao(context).queryBuilder();
|
||||
qb.where(GroupUserDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.build();
|
||||
getGroupUserDao(context).deleteInTx(qb.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupUser
|
||||
* @param context
|
||||
*/
|
||||
public static void update(Context context, GroupUser groupUser) {
|
||||
getGroupUserDao(context).update(groupUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_user = param
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
* @return
|
||||
*/
|
||||
public static List<GroupUser> getAll(Context context, String uuidUser) {
|
||||
QueryBuilder<GroupUser> qb = getGroupUserDao(context).queryBuilder();
|
||||
qb.where(GroupUserDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* select groupUser per user
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.adins.mss.svy.models;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class JsonRequestTaskWithMode extends MssRequestType {
|
||||
/** Property mode */
|
||||
@SerializedName("mode")
|
||||
String mode;
|
||||
|
||||
/**
|
||||
* Gets the mode
|
||||
*/
|
||||
public String getMode() {
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mode
|
||||
*/
|
||||
public void setMode(String value) {
|
||||
this.mode = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.adins.mss.base.about;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.mikepenz.aboutlibraries.entity.Library;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gigin.ginanjar
|
||||
*/
|
||||
public class AboutArrayAdapter extends ArrayAdapter<Library> {
|
||||
private Context mContext;
|
||||
private List<Library> libraries;
|
||||
|
||||
/**
|
||||
* Inisialisasi About Array Adapter
|
||||
*
|
||||
* @param context - Context
|
||||
* @param libraries - List of Libary
|
||||
*/
|
||||
public AboutArrayAdapter(Context context, List<Library> libraries) {
|
||||
super(context, R.layout.new_about_library_log, libraries);
|
||||
|
||||
this.mContext = context;
|
||||
if (libraries != null)
|
||||
this.libraries = libraries;
|
||||
else
|
||||
this.libraries = new ArrayList<Library>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return libraries.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.new_about_library_log, parent, false);
|
||||
}
|
||||
((TextView) convertView.findViewById(R.id.libraryname)).setText(libraries.get(position).getLibraryName());
|
||||
((TextView) convertView.findViewById(R.id.librarycreator)).setText(libraries.get(position).getAuthor());
|
||||
((TextView) convertView.findViewById(R.id.libraryversion)).setText(libraries.get(position).getLibraryVersion());
|
||||
// ((TextView)convertView.findViewById(R.id.librarylicense)).setText(libraries.get(position).getLicense().getLicenseName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
((TextView) convertView.findViewById(R.id.description)).setText(Html.fromHtml(libraries.get(position).getLibraryDescription(), Html.FROM_HTML_MODE_LEGACY));
|
||||
} else {
|
||||
((TextView) convertView.findViewById(R.id.description)).setText(Html.fromHtml(libraries.get(position).getLibraryDescription()));
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,480 @@
|
|||
package com.adins.mss.coll.loyalti.pointacquisitiondaily;
|
||||
|
||||
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.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.contracts.DailyPointContract;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.DummyMonthlyPointView;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.LoyaltyPointsDataSource;
|
||||
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.contracts.ILoyaltyPointsDataSource;
|
||||
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.UserHelpView;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.dialog.DialogManager;
|
||||
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.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class DailyPointsChartView extends Fragment implements DailyPointContract.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 NestedScrollView scrollView;
|
||||
|
||||
//presenter
|
||||
private DailyPointContract.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> 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;
|
||||
private List<PointDetail> pointDetailsDataSet;
|
||||
|
||||
public DailyPointsChartView() {
|
||||
// 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);
|
||||
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
Bundle bundle = this.getArguments();
|
||||
String[] groupPoint = bundle.getString("GroupPoint").split("-");
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.MONTH,Integer.valueOf(groupPoint[0]) - 1);
|
||||
String monthNames = calendar.getDisplayName(Calendar.MONTH,Calendar.LONG, Locale.getDefault());
|
||||
TextView title = view.findViewById(R.id.chartTitle);
|
||||
title.setText(getString(R.string.daily_point_chart_title,monthNames));
|
||||
|
||||
//set daily point logic
|
||||
String programStartDate = getArguments()!=null?getArguments().getString("ProgramStartDate"):"";
|
||||
int displayMonth = Integer.valueOf(groupPoint[0]) - 1;
|
||||
int displayYear = Integer.valueOf(groupPoint[1]);
|
||||
ILoyaltyPointsDataSource dataSource = new LoyaltyPointsDataSource(getActivity().getApplication());
|
||||
DailyPointsLogic dailyPointsLogic = new DailyPointsLogic(dataSource,programStartDate,displayMonth,displayYear);
|
||||
DailyPointsPresenter presenter = new DailyPointsPresenter(this, dailyPointsLogic);
|
||||
setPresenter(presenter);
|
||||
|
||||
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.daily_point_page_title);
|
||||
getActivity().setTitle(programName);
|
||||
Global.positionStack.push(1);
|
||||
chartContent.setVisibility(View.GONE);
|
||||
if(needShowUserHelp()){
|
||||
showUserhelp();
|
||||
}
|
||||
else {
|
||||
loadDailyPointsData();
|
||||
}
|
||||
}
|
||||
|
||||
@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(),DummyDailyPointsView.class.getSimpleName());
|
||||
if(needShowUserHelp()){
|
||||
showUserhelp();
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private boolean needShowUserHelp(){
|
||||
List<UserHelpView> userHelpViews = Global.userHelpGuide.get(DummyDailyPointsView.class.getSimpleName());
|
||||
return Global.ENABLE_USER_HELP && userHelpViews != null && userHelpViews.size() > 0;
|
||||
}
|
||||
|
||||
private void showUserhelp(){
|
||||
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
|
||||
Fragment dummyChart = new DummyDailyPointsView();
|
||||
transaction.replace(R.id.content_frame,dummyChart);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPresenter(DailyPointContract.Presenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
//kode request poin bulanan
|
||||
private void loadDailyPointsData() {
|
||||
progressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.please_wait_dialog), true);
|
||||
|
||||
//dummy request
|
||||
LoyaltyPointsRequest request = new LoyaltyPointsRequest();
|
||||
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
request.loginId = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
request.addImeiAndroidIdToUnstructured();
|
||||
String loginid = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
String[] loginIdSplit = loginid.split("@");
|
||||
request.loginId = loginIdSplit[0];
|
||||
Bundle bundle = getArguments();
|
||||
if(bundle!=null) {
|
||||
request.membershipProgramId = bundle.getString("MembershipProgramCode");
|
||||
request.pointGroup = bundle.getString("GroupPoint");
|
||||
}
|
||||
presenter.getDailyPointsData(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 < 6){
|
||||
//padding data to avoid large bar width
|
||||
float[][] newDataSet = paddingDataSet(pointDataSet,6-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();
|
||||
}
|
||||
DialogManager.showAlert(getActivity(),DialogManager.TYPE_ERROR,message,getString(R.string.error));
|
||||
chartContent.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//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.getCurrentDay());
|
||||
//avg
|
||||
setAveragePoint((int)presenter.getAvgPoint());
|
||||
//max point
|
||||
setMaxPoint(presenter.getMaxPoint());
|
||||
//total point
|
||||
setTotalPoint(presenter.getTotalPoints());
|
||||
//set days formatter
|
||||
String[] daysLabels = presenter.getDays();
|
||||
int padData = pointDataSet.length - daysLabels.length;//check different size
|
||||
if(padData > 0){
|
||||
String[] padDayLabels = new String[daysLabels.length + padData];
|
||||
for(int i=0; i<padDayLabels.length; i++){
|
||||
padDayLabels[i] = "";//set default label first
|
||||
if(i < daysLabels.length){
|
||||
padDayLabels[i] = daysLabels[i];
|
||||
}
|
||||
}
|
||||
daysLabels = padDayLabels;
|
||||
}
|
||||
LoyaltyXLabelFormatter xLabelFormatter = new LoyaltyXLabelFormatter(daysLabels);
|
||||
setxLabelFormatter(xLabelFormatter);
|
||||
//set point details
|
||||
setPointsLegend(presenter.getPointDetails());
|
||||
//set ranks
|
||||
setRanksLegend(presenter.getRanks());
|
||||
//draw chart
|
||||
drawChart();
|
||||
}
|
||||
|
||||
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);
|
||||
BarData barData = new BarData(barDataSet);
|
||||
barData.setDrawValues(false);
|
||||
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.6f,8f);
|
||||
barChart.setRenderer(renderer);
|
||||
|
||||
barChart.setPinchZoom(false);
|
||||
barChart.setDoubleTapToZoomEnabled(false);
|
||||
barChart.setExtraOffsets(0,0,0,20f);
|
||||
barChart.setFitBars(true);
|
||||
barChart.setData(barData);
|
||||
PointClickMarker marker = new PointClickMarker(20f,10f);
|
||||
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(6f);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
//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(DummyDailyPointsView.class.getSimpleName());
|
||||
return Global.ENABLE_USER_HELP && userHelpViews != null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue