Android Open Source - kluster-android Signup Fragment






From Project

Back to project page kluster-android.

License

The source code is released under:

Apache License

If you think the Android project kluster-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 com.cs446.kluster.views.fragments;
// www  .j a v  a 2 s. com
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.cs446.kluster.R;
import com.cs446.kluster.models.User;
import com.cs446.kluster.net.KlusterRestAdapter;
import com.cs446.kluster.net.KlusterService;

public class SignupFragment extends Fragment {

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater
        .inflate(R.layout.signup_fragment, container, false);
    Button doneButton = (Button) view.findViewById(R.id.signupDoneButton);
    final EditText firstName = (EditText) view
        .findViewById(R.id.signupFirstName);
    final EditText lastName = (EditText) view
        .findViewById(R.id.signupLastName);
    final EditText userName = (EditText) view
        .findViewById(R.id.signupUserName);
    final EditText userEmail = (EditText) view
        .findViewById(R.id.signupEmail);
    final EditText password = (EditText) view
        .findViewById(R.id.signupPassword);
    final EditText confirmPassword = (EditText) view
        .findViewById(R.id.signupConfirmPassword);

    doneButton.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub

        if (!(password.getText().toString().equals(confirmPassword
            .getText().toString()))) {
          Toast.makeText(getActivity().getBaseContext(),
              "Passwords don't match...", Toast.LENGTH_LONG)
              .show();
          return;
        }

        if (firstName.getText().toString().equals("")
            || lastName.getText().toString().equals("")
            || userName.getText().toString().equals("")
            || userEmail.getText().toString().equals("")
            || password.getText().toString().equals("")
            || confirmPassword.getText().toString().equals("")) {
          Toast.makeText(getActivity().getBaseContext(),
              "Complete all fields...", Toast.LENGTH_LONG)
              .show();
          return;
        }

        User user = new User(userName.getText().toString(),
                  userEmail.getText().toString(),
                  firstName.getText().toString(),
                  lastName.getText().toString());
        
        user.setPassword(password.getText().toString());
        
        RestAdapter restAdapter = new KlusterRestAdapter()
        .build();
        
        KlusterService service = restAdapter.create(KlusterService.class);
        service.createUser(user, new Callback<User>() {
          @Override
          public void success(User user, Response response) {
            Toast.makeText(getActivity().getBaseContext(),
                "Registration Complete...", Toast.LENGTH_LONG)
                .show();
            getActivity().onBackPressed();
          }    
          @Override
          public void failure(RetrofitError error) {
            Toast.makeText(getActivity().getBaseContext(),
                "Could not create user...", Toast.LENGTH_LONG)
                .show();
          }
        });
      }
    });

    return view;
  }
}




Java Source Code List

android.app.GridFragment.java
android.app.NonSwipeableViewPager.java
android.app.ScaleImageView.java
com.cs446.kluster.ConfigManager.java
com.cs446.kluster.KlusterApplication.java
com.cs446.kluster.cache.CacheUtils.java
com.cs446.kluster.cache.DiskLruCache.java
com.cs446.kluster.cache.DiskLruImageCache.java
com.cs446.kluster.cache.KlusterCache.java
com.cs446.kluster.data.AbstractContentStorageAdapter.java
com.cs446.kluster.data.EventProvider.java
com.cs446.kluster.data.EventStorageAdapter.java
com.cs446.kluster.data.PhotoProvider.java
com.cs446.kluster.data.PhotoStorageAdapter.java
com.cs446.kluster.data.SearchProvider.java
com.cs446.kluster.data.SearchStorageAdapter.java
com.cs446.kluster.data.StorageAdapter.java
com.cs446.kluster.data.StorageConstants.java
com.cs446.kluster.data.serialize.AuthUserAdapter.java
com.cs446.kluster.data.serialize.EventAdapter.java
com.cs446.kluster.data.serialize.PhotoAdapter.java
com.cs446.kluster.data.serialize.SerializerUtils.java
com.cs446.kluster.data.serialize.UserAdapter.java
com.cs446.kluster.map.MapUtils.java
com.cs446.kluster.models.AuthUser.java
com.cs446.kluster.models.Event.java
com.cs446.kluster.models.Photo.java
com.cs446.kluster.models.User.java
com.cs446.kluster.net.AuthInterceptor.java
com.cs446.kluster.net.AuthKlusterRestAdapter.java
com.cs446.kluster.net.EventsCallback.java
com.cs446.kluster.net.KlusterRestAdapter.java
com.cs446.kluster.net.KlusterService.java
com.cs446.kluster.net.NetworkUtils.java
com.cs446.kluster.net.PhotosCallback.java
com.cs446.kluster.net.UploadService.java
com.cs446.kluster.views.activities.LoginActivity.java
com.cs446.kluster.views.activities.MainActivity.java
com.cs446.kluster.views.activities.PhotoFactory.java
com.cs446.kluster.views.activities.PhotoGridActivity.java
com.cs446.kluster.views.fragments.DiscoverFragment.java
com.cs446.kluster.views.fragments.EventDialogFragment.java
com.cs446.kluster.views.fragments.EventGridAdapter.java
com.cs446.kluster.views.fragments.EventGridFragment.java
com.cs446.kluster.views.fragments.EventMapFragment.java
com.cs446.kluster.views.fragments.FilterDialogFragment.java
com.cs446.kluster.views.fragments.PhotoGridAdapter.java
com.cs446.kluster.views.fragments.PhotoGridFragment.java
com.cs446.kluster.views.fragments.PhotoViewerFragment.java
com.cs446.kluster.views.fragments.SearchFragment.java
com.cs446.kluster.views.fragments.SearchGridFragment.java
com.cs446.kluster.views.fragments.SearchMapFragment.java
com.cs446.kluster.views.fragments.SignupFragment.java
com.cs446.kluster.views.fragments.UserProfileFragment.java
com.cs446.kluster.views.map.PhotoInfoWindowAdapter.java