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.activiti.android.ui.fragments.builder.AlfrescoFragmentBuilder.java

/**
 * Used by ?//w w w  . j  a  v a2  s.  c om
 *
 * @param activity
 * @param configuration
 * @param b
 */
public AlfrescoFragmentBuilder(FragmentActivity activity, Map<String, Object> configuration, Bundle b) {
    this.onClick = onDefaultClick;
    this.activity = new WeakReference<>(activity);
    this.configuration = configuration;
    this.extraConfiguration = b;
}

From source file:com.mentor.questa.vrm.jenkins.QuestaVrmHostAction.java

public synchronized QuestaVrmRegressionResult getRegressionResult() {
    QuestaVrmRegressionResult r = new QuestaVrmRegressionResult("");
    if (run == null) {
        return r;
    }//from   w w w  .  ja v  a 2 s. com
    if (questaVrmResultRef == null) {
        QuestaVrmRegressionBuildAction action = run.getAction(QuestaVrmRegressionBuildAction.class);
        if (action == null) {
            return r;
        }
        r = action.getResult();
        questaVrmResultRef = new WeakReference<QuestaVrmRegressionResult>(r);
    } else {
        r = questaVrmResultRef.get();
    }
    return r;

}

From source file:com.vinaysshenoy.easyoauth.factory.OAuthFactory.java

/**
 * @param activity/*from  w  w w  . j  a  v a  2s . co  m*/
 * @param consumerKey Your application consumer key for OAuth 1.0a, Your Client ID for OAuth 2.0
 * @param consumerSecret Your application consumer secret for OAuth 2.0, null for OAuth 2.0
 * @param oauthProviderType One of {@link Provider} constants
 * @param oAuthConfig An {@link OAuthConfig} object, needed if you're using {@link Provider#CUSTOM}
 * @throws OAuthFactoryException
 * @throws NullPointerException
 */
public OAuthFactory(Activity activity, String consumerKey, String consumerSecret, Provider provider,
        OAuthConfig oAuthConfig, String oauthCallback) throws OAuthFactoryException, NullPointerException {

    this.activity = new WeakReference<Activity>(activity);
    this.consumerKey = consumerKey;
    this.consumerSecret = consumerSecret;
    this.provider = provider;
    this.oAuthConfig = oAuthConfig;

    if (oAuthConfig == null && provider == Provider.CUSTOM) {
        throw new NullPointerException(OAuthFactoryException.OAuthExceptionMessages.OAUTH_MISSING_CONFIG);
    }

    // Init objects
    initOAuthProvider(oauthCallback);
    initOAuthConsumer();
    initHttpManager();
}

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

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

    final Handler handler = new Handler(BaseApplication.getWorkerLooper());
    mCameraAudioHelper = new CameraAudioHelper(activity, R.raw.beep_once, handler);
}

From source file:net.solarnetwork.node.io.yasdi4j.YasdiMasterDeviceFactory.java

/**
 * Default constructor.//w ww  .j  a  v  a2 s  .c o  m
 */
public YasdiMasterDeviceFactory() {
    super();
    synchronized (FACTORIES) {
        FACTORIES.put(this, new WeakReference<Object>(MONITOR));
    }
}

From source file:com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever.java

SupplementalInfoRetriever(TextView textView, Handler handler, HistoryManager historyManager) {
    this.textViewRef = new WeakReference<TextView>(textView);
    this.handler = handler;
    this.historyManager = historyManager;
}

From source file:com.joyepay.qrcode.result.supplement.SupplementalInfoRetriever.java

SupplementalInfoRetriever(TextView textView, Handler handler
//        ,HistoryManager historyManager
) {/*from www. j av a  2s .  com*/
    this.textViewRef = new WeakReference<TextView>(textView);
    this.handler = handler;
    //    this.historyManager = historyManager;
}

From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java

public TransferListAdapter(Context context, List<Transfer> list) {
    this.context = new WeakReference<Context>(context);

    this.viewOnClickListener = new ViewOnClickListener();
    this.viewOnLongClickListener = new ViewOnLongClickListener();
    this.playOnClickListener = new OpenOnClickListener();

    this.dialogs = new ArrayList<Dialog>();

    this.list = list.equals(Collections.emptyList()) ? new ArrayList<Transfer>() : list;

    initTransferStateStringMap();/* w  w w.ja  v  a  2s  .c om*/
}

From source file:org.Cherry.Modules.Web.Engine.RequestInterceptor.java

private Boolean authenticate(final HttpRequest request, final HttpContext context)
        throws InvalidCredentialsException {
    context.setAttribute(CreateCookie, false);

    if (isOpenGateMessage(request)) {
        final User identity = getUser(request);

        if (null == authenticate(identity)) {
            context.setAttribute(CreateCookie, true);
            return true;
        }/*from w  ww .  j a va 2  s.co  m*/

        return false;
    }

    if (isCookiePathHit(request)) {
        final WeakReference<HeaderIterator> headerIterator = new WeakReference<HeaderIterator>(
                request.headerIterator(Cookie));

        Header header;
        HeaderElement[] elements;
        String value;

        while (headerIterator.get().hasNext()) {
            header = headerIterator.get().nextHeader();

            elements = header.getElements();

            for (final HeaderElement element : elements)
                if (getSessionCookie().equalsIgnoreCase(element.getName())) {
                    value = element.getValue();

                    if (!isTampered(value))
                        return true;
                    else
                        return false;
                }
        }

        return false;
    }

    throw new IllegalStateException("Unknown execution context!");
}

From source file:org.Cherry.Modules.Web.Engine.RequestHandlerTemplate.java

static CallDef scanRESTBeanURI(final String uri) {
    if (isEmpty(uri) || ROOT_URI.equals(uri))
        return CallDef.RootCall;

    final CallDef call = new CallDef();

    final WeakReference<StringTokenizer> st = new WeakReference<StringTokenizer>(
            new StringTokenizer(uri, URI_TOKEN));

    if (st.get().hasMoreTokens()) {
        String token = st.get().nextToken();

        if (isNotEmpty(token)) {
            call.setControllerURI(URI_TOKEN + token);

            if (st.get().hasMoreTokens()) {
                token = st.get().nextToken();

                if (isNotEmpty(token))
                    call.setMethodURI(URI_TOKEN + token);
            }//from   w ww .  j a v a2s.  c  o  m
        }
    }

    return call;
}