Android Open Source - location-sharing-android Sign Up Activity






From Project

Back to project page location-sharing-android.

License

The source code is released under:

MIT License

If you think the Android project location-sharing-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package lv.lu.locationsharing;
//from w ww .  j a v a 2  s .  co m
import lv.lu.locationsharing.model.Registration;
import lv.lu.locationsharing.requests.registration.RegistrationRequest;

import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.ResourceAccessException;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.octo.android.robospice.JacksonSpringAndroidSpiceService;
import com.octo.android.robospice.SpiceManager;
import com.octo.android.robospice.persistence.DurationInMillis;
import com.octo.android.robospice.persistence.exception.SpiceException;
import com.octo.android.robospice.request.listener.RequestListener;

public class SignUpActivity extends Activity {

  private String mEmail;
  private String mPassword;
  private String mPasswordConfirm;
  private String mName;
  private EditText mEmailView;
  private EditText mPasswordView;
  private EditText mPasswordConfirmView;
  private EditText mNameView;
  protected SpiceManager spiceManager;
  private static final Object REGISTRATION_CACHE_KEY = "RegistrationCacheKey";
  protected Context context;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_sign_up);

    spiceManager = new SpiceManager(JacksonSpringAndroidSpiceService.class);

    mEmailView = (EditText) findViewById(R.id.email);
    mPasswordView = (EditText) findViewById(R.id.password);
    mPasswordConfirmView = (EditText) findViewById(R.id.password_conf);
    mNameView = (EditText) findViewById(R.id.name);

    findViewById(R.id.sign_up_button).setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mEmail = mEmailView.getText().toString();
            mPassword = mPasswordView.getText().toString();
            mPasswordConfirm = mPasswordConfirmView.getText()
                .toString();
            mName = mNameView.getText().toString();

            doRegistration(mEmail, mPassword, mPasswordConfirm,
                mName);
          }
        });
  }

  @Override
  protected void onStart() {
    super.onStart();
    spiceManager.start(this);

  }

  @Override
  protected void onStop() {
    spiceManager.shouldStop();
    super.onStop();
  }

  public void doRegistration(String Email, String Password,
      String PasswordConfirm, String Name) {
    // spiceManager.execute(new RegistrationRequest(this.context, Email,
    // Password, PasswordConfirm, Name), "",
    spiceManager.execute(new RegistrationRequest(this.context,
        Email, Password, PasswordConfirm, Name), "",
        DurationInMillis.ALWAYS_EXPIRED, new AuthenticationListener());
  }

  private class AuthenticationListener implements
      RequestListener<Registration> {

    @Override
    public void onRequestFailure(SpiceException spiceException) {

      if (spiceException.getCause() instanceof HttpClientErrorException) {
        HttpClientErrorException cause = (HttpClientErrorException) spiceException
            .getCause();

        switch (Integer.valueOf(cause.getStatusCode().toString())) {
        case 401:
          Log.d("LocationSharing", "Unauthorized");
          break;

        default:
          break;
        }
      } else if (spiceException.getCause() instanceof ResourceAccessException) {

      }
      Toast.makeText(SignUpActivity.this,
          "Neizdev?s re?istr?ties .", Toast.LENGTH_LONG)
          .show();
    }

    @Override
    public void onRequestSuccess(Registration arg0) {
      Toast.makeText(SignUpActivity.this,
          "Re?istr?cija veiksm?ga.", Toast.LENGTH_LONG)
          .show();
      Intent i = new Intent(getBaseContext(), LoginActivity.class);
      startActivity(i);    }
  }

}




Java Source Code List

lv.lu.locationsharing.Fragment1.java
lv.lu.locationsharing.Fragment2.java
lv.lu.locationsharing.Fragment3.java
lv.lu.locationsharing.Fragment4.java
lv.lu.locationsharing.Fragment5.java
lv.lu.locationsharing.LocationBroadcastReceiver.java
lv.lu.locationsharing.LoginActivity.java
lv.lu.locationsharing.MainActivity.java
lv.lu.locationsharing.MenuListAdapter.java
lv.lu.locationsharing.SignUpActivity.java
lv.lu.locationsharing.application.LocationApplication.java
lv.lu.locationsharing.config.Config.java
lv.lu.locationsharing.listview.adapter.RequestAdapter.java
lv.lu.locationsharing.model.AuthenticationStatus.java
lv.lu.locationsharing.model.Friend.java
lv.lu.locationsharing.model.GetFriends.java
lv.lu.locationsharing.model.InviteFriends.java
lv.lu.locationsharing.model.LocationPostStatus.java
lv.lu.locationsharing.model.Registration.java
lv.lu.locationsharing.requests.authentication.AuthenticationRequest.java
lv.lu.locationsharing.requests.authentication.AuthenticationStatusRequest.java
lv.lu.locationsharing.requests.friends.ConfirmFriendRequest.java
lv.lu.locationsharing.requests.friends.GetFriendsRequest.java
lv.lu.locationsharing.requests.friends.InviteFriendsRequest.java
lv.lu.locationsharing.requests.friends.PostLogout.java
lv.lu.locationsharing.requests.location.PostLocationUpdate.java
lv.lu.locationsharing.requests.registration.RegistrationRequest.java
lv.lu.locationsharing.utils.Constants.java
lv.lu.locationsharing.utils.Installation.java
lv.lu.locationsharing.utils.Url.java
lv.lu.locationsharing.utils.Utils.java