Skip to content

Commit

Permalink
- Finish core order status
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Torres committed Mar 11, 2016
1 parent 274d570 commit d3a1d49
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 52 deletions.
24 changes: 18 additions & 6 deletions app/src/main/java/com/bentonow/bentonow/Utils/BentoRestClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bentonow.bentonow.Utils;

import android.location.Location;
import android.os.Looper;

import com.bentonow.bentonow.R;
import com.bentonow.bentonow.controllers.BentoApplication;
Expand All @@ -10,6 +11,7 @@
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.SyncHttpClient;

import java.io.IOException;
import java.net.Socket;
Expand All @@ -31,7 +33,8 @@ public class BentoRestClient {
static final String TAG = "BentoRestClient";
//static final String BASE_URL = BuildConfig.DEBUG ? "https://api2.dev.bentonow.com" : "https://api2.bentonow.com";
static final String BASE_URL = BentoApplication.instance.getString(R.string.server_api_url);
static AsyncHttpClient client = new AsyncHttpClient();
public static AsyncHttpClient syncHttpClient= new SyncHttpClient();
public static AsyncHttpClient asyncHttpClient = new AsyncHttpClient();

public static void init() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException, UnrecoverableKeyException, KeyManagementException {
// We initialize a default Keystore
Expand All @@ -43,31 +46,40 @@ public static void init() throws KeyStoreException, CertificateException, NoSuch
// We set that all host names are allowed in the socket factory
socketFactory.setHostnameVerifier(CustomSSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
// We set the SSL Factory
client.setSSLSocketFactory(socketFactory);
getClient().setSSLSocketFactory(socketFactory);
}


private static AsyncHttpClient getClient()
{
// Return the synchronous HTTP client when the thread is not prepared
if (Looper.myLooper() == null)
return syncHttpClient;
return asyncHttpClient;
}

public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
DebugUtils.logDebug(TAG, "[GET] " + getAbsoluteUrl(url));
DebugUtils.logDebug(TAG, "[params] " + (params != null ? params.toString() : "null"));
client.get(getAbsoluteUrl(url), params, responseHandler);
getClient().get(getAbsoluteUrl(url), params, responseHandler);
}

public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
DebugUtils.logDebug(TAG, "[POST] " + getAbsoluteUrl(url));
DebugUtils.logDebug(TAG, "[params] " + (params != null ? params.toString() : "null"));
client.post(getAbsoluteUrl(url), params, responseHandler);
getClient().post(getAbsoluteUrl(url), params, responseHandler);
}

public static void getCustom(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
DebugUtils.logDebug(TAG, "[GET] " + url);
DebugUtils.logDebug(TAG, "[params] " + (params != null ? params.toString() : "null"));
client.get(url, params, responseHandler);
getClient().get(url, params, responseHandler);
}

public static void getDirections(double dOriginLat, double dOriginLong, String dEndLat, String dEndLong, AsyncHttpResponseHandler responseHandler) {
String sUrl = BentoNowApi.getUrlGoogleDirections(dOriginLat, dOriginLong, dEndLat, dEndLong);
DebugUtils.logDebug(TAG, "[GET] " + sUrl);
client.get(sUrl, null, responseHandler);
getClient().get(sUrl, null, responseHandler);
}

private static String getAbsoluteUrl(String relativeUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class SharedPreferencesUtil {
public static final String SHOW_NOTIFICATIONS = "SHOW_NOTIFICATIONS"; //boolean
public static final String ALREADY_SHOW_NOTIFICATIONS = "ALREADY_SHOW_NOTIFICATIONS"; //boolean
public static final String ORDER_AHEAD_SUBSCRIPTION = "ORDER_AHEAD_SUBSCRIPTION"; //boolean
public static final String ORDER_HISTORY_FORCE_REFRESH = "ORDER_HISTORY_FORCE_REFRESH"; //boolean

//DATA FROM SERVER
public static final String BACKENDTEXT = "backendText"; //String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public static String getFullAddress(Address mAddress) {
return sAddress;
}

public static String getStringSecondsLeft(int iSeconds) {
int hours = iSeconds / 3600;
int minutes = (iSeconds % 3600) / 60;
int seconds = iSeconds % 60;

return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}

public static String getStreetAddress(Address mAddress) {
if (mAddress == null) return "";
return mAddress.getThoroughfare() + ", " + mAddress.getSubThoroughfare();
Expand Down Expand Up @@ -207,7 +215,7 @@ public static ArrayList<LatLng> decodePoly(String encoded) {
lng += dlng;
dLat = ((double) lat / 1E5);
dLng = ((double) lng / 1E5);
// DebugUtils.logDebug(TAG, "Latitude:: " + dLat + " Longitude:: " + dLng);
// DebugUtils.logDebug(TAG, "Latitude:: " + dLat + " Longitude:: " + dLng);
LatLng p = new LatLng(dLat, dLng);
poly.add(p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;

import com.bentonow.bentonow.R;
import com.bentonow.bentonow.Utils.AndroidUtil;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.nineoldandroids.animation.ObjectAnimator;
Expand Down Expand Up @@ -69,8 +71,9 @@ public void onAnimationUpdate(ValueAnimator animation) {
}

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static void animateMarkerToICS(Marker marker, LatLng finalPosition, float fRotation, int duration, final LatLngInterpolator latLngInterpolator) {
public static void animateMarkerToICS(Marker marker, LatLng finalPosition, float fRotation, final LatLngInterpolator latLngInterpolator) {
marker.setRotation(fRotation);

TypeEvaluator<LatLng> typeEvaluator = new TypeEvaluator<LatLng>() {
@Override
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
Expand All @@ -79,7 +82,7 @@ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
};
Property<Marker, LatLng> property = Property.of(Marker.class, LatLng.class, "position");
ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition);
animator.setDuration(duration);
animator.setDuration(2000);
animator.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public void onRefresh() {
@Override
protected void onResume() {
GoogleAnalyticsUtil.sendScreenView("Order History");

if (SharedPreferencesUtil.getBooleanPreference(SharedPreferencesUtil.ORDER_HISTORY_FORCE_REFRESH)) {
getOrderHistoryByUser();
SharedPreferencesUtil.setAppPreference(SharedPreferencesUtil.ORDER_HISTORY_FORCE_REFRESH, false);
}

super.onResume();
}

Expand Down
Loading

0 comments on commit d3a1d49

Please sign in to comment.