List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:br.com.anteros.social.facebook.AnterosFacebookSession.java
public void setActivity(Activity activity) { this.activity = new WeakReference<Activity>(activity); }
From source file:android.support.transition.TransitionManager.java
static ArrayMap<ViewGroup, ArrayList<Transition>> getRunningTransitions() { WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>> runningTransitions = sRunningTransitions.get(); if (runningTransitions == null || runningTransitions.get() == null) { ArrayMap<ViewGroup, ArrayList<Transition>> transitions = new ArrayMap<>(); runningTransitions = new WeakReference<>(transitions); sRunningTransitions.set(runningTransitions); }/*from www. ja va 2 s . c o m*/ return runningTransitions.get(); }
From source file:android.support.v7.app.ActionBarImplCompatICS.java
@Override public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { if (listener != null) { OnMenuVisibilityListenerWrapper w = new OnMenuVisibilityListenerWrapper(listener); mAddedMenuVisWrappers.add(new WeakReference<OnMenuVisibilityListenerWrapper>(w)); mActionBar.addOnMenuVisibilityListener(w); }/* www .j a v a 2 s . c o m*/ }
From source file:br.com.anteros.social.linkedin.AnterosLinkedInSession.java
@Override public void setOnLoginListener(OnLoginListener onLoginListener) { this.onLoginListener = new WeakReference<>(onLoginListener); }
From source file:com.sworddance.taskcontrol.FutureListenerProcessor.java
public void addFutureListener(FutureListener<RV> futureListener) { if (isDone()) { if (this.throwable == null) { notifyListener(futureListener); } else {//w ww . j av a2 s . c om notifyListenerException(futureListener); } } else { this.writeListenersLock.lock(); try { WeakReference<FutureListener<RV>> listener = new WeakReference<FutureListener<RV>>(futureListener); if (!this.listeners.contains(listener)) { this.listeners.add(listener); } } finally { this.writeListenersLock.unlock(); } } }
From source file:ch.entwine.weblounge.common.impl.request.WebloungeResponseImpl.java
/** * Sets the associated request object./*from w ww . j a v a 2 s . com*/ * * @param request * the request */ public void setRequest(WebloungeRequest request) { this.request = new WeakReference<WebloungeRequest>(request); }
From source file:br.com.anteros.social.linkedin.AnterosLinkedInSession.java
@Override public void setOnLogoutListener(OnLogoutListener onLogoutListener) { this.onLogoutListener = new WeakReference<>(onLogoutListener); }
From source file:com.battlelancer.seriesguide.ui.OverviewActivity.java
@Override public void onAttachFragment(Fragment fragment) { /*// www .j av a2s. c o m * View pager fragments have tags set by the pager, we can use this to * only add refs to those then, making them available to get removed if * we switch to a non-pager layout. */ if (fragment.getTag() != null) { mFragments.add(new WeakReference<Fragment>(fragment)); } }
From source file:com.osafe.services.OsafePayPalServices.java
public static Map<String, Object> setExpressCheckout(DispatchContext dctx, Map<String, ? extends Object> context) { ShoppingCart cart = (ShoppingCart) context.get("cart"); Locale locale = cart.getLocale(); if (cart == null || cart.items().size() <= 0) { return ServiceUtil.returnError( UtilProperties.getMessage(resource, "AccountingPayPalShoppingCartIsEmpty", locale)); }/* w w w .ja v a2 s . c o m*/ GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null); if (payPalConfig == null) { return ServiceUtil.returnError( UtilProperties.getMessage(resource, "AccountingPayPalPaymentGatewayConfigCannotFind", locale)); } NVPEncoder encoder = new NVPEncoder(); // Set Express Checkout Request Parameters encoder.add("METHOD", "SetExpressCheckout"); String token = (String) cart.getAttribute("payPalCheckoutToken"); if (UtilValidate.isNotEmpty(token)) { encoder.add("TOKEN", token); } encoder.add("RETURNURL", payPalConfig.getString("returnUrl")); encoder.add("CANCELURL", payPalConfig.getString("cancelReturnUrl")); if (!cart.shippingApplies()) { encoder.add("NOSHIPPING", "1"); } else { //encoder.add("CALLBACK", payPalConfig.getString("shippingCallbackUrl")); //encoder.add("CALLBACKTIMEOUT", "6"); // Default to no String reqConfirmShipping = "Y".equals(payPalConfig.getString("requireConfirmedShipping")) ? "1" : "0"; encoder.add("REQCONFIRMSHIPPING", reqConfirmShipping); // Default shipment method //encoder.add("L_SHIPPINGOPTIONISDEFAULT0", "true"); //encoder.add("L_SHIPPINGOPTIONNAME0", "Calculated Offline"); //encoder.add("L_SHIPPINGOPTIONAMOUNT0", "0.00"); //These are used in conjunction with the Shipping Call back URL. commentted by Len for our implementation // encoder.add("CALLBACK", payPalConfig.getString("shippingCallbackUrl")); // encoder.add("CALLBACKTIMEOUT", "6"); // encoder.add("L_SHIPPINGOPTIONISDEFAULT0", "true"); // encoder.add("L_SHIPPINGOPTIONNAME0", "Calculated Offline"); // encoder.add("L_SHIPPINGOPTIONAMOUNT0", "0.00"); } encoder.add("ALLOWNOTE", "1"); encoder.add("INSURANCEOPTIONOFFERED", "false"); if (UtilValidate.isNotEmpty(payPalConfig.getString("imageUrl"))) ; encoder.add("PAYMENTACTION", "Order"); // Cart information try { addCartDetails(encoder, cart); } catch (GenericEntityException e) { Debug.logError(e, module); // Len commented this line for our implementation /*return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingPayPalErrorDuringRetrievingCartDetails", locale));*/ return ServiceUtil.returnError("An error occurred while retreiving cart details"); // Len added this line for our implementation } NVPDecoder decoder; try { decoder = sendNVPRequest(payPalConfig, encoder); } catch (PayPalException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } Map<String, String> errorMessages = getErrorMessageMap(decoder); if (UtilValidate.isNotEmpty(errorMessages)) { if (errorMessages.containsKey("10411")) { // Token has expired, get a new one cart.setAttribute("payPalCheckoutToken", null); return OsafePayPalServices.setExpressCheckout(dctx, context); } return ServiceUtil.returnError(UtilMisc.toList(errorMessages.values())); } token = decoder.get("TOKEN"); cart.setAttribute("payPalCheckoutToken", token); TokenWrapper tokenWrapper = new TokenWrapper(token); cart.setAttribute("payPalCheckoutTokenObj", tokenWrapper); OsafePayPalServices.tokenCartMap.put(tokenWrapper, new WeakReference<ShoppingCart>(cart)); return ServiceUtil.returnSuccess(); }