List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:com.ichi2.anki.AbstractFlashcardViewer.java
@Override protected void onResume() { super.onResume(); resumeTimer();// www.ja v a 2 s.co m // Set the context for the Sound manager mSoundPlayer.setContext(new WeakReference<Activity>(this)); // Reset the activity title setTitle(); updateScreenCounts(); selectNavigationItem(-1); }
From source file:com.example.wechatsample.library.http.AsyncHttpClient.java
/********************************************************************************************************/ // Private stuff/*w ww.ja va2s. c o m*/ protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); } Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
private void showSavingProgress(String albumName) { ProgressDialog progress;//from w w w . j a va 2 s. co m if (mSavingProgressDialog != null) { progress = mSavingProgressDialog.get(); if (progress != null) { progress.show(); return; } } // TODO: Allow cancellation of the saving process String progressText; if (albumName == null) { progressText = getString(R.string.saving_image); } else { progressText = getString(R.string.filtershow_saving_image, albumName); } progress = ProgressDialog.show(this, "", progressText, true, false); mSavingProgressDialog = new WeakReference<ProgressDialog>(progress); }
From source file:self.philbrown.droidQuery.Ajax.java
/** * Parses the HTTP response as a Bitmap/*w ww . j a va2s . c o m*/ * @param stream the response to parse * @return a Bitmap response */ private Bitmap parseImage(InputStream stream) throws IllegalStateException, IOException { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inSampleSize = 1; opt.inPurgeable = true; opt.inInputShareable = false; if (options.imageWidth() >= 0) opt.outWidth = options.imageWidth(); if (options.imageHeight() >= 0) opt.outHeight = options.imageHeight(); WeakReference<Bitmap> bitmap = new WeakReference<Bitmap>( BitmapFactory.decodeStream(stream, new Rect(0, 0, 0, 0), opt)); if (bitmap == null || bitmap.get() == null) { return null; } if (bitmap.get().isRecycled()) { return null; } return bitmap.get(); }
From source file:cn.edu.zzu.wemall.http.AsyncHttpClient.java
/** * Puts a new request in queue as a new thread in pool to be executed * * @param client HttpClient to be used for request, can differ in single requests * @param contentType MIME body type, for POST and PUT requests, may be null * @param context Context of Android application, to hold the reference of request * @param httpContext HttpContext in which the request will be executed * @param responseHandler ResponseHandler or its subclass to put the response into * @param uriRequest instance of HttpUriRequest, which means it must be of HttpDelete, HttpPost, HttpGet, HttpPut, etc. *//* w ww . j a v a 2 s. co m*/ protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); } Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } return new RequestHandle(request); }
From source file:com.nutsuser.ridersdomain.http.AsyncHttpClient.java
/** * Puts a new request in queue as a new thread in pool to be executed * * @param client HttpClient to be used for request, can differ in single requests * @param contentType MIME body type, for POST and PUT requests, may be null * @param context Context of Android application, to hold the reference of request * @param httpContext HttpContext in which the request will be executed * @param responseHandler ResponseHandler or its subclass to put the response into * @param uriRequest instance of HttpUriRequest, which means it must be of HttpDelete, HttpPost, HttpGet, HttpPut, etc. *//*w w w . j av a2 s . c om*/ protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); } Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } return new RequestHandle(request); }
From source file:com.lxh.util.http.LXH_HttpClient.java
protected void sendRequest(Context mContext, DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, LXH_HttpResponseHandler responseHandler, Context context) {/*www. j a v a 2 s . c om*/ if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); } Future<?> request = threadPool .submit(new LXH_HttpRequest(context, client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } }
From source file:com.apptentive.android.sdk.ApptentiveInternal.java
public void setOnSurveyFinishedListener(OnSurveyFinishedListener onSurveyFinishedListener) { if (onSurveyFinishedListener != null) { this.onSurveyFinishedListener = new WeakReference<OnSurveyFinishedListener>(onSurveyFinishedListener); } else {//from www.jav a 2 s .co m this.onSurveyFinishedListener = null; } }
From source file:com.example.fertilizercrm.common.httpclient.AsyncHttpClient.java
/** * Puts a new request in queue as a new thread in pool to be executed * * @param client HttpClient to be used for request, can differ in single requests * @param contentType MIME body type, for POST and PUT requests, may be null * @param context Context of Android application, to hold the reference of request * @param httpContext HttpContext in which the request will be executed * @param responseHandler ResponseHandler or its subclass to put the response into * @param uriRequest instance of HttpUriRequest, which means it must be of HttpDelete, * HttpPost, HttpGet, HttpPut, etc. * @return RequestHandle of future request process *///from www . j a v a 2 s. c o m protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, ResponseHandlerInterface responseHandler, Context context) { if (contentType != null) { uriRequest.setHeader("Content-Type", contentType); } responseHandler.setRequestHeaders(uriRequest.getAllHeaders()); responseHandler.setRequestURI(uriRequest.getURI()); Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); } return new RequestHandle(request); }
From source file:com.hypers.frame.http.core.AsyncHttpClient.java
/** * Puts a new request in queue as a new thread in pool to be executed * * @param client HttpClient to be used for request, can differ in single requests * @param contentType MIME body type, for POST and PUT requests, may be null * @param context Context of Android application, to hold the reference of request * @param httpContext HttpContext in which the request will be executed * @param responseHandler ResponseHandler or its subclass to put the response into * @param uriRequest instance of HttpUriRequest, which means it must be of HttpDelete, * HttpPost, HttpGet, HttpPut, etc. * @return RequestHandle of future request process *//* w ww . j ava 2 s. com*/ protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, ResponseHandlerInterface responseHandler, Context context) { if (contentType != null) { uriRequest.setHeader("Content-Type", contentType); } // //token // uriRequest.addHeader("token", UserDataManger.getToken(context)); responseHandler.setRequestHeaders(uriRequest.getAllHeaders()); responseHandler.setRequestURI(uriRequest.getURI()); Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } return new RequestHandle(request); }