Android Open Source - userapp-android Main 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;
/*from   w  ww . j  a  v  a2  s . c  o m*/
import io.userapp.client.android.User;
import io.userapp.client.android.UserApp;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class MainFragment extends Fragment {
  UserApp.Session session;
  
  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        final View view = inflater.inflate(R.layout.fragment_main, container, false);
        
    // Listen for the login event so we could update the UI
        session = new UserApp.Session(this.getActivity(), new UserApp.Session.StatusCallback() {
        @Override
        public void call(Boolean authenticated, Exception exception) {
            if (authenticated) {
              if (session.hasPermission("admin")) {
                ((TextView) view.findViewById(R.id.welcome_text)).setText("Welcome Admin, " + session.user.first_name);
              } else {
                ((TextView) view.findViewById(R.id.welcome_text)).setText("Welcome " + session.user.first_name);
              }
              
              // Change name and save
              session.user.first_name = "John";
              session.saveUser(session.user, new UserApp.Session.UserCallback() {
                @Override
                public void call(User user, Exception exception) {
                    if (exception == null) {
                      System.out.println("USER SAVED");
                    } else {
                      System.out.println("ERROR SAVING USER: " + exception.getMessage());
                    }
                }
            });
            }
        }
    });
        
    return view;
    }

  @Override
  public void onResume() {
      super.onResume();
      session.onResume();
  }

  @Override
  public void onPause() {
      super.onPause();
      session.onPause();
  }
}




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