Android java.lang.NullPointerException: Attempt to invoke interface method
<p>I have use<br>
<a href="https://github.com/justomiguel/AndroidCubeDemo" rel="nofollow">Android Cube Demo</a></p>

<p>In CubeLayout class. I add a interface CubeCompleted  </p>

<p>public class CubeLayout extends FrameLayout {</p>

<pre><code>private BaseInterpolator mInterpolator = new AccelerateDecelerateInterpolator();

public CubeLayout(Context context) {
    this(context, null);
}

public CubeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

public CubeLayout(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    View foregroundView = getChildAt(0);
    View backgroundView = getChildAt(1);

    CubeLeftOutAnimation cubeLeftOutAnimation = new CubeLeftOutAnimation();
    cubeLeftOutAnimation.setDuration(1000);
    cubeLeftOutAnimation.setFillAfter(true);

    CubeRightInAnimation cubeRightInAnimation = new CubeRightInAnimation();
    cubeRightInAnimation.setDuration(1000);
    cubeRightInAnimation.setFillAfter(true);

    foregroundView.startAnimation(cubeLeftOutAnimation);
    backgroundView.startAnimation(cubeRightInAnimation);

    cubeRightInAnimation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            completed.completedCube();

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

}
public interface CubeCompleted {
    public void completedCube();
}

CubeCompleted completed;

}
</code></pre>

<p>In my Activity. I have Replace a Fragment</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    FragmentManager manager = getSupportFragmentManager();
    manager.beginTransaction()
            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
            .replace(R.id.content_main, mHomeFragment)
            .commit();

}
</code></pre>

<p>In MyFragment. I overide completedCube</p>

<pre><code>public class HomeFragment extends Fragment implements CubeLayout.CubeCompleted {

 @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_home, container, false);

    return view;
}

@Override
public void completedCube() {
    //  donutProgress();
}
}
</code></pre>

<p>This is my Bug in Logcat</p>

<pre><code>Process: com.seesaa.newsaudiocast, PID: 31189  

                                                                   java.lang.NullPointerException: Attempt to invoke interface method 'void com.view.CubeLayout$CubeCompleted.completedCube()' on a null object reference
at com.seesaa.newsaudiocast.view.CubeLayout$1.onAnimationEnd(CubeLayout.java:56)
at android.view.animation.Animation$3.run(Animation.java:374)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
</code></pre>