List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:com.cleverua.test.thumbs.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not used. * Kept private at the moment as its interest is not clear. */// ww w. j a v a 2s.co m private void forceDownload(String url, ImageView imageView, Drawable placeHolder) { // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys. if (url == null) { imageView.setImageDrawable(null); return; } if (removePotentialDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(url, imageView); imageView.setImageDrawable(placeHolder); imageView.setTag(new WeakReference<BitmapDownloaderTask>(task)); imageView.setMinimumHeight(156); pendingTasks.offerLast(task); if (loaderTask == null || loaderTask.getStatus() == AsyncTask.Status.FINISHED) { loaderTask = pendingTasks.poll(); loaderTask.execute(); } } }
From source file:ca.phon.app.session.editor.view.media_player.PlayCustomSegmentDialog.java
/** * Constructor//ww w . j ava2s . c o m */ public PlayCustomSegmentDialog(SessionEditor editor, PhonMediaPlayer player) { super(); this.mediaPlayerRef = new WeakReference<PhonMediaPlayer>(player); this.editorRef = new WeakReference<SessionEditor>(editor); init(); }
From source file:com.holonplatform.core.internal.beans.DefaultBeanPropertySet.java
/** * Constructor./*from w w w . j a v a 2s . c o m*/ * @param <P> Actual property type * @param beanClass Bean class to which this property set refers * @param properties Properties of the set */ public <P extends PathProperty<?>> DefaultBeanPropertySet(Class<? extends T> beanClass, Collection<P> properties) { super(properties); this.beanClass = new WeakReference<>(beanClass); }
From source file:de.uniba.wiai.kinf.pw.projects.lillytab.reasoner.tbox.AssertedRBox.java
public AssertedRBox(ITBox<I, L, K, R> tbox) { super();//from www . j a va2 s. co m _tboxRef = new WeakReference<>(tbox); _roleDomains = new GenericMultiHashMap<>(new TreeSetFactory<IDLClassExpression<I, L, K, R>>()); _roleRanges = new GenericMultiHashMap<>(new TreeSetFactory<IDLNodeTerm<I, L, K, R>>()); final ICollectionFactory<R, ? extends Collection<R>> roleSetFactory = new SortedListSetFactory<>(); _roleTypeMap = new HashMap<>(); _typeRoleMap = new GenericMultiHashMap<>(roleSetFactory); _rolePropertyMap = new GenericMultiHashMap<>(new EnumSetFactory<>(RoleProperty.class)); _propertyRoleMap = new GenericMultiHashMap<>(roleSetFactory); _inverseRoles = new GenericMultiHashMap<>(roleSetFactory); _equivalentRoles = new GenericMultiHashMap<>(roleSetFactory); _subRoles = new GenericMultiHashMap<>(roleSetFactory); _superRoles = new GenericMultiHashMap<>(roleSetFactory); _rbox = new RBox<>(this); }
From source file:com.todoroo.andlib.service.HttpRestClient.java
private synchronized HttpClient getClient() { if (httpClient == null || httpClient.get() == null) { DefaultHttpClient client = new DefaultHttpClient(cm, params); httpClient = new WeakReference<HttpClient>(client); actsAsGzippable(client);/*from w w w .j a v a 2 s .com*/ return client; } return httpClient.get(); }
From source file:com.pdi.hybridge.HybridgeBroadcaster.java
public static synchronized HybridgeBroadcaster getInstance(WebView client) { final int hash = client.hashCode(); WeakReference<HybridgeBroadcaster> instance = sClients.get(hash); if (instance == null || instance.get() == null) { instance = new WeakReference<HybridgeBroadcaster>(new HybridgeBroadcaster()); sClients.put(hash, instance);/* www .j ava 2s .com*/ } return instance.get(); }
From source file:android.support.transition.TransitionManagerPort.java
static ArrayMap<ViewGroup, ArrayList<TransitionPort>> getRunningTransitions() { WeakReference<ArrayMap<ViewGroup, ArrayList<TransitionPort>>> runningTransitions = sRunningTransitions .get();//from w w w .jav a 2 s . c o m if (runningTransitions == null || runningTransitions.get() == null) { ArrayMap<ViewGroup, ArrayList<TransitionPort>> transitions = new ArrayMap<>(); runningTransitions = new WeakReference<>(transitions); sRunningTransitions.set(runningTransitions); } return runningTransitions.get(); }
From source file:StackLayout.java
/** * Set the currently displayed component. If passed null for the component, * all contained components will be made invisible (sliding windows do this) * @param c Component to show//from w ww .java 2 s.c o m * @param parent Parent container */ public void showComponent(Component c, Container parent) { Component comp = getVisibleComponent(); if (comp != c) { if (!parent.isAncestorOf(c) && c != null) { parent.add(c); } synchronized (parent.getTreeLock()) { if (comp != null) { comp.setVisible(false); } visibleComp = new WeakReference<Component>(c); if (c != null) { c.setVisible(true); } // trigger re-layout if (c instanceof JComponent) { ((JComponent) c).revalidate(); } else { parent.validate(); //XXX revalidate should work! } } } }
From source file:edu.umich.flowfence.service.NamespaceSharedPrefs.java
public static NamespaceSharedPrefs get(SharedPreferences basePrefs, String taintSetNamespace, String... taintNamespaces) { Objects.requireNonNull(taintSetNamespace); taintNamespaces = ArrayUtils.nullToEmpty(taintNamespaces); if (taintNamespaces.length == 0) { throw new IllegalArgumentException("Need at least one taint namespace!"); }//from w w w . j a v a 2s . c om Set<String> taintNamespaceSet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(taintNamespaces))); if (taintNamespaceSet.contains(taintSetNamespace)) { throw new IllegalArgumentException("Taint set namespace also a taint namespace"); } synchronized (g_mPrefsLookup) { NamespaceSharedPrefs prefsStrong = null; WeakReference<NamespaceSharedPrefs> prefsWeak = g_mPrefsLookup.get(basePrefs); if (prefsWeak != null) { prefsStrong = prefsWeak.get(); } if (prefsStrong != null) { if (!taintSetNamespace.equals(prefsStrong.mTaintSetNamespace) || !taintNamespaceSet.equals(prefsStrong.mTaintNamespaces)) { Log.w(TAG, String.format( "Inconsistent initialization: " + "initialized with TS=%s T=%s, retrieved with TS=%s T=%s", prefsStrong.mTaintSetNamespace, prefsStrong.mTaintNamespaces, taintSetNamespace, taintNamespaceSet)); } } else { prefsStrong = new NamespaceSharedPrefs(basePrefs, taintSetNamespace, taintNamespaceSet); prefsWeak = new WeakReference<>(prefsStrong); g_mPrefsLookup.put(basePrefs, prefsWeak); } return prefsStrong; } }
From source file:com.fatelon.partyphotobooth.setup.fragments.EventInfoSetupFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mCallbacks = new WeakReference<EventInfoSetupFragment.ICallbacks>( (EventInfoSetupFragment.ICallbacks) activity); }