Android Open Source - hacktoolkit-android_lib Parse Helper






From Project

Back to project page hacktoolkit-android_lib.

License

The source code is released under:

MIT License

If you think the Android project hacktoolkit-android_lib 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.hacktoolkit.android.api_helpers;
/*ww w  .  j  ava  2  s .com*/
import java.util.Arrays;

import android.app.Activity;
import android.util.Log;

import com.hacktoolkit.android.user.HTKUser;
import com.parse.LogInCallback;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseFacebookUtils.Permissions;
import com.parse.ParseObject;
import com.parse.ParseUser;

public class ParseHelper {
  public static boolean initialized = false;
  
  public static void init(Activity activity, String appId, String clientId) {
      Parse.initialize(activity, appId, clientId);
      ParseAnalytics.trackAppOpened(activity.getIntent());
      ParseHelper.initialized = true; 
  }
  
  public static void fbInit(String fbAppId) {
      ParseFacebookUtils.initialize(fbAppId);
  }
  
  public static void test() {
      ParseObject testObject = new ParseObject("TestObject");
      testObject.put("foo", "bar");
      testObject.saveInBackground();
  }
  
  public static void facebookLogin(String fbAppId, Activity activity, final HTKCallback callback) {
    ParseHelper.fbInit(fbAppId);
      ParseFacebookUtils.logIn(Arrays.asList("email", Permissions.Friends.ABOUT_ME),
          activity, new LogInCallback() {
          @Override
          public void done(ParseUser parseUser, ParseException err) {
            if (parseUser == null) {
              Log.d("Hacktoolkit", "Uh oh. The user cancelled the Facebook login.");
            } else {
                HTKUser.getCurrentUser(parseUser).updateWithGraphUser();
                if (parseUser.isNew()) {
                  Log.d("Hacktoolkit", "User signed up and logged in through Facebook!");
                } else {
                  Log.d("Hacktoolkit", "User logged in through Facebook!");
                }
                callback.execute(null);
            }
          }
        });
  }
}




Java Source Code List

com.hacktoolkit.android.activities.HTKSplashScreenActivity.java
com.hacktoolkit.android.adapters.HTKContactsAdapter.java
com.hacktoolkit.android.api_helpers.FacebookHelper.java
com.hacktoolkit.android.api_helpers.HTKCallback.java
com.hacktoolkit.android.api_helpers.ParseHelper.java
com.hacktoolkit.android.constants.GeoConstants.java
com.hacktoolkit.android.constants.StringConstants.java
com.hacktoolkit.android.constants.TimeConstants.java
com.hacktoolkit.android.constants.UnitConstants.java
com.hacktoolkit.android.fragments.ContactsFragment.java
com.hacktoolkit.android.maps.MapUtils.java
com.hacktoolkit.android.maps.Mapper.java
com.hacktoolkit.android.models.HTKContact.java
com.hacktoolkit.android.user.HTKUser.java
com.hacktoolkit.android.utils.BitmapUtils.java
com.hacktoolkit.android.utils.ContactsUtils.java
com.hacktoolkit.android.utils.FileUtils.java
com.hacktoolkit.android.utils.HTKUtils.java
com.hacktoolkit.android.utils.SystemUiHiderBase.java
com.hacktoolkit.android.utils.SystemUiHiderHoneycomb.java
com.hacktoolkit.android.utils.SystemUiHider.java