當前位置: 首頁>>代碼示例>>Java>>正文


Java WeakReference.clear方法代碼示例

本文整理匯總了Java中java.lang.ref.WeakReference.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java WeakReference.clear方法的具體用法?Java WeakReference.clear怎麽用?Java WeakReference.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.ref.WeakReference的用法示例。


在下文中一共展示了WeakReference.clear方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unregisterCursor

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
/**
 * Deregisters a cursor from the list to be notified of changes.
 *
 * @param cursor  the cursor to deregister
 */
protected void unregisterCursor(final Cursor<E> cursor) {
    for (final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
        final WeakReference<Cursor<E>> ref = it.next();
        final Cursor<E> cur = ref.get();
        if (cur == null) {
            // some other unrelated cursor object has been
            // garbage-collected; let's take the opportunity to
            // clean up the cursors list anyway..
            it.remove();
        } else if (cur == cursor) {
            ref.clear();
            it.remove();
            break;
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:CursorableLinkedList.java

示例2: compressBitmap

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
public static byte[] compressBitmap(String path, int maxSize, int rqsW, int rqsH) {
    if (TextUtils.isEmpty(path)) {
        return null;
    }
    try {
        WeakReference<Bitmap> bitmap = cprsBmpBySize(path, rqsW, rqsH);
        WeakReference<Bitmap> rotatedBmp = autoRotateBitmap(path, bitmap);
        if (!(bitmap == null || rotatedBmp == null || bitmap.get() == rotatedBmp.get())) {
            ((Bitmap) bitmap.get()).recycle();
            bitmap.clear();
        }
        return cprsBmpByQuality(rotatedBmp, maxSize);
    } catch (Exception e) {
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:BitmapUtils.java

示例3: removeAllInternetConnectivityChangeListeners

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
public void removeAllInternetConnectivityChangeListeners() {
    if (mInternetConnectivityListenersWeakReferences == null) {
        return;
    }

    Iterator<WeakReference<InternetConnectivityListener>> iterator = mInternetConnectivityListenersWeakReferences.iterator();
    while (iterator.hasNext()) {
        WeakReference<InternetConnectivityListener> reference = iterator.next();
        if (reference != null) {
            reference.clear();
        }
        iterator.remove();
    }
    unregisterNetworkChangeReceiver();
}
 
開發者ID:AggarwalAnkit,項目名稱:InternetAvailabilityChecker,代碼行數:16,代碼來源:InternetAvailabilityChecker.java

示例4: instantiateItem

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
@NonNull
@Override
public Object instantiateItem(@NonNull final ViewGroup container, final int position) {
    final Fragment mFragment = (Fragment) super.instantiateItem(container, position);
    final WeakReference<Fragment> mWeakFragment = mFragmentArray.get(position);
    if (mWeakFragment != null) {
        mWeakFragment.clear();
    }
    mFragmentArray.put(position, new WeakReference<>(mFragment));
    return mFragment;
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:12,代碼來源:MusicLibraryPagerAdapter.java

示例5: destroyItem

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
@Override
public void destroyItem(final ViewGroup container, final int position, final Object object) {
    super.destroyItem(container, position, object);
    final WeakReference<Fragment> mWeakFragment = mFragmentArray.get(position);
    if (mWeakFragment != null) {
        mWeakFragment.clear();
    }
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:9,代碼來源:MusicLibraryPagerAdapter.java

示例6: destroyItem

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    super.destroyItem(container, position, object);
    WeakReference<Fragment> weakFragment = weakFragmentMap.get(position);
    if (weakFragment != null) {
        weakFragment.clear();
    }
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:9,代碼來源:HistoryTabFragment.java

示例7: changeDataset

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
public void changeDataset() {
    for (int i = 0; i < weakFragmentMap.size(); i++) {
        WeakReference<Fragment> weakFragment = weakFragmentMap.valueAt(i);
        if (weakFragment != null) {
            weakFragment.clear();
        }
    }
    notifyDataSetChanged();
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:10,代碼來源:HistoryTabFragment.java

示例8: remove

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
public XulDrawable remove(String key) {
	WeakReference<XulDrawable> xulDrawableWeakReference = _cache.remove(key);
	if (xulDrawableWeakReference == null) {
		return null;
	}
	XulDrawable xulDrawable = xulDrawableWeakReference.get();
	xulDrawableWeakReference.clear();
	return xulDrawable;
}
 
開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:10,代碼來源:XulWorker.java

示例9: removeInternetConnectivityChangeListener

import java.lang.ref.WeakReference; //導入方法依賴的package包/類
/**
 * remove the weak reference to the listener
 */
public void removeInternetConnectivityChangeListener(InternetConnectivityListener internetConnectivityListener) {
    if (internetConnectivityListener == null) {
        return;
    }

    if (mInternetConnectivityListenersWeakReferences == null) {
        return;
    }

    Iterator<WeakReference<InternetConnectivityListener>> iterator = mInternetConnectivityListenersWeakReferences.iterator();
    while (iterator.hasNext()) {

        //if weak reference is null then remove it from iterator
        WeakReference<InternetConnectivityListener> reference = iterator.next();
        if (reference == null) {
            iterator.remove();
            continue;
        }

        //if listener referenced by this weak reference is garbage collected then remove it from iterator
        InternetConnectivityListener listener = reference.get();
        if (listener == null) {
            reference.clear();
            iterator.remove();
            continue;
        }

        //if listener to be removed is found then remove it
        if (listener == internetConnectivityListener) {
            reference.clear();
            iterator.remove();
            break;
        }
    }

    //if all listeners are removed then unregister NetworkChangeReceiver
    if (mInternetConnectivityListenersWeakReferences.size() == 0) {
        unregisterNetworkChangeReceiver();
    }
}
 
開發者ID:AggarwalAnkit,項目名稱:InternetAvailabilityChecker,代碼行數:44,代碼來源:InternetAvailabilityChecker.java


注:本文中的java.lang.ref.WeakReference.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。