List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:br.com.uol.runas.classloader.ClassLoaderGC.java
public void collect(ClassLoader classLoader) { classLoaders.add(new WeakReference<ClassLoader>(classLoader)); }
From source file:android.support.wear.widget.drawer.NestedScrollViewFlingWatcher.java
NestedScrollViewFlingWatcher(FlingListener listener, NestedScrollView nestedScrollView) {
mListener = listener;
mNestedScrollView = new WeakReference<>(nestedScrollView);
}
From source file:org.Cherry.Modules.Web.Engine.TemplateRequestHandler.java
@Override public void handle(final RequestCommand command) throws HttpException, IOException { final WeakReference<CallDef> call = new WeakReference<CallDef>(scanRESTBeanURI(command.getUri())); final JSONAgentDefinition jsonAgent = getController(call.get().getControllerURI()); assert null != jsonAgent : "Undefined controller for URI [" + command.getUri() + "]"; final RESTMethodDefinition restMethodDef = jsonAgent.get(call.get().getMethodURI()); assert null != restMethodDef : "Undefined controller method for URI [" + command.getUri() + "/" + call.get().getMethodURI() + "]"; final Object result = restMethodDef.invoke((Object[]) null); AbstractHttpEntity entity = null;/*from w ww. j a v a 2 s .co m*/ if (null != result) { final WeakReference<DictionaryModel> model = new WeakReference<DictionaryModel>(createModel()); model.get().putAll((Map<?, ?>) result); final WeakReference<Writer> writer = new WeakReference<Writer>(new FastStringWriter()); final WeakReference<RequestTemplateCommand> tmpltCmd = new WeakReference<RequestTemplateCommand>( new RequestTemplateCommand(command)); String tmpltDoc; if (tmpltCmd.get().isRootCall()) tmpltDoc = getWelcomeDoc(); else tmpltDoc = tmpltCmd.get().getUri(); try { getFreeMarkerService().process(tmpltDoc, model.get(), writer.get()); entity = new ByteArrayEntity(((FastStringWriter) writer.get()).getBuffer().toString().getBytes(), APPLICATION_HTML_CONTENT_TYPE); } catch (final Throwable t) { throw new IllegalStateException(t); } } else warn("JSON Controller returned null for expected result of type [{}]", restMethodDef.getBeanParameterType()); if (null == entity) throw new IllegalStateException("Template file [" + command.getUri() + "] not found!"); command.getResponse().setStatusCode(HttpStatus.SC_OK); command.getResponse().setEntity(entity); }
From source file:com.fatelon.partyphotobooth.setup.fragments.PhotoBoothSetupFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mCallbacks = new WeakReference<PhotoBoothSetupFragment.ICallbacks>( (PhotoBoothSetupFragment.ICallbacks) activity); }
From source file:com.softenido.findrepe.FileComparatorByImage.java
private Hash getHash(VirtualFile pf) throws FileNotFoundException, IOException, ArchiveException { WeakReference<Hash> wr = map.get(pf); Hash fh = wr != null ? wr.get() : null; if (fh == null) { fh = ihb.buildHash(pf);/* ww w . j a v a2s. com*/ if (fh != null) { map.put(pf, new WeakReference<Hash>(fh)); } //fh = new FileHash(pf); } return fh; }
From source file:com.appsimobile.appsii.plugins.IconCache.java
private void cacheIcon(CacheKey cn, Bitmap result) { mCache.put(cn, result); mWeakCache.put(cn, new WeakReference<>(result)); }
From source file:ac.robinson.paperchains.SoundCloudUploadTask.java
public SoundCloudUploadTask(PaperChainsActivity context, ApiWrapper wrapper, Token accessToken, String pageId, Rect audioRect) {//from w w w .j a v a 2 s. c o m mContext = new WeakReference<>(context); // set up upload parameters mApiWrapper = wrapper; mAccessToken = accessToken; mClientId = context.getString(R.string.soundcloud_client_id); mUploadFileTitle = context.getString(R.string.audio_upload_file_title); mUploadFileDescription = context.getString(R.string.audio_upload_file_description); mPageId = pageId; mAudioRect = audioRect; // set up notifications mNotifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle(context.getString(R.string.audio_upload_title)) .setContentText(context.getString(R.string.audio_upload_progress)) .setSmallIcon(R.drawable.ic_notification).setColor(context.getResources().getColor(R.color.primary)) .setAutoCancel(true); }
From source file:count.ly.messaging.TitaniumCountlyAndroidMessagingModule.java
public TitaniumCountlyAndroidMessagingModule() { super(); lastInstance = new WeakReference(this); }
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.CfpSyncManager.java
public CfpSyncManager(Context context) { this.mContext = new WeakReference<Context>(context); }
From source file:com.bellman.bible.android.view.activity.base.actionbar.QuickActionButton.java
/** * Provide the possibility of handling clicks outside of the button e.g. in Activity *//*from w ww.j a v a2 s . co m*/ public void registerClickListener(OnClickListener onClickListener) { this.weakOnClickListener = new WeakReference<OnClickListener>(onClickListener); }