Android Open Source - student_travel_app Signup Activity






From Project

Back to project page student_travel_app.

License

The source code is released under:

Apache License

If you think the Android project student_travel_app 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 com.piasy.simpletravel;
/*from  w  ww . j a  v  a  2 s. co m*/
import org.json.JSONException;
import org.json.JSONObject;

import com.piasy.simpletravel.controller.Controller;
import com.piasy.simpletravel.model.Constant;
import com.piasy.simpletravel.util.Util;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SignupActivity extends Activity
{
  EditText mailEdit, passEdit, nameEdit;
  Button signupButton;
  String mail, password, name;
  Controller myController;
  ProgressDialog dialog = null;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup_one);
    
    myController = Controller.getController();
    myController.setActivityHandler(handler);
    
    mailEdit = (EditText) findViewById(R.id.mailEdit);
    passEdit = (EditText) findViewById(R.id.passwordEdit);
    nameEdit = (EditText) findViewById(R.id.nameEdit);
    signupButton = (Button) findViewById(R.id.signupButton);
    
    signupButton.setOnClickListener(new View.OnClickListener()
    {
      
      @Override
      public void onClick(View v)
      {
        mail = mailEdit.getText().toString();
        password = passEdit.getText().toString();
        name = nameEdit.getText().toString();
        
        if (mail.equals(""))
        {
          Controller.makeToast("???????");
          return;
        }
        if (password.equals("") || password.length() < 6)
        {
          Controller.makeToast("??????????????");
          return;
        }
        if (name.equals(""))
        {
          Controller.makeToast("???????");
          return;
        }
        
        JSONObject info = new JSONObject();
        try
        {
          info.put("name", name);
        }
        catch (JSONException e)
        {
          e.printStackTrace();
        }
        
        //salt hash
        password = Util.getSHA1Value(Util.getSHA1Value(mail) + Util.getSHA1Value(password));
        myController.signup(mail, password, info);
        
        dialog = new ProgressDialog(SignupActivity.this);
        dialog.setMessage("?????????...");
        dialog.setIndeterminate(false);
        dialog.setCancelable(true);
        dialog.show();
      }
    });
  }
  
  @SuppressLint("HandlerLeak")
  Handler handler = new Handler()
  {
    public void handleMessage(Message msg)
    {
      Log.d(Constant.LOG_LEVEL_DEBUG, "get info at launch activity : " + (String)msg.obj);
      
      try
      {
        JSONObject info = new JSONObject((String)msg.obj);
        
        String type = info.getString("type");
        
        if (type.equals("signup"))
        {
          if (dialog != null)
          {
            dialog.cancel();
          }
          
          if (info.getString("result").equals("success"))
          {
            Intent data = new Intent();
            data.putExtra("username", mail);
            data.putExtra("password", password);
            setResult(Constant.SIGNUP_SUCCESS, data);
            finish();
          }
          else
          {
            Controller.makeToast(info.getString("reason"));
          }
        }
      }
      catch (JSONException e)
      {
        e.printStackTrace();
      }
    }
  };

  @Override
  protected void onResume()
  {
    super.onResume();
    myController.setActivityHandler(handler);
    
    System.out.println("SignupActivity.onResume()");
    
    if (myController.exiting())
    {
      System.out.println("SignupActivity.onResume()");
      finish();
    }
  }
}




Java Source Code List

com.piasy.simpletravel.AllPlanActivity.java
com.piasy.simpletravel.HotelDetailActivity.java
com.piasy.simpletravel.LaunchActivity.java
com.piasy.simpletravel.MapViewActivity.java
com.piasy.simpletravel.MyListViewAdapter.java
com.piasy.simpletravel.PopMenu.java
com.piasy.simpletravel.ScrollRefreshListView.java
com.piasy.simpletravel.SearchActivity.java
com.piasy.simpletravel.SettingActivity.java
com.piasy.simpletravel.SignupActivity.java
com.piasy.simpletravel.SimpleTravelApplication.java
com.piasy.simpletravel.SingledayPlanActivity.java
com.piasy.simpletravel.SpotDetailActivity.java
com.piasy.simpletravel.controller.Controller.java
com.piasy.simpletravel.dao.DBHelper.java
com.piasy.simpletravel.dao.DBManager.java
com.piasy.simpletravel.model.CommitModule.java
com.piasy.simpletravel.model.Constant.java
com.piasy.simpletravel.model.Flag.java
com.piasy.simpletravel.model.HotelSeacher.java
com.piasy.simpletravel.model.ListViewItems.java
com.piasy.simpletravel.model.LocationModule.java
com.piasy.simpletravel.model.PlanGenerator.java
com.piasy.simpletravel.model.RouteEntry.java
com.piasy.simpletravel.model.Setting.java
com.piasy.simpletravel.model.SignupModule.java
com.piasy.simpletravel.model.SpotsSeacher.java
com.piasy.simpletravel.model.VerifyModule.java
com.piasy.simpletravel.util.Util.java
dao.DBManager.java
driver.Driver.java
model.CommitHandler.java
model.Constant.java
model.QueryHandler.java
model.Setting.java
model.SignupHandler.java
model.VerifyHandler.java
parser.Driver.java
parser.HotelSeacher.java
util.Util.java