Created
May 11, 2019 21:53
-
-
Save madsunrise/81f2dc65536ed260126fece15ebe4028 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void isAuthorised(Callback callback) { | |
if (mSettings.contains(APP_PREFERENCES_LOGIN) && mSettings.contains(APP_PREFERENCES_PASSWORD)) { | |
final String login = mSettings.getString(APP_PREFERENCES_LOGIN, ""); | |
final String passwd = mSettings.getString(APP_PREFERENCES_PASSWORD, ""); | |
NetworkService.getInstance().getApi().getUserWithCreds(login, passwd).enqueue(new Callback<User>() { | |
@Override | |
public void onResponse(Call<User> call, Response<User> response) { | |
User u = response.body(); | |
callback.onResult(u.isHasPermit()); | |
} | |
@Override | |
public void onFailure(Call<User> call, Throwable t) { | |
Log.e(LOG_TAG, t.getMessage(), t); | |
callback.onResult(false); | |
} | |
}); | |
} else { | |
callback.onResult(false); | |
} | |
public interface Callback { | |
void onResult(boolean authSuccessful); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment