Esempio n. 1
0
  /** @return the user logged in the device, or null if there is no user logged. */
  public static User getLoggedUser(Context context) {
    ParseUser current = ParseUser.getCurrentUser();
    if (current == null) {
      return null;
    }

    User user = new User(current);
    user.mBluetoothListener = (OnUserBluetoothToActivityResponse) context;
    user.mMasterListener = (OnActionMasterResponse) context;
    user.mPermissionsListener = (OnPermissionsResponse) context;
    user.mContext = context;
    sLoggedUser = user;
    return user;
  }
Esempio n. 2
0
 public static User getUser(String email) {
   ParseQuery<ParseUser> query = ParseQuery.getQuery(ParseUser.class);
   query.whereEqualTo(EMAIL, email);
   try {
     ParseUser parseUser = query.getFirst();
     return User.create(parseUser);
   } catch (ParseException e) {
     return null;
   }
 }
Esempio n. 3
0
 public ArrayList<Permission> getInterestedPermissions(Master master) {
   ArrayList<Permission> permissions = new ArrayList<>();
   HashMap<Integer, Permission> userPermissions = master.getPermissions(User.getLoggedUser());
   if (userPermissions == null) return permissions;
   if (userPermissions.containsKey(0)) {
     permissions.addAll(master.getAllPermissions());
   } else {
     permissions.addAll(userPermissions.values());
   }
   return permissions;
 }
Esempio n. 4
0
 public static User getUserLocal(String email) {
   ParseQuery<ParseUser> query = ParseQuery.getQuery(ParseUser.class);
   query.fromLocalDatastore();
   query.whereEqualTo(EMAIL, email);
   try {
     ParseUser parseUser = query.getFirst();
     return User.create(parseUser);
   } catch (ParseException e) {
     e.printStackTrace();
     return null;
   }
 }