com.parse.ParseUser Java Examples

The following examples show how to use com.parse.ParseUser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PerfTestParse.java    From android-database-performance with Apache License 2.0 7 votes vote down vote up
private void setupParse() {
    // Enable Local Datastore.
    Parse.enableLocalDatastore(getTargetContext());

    // Add your initialization code here
    Parse.initialize(getTargetContext(), "X9MEmCvnlX9oGRLmVhunkatw33jlF7wMPZZFw8lZ",
            "FKI8s0UnK6nT6PdGVO2XgKlcsPZnGJlI8qoPpUKa");

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    // Optionally enable public read access.
    // defaultACL.setPublicReadAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);
}
 
Example #2
Source File: MainActivity.java    From Oy with Apache License 2.0 6 votes vote down vote up
/**
 * Load the list of added friends into mFriends
 */
public void loadFriendsList() {
    mFriendsRelation = mCurrentUser.getRelation(ParseConstants.KEY_FRIENDS_RELATION);
    ParseQuery<ParseUser> query = mFriendsRelation.getQuery();
    query.addAscendingOrder(ParseConstants.KEY_USERNAME);
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> friends, ParseException e) {
            if (e == null) {
                mFriends = friends;
                mAdapter = new FriendsAdapter();
                getListView().setAdapter(mAdapter);
                OyUtils.setListViewHeightBasedOnChildren(getListView());
                Log.d("friends", mFriends.size() + "");
            } else {
                Toast.makeText(MainActivity.this, getString(R.string.error_friends), Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
Example #3
Source File: OyUtils.java    From Oy with Apache License 2.0 5 votes vote down vote up
public static void sendInvite(Context context) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, "Oy! Wanna fraandship?\nSend me an Oy: " + ParseUser.getCurrentUser().getUsername().toUpperCase());
    sendIntent.setType("text/plain");
    context.startActivity(sendIntent);
}
 
Example #4
Source File: OyUtils.java    From Oy with Apache License 2.0 5 votes vote down vote up
public static void sendOy(String username, SendCallback callback) {
    try {
        String message = "From " + ParseUser.getCurrentUser().getUsername().toLowerCase();
        JSONObject data = new JSONObject("{\"action\": \"mohammad.adib.oy.UPDATE_STATUS\",\"alert\": \"" + message + "\"}");
        // Send push notification to query
        ParsePush push = new ParsePush();
        push.setChannel(username);
        push.setData(data);
        push.sendInBackground(callback);
    } catch (Exception e) {

    }
}
 
Example #5
Source File: OyReceiver.java    From Oy with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    Log.d("push", "registered");
    ParseUser mCurrentUser = ParseUser.getCurrentUser();
    int oys = 0;
    if (mCurrentUser.containsKey(ParseConstants.KEY_OYS)) {
        oys = (Integer) mCurrentUser.get(ParseConstants.KEY_OYS);
    }
    mCurrentUser.put(ParseConstants.KEY_OYS, oys + 1);
    mCurrentUser.saveInBackground();
    //Update AccountActivity if it's shown
    Intent broadcast = new Intent(AccountActivity.ACTION_UPDATE_OYS);
    LocalBroadcastManager.getInstance(context).sendBroadcast(broadcast);
}
 
Example #6
Source File: AccountActivity.java    From Oy with Apache License 2.0 5 votes vote down vote up
private void updateOys() {
    try {
        if (mCurrentUser == null)
            mCurrentUser = ParseUser.getCurrentUser();
        int oys = (Integer) mCurrentUser.get(ParseConstants.KEY_OYS) + 0;
        ((TextView) findViewById(R.id.oys)).setText(getResources().getString(R.string.oys) + oys);
    } catch (Exception e) {
        ((TextView) findViewById(R.id.oys)).setText(getResources().getString(R.string.oys) + 0);
    }
}
 
Example #7
Source File: ParseTools.java    From DataSync with Apache License 2.0 5 votes vote down vote up
public static String getUserFullName(ParseUser pu) {
    String fullName = pu.has("lastName") ? pu.getString("lastName") : "";
    if (!TextUtils.isEmpty(fullName))
        fullName += " ";
    if (pu.has("firstName"))
        fullName += pu.getString("firstName");
    return fullName;
}
 
Example #8
Source File: MainFragment.java    From RxParse with Apache License 2.0 5 votes vote down vote up
@Override
public void onBind(int position, ParseUser item) {
    android.util.Log.d("RxParse", "onBind");
    String email = item.getEmail() != null ? item.getEmail() : "";
    if (!android.text.TextUtils.isEmpty(email)) {
        icon.setImageURI(Uri.parse("http://gravatar.com/avatar/" + MD5Util.md5Hex(email)));
    }
    text1.setText(email + ", " + item.getObjectId());
}
 
Example #9
Source File: MainFragment.java    From RxParse with Apache License 2.0 5 votes vote down vote up
@Override
public void onBind(int position, ParseUser item) {
    android.util.Log.d("RxParse", "onBind");
    String email = item.getEmail() != null ? item.getEmail() : "";
    if (!android.text.TextUtils.isEmpty(email)) {
        icon.setImageURI(Uri.parse("http://gravatar.com/avatar/" + MD5Util.md5Hex(email)));
    }
    text1.setText(email + ", " + item.getObjectId());
}
 
Example #10
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 5 votes vote down vote up
@CheckReturnValue
@NonNull
public static Single<ParseUser> logIn(@NonNull final Collection<String> permissions, @NonNull final Activity activity) {
    // package class com.parse.FacebookAuthenticationProvider.DEFAULT_AUTH_ACTIVITY_CODE
    // private com.facebook.android.Facebook.DEFAULT_AUTH_ACTIVITY_CODE = 32665
    return logIn(permissions, activity, 32665);
}
 
Example #11
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable link(@NonNull final ParseUser user, @NonNull final String facebookId, @NonNull final String accessToken, @NonNull final Date expirationDate) {
    return RxTask.completable(() -> ParseFacebookUtils.linkInBackground(user, facebookId, accessToken, expirationDate));
}
 
Example #12
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
@CheckReturnValue
public static Single<ParseUser> logInWithPublishPermissions(@NonNull final Activity activity, @NonNull final Collection<String> permissions) {
    return RxTask.single(() -> ParseFacebookUtils.logInWithPublishPermissionsInBackground(activity, permissions));
}
 
Example #13
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
@CheckReturnValue
public static Single<ParseUser> logInWithPublishPermissions(@NonNull final Fragment fragment, @NonNull final Collection<String> permissions) {
    return RxTask.single(() -> ParseFacebookUtils.logInWithPublishPermissionsInBackground(fragment, permissions));
}
 
Example #14
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
@CheckReturnValue
public static Single<ParseUser> logInWithReadPermissions(@NonNull final Activity activity, @NonNull final Collection<String> permissions) {
    return RxTask.single(() -> ParseFacebookUtils.logInWithReadPermissionsInBackground(activity, permissions));
}
 
Example #15
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
@CheckReturnValue
public static Single<ParseUser> logInWithReadPermissions(@NonNull final Fragment fragment, @NonNull final Collection<String> permissions) {
    return RxTask.single(() -> ParseFacebookUtils.logInWithReadPermissionsInBackground(fragment, permissions));
}
 
Example #16
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable unlink(@NonNull final ParseUser user) {
    return RxTask.completable(() -> ParseFacebookUtils.unlinkInBackground(user));
}
 
Example #17
Source File: MainFragment.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);
    ButterKnife.inject(this, view);

    listAdapter = ListRecyclerAdapter.create();

    listAdapter.createViewHolder(new ListRecyclerAdapter.Func2<ViewGroup, Integer, ParseUserViewHolder>() {
        @Override
        public ParseUserViewHolder call(@Nullable ViewGroup viewGroup, Integer position) {
            android.util.Log.d("RxParse", "ParseUserViewHolder");
            return new ParseUserViewHolder(inflater.inflate(R.layout.item_parse_user, viewGroup, false));
        }
    });

    listView.setLayoutManager(new android.support.v7.widget.LinearLayoutManager(getActivity()));
    listView.setAdapter(listAdapter);

    refresher = new SwipeRefreshLayout.OnRefreshListener() {
        @Override public void onRefresh() {
            loading.setRefreshing(true);
            ParseObservable.find(ParseUser.getQuery())
                    .compose(MainFragment.this.<ParseUser>bindToLifecycle())
                    .doOnNext(new Consumer<ParseUser>() {
                        @Override
                        public void accept(final ParseUser user) {
                            android.util.Log.d("RxParse", "onNext: " + user.getObjectId());
                        }
                    })
                    .toList()
                    .subscribe(new Consumer<List<? super ParseUser>>() {
                        @Override
                        public void accept(final List<? super ParseUser> users) {
                            loading.setRefreshing(false);
                            android.util.Log.d("RxParse", "subscribe: " + users);
                            handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    listAdapter.getList().clear();
                                    listAdapter.getList().addAll((List<ParseUser>) users);
                                    listAdapter.notifyDataSetChanged();
                                }
                            });
                        }
                    });
        }
    };

    loading.setOnRefreshListener(refresher);

    handler.post(new Runnable() {
        @Override
        public void run() {
            refresher.onRefresh();
        }
    });
    return view;
}
 
Example #18
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@CheckReturnValue
@NonNull
public static Single<ParseUser> logIn(@NonNull final Collection<String> permissions, Activity activity, int activityCode) {
    return RxTask.single(() -> ParseFacebookUtils.logInInBackground(permissions, activity, activityCode));
}
 
Example #19
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable linkWithReadPermissions(@NonNull final ParseUser user, @NonNull final Fragment fragment, @NonNull final Collection<String> permissions) {
    return RxTask.completable(() -> ParseFacebookUtils.linkWithReadPermissionsInBackground(user, fragment, permissions));
}
 
Example #20
Source File: MainActivity.java    From Oy with Apache License 2.0 4 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (ParseUser.getCurrentUser() != null)
        loadFriendsList();
}
 
Example #21
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable link(@NonNull final ParseUser user, @NonNull final Collection<String> permissions, @NonNull final Activity activity, int activityCode) {
    return RxTask.completable(() -> ParseFacebookUtils.linkInBackground(user, permissions, activity, activityCode));
}
 
Example #22
Source File: MainActivity.java    From Oy with Apache License 2.0 4 votes vote down vote up
public void addItem(final ParseUser item) {
    mFriends.add(item);
    notifyDataSetChanged();
    OyUtils.setListViewHeightBasedOnChildren(getListView());
}
 
Example #23
Source File: MainActivity.java    From Oy with Apache License 2.0 4 votes vote down vote up
public void setUser(ParseUser user) {
    this.user = user;
}
 
Example #24
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable link(@NonNull final ParseUser user, @NonNull final Collection<String> permissions, @NonNull final Activity activity) {
    return RxTask.completable(() -> ParseFacebookUtils.linkInBackground(user, permissions, activity));
}
 
Example #25
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable link(@NonNull final ParseUser user, @NonNull final Activity activity, int activityCode) {
    return RxTask.completable(() -> ParseFacebookUtils.linkInBackground(user, activity, activityCode));
}
 
Example #26
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable link(@NonNull final ParseUser user, @NonNull final Activity activity) {
    return RxTask.completable(() -> ParseFacebookUtils.linkInBackground(user, activity));
}
 
Example #27
Source File: App.java    From NMSAlphabetAndroidApp with MIT License 4 votes vote down vote up
private void initParse(){
    Parse.enableLocalDatastore(this);
    Parse.initialize(this);
    Parse.setLogLevel(BuildConfig.DEBUG ? Parse.LOG_LEVEL_VERBOSE : Parse.LOG_LEVEL_NONE);
    ParseUser.enableRevocableSessionInBackground();
}
 
Example #28
Source File: ParseObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable resetPassword(@NonNull final String email) {
    return RxTask.completable(() -> ParseUser.requestPasswordResetInBackground(email));
}
 
Example #29
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable saveLatestSessionData(@NonNull final ParseUser user) {
    return RxTask.completable(() -> ParseFacebookUtils.saveLatestSessionDataInBackground(user));
}
 
Example #30
Source File: ParseFacebookObservable.java    From RxParse with Apache License 2.0 4 votes vote down vote up
@NonNull
public static Completable unlink(@NonNull final ParseUser user) {
    return RxTask.completable(() -> ParseFacebookUtils.unlinkInBackground(user));
}