Code example for WeakReference

Methods: clear

0
        if (localDrawable != null)
            localDrawable.setCallback(null);
         
        // If this View still exists, clears the weak reference, then sets the reference to null 
        if (mThisView != null) {
            mThisView.clear();
            mThisView = null;
        } 
         
        // Sets the downloader thread to null 
        this.mDownloadThread = null;
         
        // Always call the super method last 
        super.onDetachedFromWindow(); 
    } 
 
    /* 
     * This callback is invoked when the system tells the View to draw itself. If the View isn't 
     * already drawn, and its URL isn't null, it invokes a Thread to download the image. Otherwise, 
     * it simply passes the existing Canvas to the super method 
     */