Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
#823 - Building request method
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Feb 25, 2015
1 parent 885185b commit 2bfafad
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package com.mapbox.mapboxgl.lib.util;

import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;

public class JavaFileSource {

private static JavaFileSource instance = null;

// Single reference to OkHttp for performance gains
private OkHttpClient client;

/**
* Private Constructor to support Singleton pattern
*/
private JavaFileSource() {
super();
client = new OkHttpClient();
}

/**
Expand All @@ -21,4 +29,18 @@ public static JavaFileSource getInstance() {
}
return instance;
}

/**
* Make an HTTP Request
* @param resourceUrl URL to resource
* @param callback Callback class
* @return Request created
*/
public Request request(final String resourceUrl, final Callback callback) {
Request request = new Request.Builder().url(resourceUrl).build();

client.newCall(request).enqueue(callback);

return request;
}
}

0 comments on commit 2bfafad

Please sign in to comment.