List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:com.amaze.filemanager.asynchronous.asynctasks.compress.TarHelperTask.java
public TarHelperTask(Context context, String filePath, String relativePath, boolean goBack, OnAsyncTaskFinished<ArrayList<CompressedObjectParcelable>> l) { super(goBack, l); this.context = new WeakReference<>(context); this.filePath = filePath; this.relativePath = relativePath; }
From source file:my.home.domain.usecase.SendMsgUsecaseImpl.java
public SendMsgUsecaseImpl(Context context, String homeId) { mContext = new WeakReference<>(context); mHomeId = homeId; init(context); }
From source file:org.t2framework.commons.util.LazyLoadingReference.java
public T get() throws IllegalStateException { while (true) { WeakReference<Future<T>> ref = reference.get(); boolean valid = true; if (ref == null) { FutureTask<T> f = new FutureTask<T>(new Callable<T>() { @Override/*from w w w . j a va 2 s. co m*/ public T call() throws Exception { return factory.create(); } }); ref = new WeakReference<Future<T>>(f); if (valid = reference.compareAndSet(null, ref)) { f.run(); } } if (valid) { try { Future<T> f = ref.get(); if (f != null) { return f.get(); } else { reference.compareAndSet(ref, null); } } catch (CancellationException e) { reference.compareAndSet(ref, null); } catch (ExecutionException e) { throw new IllegalStateException(e.getCause()); } catch (Exception e) { throw new IllegalStateException(e); } } } }
From source file:com.fatelon.partyphotobooth.kiosk.KioskSetupFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mCallbacks = new WeakReference<KioskSetupFragment.ICallbacks>((KioskSetupFragment.ICallbacks) activity); }
From source file:io.github.moosbusch.lumpi.gui.impl.SelectionAdapter.java
@Override public void setEventSource(Component eventSource) { this.eventSourceRef = new WeakReference<>(Objects.requireNonNull(eventSource)); }
From source file:com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.java
/** Creates an EventLoop for the webClient. * * @param webClient the provided webClient *///from w ww. j a va2s. c o m public DefaultJavaScriptExecutor(final WebClient webClient) { webClient_ = new WeakReference<>(webClient); }
From source file:my.home.lehome.asynctask.LoadAutoCompleteConfAsyncTask.java
public LoadAutoCompleteConfAsyncTask(Context context, String serverURL, String deviceID) { mContext = new WeakReference<Context>(context); mDeviceID = deviceID;// w w w . j a va 2 s . c o m mServerURL = serverURL; mAutoCompleteItemUsecase = new AutoCompleteItemUsecaseImpl(context); }
From source file:org.Cherry.Modules.Web.Engine.MetricsService.java
public void examine(final HttpServerConnection connection) { if (null != connection && log.isDebugEnabled() && !connection.isOpen()) { log.debug("Connection [{}] closed. Capturing metrics.", connection); final HttpConnectionMetrics metrics = connection.getMetrics(); final WeakReference<StringBuilder> sb = new WeakReference<StringBuilder>( new StringBuilder("{'connection_metrics':{'requests':'")); sb.get().append(metrics.getRequestCount()).append("','responses':'").append(metrics.getResponseCount()) .append("', 'received_bytes':'").append(metrics.getReceivedBytesCount()) .append("', 'sent_bytes':'").append(metrics.getSentBytesCount()).append("'}}"); log.debug("[{}]", sb.get().toString()); }// ww w. j a v a 2s . c o m }
From source file:com.bydavy.card.receipts.ReceiptPagerAdapter.java
@Override public void setPrimaryItem(ViewGroup container, int position, Object object) { // can cast safely (object can only be of type fragment) mPrimary = new WeakReference<Fragment>((Fragment) object); }
From source file:com.appCrawler.utils.MyNicelyResynchronizingAjaxController.java
/** * Initializes this instance. */ private void init() { originatedThread_ = new WeakReference<Thread>(Thread.currentThread()); }