Soft reference and weak reference
<p>I'm cursious about the soft and weak references in the Java environment. I have also read a bit about both topics. Just to sum up, the weak reference are as the name says, weak references to an object. This means that the reference to this object is easily collected by the <code>GC</code>. A weak reference is created this way:</p>

<pre><code>WeakReference&lt;SomeOtherRef&gt; weakReference = new WeakReference(someOtherRef); 
</code></pre>

<p>On the other hand a soft reference will stick around much longer than a weak reference. So my question is:</p>

<p>In my application, I have a custom adapter for a <code>ListView</code> This class will handle all the basic <code>ListView</code> stuff as handling clicks etc. When the user click on off the items in my list, a AsyncTask will be started. </p>

<pre><code>convertView.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                LoadCase loadCase = new LoadCase(position, holder);
                loadCase.execute("");

            }
        });
</code></pre>

<p>For now I dont show any progressDialog, for one reason. The <code>context</code> object. My problem is that the <code>Activity</code> which will initialize the CustomAdapter holds many object, and I have to pass a reference to the <code>Activity Context</code> in order to show a <code>ProgressDialog</code>, this <strong>will</strong> cause memory leaks, yes, I have tried. Is it safe to apply the Weak/Soft reference to deal with this? A <code>WeakReference</code> can be, at some time, null..this will cause a <code>NullPointerException</code> when I try to initialize my <code>ProgressDialog</code>. </p>
