Android Open Source - userapp-android Signup Fragment






From Project

Back to project page userapp-android.

License

The source code is released under:

MIT License

If you think the Android project userapp-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.example.demo;
/*w  w  w. jav a2s  . c om*/
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import io.userapp.client.android.AuthFragment;
import io.userapp.client.android.Property;
import io.userapp.client.android.Subscription;
import io.userapp.client.android.User;

public class SignupFragment extends AuthFragment {
  
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_signup, container, false);
        
        // Setup the login form with bindings to UserApp
        super.setupSignupForm(view, R.id.signup_button, R.id.email, R.id.login, R.id.password);
        
        return view;
    }
    
    @Override
  public User onSignupStart(User user) {
      // Show loader when waiting for server
      getView().findViewById(R.id.signup_form).setVisibility(View.GONE);
      getView().findViewById(R.id.signup_status).setVisibility(View.VISIBLE);
      
      // Set subscription
      user.subscription = new Subscription();
      user.subscription.price_list_id = "IEiVxVpxSxy1xE8oIzsSeA";
      user.subscription.plan_id = "CBPJdFORQ-qsefa7LxrX-A";
      
      // Set age property
      user.properties.put("age", new Property(42, true));
    
      // Return the user to complete the signup
      return user;
    }
    
  @Override
  public void onSignupCompleted(User user, Boolean verified, Exception exception) {
    if (exception != null) {
      // Hide the loader
      getView().findViewById(R.id.signup_form).setVisibility(View.VISIBLE);
      getView().findViewById(R.id.signup_status).setVisibility(View.GONE);
      
      // Show an error message
      ((TextView) getView().findViewById(R.id.error_text)).setText(exception.getMessage());
    } else {
      // Clear the message
      ((TextView) getView().findViewById(R.id.error_text)).setText("");
      
      // Need to verify the email address?
      if (verified == false) {
        // Hide the loader
        getView().findViewById(R.id.signup_form).setVisibility(View.VISIBLE);
        getView().findViewById(R.id.signup_status).setVisibility(View.GONE);
        
        ((TextView) getView().findViewById(R.id.error_text)).setText("An email has been sent to your inbox.");
      } else {
        // Call the superclass to log in the signed up user
        super.onSignupCompleted(user, verified, exception);
      }
    }
  }
    
}




Java Source Code List

com.example.demo.LoginFragment.java
com.example.demo.MainActivity.java
com.example.demo.MainFragment.java
com.example.demo.SignupFragment.java
io.userapp.client.JsonHelper.java
io.userapp.client.UserAppClient.java
io.userapp.client.android.AuthFragment.java
io.userapp.client.android.Feature.java
io.userapp.client.android.Lock.java
io.userapp.client.android.OAuthFragment.java
io.userapp.client.android.Permission.java
io.userapp.client.android.Property.java
io.userapp.client.android.Subscription.java
io.userapp.client.android.UserApp.java
io.userapp.client.android.User.java
io.userapp.client.android.WebViewRelativeLayout.java
io.userapp.client.exceptions.InvalidMethodException.java
io.userapp.client.exceptions.InvalidServiceException.java
io.userapp.client.exceptions.ServiceException.java
io.userapp.client.exceptions.TransportException.java
io.userapp.client.exceptions.UserAppException.java
io.userapp.client.rest.RestfulContext.java
io.userapp.client.rest.Restful.java
io.userapp.client.rest.UserCredentials.java
io.userapp.client.rest.core.HttpHeaderCollection.java
io.userapp.client.rest.core.HttpMethodType.java
io.userapp.client.rest.core.HttpProtocolVersionType.java
io.userapp.client.rest.core.HttpResponseHead.java
io.userapp.client.rest.core.HttpResponseStatusHead.java
io.userapp.client.rest.core.HttpResponse.java
io.userapp.client.rest.core.HttpStatusCode.java