// Path: app/src/main/java/org/emoncms/myapps/HTTPClient.java
// public class HTTPClient
// {
//     private static HTTPClient mInstance;
//     private RequestQueue mRequestQueue;
//     private static Context mCtx;
// 
//     private HTTPClient(Context context) {
//         mCtx = context;
//         mRequestQueue = getRequestQueue();
//     }
// 
//     public static synchronized HTTPClient getInstance(Context context) {
//         if (mInstance == null) {
//             mInstance = new HTTPClient(context);
//         }
//         return mInstance;
//     }
// 
//     public RequestQueue getRequestQueue() {
//         if (mRequestQueue == null) {
//             // getApplicationContext() is key, it keeps you from leaking the
//             // Activity or BroadcastReceiver if someone passes one in.
//             mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
//             mRequestQueue.getCache().clear();
//         }
//         return mRequestQueue;
//     }
// 
//     public void cancellAll(String TAG) {
//         if (mRequestQueue != null) {
//             mRequestQueue.cancelAll(TAG);
//         }
//     }
// 
//     public <T> void addToRequestQueue(Request<T> req) {
//         req.setShouldCache(false);
//         req.setRetryPolicy(new DefaultRetryPolicy(2500, 0, 1f));
//         getRequestQueue().add(req);
//     }
// }


import android.content.Context;
import android.util.Log;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import org.emoncms.myapps.HTTPClient;
import org.emoncms.myapps.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

                                if (watt_default_feed_name.equals(row.getString("name"))) {
                                    wattFeedId = row.getInt("id");
                                }

                                if (kwh_default_feed_name.equals(row.getString("name"))) {
                                    kWhFeelId = row.getInt("id");
                                }

                                if (wattFeedId >= 0 && kWhFeelId >= 0) {
                                    myElectricDataManager.setFeedIds(wattFeedId, kWhFeelId);
                                    myElectricDataManager.loadPowerNow(0);
                                    return;
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }

                        myElectricDataManager.showMessage(R.string.me_not_configured_text);
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        myElectricDataManager.showMessage(R.string.feed_download_error_message);
                        myElectricDataManager.loadFeeds(5000);
                    }
                });
        jsArrayRequest.setTag(myElectricDataManager.getPageTag());
// Path: app/src/main/java/org/emoncms/myapps/HTTPClient.java
// public class HTTPClient
// {
//     private static HTTPClient mInstance;
//     private RequestQueue mRequestQueue;
//     private static Context mCtx;
// 
//     private HTTPClient(Context context) {
//         mCtx = context;
//         mRequestQueue = getRequestQueue();
//     }
// 
//     public static synchronized HTTPClient getInstance(Context context) {
//         if (mInstance == null) {
//             mInstance = new HTTPClient(context);
//         }
//         return mInstance;
//     }
// 
//     public RequestQueue getRequestQueue() {
//         if (mRequestQueue == null) {
//             // getApplicationContext() is key, it keeps you from leaking the
//             // Activity or BroadcastReceiver if someone passes one in.
//             mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
//             mRequestQueue.getCache().clear();
//         }
//         return mRequestQueue;
//     }
// 
//     public void cancellAll(String TAG) {
//         if (mRequestQueue != null) {
//             mRequestQueue.cancelAll(TAG);
//         }
//     }
// 
//     public <T> void addToRequestQueue(Request<T> req) {
//         req.setShouldCache(false);
//         req.setRetryPolicy(new DefaultRetryPolicy(2500, 0, 1f));
//         getRequestQueue().add(req);
//     }
// }


// Path: app/src/main/java/org/emoncms/myapps/chart/FeedDataLoader.java
import android.content.Context;
import android.util.Log;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import org.emoncms.myapps.HTTPClient;
import org.emoncms.myapps.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


                                if (watt_default_feed_name.equals(row.getString("name"))) {
                                    wattFeedId = row.getInt("id");
                                }

                                if (kwh_default_feed_name.equals(row.getString("name"))) {
                                    kWhFeelId = row.getInt("id");
                                }

                                if (wattFeedId >= 0 && kWhFeelId >= 0) {
                                    myElectricDataManager.setFeedIds(wattFeedId, kWhFeelId);
                                    myElectricDataManager.loadPowerNow(0);
                                    return;
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }

                        myElectricDataManager.showMessage(R.string.me_not_configured_text);
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        myElectricDataManager.showMessage(R.string.feed_download_error_message);
                        myElectricDataManager.loadFeeds(5000);
                    }
                });
        jsArrayRequest.setTag(myElectricDataManager.getPageTag());
        HTTPClient.getInstance(context).addToRequestQueue(jsArrayRequest);