add project adins

This commit is contained in:
Alfrid Sanjaya Leo Putra 2024-07-25 14:44:22 +07:00
commit f8f85d679d
5299 changed files with 625430 additions and 0 deletions

View file

@ -0,0 +1,68 @@
/*
* Copyright 2012 Kevin Gaudin
*
* 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.
*/
package org.acra;
import android.content.Context;
import java.io.File;
import java.io.FilenameFilter;
import static org.acra.ACRA.LOG_TAG;
/**
* Responsible for retrieving the location of Crash Report files.
* <p/>
*
* @author William Ferguson
* @since 4.3.0
*/
final class CrashReportFinder {
private final Context context;
public CrashReportFinder(Context context) {
this.context = context;
}
/**
* Returns an array containing the names of pending crash report files.
*
* @return an array containing the names of pending crash report files.
*/
public String[] getCrashReportFiles() {
if (context == null) {
ACRA.log.e(LOG_TAG, "Trying to get ACRA reports but ACRA is not initialized.");
return new String[0];
}
final File dir = context.getFilesDir();
if (dir == null) {
ACRA.log.w(LOG_TAG, "Application files directory does not exist! The application may not be installed correctly. Please try reinstalling.");
return new String[0];
}
ACRA.log.d(LOG_TAG, "Looking for error files in " + dir.getAbsolutePath());
// Filter for ".stacktrace" files
final FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(ACRAConstants.REPORTFILE_EXTENSION);
}
};
final String[] result = dir.list(filter);
return (result == null) ? new String[0] : result;
}
}

View file

@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 2015 Paul Burke
*
* 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.
*/
package com.adins.mss.base.todolist.form.helper;
import androidx.recyclerview.widget.RecyclerView;
/**
* Listener for manual initiation of a drag.
*/
public interface OnStartDragListener {
/**
* Called when a view is requesting a start of a drag.
*
* @param viewHolder The holder of the view to drag.
*/
void onStartDrag(RecyclerView.ViewHolder viewHolder);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -0,0 +1,52 @@
package com.adins.mss.coll.models;
import com.adins.mss.dao.ReceiptHistory;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class ReceiptHistoryResponse extends MssResponseType {
@SerializedName("agreementNo")
private String agreementNo;
@SerializedName("listPaymentHistory")
private List<ReceiptHistory> receiptHistoryList;
@SerializedName("statusCode")
private String statusCode;
@SerializedName("message")
private String message;
public String getAgreementNo() {
return agreementNo;
}
public void setAgreementNo(String agreementNo) {
this.agreementNo = agreementNo;
}
public List<ReceiptHistory> getReceiptHistoryList() {
return receiptHistoryList;
}
public void setReceiptHistoryList(List<ReceiptHistory> receiptHistoryList) {
this.receiptHistoryList = receiptHistoryList;
}
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View file

@ -0,0 +1,12 @@
package com.adins.mss.base.dynamictheme;
import com.google.gson.annotations.SerializedName;
/**
* Created by intishar.fa on 04/09/2018.
*/
public class ColorSetRequest {
@SerializedName("version")
private int version;
}

View file

@ -0,0 +1,245 @@
package com.adins.mss.dao;
import android.database.Cursor;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;
import com.adins.mss.dao.CollectionActivity;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "TR_COLLECTIONACTIVITY".
*/
public class CollectionActivityDao extends AbstractDao<CollectionActivity, String> {
public static final String TABLENAME = "TR_COLLECTIONACTIVITY";
/**
* Properties of entity CollectionActivity.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Uuid_collection_activity = new Property(0, String.class, "uuid_collection_activity", true, "UUID_COLLECTION_ACTIVITY");
public final static Property Uuid_task_h = new Property(1, String.class, "uuid_task_h", false, "UUID_TASK_H");
public final static Property Agreement_no = new Property(2, String.class, "agreement_no", false, "AGREEMENT_NO");
public final static Property Branch_code = new Property(3, String.class, "branch_code", false, "BRANCH_CODE");
public final static Property Collector_name = new Property(4, String.class, "collector_name", false, "COLLECTOR_NAME");
public final static Property Activity = new Property(5, String.class, "activity", false, "ACTIVITY");
public final static Property Result = new Property(6, String.class, "result", false, "RESULT");
public final static Property Notes = new Property(7, String.class, "notes", false, "NOTES");
public final static Property Overdue_days = new Property(8, String.class, "overdue_days", false, "OVERDUE_DAYS");
public final static Property Activity_date = new Property(9, java.util.Date.class, "activity_date", false, "ACTIVITY_DATE");
public final static Property Ptp_date = new Property(10, java.util.Date.class, "ptp_date", false, "PTP_DATE");
public final static Property Usr_crt = new Property(11, String.class, "usr_crt", false, "USR_CRT");
public final static Property Dtm_crt = new Property(12, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
public final static Property Usr_upd = new Property(13, String.class, "usr_upd", false, "USR_UPD");
public final static Property Dtm_upd = new Property(14, java.util.Date.class, "dtm_upd", false, "DTM_UPD");
public final static Property Next_plan_date = new Property(15, java.util.Date.class, "next_plan_date", false, "NEXT_PLAN_DATE");
public final static Property Next_plan_action = new Property(16, String.class, "next_plan_action", false, "NEXT_PLAN_ACTION");
};
public CollectionActivityDao(DaoConfig config) {
super(config);
}
public CollectionActivityDao(DaoConfig config, DaoSession daoSession) {
super(config, 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_COLLECTIONACTIVITY\" (" + //
"\"UUID_COLLECTION_ACTIVITY\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_collection_activity
"\"UUID_TASK_H\" TEXT," + // 1: uuid_task_h
"\"AGREEMENT_NO\" TEXT," + // 2: agreement_no
"\"BRANCH_CODE\" TEXT," + // 3: branch_code
"\"COLLECTOR_NAME\" TEXT," + // 4: collector_name
"\"ACTIVITY\" TEXT," + // 5: activity
"\"RESULT\" TEXT," + // 6: result
"\"NOTES\" TEXT," + // 7: notes
"\"OVERDUE_DAYS\" TEXT," + // 8: overdue_days
"\"ACTIVITY_DATE\" INTEGER," + // 9: activity_date
"\"PTP_DATE\" INTEGER," + // 10: ptp_date
"\"USR_CRT\" TEXT," + // 11: usr_crt
"\"DTM_CRT\" INTEGER," + // 12: dtm_crt
"\"USR_UPD\" TEXT," + // 13: usr_upd
"\"DTM_UPD\" INTEGER," + // 14: dtm_upd
"\"NEXT_PLAN_DATE\" INTEGER," + // 15: next_plan_date
"\"NEXT_PLAN_ACTION\" TEXT);"); // 16: next_plan_action
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_COLLECTIONACTIVITY\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(DatabaseStatement stmt, CollectionActivity entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getUuid_collection_activity());
String uuid_task_h = entity.getUuid_task_h();
if (uuid_task_h != null) {
stmt.bindString(2, uuid_task_h);
}
String agreement_no = entity.getAgreement_no();
if (agreement_no != null) {
stmt.bindString(3, agreement_no);
}
String branch_code = entity.getBranch_code();
if (branch_code != null) {
stmt.bindString(4, branch_code);
}
String collector_name = entity.getCollector_name();
if (collector_name != null) {
stmt.bindString(5, collector_name);
}
String activity = entity.getActivity();
if (activity != null) {
stmt.bindString(6, activity);
}
String result = entity.getResult();
if (result != null) {
stmt.bindString(7, result);
}
String notes = entity.getNotes();
if (notes != null) {
stmt.bindString(8, notes);
}
String overdue_days = entity.getOverdue_days();
if (overdue_days != null) {
stmt.bindString(9, overdue_days);
}
java.util.Date activity_date = entity.getActivity_date();
if (activity_date != null) {
stmt.bindLong(10, activity_date.getTime());
}
java.util.Date ptp_date = entity.getPtp_date();
if (ptp_date != null) {
stmt.bindLong(11, ptp_date.getTime());
}
String usr_crt = entity.getUsr_crt();
if (usr_crt != null) {
stmt.bindString(12, usr_crt);
}
java.util.Date dtm_crt = entity.getDtm_crt();
if (dtm_crt != null) {
stmt.bindLong(13, dtm_crt.getTime());
}
String usr_upd = entity.getUsr_upd();
if (usr_upd != null) {
stmt.bindString(14, usr_upd);
}
java.util.Date dtm_upd = entity.getDtm_upd();
if (dtm_upd != null) {
stmt.bindLong(15, dtm_upd.getTime());
}
java.util.Date next_plan_date = entity.getNext_plan_date();
if (next_plan_date != null) {
stmt.bindLong(16, next_plan_date.getTime());
}
String next_plan_action = entity.getNext_plan_action();
if (next_plan_action != null) {
stmt.bindString(17, next_plan_action);
}
}
/** @inheritdoc */
@Override
public String readKey(Cursor cursor, int offset) {
return cursor.getString(offset + 0);
}
/** @inheritdoc */
@Override
public CollectionActivity readEntity(Cursor cursor, int offset) {
CollectionActivity entity = new CollectionActivity( //
cursor.getString(offset + 0), // uuid_collection_activity
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // uuid_task_h
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // agreement_no
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // branch_code
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // collector_name
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // activity
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // result
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // notes
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // overdue_days
cursor.isNull(offset + 9) ? null : new java.util.Date(cursor.getLong(offset + 9)), // activity_date
cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)), // ptp_date
cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // usr_crt
cursor.isNull(offset + 12) ? null : new java.util.Date(cursor.getLong(offset + 12)), // dtm_crt
cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // usr_upd
cursor.isNull(offset + 14) ? null : new java.util.Date(cursor.getLong(offset + 14)), // dtm_upd
cursor.isNull(offset + 15) ? null : new java.util.Date(cursor.getLong(offset + 15)), // next_plan_date
cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16) // next_plan_action
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, CollectionActivity entity, int offset) {
entity.setUuid_collection_activity(cursor.getString(offset + 0));
entity.setUuid_task_h(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setAgreement_no(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setBranch_code(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setCollector_name(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setActivity(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setResult(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setNotes(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setOverdue_days(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setActivity_date(cursor.isNull(offset + 9) ? null : new java.util.Date(cursor.getLong(offset + 9)));
entity.setPtp_date(cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)));
entity.setUsr_crt(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
entity.setDtm_crt(cursor.isNull(offset + 12) ? null : new java.util.Date(cursor.getLong(offset + 12)));
entity.setUsr_upd(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
entity.setDtm_upd(cursor.isNull(offset + 14) ? null : new java.util.Date(cursor.getLong(offset + 14)));
entity.setNext_plan_date(cursor.isNull(offset + 15) ? null : new java.util.Date(cursor.getLong(offset + 15)));
entity.setNext_plan_action(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
}
/** @inheritdoc */
@Override
protected String updateKeyAfterInsert(CollectionActivity entity, long rowId) {
return entity.getUuid_collection_activity();
}
/** @inheritdoc */
@Override
public String getKey(CollectionActivity entity) {
if(entity != null) {
return entity.getUuid_collection_activity();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}

View file

@ -0,0 +1,750 @@
package lib.gegemobile.gddlibrary;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
public class GoogleDirection {
public final static String MODE_DRIVING = "driving";
public final static String MODE_WALKING = "walking";
public final static String MODE_BICYCLING = "bicycling";
public final static String STATUS_OK = "OK";
public final static String STATUS_NOT_FOUND = "NOT_FOUND";
public final static String STATUS_ZERO_RESULTS = "ZERO_RESULTS";
public final static String STATUS_MAX_WAYPOINTS_EXCEEDED = "MAX_WAYPOINTS_EXCEEDED";
public final static String STATUS_INVALID_REQUEST = "INVALID_REQUEST";
public final static String STATUS_OVER_QUERY_LIMIT = "OVER_QUERY_LIMIT";
public final static String STATUS_REQUEST_DENIED = "REQUEST_DENIED";
public final static String STATUS_UNKNOWN_ERROR = "UNKNOWN_ERROR";
public final static int SPEED_VERY_FAST = 1;
public final static int SPEED_FAST = 2;
public final static int SPEED_NORMAL = 3;
public final static int SPEED_SLOW = 4;
public final static int SPEED_VERY_SLOW = 5;
private OnDirectionResponseListener mDirectionListener = null;
private OnAnimateListener mAnimateListener = null;
private boolean isLogging = false;
private LatLng animateMarkerPosition = null;
private LatLng beginPosition = null;
private LatLng endPosition = null;
private ArrayList<LatLng> animatePositionList = null;
private Marker animateMarker = null;
private Polyline animateLine = null;
private GoogleMap gm = null;
private int step = -1;
private int animateSpeed = -1;
private int zoom = -1;
private double animateDistance = -1;
private double animateCamera = -1;
private double totalAnimateDistance = 0;
private boolean cameraLock = false;
private boolean drawMarker = false;
private boolean drawLine = false;
private boolean flatMarker = false;
private boolean isCameraTilt = false;
private boolean isCameraZoom = false;
private boolean isAnimated = false;
private Context mContext = null;
private Runnable r = new Runnable() {
public void run() {
animateMarkerPosition = getNewPosition(animateMarkerPosition, endPosition);
if (drawMarker)
animateMarker.setPosition(animateMarkerPosition);
if (drawLine) {
List<LatLng> points = animateLine.getPoints();
points.add(animateMarkerPosition);
animateLine.setPoints(points);
}
if ((animateMarkerPosition.latitude == endPosition.latitude
&& animateMarkerPosition.longitude == endPosition.longitude)) {
if (step == animatePositionList.size() - 2) {
isAnimated = false;
totalAnimateDistance = 0;
if (mAnimateListener != null)
mAnimateListener.onFinish();
} else {
step++;
beginPosition = animatePositionList.get(step);
endPosition = animatePositionList.get(step + 1);
animateMarkerPosition = beginPosition;
if (flatMarker && step + 3 < animatePositionList.size() - 1) {
float rotation = getBearing(animateMarkerPosition, animatePositionList.get(step + 3)) + 180;
animateMarker.setRotation(rotation);
}
if (mAnimateListener != null)
mAnimateListener.onProgress(step, animatePositionList.size());
}
}
if (cameraLock && (totalAnimateDistance > animateCamera || !isAnimated)) {
totalAnimateDistance = 0;
float bearing = getBearing(beginPosition, endPosition);
CameraPosition.Builder cameraBuilder = new CameraPosition.Builder()
.target(animateMarkerPosition).bearing(bearing);
if (isCameraTilt)
cameraBuilder.tilt(90);
else
cameraBuilder.tilt(gm.getCameraPosition().tilt);
if (isCameraZoom)
cameraBuilder.zoom(zoom);
else
cameraBuilder.zoom(gm.getCameraPosition().zoom);
CameraPosition cameraPosition = cameraBuilder.build();
gm.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
if (isAnimated) {
new Handler().postDelayed(r, animateSpeed);
}
}
};
public GoogleDirection(Context context) {
mContext = context;
}
public String request(LatLng start, LatLng end, String mode, boolean isAvoidTools) {
StringBuffer sb = new StringBuffer();
sb.append("http://maps.googleapis.com/maps/api/directions/xml?"
+ "origin=" + start.latitude + "," + start.longitude
+ "&destination=" + end.latitude + "," + end.longitude);
if (isAvoidTools)
sb.append("&avoid=tolls");
sb.append("&sensor=false&units=metric&mode=" + mode);
final String url = sb.toString();
if (isLogging)
Log.i("GoogleDirection", "URL : " + url);
new RequestTask().execute(new String[]{url});
return url;
}
public String request(LatLng start, LatLng end, List<LatLng> waypoints,
String mode, boolean isAvoidTools) {
//avoid=tolls
StringBuffer sb = new StringBuffer();
sb.append("https://maps.googleapis.com/maps/api/directions/xml?"
+ "origin=" + start.latitude + "," + start.longitude
+ "&destination=" + end.latitude + "," + end.longitude);
if (waypoints.size() > 0) {
sb.append("&waypoints=optimize:true");
StringBuffer sbwpoint = new StringBuffer();
sbwpoint.append("|");
for (int i = 0; i < waypoints.size(); i++) {
LatLng ltg = waypoints.get(i);
sbwpoint.append(ltg.latitude + "," + ltg.longitude);
if (i != waypoints.size() - 1)
sbwpoint.append("|");
}
try {
sb.append(URLEncoder.encode(sbwpoint.toString(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (isAvoidTools)
sb.append("&avoid=tolls");
sb.append("&sensor=false&units=metric&mode=" + mode);
final String url = sb.toString();
if (isLogging)
Log.i("GoogleDirection", "URL : " + url);
new RequestTask().execute(new String[]{url});
return url;
}
public void setLogging(boolean state) {
isLogging = state;
}
public String getStatus(Document doc) {
NodeList nl1 = doc.getElementsByTagName("status");
Node node1 = nl1.item(0);
if (isLogging)
Log.i("GoogleDirection", "Status : " + node1.getTextContent());
return node1.getTextContent();
}
public String[] getDurationText(Document doc) {
NodeList nl1 = doc.getElementsByTagName("duration");
String[] arr_str = new String[nl1.getLength() - 1];
for (int i = 0; i < nl1.getLength() - 1; i++) {
Node node1 = nl1.item(i);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "text"));
arr_str[i] = node2.getTextContent();
if (isLogging)
Log.i("GoogleDirection", "DurationText : " + node2.getTextContent());
}
return arr_str;
}
public int[] getDurationValue(Document doc) {
NodeList nl1 = doc.getElementsByTagName("duration");
int[] arr_int = new int[nl1.getLength() - 1];
for (int i = 0; i < nl1.getLength() - 1; i++) {
Node node1 = nl1.item(i);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
arr_int[i] = Integer.parseInt(node2.getTextContent());
if (isLogging)
Log.i("GoogleDirection", "Duration : " + node2.getTextContent());
}
return arr_int;
}
public int[] getDurationLegsValue(Document doc) {
NodeList nl0 = doc.getElementsByTagName("leg");
int[] arr_int0 = new int[nl0.getLength()];
for (int j = 0; j < nl0.getLength(); j++) {
Node node0 = nl0.item(j);
NodeList nl01 = node0.getChildNodes();
Node nl1 = nl01.item(getNodeIndex(nl01, "duration"));
NodeList nl2 = nl1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
arr_int0[j] = Integer.parseInt(node2.getTextContent());
}
return arr_int0;
}
public int[] getDistanceLegsValue(Document doc) {
NodeList nl0 = doc.getElementsByTagName("leg");
int[] arr_int0 = new int[nl0.getLength()];
for (int j = 0; j < nl0.getLength(); j++) {
Node node0 = nl0.item(j);
NodeList nl01 = node0.getChildNodes();
Node nl1 = nl01.item(getNodeIndex(nl01, "distance"));
NodeList nl2 = nl1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
arr_int0[j] = Integer.parseInt(node2.getTextContent());
}
return arr_int0;
}
public String getAllTotalDistanceText(Document doc) {
int[] alldistance = getDistanceLegsValue(doc);
int sum = 0;
for (int i = 0; i < alldistance.length; i++) {
sum += alldistance[i];
}
double sec = sum / 1000;
int margin = sum % 1000;
double total = sec + Double.parseDouble("0." + margin);
String time = " : " + total + " km";
return time;
}
public String getAllTotalDurationText(Document doc) {
int[] allduration = getDurationLegsValue(doc);
int sum = 0;
for (int i = 0; i < allduration.length; i++) {
sum += allduration[i];
}
int count = sum % 60;
if (count > 30) sum += 60;
int sec = sum / 60;
String time = " : " + sec + " min";
return time;
}
public String getTotalDurationText(Document doc) {
NodeList nl1 = doc.getElementsByTagName("duration");
Node node1 = nl1.item(nl1.getLength() - 1);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "text"));
if (isLogging)
Log.i("GoogleDirection", "TotalDuration : " + node2.getTextContent());
return node2.getTextContent();
}
public int getTotalDurationValue(Document doc) {
NodeList nl1 = doc.getElementsByTagName("duration");
Node node1 = nl1.item(nl1.getLength() - 1);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
if (isLogging)
Log.i("GoogleDirection", "TotalDuration : " + node2.getTextContent());
return Integer.parseInt(node2.getTextContent());
}
public String[] getDistanceText(Document doc) {
NodeList nl1 = doc.getElementsByTagName("distance");
String[] arr_str = new String[nl1.getLength() - 1];
for (int i = 0; i < nl1.getLength() - 1; i++) {
Node node1 = nl1.item(i);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "text"));
arr_str[i] = node2.getTextContent();
if (isLogging)
Log.i("GoogleDirection", "DurationText : " + node2.getTextContent());
}
return arr_str;
}
public int[] getDistanceValue(Document doc) {
NodeList nl1 = doc.getElementsByTagName("distance");
int[] arr_int = new int[nl1.getLength() - 1];
for (int i = 0; i < nl1.getLength() - 1; i++) {
Node node1 = nl1.item(i);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
arr_int[i] = Integer.parseInt(node2.getTextContent());
if (isLogging)
Log.i("GoogleDirection", "Duration : " + node2.getTextContent());
}
return arr_int;
}
public int[] getWaypointOrder(Document doc) {
NodeList nl1 = doc.getElementsByTagName("waypoint_index");
int[] arr_int = new int[nl1.getLength()];
for (int i = 0; i < nl1.getLength(); i++) {
Node node1 = nl1.item(i);
arr_int[i] = Integer.parseInt(node1.getTextContent());
if (isLogging)
Log.i("GoogleDirection", "Waypoint : " + node1.getTextContent());
}
return arr_int;
}
public String getTotalDistanceText(Document doc) {
NodeList nl1 = doc.getElementsByTagName("distance");
Node node1 = nl1.item(nl1.getLength() - 1);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "text"));
if (isLogging)
Log.i("GoogleDirection", "TotalDuration : " + node2.getTextContent());
return node2.getTextContent();
}
public int getTotalDistanceValue(Document doc) {
NodeList nl1 = doc.getElementsByTagName("distance");
Node node1 = nl1.item(nl1.getLength() - 1);
NodeList nl2 = node1.getChildNodes();
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
if (isLogging)
Log.i("GoogleDirection", "TotalDuration : " + node2.getTextContent());
return Integer.parseInt(node2.getTextContent());
}
public String getStartAddress(Document doc) {
NodeList nl1 = doc.getElementsByTagName("start_address");
Node node1 = nl1.item(0);
if (isLogging)
Log.i("GoogleDirection", "StartAddress : " + node1.getTextContent());
return node1.getTextContent();
}
public String getEndAddress(Document doc) {
NodeList nl1 = doc.getElementsByTagName("end_address");
Node node1 = nl1.item(0);
if (isLogging)
Log.i("GoogleDirection", "StartAddress : " + node1.getTextContent());
return node1.getTextContent();
}
public String getCopyRights(Document doc) {
NodeList nl1 = doc.getElementsByTagName("copyrights");
Node node1 = nl1.item(0);
if (isLogging)
Log.i("GoogleDirection", "CopyRights : " + node1.getTextContent());
return node1.getTextContent();
}
public ArrayList<LatLng> getDirection(Document doc) {
NodeList nl1, nl2, nl3;
ArrayList<LatLng> listGeopoints = new ArrayList<LatLng>();
nl1 = doc.getElementsByTagName("step");
if (nl1.getLength() > 0) {
for (int i = 0; i < nl1.getLength(); i++) {
Node node1 = nl1.item(i);
nl2 = node1.getChildNodes();
Node locationNode = nl2.item(getNodeIndex(nl2, "start_location"));
nl3 = locationNode.getChildNodes();
Node latNode = nl3.item(getNodeIndex(nl3, "lat"));
double lat = Double.parseDouble(latNode.getTextContent());
Node lngNode = nl3.item(getNodeIndex(nl3, "lng"));
double lng = Double.parseDouble(lngNode.getTextContent());
listGeopoints.add(new LatLng(lat, lng));
locationNode = nl2.item(getNodeIndex(nl2, "polyline"));
nl3 = locationNode.getChildNodes();
latNode = nl3.item(getNodeIndex(nl3, "points"));
ArrayList<LatLng> arr = decodePoly(latNode.getTextContent());
for (int j = 0; j < arr.size(); j++) {
listGeopoints.add(new LatLng(arr.get(j).latitude
, arr.get(j).longitude));
}
locationNode = nl2.item(getNodeIndex(nl2, "end_location"));
nl3 = locationNode.getChildNodes();
latNode = nl3.item(getNodeIndex(nl3, "lat"));
lat = Double.parseDouble(latNode.getTextContent());
lngNode = nl3.item(getNodeIndex(nl3, "lng"));
lng = Double.parseDouble(lngNode.getTextContent());
listGeopoints.add(new LatLng(lat, lng));
}
}
return listGeopoints;
}
public ArrayList<LatLng> getSection(Document doc) {
NodeList nl1, nl2, nl3;
ArrayList<LatLng> listGeopoints = new ArrayList<LatLng>();
nl1 = doc.getElementsByTagName("step");
if (nl1.getLength() > 0) {
for (int i = 0; i < nl1.getLength(); i++) {
Node node1 = nl1.item(i);
nl2 = node1.getChildNodes();
Node locationNode = nl2.item(getNodeIndex(nl2, "end_location"));
nl3 = locationNode.getChildNodes();
Node latNode = nl3.item(getNodeIndex(nl3, "lat"));
double lat = Double.parseDouble(latNode.getTextContent());
Node lngNode = nl3.item(getNodeIndex(nl3, "lng"));
double lng = Double.parseDouble(lngNode.getTextContent());
listGeopoints.add(new LatLng(lat, lng));
}
}
return listGeopoints;
}
public PolylineOptions getPolyline(Document doc, int width, int color) {
ArrayList<LatLng> arr_pos = getDirection(doc);
PolylineOptions rectLine = new PolylineOptions().width(dpToPx(width)).color(color);
for (int i = 0; i < arr_pos.size(); i++)
rectLine.add(arr_pos.get(i));
return rectLine;
}
private int getNodeIndex(NodeList nl, String nodename) {
for (int i = 0; i < nl.getLength(); i++) {
if (nl.item(i).getNodeName().equals(nodename))
return i;
}
return -1;
}
private ArrayList<LatLng> decodePoly(String encoded) {
ArrayList<LatLng> poly = new ArrayList<LatLng>();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
LatLng position = new LatLng((double) lat / 1E5, (double) lng / 1E5);
poly.add(position);
}
return poly;
}
private int dpToPx(int dp) {
DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
return px;
}
public void setOnDirectionResponseListener(OnDirectionResponseListener listener) {
mDirectionListener = listener;
}
public void setOnAnimateListener(OnAnimateListener listener) {
mAnimateListener = listener;
}
public void animateDirection(GoogleMap gm, ArrayList<LatLng> direction, int speed
, boolean cameraLock, boolean isCameraTilt, boolean isCameraZoom
, boolean drawMarker, MarkerOptions mo, boolean flatMarker
, boolean drawLine, PolylineOptions po) {
if (direction.size() > 1) {
isAnimated = true;
animatePositionList = direction;
animateSpeed = speed;
this.drawMarker = drawMarker;
this.drawLine = drawLine;
this.flatMarker = flatMarker;
this.isCameraTilt = isCameraTilt;
this.isCameraZoom = isCameraZoom;
step = 0;
this.cameraLock = cameraLock;
this.gm = gm;
setCameraUpdateSpeed(speed);
beginPosition = animatePositionList.get(step);
endPosition = animatePositionList.get(step + 1);
animateMarkerPosition = beginPosition;
if (mAnimateListener != null)
mAnimateListener.onProgress(step, animatePositionList.size());
if (cameraLock) {
float bearing = getBearing(beginPosition, endPosition);
CameraPosition.Builder cameraBuilder = new CameraPosition.Builder()
.target(animateMarkerPosition).bearing(bearing);
if (isCameraTilt)
cameraBuilder.tilt(90);
else
cameraBuilder.tilt(gm.getCameraPosition().tilt);
if (isCameraZoom)
cameraBuilder.zoom(zoom);
else
cameraBuilder.zoom(gm.getCameraPosition().zoom);
CameraPosition cameraPosition = cameraBuilder.build();
gm.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
if (drawMarker) {
if (mo != null)
animateMarker = gm.addMarker(mo.position(beginPosition));
else
animateMarker = gm.addMarker(new MarkerOptions().position(beginPosition));
if (flatMarker) {
animateMarker.setFlat(true);
float rotation = getBearing(animateMarkerPosition, endPosition) + 180;
animateMarker.setRotation(rotation);
}
}
if (drawLine) {
if (po != null)
animateLine = gm.addPolyline(po.add(beginPosition)
.add(beginPosition).add(endPosition)
.width(dpToPx((int) po.getWidth())));
else
animateLine = gm.addPolyline(new PolylineOptions()
.width(dpToPx(5)));
}
new Handler().postDelayed(r, speed);
if (mAnimateListener != null)
mAnimateListener.onStart();
}
}
public void cancelAnimated() {
isAnimated = false;
}
public boolean isAnimated() {
return isAnimated;
}
public Marker getAnimateMarker() {
return animateMarker;
}
public Polyline getAnimatePolyline() {
return animateLine;
}
private LatLng getNewPosition(LatLng begin, LatLng end) {
double lat = Math.abs(begin.latitude - end.latitude);
double lng = Math.abs(begin.longitude - end.longitude);
double dis = Math.sqrt(Math.pow(lat, 2) + Math.pow(lng, 2));
if (dis >= animateDistance) {
double angle = -1;
if (begin.latitude <= end.latitude && begin.longitude <= end.longitude)
angle = Math.toDegrees(Math.atan(lng / lat));
else if (begin.latitude > end.latitude && begin.longitude <= end.longitude)
angle = (90 - Math.toDegrees(Math.atan(lng / lat))) + 90;
else if (begin.latitude > end.latitude && begin.longitude > end.longitude)
angle = Math.toDegrees(Math.atan(lng / lat)) + 180;
else if (begin.latitude <= end.latitude && begin.longitude > end.longitude)
angle = (90 - Math.toDegrees(Math.atan(lng / lat))) + 270;
double x = Math.cos(Math.toRadians(angle)) * animateDistance;
double y = Math.sin(Math.toRadians(angle)) * animateDistance;
totalAnimateDistance += animateDistance;
double finalLat = begin.latitude + x;
double finalLng = begin.longitude + y;
return new LatLng(finalLat, finalLng);
} else {
return end;
}
}
private float getBearing(LatLng begin, LatLng end) {
double lat = Math.abs(begin.latitude - end.latitude);
double lng = Math.abs(begin.longitude - end.longitude);
if (begin.latitude < end.latitude && begin.longitude < end.longitude)
return (float) (Math.toDegrees(Math.atan(lng / lat)));
else if (begin.latitude >= end.latitude && begin.longitude < end.longitude)
return (float) ((90 - Math.toDegrees(Math.atan(lng / lat))) + 90);
else if (begin.latitude >= end.latitude && begin.longitude >= end.longitude)
return (float) (Math.toDegrees(Math.atan(lng / lat)) + 180);
else if (begin.latitude < end.latitude && begin.longitude >= end.longitude)
return (float) ((90 - Math.toDegrees(Math.atan(lng / lat))) + 270);
return -1;
}
public void setCameraUpdateSpeed(int speed) {
if (speed == SPEED_VERY_SLOW) {
animateDistance = 0.000005;
animateSpeed = 20;
animateCamera = 0.0004;
zoom = 19;
} else if (speed == SPEED_SLOW) {
animateDistance = 0.00001;
animateSpeed = 20;
animateCamera = 0.0008;
zoom = 18;
} else if (speed == SPEED_NORMAL) {
animateDistance = 0.00005;
animateSpeed = 20;
animateCamera = 0.002;
zoom = 16;
} else if (speed == SPEED_FAST) {
animateDistance = 0.0001;
animateSpeed = 20;
animateCamera = 0.004;
zoom = 15;
} else if (speed == SPEED_VERY_FAST) {
animateDistance = 0.0005;
animateSpeed = 20;
animateCamera = 0.004;
zoom = 13;
} else {
animateDistance = 0.00005;
animateSpeed = 20;
animateCamera = 0.002;
zoom = 16;
}
}
public interface OnDirectionResponseListener {
public void onResponse(String status, Document doc, GoogleDirection gd);
}
public interface OnAnimateListener {
public void onFinish();
public void onStart();
public void onProgress(int progress, int total);
}
private class RequestTask extends AsyncTask<String, Void, Document> {
protected Document doInBackground(String... url) {
try {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(url[0]);
HttpResponse response = httpClient.execute(httpPost, localContext);
InputStream in = response.getEntity().getContent();
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
return builder.parse(in);
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Document doc) {
super.onPostExecute(doc);
if (mDirectionListener != null)
mDirectionListener.onResponse(getStatus(doc), doc, GoogleDirection.this);
}
private String getStatus(Document doc) {
NodeList nl1 = doc.getElementsByTagName("status");
Node node1 = nl1.item(0);
if (isLogging)
Log.i("GoogleDirection", "Status : " + node1.getTextContent());
return node1.getTextContent();
}
}
}

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" >
<shape>
<solid
android:color="@android:color/darker_gray" />
<stroke
android:width="2dp"
android:color="@android:color/transparent" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:state_pressed="true" >
<shape>
<solid
android:color="@color/ab_end" />
<stroke
android:width="2dp"
android:color="@android:color/transparent" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:startColor="@color/gradient_start"
android:endColor="@color/gradient_end"
android:angle="270" />
<stroke
android:width="2dp"
android:color="@android:color/transparent" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>