package cn.droidlover.xdroidmvp.mvp;

/**
 * Created by wanglei on 2016/12/29.
 */

public class XPresent<V extends IView> implements IPresent<V> {
    private V v;

    @Override
    public void attachV(V view) {
        v = view;
    }

    @Override
    public void detachV() {
        v = null;
    }

    protected V getV() {
        if (v == null) {
            throw new IllegalStateException("v can not be null");
        }
        return v;
    }
}

@@ -31,16 +31,53 @@
 p.mvp;%0A%0A
+import java.lang.ref.WeakReference;%0A%0A
 /**%0A * C
@@ -190,17 +190,32 @@
 private 
-V
+WeakReference%3CV%3E
  v;%0A%0A   
@@ -271,20 +271,42 @@
     v = 
+new WeakReference%3CV%3E(
 view
+)
 ;%0A    %7D%0A
@@ -344,24 +344,88 @@
 detachV() %7B%0A
+        if (v.get() != null) %7B%0A            v.clear();%0A        %7D%0A
         v = 
@@ -555,32 +555,32 @@
 ll%22);%0A        %7D%0A
-
         return v
@@ -579,16 +579,22 @@
 return v
+.get()
 ;%0A    %7D%0A

add weak referense