List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:io.selendroid.server.model.AndroidNativeElement.java
public AndroidNativeElement(View view, ServerInstrumentation instrumentation, KeySender keys, KnownElements ke) {/* w w w.j av a 2 s .c o m*/ Preconditions.checkNotNull(view); this.viewRef = new WeakReference<View>(view); hashCode = view.hashCode() + 31; this.instrumentation = instrumentation; this.keys = keys; this.nativeElementSearchScope = new NativeElementSearchScope(instrumentation, keys, ke); this.ke = ke; Random random = new Random(); this.id = new UUID(random.nextLong(), random.nextLong()).toString(); }
From source file:com.fastbootmobile.encore.app.fragments.SearchFragment.java
/** * Default constructor/* w w w . j a v a2s .c o m*/ */ public SearchFragment() { mHandler = new SearchHandler(new WeakReference<>(this)); setRetainInstance(true); }
From source file:ch.entwine.weblounge.common.impl.content.image.ImageContentReader.java
/** * This method is called to parse the serialized XML of a * {@link ch.entwine.weblounge.common.content.ResourceContent}. * //from ww w . java2s. c om * @param is * the content data * @throws ParserConfigurationException * if the SAX parser setup failed * @throws IOException * if reading the input stream fails * @throws SAXException * if an error occurs while parsing */ public ImageContent createFromXml(InputStream is) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = parserRef.get(); if (parser == null) { parser = parserFactory.newSAXParser(); parserRef = new WeakReference<SAXParser>(parser); } parser.parse(is, this); return content; }
From source file:com.actionbarsherlock.internal.view.StandaloneActionMode.java
@Override public void setCustomView(View view) { mContextView.setCustomView(view);//from w w w . j ava2 s . c o m mCustomView = view != null ? new WeakReference<View>(view) : null; }
From source file:com.sworddance.util.WeakProxy.java
public static <T> WeakReference<T> newWeakReference(T referent) { if (referent == null) { return null; } else {/*ww w . java 2 s . c o m*/ return new WeakReference<T>(referent); } }
From source file:com.android.leanlauncher.LauncherAppState.java
static void setLauncherProvider(LauncherProvider provider) { sLauncherProvider = new WeakReference<LauncherProvider>(provider); }
From source file:com.activiti.android.ui.form.FormManager.java
public FormManager(AlfrescoFragment fr, ViewGroup vRoot, FormDefinitionRepresentation data, AppVersion version) {// w w w . j a v a 2 s . c o m this.fr = fr; this.vRoot = vRoot; this.activity = new WeakReference<>(fr.getActivity()); this.data = data; this.version = version; }
From source file:io.kristal.pubsubplugin.PubSubReceiver.java
/** * Creates and return a PubSubReceiver for the specified CobaltFragment registered to the specified channel. * @param fragment the CobaltFragment containing the WebView to which send messages. * @param callback the callback to call to forward messages from the specified channel. * @param channel the channel from which the messages will come from. *///from w w w . j a v a 2 s . c om public PubSubReceiver(CobaltFragment fragment, String callback, String channel) { fragmentReference = new WeakReference<CobaltFragment>(fragment); callbackForChannel = new SimpleArrayMap<>(1); callbackForChannel.put(channel, callback); }
From source file:com.gh.bmd.jrt.android.v4.core.DefaultInvocationContextRoutineBuilder.java
/** * Constructor.// ww w . j av a 2 s . c o m * * @param context the context instance. * @param classToken the invocation class token. * @throws java.lang.NullPointerException if the context or class token are null. */ @SuppressWarnings("ConstantConditions") private DefaultInvocationContextRoutineBuilder(@Nonnull final Object context, @Nonnull final ClassToken<? extends ContextInvocation<INPUT, OUTPUT>> classToken) { if (context == null) { throw new NullPointerException("the routine context must not be null"); } mContext = new WeakReference<Object>(context); mInvocationClass = classToken.getRawClass(); }
From source file:com.predic8.membrane.core.transport.http.HttpTransport.java
/** * Closes the corresponding server port. Note that connections might still be open and exchanges still running after * this method completes.//from w w w . java 2 s . co m */ public synchronized void closePort(String ip, int port) throws IOException { IpPort p = new IpPort(ip, port); log.debug("Closing server port: " + p); HttpEndpointListener plt = portListenerMapping.get(p); if (plt == null) return; plt.closePort(); try { plt.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } portListenerMapping.remove(p); stillRunning.add(new WeakReference<HttpEndpointListener>(plt)); for (IPortChangeListener listener : menuListeners) { listener.removePort(port); } }