List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:com.thoughtworks.go.plugin.infra.monitor.DefaultPluginJarLocationMonitor.java
@Override public void addPluginJarChangeListener(PluginJarChangeListener listener) { pluginJarChangeListener.add(new WeakReference<>(listener)); removeClearedWeakReferences();//from ww w .j a va 2s.c o m }
From source file:com.anysoftkeyboard.addons.AddOnImpl.java
@Nullable public final Context getPackageContext() { Context c = mPackageContext.get(); if (c == null) { try {// ww w. j a v a 2 s . c om c = mAskAppContext.createPackageContext(mPackageName, Context.CONTEXT_IGNORE_SECURITY); mPackageContext = new WeakReference<>(c); } catch (NameNotFoundException e) { Logger.w(TAG, "Failed to find package %s!", mPackageName); Logger.w(TAG, "Failed to find package! ", e); } } return c; }
From source file:com.fatelon.partyphotobooth.fragments.ConfirmationFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mCallbacks = new WeakReference<ConfirmationFragment.ICallbacks>((ConfirmationFragment.ICallbacks) activity); }
From source file:br.com.anteros.social.facebook.AnterosFacebookSession.java
public AnterosFacebookSession(AnterosFacebookConfiguration configuration) { this.configuration = configuration; this.onLoginListener = new WeakReference<OnLoginListener>(configuration.getOnLoginListener()); this.onLogoutListener = new WeakReference<OnLogoutListener>(configuration.getOnLogoutListener()); setActivity(configuration.getActivity()); loginManager = LoginManager.getInstance(); loginManager.registerCallback(callbackManager, loginCallback); loginManager.setDefaultAudience(configuration.getDefaultAudience()); loginManager.setLoginBehavior(configuration.getLoginBehavior()); }
From source file:de.micromata.genome.util.event.SimpleEventClassRegistry.java
/** * Adds the listener.//from ww w.j a v a 2s . c o m * * @param event the event * @param listener the listener */ protected void addListener(Class<? extends MgcEvent> event, Class<? extends MgcEventListener<?>> listener) { Map<Class<? extends MgcEvent>, List<Reference<Class<? extends MgcEventListener<?>>>>> nmp = new ReferenceMap<>( ReferenceMap.ReferenceStrength.WEAK, ReferenceMap.ReferenceStrength.HARD); nmp.putAll(listenerMap); List<Reference<Class<? extends MgcEventListener<?>>>> list = nmp.get(event); if (list == null) { list = new ArrayList<>(); nmp.put(event, list); } list.add(new WeakReference<Class<? extends MgcEventListener<?>>>(listener)); listenerMap = nmp; }
From source file:org.agatom.springatom.data.oid.creators.PersistableSOidCreator.java
@Override @SuppressWarnings("unchecked") public <S extends Persistable<?>> SOid fromObject(final S from) throws Exception { return new PersistableOid().setReference(new WeakReference<Persistable<?>>(from)) .setObjectClass((Class<Persistable<?>>) ClassUtils.getUserClass(from)) .setObjectId((Long) from.getId()).setObjectPrefix(PERSISTABLE_TYPE_PREFIX); }
From source file:com.example.prox.model.DrawableLoader.java
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { imageViewReference = new WeakReference<ImageView>(imageView); if (drawableMap.containsKey(urlString)) { imageViewReference.get().setImageDrawable(drawableMap.get(urlString)); }//from www. j av a 2 s . com final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageViewReference.get().setImageDrawable((Drawable) message.obj); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:com.digium.respokesdk.RespokeDirectConnection.java
/** * The constructor for this class// w ww .j av a 2 s.c om * * @param call The call instance with which this direct connection is associated */ public RespokeDirectConnection(RespokeCall call) { callReference = new WeakReference<RespokeCall>(call); }
From source file:org.brekka.stillingar.spring.pc.PropertyDefChangeListener.java
/** * @param beanName/*from w w w.j a v a2 s .c o m*/ * The name of the bean within the Spring context. Will be used to lookup its current definition. * @param propertyName * The name of the property being updated. * @param beanFactory * The bean factory in which to resolve the bean definition of bean identified by <code>beanName</code> * @param fragment * the fragment that will be used to evaluate and obtain the value which will be passed to * {@link #onChange(String)} */ public PropertyDefChangeListener(String beanName, String propertyName, ConfigurableListableBeanFactory beanFactory, Fragment fragment) { super(fragment); this.beanName = beanName; this.propertyName = propertyName; this.beanFactoryRef = new WeakReference<ConfigurableListableBeanFactory>(beanFactory); }
From source file:com.haulmont.chile.core.model.impl.AbstractInstance.java
@Override public void addPropertyChangeListener(PropertyChangeListener listener) { if (__propertyChangeListeners == null) { __propertyChangeListeners = new ArrayList<>(); }// w ww . j a v a 2 s. c o m __propertyChangeListeners.add(new WeakReference<>(listener)); }