Example usage for java.lang.ref WeakReference WeakReference

List of usage examples for java.lang.ref WeakReference WeakReference

Introduction

In this page you can find the example usage for java.lang.ref WeakReference WeakReference.

Prototype

public WeakReference(T referent) 

Source Link

Document

Creates a new weak reference that refers to the given object.

Usage

From source file:com.dycody.android.idealnote.async.AttachmentTask.java

public AttachmentTask(Fragment mFragment, Uri uri, String fileName,
        OnAttachingFileListener mOnAttachingFileListener) {
    mFragmentWeakReference = new WeakReference<>(mFragment);
    this.uri = uri;
    this.fileName = TextUtils.isEmpty(fileName) ? "" : fileName;
    this.mOnAttachingFileListener = mOnAttachingFileListener;
}

From source file:net.kervala.comicsreader.BrowseRemoteAlbumsTask.java

public BrowseRemoteAlbumsTask(BrowserActivity activity, String url) {
    mActivity = new WeakReference<BrowserActivity>(activity);
    mUrl = url;
}

From source file:com.sworddance.taskcontrol.SingletonTaskControlFactory.java

/**
 * @see com.sworddance.taskcontrol.TaskControlFactory#newTaskControl()
 *//*w  w w .  j a  v  a2s  .c  o  m*/
public TaskControl newTaskControl() {
    TaskControl taskControl = getTaskControl();
    if (taskControl == null) {
        taskControl = new TaskControl(getLog());
        if (taskControlRef.compareAndSet(null, taskControl)) {
            Thread taskControlThread = new Thread(taskControl, getThreadName());
            taskControlThread.start();
            taskControlThreadRef = new WeakReference<Thread>(taskControlThread);
        } else {
            // assumes that taskControlRef is never changed once set.
            taskControl = getTaskControl();
        }
    }
    return taskControl;
}

From source file:com.fatelon.partyphotobooth.fragments.ErrorDialogFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mCallbacks = new WeakReference<ErrorDialogFragment.ICallbacks>((ErrorDialogFragment.ICallbacks) activity);
}

From source file:com.extradea.framework.images.cache.LruBitmapCache.java

@Override
public void cache(String key, Bitmap value) {
    imageCache.put(key, value);
    imageTempCache.put(key, new WeakReference<Bitmap>(value));
}

From source file:net.openid.appauthdemo.Configuration.java

public static Configuration getInstance(Context context) {
    Configuration config = sInstance.get();
    if (config == null) {
        config = new Configuration(context);
        sInstance = new WeakReference<Configuration>(config);
    }/*  w w w. j ava 2  s .  c  om*/

    return config;
}

From source file:org.brekka.stillingar.spring.bpp.BeanReferenceResolver.java

public BeanReferenceResolver(BeanFactory beanFactory, Qualifier qualifier, Class<?> type) {
    this.beanFactoryRef = new WeakReference<BeanFactory>(beanFactory);
    this.qualifier = qualifier;
    this.type = type;
}

From source file:be.fgov.kszbcss.rhq.websphere.util.PIDWatcher.java

public synchronized PIDChangeTracker createTracker() {
    PIDChangeTracker tracker = new PIDChangeTracker(this);
    trackers.add(new WeakReference<PIDChangeTracker>(tracker));
    return tracker;
}

From source file:cc.osint.graphd.sim.GraphProcess.java

protected void setup(String pid, WeakReference<Graph> graphRef, T context, String name, Fiber fiber,
        Channel channel) {/*from   w ww .ja v a2s .c  om*/
    this.pid = pid;
    this.name = name;
    this.fiber = fiber;
    this.channel = channel;
    this.graphRef = graphRef;
    this.contextRef = new WeakReference<T>(context);
    log("setup: " + name + " fiber = " + fiber + ", channel = " + channel);
}

From source file:org.cybercat.automation.core.WeakReferenceThreadScope.java

@SuppressWarnings("rawtypes")
public Object get(String name, ObjectFactory objectFactory) {
    System.gc();//from  www  .j a  va  2s  .  co m
    Map<String, WeakReference<Object>> scope = threadScope.get();
    WeakReference<Object> wRef = scope.get(name);
    Object object;
    if (wRef == null || wRef.get() == null) {
        scope.remove(name);
        object = objectFactory.getObject();
        wRef = new WeakReference<Object>(object);
        scope.put(name, wRef);
    } else {
        object = wRef.get();
    }
    return object;
}