What is the purpose of interface inside a Java class?

Viewed 166

In the sample code below, I have an interface inside class so that I'm using the methods of interface. But i don't see any effect with/without interface methods. Can someone help me what is the purpose of adding including them?

public class Controller {

    FlowerCallBackReceiver mListener;

    @Override
    public void success(String s, Response response) {
        try { 
            mListener.onFetchProgress(flower);
        } catch (JSONException e) {
            mListener.onFetchFailed();
        }
        mListener.onFetchComplete();
    }

    @Override
    public void failure(RetrofitError error) {
        mListener.onFetchComplete();
    }

    public interface FlowerCallBackReceiver {
        void onFetchProgress(Flower flower);
        void onFetchComplete();
        void onFetchFailed();
    }
}
2 Answers
Related