示例#1
0
  @Override
  public void onRequestFinish(MegaApiJava api, MegaRequest request, MegaError e) {
    log("onRequestFinish: " + request.getRequestString());

    if (request.getType() == MegaRequest.TYPE_LOGIN) {
      if (e.getErrorCode() == MegaError.API_OK) {
        megaApi.fetchNodes(this);
      } else {
        String errorMessage = e.getErrorString();
        if (e.getErrorCode() == MegaError.API_ENOENT) {
          errorMessage = getString(R.string.error_incorrect_email_or_password);
        }
        Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();

        title.setText(getResources().getString(R.string.login_text));
        loginText.setVisibility(View.VISIBLE);
        passwordText.setVisibility(View.VISIBLE);
        loginButton.setVisibility(View.VISIBLE);
      }
    } else if (request.getType() == MegaRequest.TYPE_FETCH_NODES) {
      if (e.getErrorCode() != MegaError.API_OK) {
        Toast.makeText(this, e.getErrorString(), Toast.LENGTH_LONG).show();
        title.setText(getResources().getString(R.string.login_text));
        loginText.setVisibility(View.VISIBLE);
        passwordText.setVisibility(View.VISIBLE);
        loginButton.setVisibility(View.VISIBLE);
        fetchingNodesBar.setProgress(0);
        fetchingNodesBar.setVisibility(View.GONE);
      } else {
        Intent intent = new Intent(this, NavigationActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        finish();
      }
    }
  }
示例#2
0
 public static void log(String message) {
   MegaApiAndroid.log(MegaApiAndroid.LOG_LEVEL_INFO, message, "MainActivity");
 }
示例#3
0
  private void onKeysGenerated(String privateKey, String publicKey) {
    this.gPrivateKey = privateKey;
    this.gPublicKey = publicKey;

    megaApi.fastLogin(email, publicKey, privateKey, this);
  }