I have an Activity which implements two interfaces for call backs on certain actions. I want to send a context of my Activity to another Class which will access the object of the specified callback.
Here is my code :-
public class OpenSchoolFragment extends Fragment implements IOpenSchoolCallBack, INetworkCallback
{
// 1st case
expandableListAdapter = new AdapterOpenSchool(getActivity(), this); // IOpenSchoolCallBack should provided
//2nd case
call.enqueue(new Callback<OpenSchool>()
{
@Override
public void onResponse(Call<OpenSchool> call, Response<OpenSchool> response)
{
if (response.isSuccessful())
{
OpenSchool userBatch = response.body();
if (userBatch != null)
{
RLProgressRoot.setVisibility(View.GONE);
}
}
else
{
RLProgressRoot.setVisibility(View.GONE);
if (response.code() == getResources().getInteger(R.integer.integer_404))
{
DialogHelperUtil.showRetrySnackbar(RLContainer, getString(R.string.str_error_unauthorised),this); //INetworkCallBack should be provided
}
else
{
DialogHelperUtil.showMessageSnackbar(RLContainer, response.raw().message());
}
}
}
}
So when I try to pass "this" in the second case, I get an error saying :-
Wrong 3rd argument type. Found: 'Callback<OpenSchool>', required: 'INetworkCallback'
How can I make sure the right callback is passed in "this" for the second case ie. INetworkCallback
?