// Path: app/src/main/java/clock/socoolby/com/clock/ClockApplication.java
// public class ClockApplication extends Application {
// 
//     private static ClockApplication sEndzoneBoxApp;
//     private BusinessService mBusinessService = new BusinessService();
// 
//     public static ClockApplication getInstance() {
//         return sEndzoneBoxApp;
//     }
// 
//     @Override
//     public void onCreate() {
//         sEndzoneBoxApp = this;
//         init();
//         super.onCreate();
//     }
// 
// 
//     public void init() {
//         if (!FileUtils.isExistsFile(Constants.SHARE_PERFERENCE_FILE)) {
//             SharePerferenceModel model = new SharePerferenceModel();
//             model.setTypeHourPower(Constants.TALKING_HALF_AN_HOUR);
//             DateModel startTimeModel = new DateModel();
//             startTimeModel.setTime(12, 31);
//             DateModel stopTimeModel = new DateModel();
//             stopTimeModel.setTime(14, 31);
//             model.setStartHourPowerTime(startTimeModel);
//             model.setStopHourPowerTime(stopTimeModel);
//             model.setCity(getString(R.string.shenzhen));
//             model.save();
//         }
//     }
// 
//     public static Context getContext() {
//         return ClockApplication.getInstance().getApplicationContext();
//     }
// 
//     public BusinessService getBusinessService() {
//         return mBusinessService;
//     }
// 
//     private MainActivity mMainActivity;
// 
//     public void setMainActivity(MainActivity mainActivity) {
//         this.mMainActivity = mainActivity;
//     }
// 
//     public MainActivity getMainActivity() {
//         return mMainActivity;
//     }
// 
// }
// 
// Path: app/src/main/java/clock/socoolby/com/clock/protocol/RequestBase.java
// public abstract class RequestBase {
//     RequestBase() {
//     }
// 
//     public String getUrl() {
//         return "";
//     }
// 
//     public JSONObject createRequest() {
//         JSONObject object = new JSONObject();
//         try {
//             buildRequest(object);
//         } catch (JSONException e) {
//             e.printStackTrace();
//         }
//         return object;
//     }
// 
//     protected abstract void buildRequest(JSONObject object) throws JSONException;
// }


import android.util.Log;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.protocol.RequestBase;

package clock.socoolby.com.clock.utils;






public final class NetworkService {
    private static NetworkService mInstance;
    private RequestQueue mRequestQueue;

    private DefaultRetryPolicy mRetryPolicy;


    private NetworkService() {
        mRequestQueue = getRequestQueue();
    }

    private final static String TAG = "NetworkService";

    public static synchronized NetworkService getInstance() {
        if (mInstance == null) {
            mInstance = new NetworkService();
        }
        return mInstance;
    }

    private RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue =
                    Volley.newRequestQueue(ClockApplication.getContext());
        }
        return mRequestQueue;
    }


    private void setRequestTimeout(int ms) {
        int timeout = (ms == 0) ? DefaultRetryPolicy.DEFAULT_TIMEOUT_MS : ms;

        mRetryPolicy = new DefaultRetryPolicy(timeout,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    }



// Path: app/src/main/java/clock/socoolby/com/clock/ClockApplication.java
// public class ClockApplication extends Application {
// 
//     private static ClockApplication sEndzoneBoxApp;
//     private BusinessService mBusinessService = new BusinessService();
// 
//     public static ClockApplication getInstance() {
//         return sEndzoneBoxApp;
//     }
// 
//     @Override
//     public void onCreate() {
//         sEndzoneBoxApp = this;
//         init();
//         super.onCreate();
//     }
// 
// 
//     public void init() {
//         if (!FileUtils.isExistsFile(Constants.SHARE_PERFERENCE_FILE)) {
//             SharePerferenceModel model = new SharePerferenceModel();
//             model.setTypeHourPower(Constants.TALKING_HALF_AN_HOUR);
//             DateModel startTimeModel = new DateModel();
//             startTimeModel.setTime(12, 31);
//             DateModel stopTimeModel = new DateModel();
//             stopTimeModel.setTime(14, 31);
//             model.setStartHourPowerTime(startTimeModel);
//             model.setStopHourPowerTime(stopTimeModel);
//             model.setCity(getString(R.string.shenzhen));
//             model.save();
//         }
//     }
// 
//     public static Context getContext() {
//         return ClockApplication.getInstance().getApplicationContext();
//     }
// 
//     public BusinessService getBusinessService() {
//         return mBusinessService;
//     }
// 
//     private MainActivity mMainActivity;
// 
//     public void setMainActivity(MainActivity mainActivity) {
//         this.mMainActivity = mainActivity;
//     }
// 
//     public MainActivity getMainActivity() {
//         return mMainActivity;
//     }
// 
// }
// 
// Path: app/src/main/java/clock/socoolby/com/clock/protocol/RequestBase.java
// public abstract class RequestBase {
//     RequestBase() {
//     }
// 
//     public String getUrl() {
//         return "";
//     }
// 
//     public JSONObject createRequest() {
//         JSONObject object = new JSONObject();
//         try {
//             buildRequest(object);
//         } catch (JSONException e) {
//             e.printStackTrace();
//         }
//         return object;
//     }
// 
//     protected abstract void buildRequest(JSONObject object) throws JSONException;
// }


// Path: app/src/main/java/clock/socoolby/com/clock/utils/NetworkService.java
import android.util.Log;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.protocol.RequestBase;

package clock.socoolby.com.clock.utils;






public final class NetworkService {
    private static NetworkService mInstance;
    private RequestQueue mRequestQueue;

    private DefaultRetryPolicy mRetryPolicy;


    private NetworkService() {
        mRequestQueue = getRequestQueue();
    }

    private final static String TAG = "NetworkService";

    public static synchronized NetworkService getInstance() {
        if (mInstance == null) {
            mInstance = new NetworkService();
        }
        return mInstance;
    }

    private RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue =
                    Volley.newRequestQueue(ClockApplication.getContext());
        }
        return mRequestQueue;
    }


    private void setRequestTimeout(int ms) {
        int timeout = (ms == 0) ? DefaultRetryPolicy.DEFAULT_TIMEOUT_MS : ms;

        mRetryPolicy = new DefaultRetryPolicy(timeout,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    }



    public boolean sendRequest(RequestBase request, final RequestListener listener) {
