Java Code Examples for java.lang.ref.WeakReference

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AlbiteREADER, under directory /src/org/albite/image/.

Source file: AlbiteImageARGB.java

  18 
vote

private Image getCache(){
  WeakReference cache=this.cache;
  if (cache != null) {
    Image image=(Image)cache.get();
    if (image != null) {
      if (cacheColor == color) {
        return image;
      }
    }
  }
  Image image=Image.createRGBImage(argbData,width,height,true);
  cache=new WeakReference(image);
  return image;
}
 

Example 2

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/net/poolable/copy/.

Source file: CursorableLinkedList.java

  18 
vote

/** 
 * Registers a  {@link CursorableLinkedList.Cursor} to be notifiedof changes to this list.
 */
protected void registerCursor(Cursor cur){
  for (Iterator it=_cursors.iterator(); it.hasNext(); ) {
    WeakReference ref=(WeakReference)it.next();
    if (ref.get() == null) {
      it.remove();
    }
  }
  _cursors.add(new WeakReference(cur));
}
 

Example 3

From project cloudhopper-commons-util, under directory /src/test/java/com/cloudhopper/commons/util/.

Source file: UnwrappedWeakReferenceTest.java

  18 
vote

@Test @SuppressWarnings("IncompatibleEquals") public void equals() throws Exception {
  String o=new String();
  WeakReference ref0=new UnwrappedWeakReference(o);
  WeakReference ref1=new UnwrappedWeakReference(o);
  Assert.assertTrue(ref0.equals(ref1));
  Assert.assertTrue(ref0.equals(o));
  Assert.assertTrue(ref1.equals(o));
}
 

Example 4

From project collections-generic, under directory /src/java/org/apache/commons/collections15/list/.

Source file: CursorableLinkedList.java

  18 
vote

/** 
 * Deregisters a cursor from the list to be notified of changes.
 * @param cursor the cursor to deregister
 */
protected void unregisterCursor(Cursor<E> cursor){
  for (Iterator it=cursors.iterator(); it.hasNext(); ) {
    WeakReference ref=(WeakReference)it.next();
    Cursor cur=(Cursor)ref.get();
    if (cur == null) {
      it.remove();
    }
 else     if (cur == cursor) {
      ref.clear();
      it.remove();
      break;
    }
  }
}
 

Example 5

From project commons-pool, under directory /src/java/org/apache/commons/pool/impl/.

Source file: CursorableLinkedList.java

  18 
vote

/** 
 * Registers a  {@link CursorableLinkedList.Cursor} to be notifiedof changes to this list.
 */
protected void registerCursor(Cursor cur){
  for (Iterator it=_cursors.iterator(); it.hasNext(); ) {
    WeakReference ref=(WeakReference)it.next();
    if (ref.get() == null) {
      it.remove();
    }
  }
  _cursors.add(new WeakReference(cur));
}
 

Example 6

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.

Source file: SamsungWidgetPackageManager.java

  17 
vote

SamsungWidgetsLoader(Context context){
  this$0=SamsungWidgetPackageManager.this;
  Object();
  mRunning=true;
  mContext=new WeakReference(context);
}
 

Example 7

From project Clotho-Core, under directory /ClothoApps/BglBrickiDigester/src/org/clothocad/tool/bglbrickdigester/.

Source file: connect.java

  17 
vote

@Override public void launch(){
  Preferences _prefs=Preferences.userNodeForPackage(digestMultiple.class);
  String uuid=_prefs.get("DefaultCollection","");
  Collection joshcoll=Collector.getCollection(uuid);
  if (joshcoll != null) {
    digestMultiple v=new digestMultiple(joshcoll);
    pig.add(new WeakReference(v));
    return;
  }
  Collection chosen=new Collection();
  digestMultiple v=new digestMultiple(chosen);
  pig.add(new WeakReference(v));
}
 

Example 8

From project commons-logging, under directory /src/test/org/apache/commons/logging/impl/.

Source file: WeakHashtableTest.java

  17 
vote

public void testRelease() throws Exception {
  assertNotNull(weakHashtable.get(new Long(1)));
  ReferenceQueue testQueue=new ReferenceQueue();
  WeakReference weakKeyOne=new WeakReference(keyOne,testQueue);
  keyOne=null;
  keyTwo=null;
  keyThree=null;
  valueOne=null;
  valueTwo=null;
  valueThree=null;
  int iterations=0;
  int bytz=2;
  while (true) {
    System.gc();
    if (iterations++ > MAX_GC_ITERATIONS) {
      fail("Max iterations reached before resource released.");
    }
    if (weakHashtable.get(new Long(1)) == null) {
      break;
    }
 else {
      byte[] b=new byte[bytz];
      bytz=bytz * 2;
    }
  }
  while (testQueue.poll() == null) {
  }
  assertEquals("underlying table not emptied",0,weakHashtable.size());
}
 

Example 9

From project clojure, under directory /src/jvm/clojure/lang/.

Source file: Keyword.java

  16 
vote

public static Keyword intern(Symbol sym){
  if (sym.meta() != null)   sym=(Symbol)sym.withMeta(null);
  Util.clearCache(rq,table);
  Keyword k=new Keyword(sym);
  Reference<Keyword> existingRef=table.putIfAbsent(sym,new WeakReference<Keyword>(k,rq));
  if (existingRef == null)   return k;
  Keyword existingk=existingRef.get();
  if (existingk != null)   return existingk;
  table.remove(sym,existingRef);
  return intern(sym);
}
 

Example 10

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 11

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 12

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: SimpleMenu.java

  15 
vote

/** 
 * Remove a presenter from this menu. That presenter will no longer receive notifications of updates to this menu's data.
 * @param presenter The presenter to remove
 */
public void removeMenuPresenter(SimpleMenuPresenter presenter){
  for (  WeakReference<SimpleMenuPresenter> ref : mPresenters) {
    final SimpleMenuPresenter item=ref.get();
    if (item == null || item == presenter) {
      mPresenters.remove(ref);
    }
  }
}
 

Example 13

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 14

From project AdminCmd, under directory /src/main/java/be/Balor/Manager/Permissions/.

Source file: PermissionManager.java

  15 
vote

public synchronized boolean addPermissionLinker(final PermissionLinker perm){
  final String name=perm.getName();
  if (name == null) {
    throw new NullPointerException();
  }
  final WeakReference<PermissionLinker> ref=permissionLinkers.get(name);
  if (ref != null) {
    if (ref.get() == null) {
      permissionLinkers.remove(name);
    }
 else {
      return false;
    }
  }
  permissionLinkers.put(name,new WeakReference<PermissionLinker>(perm));
  return true;
}
 

Example 15

From project aether-core, under directory /aether-impl/src/main/java/org/eclipse/aether/internal/impl/.

Source file: ObjectPool.java

  15 
vote

public synchronized T intern(T object){
  Reference<T> pooledRef=objects.get(object);
  if (pooledRef != null) {
    T pooled=pooledRef.get();
    if (pooled != null) {
      return pooled;
    }
  }
  objects.put(object,new WeakReference<T>(object));
  return object;
}
 

Example 16

From project agile, under directory /agile-web/src/main/java/org/headsupdev/agile/web/wicket/.

Source file: HeadsUpPageRequestTargetUrlCodingStrategy.java

  15 
vote

public HeadsUpPageRequestTargetUrlCodingStrategy(String mount,Class page){
  super(mount);
  if (page == null) {
    throw new IllegalArgumentException("Argument bookmarkablePageClass must be not null");
  }
  bookmarkablePageClassRef=new WeakReference<Class<? extends Page>>(page);
}
 

Example 17

From project akubra, under directory /akubra-rmi/src/main/java/org/akubraproject/rmi/server/.

Source file: Exportable.java

  15 
vote

/** 
 * Creates a new Exportable object.
 * @param exporter the exporter to use
 * @throws RemoteException on an export error
 */
protected Exportable(Exporter exporter) throws RemoteException {
  this.exporter=exporter;
  exported=new WeakReference<Remote>(exporter.exportObject(this));
  if (log.isDebugEnabled()) {
    String client=getClient();
    if (client != null)     log.debug("Exported " + this + " for "+ client);
 else     log.debug("Exported " + this + " for all clients.");
  }
}
 

Example 18

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 19

From project amplafi-sworddance, under directory /src/main/java/com/sworddance/taskcontrol/.

Source file: FutureListenerProcessor.java

  15 
vote

public void addFutureListener(FutureListener<RV> futureListener){
  if (isDone()) {
    if (this.throwable == null) {
      notifyListener(futureListener);
    }
 else {
      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();
    }
  }
}
 

Example 20

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 21

From project Android, under directory /app/src/main/java/com/github/mobile/.

Source file: GitHubModule.java

  15 
vote

@Provides IssueStore issueStore(IssueService issueService,PullRequestService pullService){
  IssueStore store=issues != null ? issues.get() : null;
  if (store == null) {
    store=new IssueStore(issueService,pullService);
    issues=new WeakReference<IssueStore>(store);
  }
  return store;
}
 

Example 22

From project android-async-http, under directory /src/com/loopj/android/http/.

Source file: AsyncHttpClient.java

  15 
vote

/** 
 * Cancels any pending (or potentially active) requests associated with the passed Context. <p> <b>Note:</b> This will only affect requests which were created with a non-null android Context. This method is intended to be used in the onDestroy method of your android activities to destroy all requests which are no longer required.
 * @param context the android Context instance associated to the request.
 * @param mayInterruptIfRunning specifies if active requests should be cancelled along with pending requests.
 */
public void cancelRequests(Context context,boolean mayInterruptIfRunning){
  List<WeakReference<Future<?>>> requestList=requestMap.get(context);
  if (requestList != null) {
    for (    WeakReference<Future<?>> requestRef : requestList) {
      Future<?> request=requestRef.get();
      if (request != null) {
        request.cancel(mayInterruptIfRunning);
      }
    }
  }
  requestMap.remove(context);
}
 

Example 23

From project android-database-sqlcipher, under directory /src/net/sqlcipher/database/.

Source file: SQLiteDatabase.java

  15 
vote

/** 
 * Open the database according to the flags  {@link #OPEN_READWRITE}{@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}. <p>Sets the locale of the database to the  the system's current locale. Call  {@link #setLocale} if you would like something else.</p>
 * @param path to database file to open and/or create
 * @param factory an optional factory class that is called to instantiate acursor when query is called, or null for default
 * @param flags to control database access mode
 * @return the newly opened database
 * @throws SQLiteException if the database cannot be opened
 */
public static SQLiteDatabase openDatabase(String path,String password,CursorFactory factory,int flags,SQLiteDatabaseHook databaseHook){
  SQLiteDatabase sqliteDatabase=null;
  try {
    sqliteDatabase=new SQLiteDatabase(path,password,factory,flags,databaseHook);
    if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
      sqliteDatabase.enableSqlTracing(path);
    }
    if (SQLiteDebug.DEBUG_SQL_TIME) {
      sqliteDatabase.enableSqlProfiling(path);
    }
  }
 catch (  SQLiteDatabaseCorruptException e) {
    Log.e(TAG,"Deleting and re-creating corrupt database " + path,e);
    if (!path.equalsIgnoreCase(":memory")) {
      new File(path).delete();
    }
    sqliteDatabase=new SQLiteDatabase(path,password,factory,flags,databaseHook);
  }
  ActiveDatabases.getInstance().mActiveDatabases.add(new WeakReference<SQLiteDatabase>(sqliteDatabase));
  return sqliteDatabase;
}
 

Example 24

From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/.

Source file: MainApplication.java

  15 
vote

public void registerAction(ActionBusListener actionBusListener,Integer... actions){
  if (null == actionBusListener || null == actions) {
    return;
  }
  for (  Integer action : actions) {
    List<WeakReference<ActionBusListener>> listeners=actionBusListeners.get(action);
    if (null == listeners) {
      listeners=new ArrayList<WeakReference<ActionBusListener>>();
    }
    removeReference(listeners,actionBusListener);
    listeners.add(new WeakReference<ActionBusListener>(actionBusListener));
    actionBusListeners.put(action,listeners);
  }
}
 

Example 25

From project android-flip, under directory /FlipView/FlipLibrary/src/com/aphidmobile/flip/.

Source file: ViewDualCards.java

  15 
vote

public boolean setView(int index,View view){
  UI.assertInMainThread();
  this.index=index;
  if (getView() == view && (screenshot != null || TextureUtils.isValidTexture(texture)))   return false;
  viewRef=null;
  if (texture != null) {
    texture.postDestroy();
    texture=null;
  }
  if (view != null) {
    viewRef=new WeakReference<View>(view);
    UI.recycleBitmap(screenshot);
    screenshot=GrabIt.takeScreenshot(view);
  }
 else {
    UI.recycleBitmap(screenshot);
  }
  return true;
}
 

Example 26

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/.

Source file: QuickActionBar.java

  15 
vote

@Override protected void populateQuickActions(List<QuickAction> quickActions){
  mQuickActions=quickActions;
  final LayoutInflater inflater=LayoutInflater.from(getContext());
  for (  QuickAction action : quickActions) {
    TextView view=(TextView)inflater.inflate(R.layout.gd_quick_action_bar_item,mQuickActionItems,false);
    view.setText(action.mTitle);
    view.setCompoundDrawablesWithIntrinsicBounds(null,action.mDrawable,null,null);
    view.setOnClickListener(mClickHandlerInternal);
    mQuickActionItems.addView(view);
    action.mView=new WeakReference<View>(view);
  }
}
 

Example 27

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharingExample/src/com/nostra13/example/socialsharing/assist/.

Source file: FacebookEventObserver.java

  15 
vote

/** 
 * Should be call at  {@link Activity#onStart()} 
 */
public void registerListeners(Activity context){
  this.context=new WeakReference<Activity>(context);
  FacebookEvents.addAuthListener(authListener);
  FacebookEvents.addPostListener(postListener);
  FacebookEvents.addLogoutListener(logoutListener);
}
 

Example 28

From project androidquery, under directory /src/com/androidquery/callback/.

Source file: AbstractAjaxCallback.java

  15 
vote

/** 
 * Set a callback handler with a weak reference. Use weak handler if you do not want the ajax callback to hold the handler object from garbage collection. For example, if the handler is an activity, weakHandler should be used since the method shouldn't be invoked if an activity is already dead and garbage collected.
 * @param handler the handler
 * @param callback the callback
 * @return self
 */
public K weakHandler(Object handler,String callback){
  this.whandler=new WeakReference<Object>(handler);
  this.callback=callback;
  this.handler=null;
  return self();
}
 

Example 29

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 30

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/applications/.

Source file: InstalledAppDetails.java

  15 
vote

DisableChanger(InstalledAppDetails activity,ApplicationInfo info,int state){
  mPm=activity.mPm;
  mActivity=new WeakReference<InstalledAppDetails>(activity);
  mInfo=info;
  mState=state;
}
 

Example 31

From project android_external_guava, under directory /src/com/google/common/base/internal/.

Source file: Finalizer.java

  15 
vote

/** 
 * Constructs a new finalizer thread. 
 */
private Finalizer(Class<?> finalizableReferenceClass,Object frq){
  super(Finalizer.class.getName());
  this.finalizableReferenceClassReference=new WeakReference<Class<?>>(finalizableReferenceClass);
  this.frqReference=new PhantomReference<Object>(frq,queue);
  setDaemon(true);
  try {
    if (inheritableThreadLocals != null) {
      inheritableThreadLocals.set(this,null);
    }
  }
 catch (  Throwable t) {
    logger.log(Level.INFO,"Failed to clear thread local values inherited" + " by reference finalizer thread.",t);
  }
}
 

Example 32

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: ThumbnailLoader.java

  15 
vote

/** 
 * @param parentFile The current directory.
 * @param text The IconifiedText container.
 * @param imageView The ImageView from the IconifiedTextView.
 */
public void loadImage(String parentFile,IconifiedText text,ImageView imageView){
  if (!cancel && !mBlacklist.contains(text.getText())) {
    resetPurgeTimer();
    Bitmap bitmap=getBitmapFromCache(text.getText());
    if (bitmap != null) {
      imageView.setImageBitmap(bitmap);
      text.setIcon(bitmap);
    }
 else {
      if (!cancel) {
        Thumbnail thumbnail=new Thumbnail(parentFile,imageView,text);
        WeakReference<ThumbnailRunner> runner=new WeakReference<ThumbnailRunner>(new ThumbnailRunner(thumbnail));
        mExecutor.submit(runner.get());
      }
    }
  }
}
 

Example 33

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: MenuHelper.java

  15 
vote

private static void setLatLngDetails(final View d,Activity context,ExifInterface exif){
  float[] latlng=new float[2];
  if (exif.getLatLong(latlng)) {
    setDetailsValue(d,String.valueOf(latlng[0]),R.id.details_latitude_value);
    setDetailsValue(d,String.valueOf(latlng[1]),R.id.details_longitude_value);
    if (latlng[0] == INVALID_LATLNG || latlng[1] == INVALID_LATLNG) {
      hideDetailsRow(d,R.id.details_latitude_row);
      hideDetailsRow(d,R.id.details_longitude_row);
      hideDetailsRow(d,R.id.details_location_row);
      return;
    }
    UpdateLocationCallback cb=new UpdateLocationCallback(new WeakReference<View>(d));
    Geocoder geocoder=new Geocoder(context);
    new ReverseGeocoderTask(geocoder,latlng,cb).execute();
  }
 else {
    hideDetailsRow(d,R.id.details_latitude_row);
    hideDetailsRow(d,R.id.details_longitude_row);
    hideDetailsRow(d,R.id.details_location_row);
  }
}
 

Example 34

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/data/.

Source file: Path.java

  15 
vote

public void setObject(MediaObject object){
synchronized (Path.class) {
    Utils.assertTrue(mObject == null || mObject.get() == null);
    mObject=new WeakReference<MediaObject>(object);
  }
}
 

Example 35

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.

Source file: MyTagList.java

  15 
vote

@Override protected Dialog onCreateDialog(int id,Bundle args){
  Context lightTheme=new ContextThemeWrapper(this,android.R.style.Theme_Light);
  if (id == DIALOG_ID_SELECT_ACTIVE_TAG) {
    SelectActiveTagDialog dialog=new SelectActiveTagDialog(lightTheme,mAdapter.getCursor());
    dialog.setInverseBackgroundForced(true);
    mSelectActiveTagDialog=new WeakReference<SelectActiveTagDialog>(dialog);
    return dialog;
  }
 else   if (id == DIALOG_ID_ADD_NEW_TAG) {
    ContentSelectorAdapter adapter=new ContentSelectorAdapter(lightTheme,SUPPORTED_TYPES);
    AlertDialog dialog=new AlertDialog.Builder(lightTheme).setTitle(R.string.select_type).setIcon(0).setNegativeButton(android.R.string.cancel,this).setAdapter(adapter,this).create();
    adapter.setListView(dialog.getListView());
    dialog.setInverseBackgroundForced(true);
    return dialog;
  }
  return super.onCreateDialog(id,args);
}
 

Example 36

From project apps-for-android, under directory /Panoramio/src/com/google/android/panoramio/.

Source file: ImageManager.java

  15 
vote

/** 
 * Called when something changes in our data set. Cleans up any weak references that are no longer valid along the way.
 */
private void notifyObservers(){
  final ArrayList<WeakReference<DataSetObserver>> observers=mObservers;
  final int count=observers.size();
  for (int i=count - 1; i >= 0; i--) {
    WeakReference<DataSetObserver> weak=observers.get(i);
    DataSetObserver obs=weak.get();
    if (obs != null) {
      obs.onChanged();
    }
 else {
      observers.remove(i);
    }
  }
}
 

Example 37

From project arquillian-core, under directory /container/spi/src/main/java/org/jboss/arquillian/container/spi/client/protocol/metadata/.

Source file: JMXContext.java

  15 
vote

/** 
 * @return the openConnection
 */
public MBeanServerConnection getConnection(){
  if (connection == null) {
    try {
      JMXConnector connector=JMXConnectorFactory.connect(getRemoteJMXURL(),null);
      connection=connector.getMBeanServerConnection();
      WeakReference<MBeanServerConnection> ref=new JMXConnectorReference(connection,connector);
      jmxConnectorRefs.add(ref);
    }
 catch (    IOException e) {
      throw new RuntimeException("Could not create remote JMX connection: " + this,e);
    }
  }
  return connection;
}
 

Example 38

From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/.

Source file: DynamicCollection.java

  15 
vote

public DynamicIterator iterator(int index){
  DynamicIterator iterator=createIterator(index);
synchronized (lock) {
    for (Iterator<WeakReference<DynamicIterator>> it=iterators.iterator(); it.hasNext(); ) {
      if (it.next().get() == null) {
        it.remove();
      }
    }
    iterators.add(new WeakReference<DynamicIterator>(iterator));
  }
  return iterator;
}
 

Example 39

From project BMach, under directory /src/jsyntaxpane/actions/gui/.

Source file: GotoLineDialog.java

  15 
vote

/** 
 * Creates new form GotoLineDialog
 * @param text
 */
private GotoLineDialog(JTextComponent text){
  super(ActionUtils.getFrameFor(text),false);
  initComponents();
  this.text=new WeakReference<JTextComponent>(text);
  setLocationRelativeTo(text.getRootPane());
  getRootPane().setDefaultButton(jBtnOk);
  text.getDocument().putProperty(PROPERTY_KEY,this);
  SwingUtils.addEscapeListener(this);
}
 

Example 40

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: GetThumbnailTask.java

  15 
vote

/** 
 * Constructor. Clean the view and save the details of what we want.
 * @param queue
 * @param bookId
 * @param v
 * @param width
 * @param height
 */
public GetThumbnailTask(final String hash,final ImageView v,int maxWidth,int maxHeight,boolean cacheWasChecked){
  clearOldTaskFromView(v);
  mView=new WeakReference<ImageView>(v);
  mBookHash=hash;
  mCacheWasChecked=cacheWasChecked;
  mWidth=maxWidth;
  mHeight=maxHeight;
  v.setImageBitmap(null);
  ViewTagger.setTag(v,R.id.TAG_GET_THUMBNAIL_TASK,this);
}
 

Example 41

From project camel-osgi, under directory /component/src/main/java/org/apache/camel/osgi/service/util/.

Source file: DynamicCollection.java

  15 
vote

public DynamicIterator iterator(int index){
  DynamicIterator iterator=createIterator(index);
synchronized (lock) {
    for (Iterator<WeakReference<DynamicIterator>> it=iterators.iterator(); it.hasNext(); ) {
      if (it.next().get() == null) {
        it.remove();
      }
    }
    iterators.add(new WeakReference<DynamicIterator>(iterator));
  }
  return iterator;
}
 

Example 42

From project ceres, under directory /ceres-jai/src/main/java/com/bc/ceres/jai/tilecache/.

Source file: MemoryTile.java

  15 
vote

MemoryTile(RenderedImage owner,int tileX,int tileY,Raster tile,Object tileCacheMetric){
  this.owner=new WeakReference<RenderedImage>(owner);
  this.tile=tile;
  this.tileX=tileX;
  this.tileY=tileY;
  this.tileCacheMetric=tileCacheMetric;
  this.key=hashKey(owner,tileX,tileY);
  DataBuffer db=tile.getDataBuffer();
  this.tileSize=DataBuffer.getDataTypeSize(db.getDataType()) / 8L * db.getSize() * db.getNumBanks();
}
 

Example 43

From project Cinch, under directory /src/com/palantir/ptoss/cinch/core/.

Source file: WeakBindableModelSupport.java

  15 
vote

/** 
 * {@inheritDoc}
 */
public <T extends Enum<T> & ModelUpdate>void modelUpdated(final T... changed){
  final Set<WeakReference<Binding>> toRemove=Sets.newHashSet();
  for (  final WeakReference<Binding> weakBinding : bindings) {
    final Binding binding=weakBinding.get();
    if (binding != null) {
      binding.update(changed);
    }
 else {
      toRemove.add(weakBinding);
    }
  }
  if (!toRemove.isEmpty()) {
    bindings.removeAll(toRemove);
  }
}
 

Example 44

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/pl/polidea/coverflow/.

Source file: AbstractCoverFlowImageAdapter.java

  15 
vote

@Override public Object getItem(final int position){
  final WeakReference<Bitmap> weakBitmapReference=bitmapMap.get(position);
  if (weakBitmapReference != null) {
    final Bitmap bitmap=weakBitmapReference.get();
    if (bitmap == null) {
      Log.v(TAG,"Empty bitmap reference at position: " + position + ":"+ this);
    }
 else {
      Log.v(TAG,"Reusing bitmap item at position: " + position + ":"+ this);
      return bitmap;
    }
  }
  Log.v(TAG,"Creating item at position: " + position + ":"+ this);
  final Bitmap bitmap=createBitmap(position);
  bitmapMap.put(position,new WeakReference<Bitmap>(bitmap));
  Log.v(TAG,"Created item at position: " + position + ":"+ this);
  return bitmap;
}
 

Example 45

From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/nodes/.

Source file: CCTextureCache.java

  15 
vote

/** 
 * Purges the dictionary of loaded textures. Call this method if you receive the "Memory Warning" In the short term: it will free some resources preventing your app from being killed In the medium term: it will allocate more resources In the long term: it will be the same
 */
public void removeAllTextures(){
  for (  WeakReference<CCTexture2D> texSR : textures.values()) {
    CCTexture2D tex=texSR.get();
    if (tex != null)     tex.releaseTexture(CCDirector.gl);
  }
  textures.clear();
}
 

Example 46

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/util/sqleditor/components/.

Source file: DataBasePopupLogic.java

  15 
vote

public DataBasePopupLogic(EventsBinder eventsBinder,DatabaseJTree databaseJTree,SQLSyntaxEditor sqlEditor) throws EventBinderException {
  weakDatabaseJTree=new WeakReference<DatabaseJTree>(databaseJTree);
  weakSqlEditor=new WeakReference<SQLSyntaxEditor>(sqlEditor);
  dataBasePopupGui=new DataBasePopupGui();
  eventsBinder.bind(this,dataBasePopupGui);
}
 

Example 47

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  15 
vote

private AnimatorProxy(View view){
  setDuration(0);
  setFillAfter(true);
  view.setAnimation(this);
  mView=new WeakReference<View>(view);
}
 

Example 48

From project connectbot, under directory /src/sk/vx/connectbot/service/.

Source file: TerminalManager.java

  15 
vote

/** 
 * Open a new SSH session using the given parameters.
 */
private TerminalBridge openConnection(HostBean host) throws IllegalArgumentException, IOException {
  if (getConnectedBridge(host) != null) {
    throw new IllegalArgumentException("Connection already open for that nickname");
  }
  TerminalBridge bridge=new TerminalBridge(this,host);
  bridge.setOnDisconnectedListener(this);
  bridge.startConnection();
synchronized (bridges) {
    bridges.add(bridge);
    WeakReference<TerminalBridge> wr=new WeakReference<TerminalBridge>(bridge);
    mHostBridgeMap.put(bridge.host,wr);
    mNicknameBridgeMap.put(bridge.host.getNickname(),wr);
  }
synchronized (disconnected) {
    disconnected.remove(bridge.host);
  }
  if (bridge.isUsingNetwork()) {
    connectivityManager.incRef();
  }
  if (prefs.getBoolean(PreferenceConstants.CONNECTION_PERSIST,true)) {
    connectionNotifier.showRunningNotification(this);
  }
  touchHost(host);
  return bridge;
}