@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_list);

    currentUser = ParseUser.getCurrentUser();

    // ----------------------------------------------------------------------
    // Check if service is running.

    if (!MessageService.isMessageServiceRunning()) {

      // Start the service
      // registerReceiver(messageReceiver, messageFilter);

      Log.d("UserListActivity", "Starting message service");

      Intent messageservice = new Intent(this, MessageService.class);
      messageservice.putExtra("channel", currentUser.getUsername());
      startService(messageservice);
    }

    // ----------------------------------------------------------------------

    new RemoteDataTask().execute();
  }
示例#2
0
  public void listenSignUp(View v) {
    boolean valid = true;
    if (isEmpty(user)) valid = false;
    if (isEmpty(pass)) valid = false;
    if (isEmpty(passConfirm)) valid = false;
    if (!isMatching(pass, passConfirm)) valid = false;

    if (!valid) {
      Toast.makeText(this, "Fields cannot be empty, and passwords have to match", Toast.LENGTH_LONG)
          .show();
      return;
    }

    ParseUser newUser = new ParseUser();
    newUser.setUsername(user.getText().toString());
    newUser.setPassword(pass.getText().toString());

    newUser.signUpInBackground(
        new SignUpCallback() {
          @Override
          public void done(com.parse.ParseException e) {
            if (e != null) {
              Toast.makeText(SignUpActivity.this, "Sign-up Successful!", Toast.LENGTH_LONG).show();
            } else {
              Toast.makeText(SignUpActivity.this, "Sign-up Failed...", Toast.LENGTH_LONG).show();
            }
          }
        });
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   getSupportActionBar().hide();
   ParseAnalytics.trackAppOpenedInBackground(getIntent());
   mUserSwitch = (Switch) findViewById(R.id.typeSwitch);
   // check if user is logged in if not lets create a new User
   if (ParseUser.getCurrentUser() == null) {
     ParseAnonymousUtils.logIn(
         new LogInCallback() {
           @Override
           public void done(ParseUser user, ParseException e) {
             if (e == null) {
               Log.d(getPackageName(), "Anon user Logged in");
             } else {
               Log.d(getPackageName(), "Anon User login error " + e.getMessage());
             }
           }
         });
   }
   // check if user is rider or driver
   else {
     if (ParseUser.getCurrentUser().get("riderOrDriver") != null) {
       redirectUser();
     }
   }
 }
示例#4
0
文件: Friends.java 项目: Arielr13/L2T
 public void theyRequested(final ParseUser user) {
   ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
   query.whereEqualTo("areFriends", false);
   query.whereEqualTo("fromUser", user.getObjectId() + "");
   query.whereEqualTo("toUser", currentUser.getObjectId() + "");
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> list, ParseException e) {
           if (e == null && list.size() > 0) {
             ParseObject relation = list.get(0);
             relation.put("areFriends", true);
             relation.saveInBackground();
             new AlertDialog.Builder(Friends.this)
                 .setTitle("This User Already Sent You a Request!")
                 .setMessage("You Two Are Now Friends!")
                 .setPositiveButton(
                     "OK",
                     new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                         add.setEnabled(true);
                         getRelations();
                         setNotifications();
                       }
                     })
                 .show();
           } else {
             createRelation(user);
           }
         }
       });
 }
  protected ParseObject createMessage() {

    // Create a new ParseObject
    ParseObject message = new ParseObject(ParseConstants.CLASS_MESSAGES);

    // Send the message to a sender
    message.put(ParseConstants.KEY_SENDER_ID, ParseUser.getCurrentUser().getObjectId());
    message.put(ParseConstants.KEY_SENDER_NAME, ParseUser.getCurrentUser().getUsername());
    message.put(ParseConstants.KEY_RECIPIENT_IDS, getRecipientIds());
    message.put(ParseConstants.KEY_FILE_TYPE, mFileType);

    byte[] fileBytes = FileHelper.getByteArrayFromFile(this, mMediaUri);

    if (fileBytes == null) {
      return null;
    } else {

      if (mFileType.equals(ParseConstants.TYPE_IMAGE)) {
        // Reduce the size of the file to upload it on the backend
        fileBytes = FileHelper.reduceImageForUpload(fileBytes);
      }
      String fileName = FileHelper.getFileName(this, mMediaUri, mFileType);

      ParseFile file = new ParseFile(fileName, fileBytes);

      // Attach it to the message method
      message.put(ParseConstants.KEY_FILE, file);

      return message;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Don't show the Action Bar on the start screen
    getActionBar().hide();

    setFonts();

    buttonStart = (Button) findViewById(R.id.button_play);
    buttonStart.setVisibility(View.INVISIBLE);

    buttonFbLogin = (Button) findViewById(R.id.facebook);
    buttonFbLogin.setVisibility(View.INVISIBLE);

    ParseUser currentUser = ParseUser.getCurrentUser();

    if (currentUser != null) {
      System.out.println("doctor please");
      System.out.println(currentUser.getEmail());
      System.out.println(currentUser.getUsername());
    }

    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.VISIBLE);

    new GetIdsAsync().execute("");
  }
示例#7
0
文件: Friends.java 项目: Arielr13/L2T
 public void areFriends1(final ParseUser user) {
   ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
   query.whereEqualTo("areFriends", true);
   query.whereEqualTo("toUser", currentUser.getObjectId() + "");
   query.whereEqualTo("fromUser", user.getObjectId() + "");
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> list, ParseException e) {
           findViewById(R.id.LoadingIcon).setVisibility(View.INVISIBLE);
           if (e == null && list.size() > 0) {
             new AlertDialog.Builder(Friends.this)
                 .setTitle("You Are Already Friends!")
                 .setPositiveButton(
                     "OK",
                     new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                         add.setEnabled(true);
                       }
                     })
                 .show();
           } else {
             alreadyRequested(user);
           }
         }
       });
 }
 private void getAttendedBy() {
   if (hasEmployee && employeeId != null) {
     ParseQuery<ParseUser> query = ParseUser.getQuery();
     query.whereEqualTo("objectId", employeeId);
     query.getFirstInBackground(
         new GetCallback<ParseUser>() {
           @Override
           public void done(ParseUser parseUser, ParseException e) {
             if (e == null) {
               if (parseUser.getParseFile("userImage") != null) {
                 attendedByAvatar = parseUser.getParseFile("userImage").getUrl();
               }
               updateHomeServiceRequestStatus(parseUser);
             } else {
               Log.e("ERROR", "empleado no encontrado: " + e.getMessage());
             }
           }
         });
   } else {
     if (ParseUser.getCurrentUser().getParseFile("userImage") != null) {
       attendedByAvatar = ParseUser.getCurrentUser().getParseFile("userImage").getUrl();
     }
     updateHomeServiceRequestStatus(ParseUser.getCurrentUser());
   }
 }
示例#9
0
  /**
   * Execute item code when it is pressed on navigation drawer
   *
   * @param item
   * @return returns true
   */
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_logout) {
      ParseUser.logOut();
      if (ParseUser.getCurrentUser() == null) {
        Toast.makeText(MainActivity.this, "Logout Successful!", Toast.LENGTH_LONG).show();
        startActivity(new Intent(MainActivity.this, LoginActivity.class));
        finish();
      } else {
        Toast.makeText(MainActivity.this, "Logout Unsuccessful!", Toast.LENGTH_LONG).show();
      }

    } else if (id == R.id.nav_account_mod) {
      Intent intent = new Intent(this, AccSetActivity.class);
      startActivity(intent);

    } else if (id == R.id.nav_profile_mod) {
      Intent intent = new Intent(this, ProfileEditActivity.class);
      startActivity(intent);
    } else if (id == R.id.nav_favorites) {
      Intent intent = new Intent(this, FavoritesActivity.class);
      startActivity(intent);
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
示例#10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addgroup);
    getContacts();
    ParseUser pu = ParseUser.getCurrentUser();
    ArrayList<String> names = (ArrayList<String>) pu.get("Names");
    ArrayList<String> lastmessage = (ArrayList<String>) pu.get("Numbers");
    List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
    String[] from = new String[] {"rowid", "col_1"};
    int[] to = new int[] {R.id.message_tv, R.id.time_tv};

    for (int i = 0; i < names.size(); i++) {
      HashMap<String, String> map = new HashMap<String, String>();
      map.put("rowid", "" + names.get(i));
      map.put("col_1", "" + lastmessage.get(i));
      fillMaps.add(map);
    }
    lv = (ListView) findViewById(android.R.id.list);
    adapter = new SimpleAdapter(this, fillMaps, R.layout.list_item, from, to);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckBox cx = (CheckBox) view.findViewById(R.id.check);
            cx.toggle();
          }
        });
  }
示例#11
0
  private void saveNewUser() {
    parseUser = ParseUser.getCurrentUser();
    parseUser.setUsername(name);
    parseUser.setEmail(email);

    //        Saving profile photo as a ParseFile
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    Bitmap bitmap = ((BitmapDrawable) mProfileImage.getDrawable()).getBitmap();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
    byte[] data = stream.toByteArray();
    String thumbName = parseUser.getUsername().replaceAll("\\s+", "");
    final ParseFile parseFile = new ParseFile(thumbName + "_thumb.jpg", data);

    parseFile.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            parseUser.put("profileThumb", parseFile);

            // Finally save all the user details
            parseUser.saveInBackground(
                new SaveCallback() {
                  @Override
                  public void done(ParseException e) {
                    Toast.makeText(
                            MainActivity.this,
                            "New user:"******" Signed up",
                            Toast.LENGTH_SHORT)
                        .show();
                  }
                });
          }
        });
  }
示例#12
0
 private void saveNewUser(Bitmap profileImageBitmap) {
   parseUser = ParseUser.getCurrentUser();
   parseUser.setUsername(name);
   parseUser.setEmail(email);
   parseUser.put("dob", birthday);
   //        Saving profile photo as a ParseFile
   ByteArrayOutputStream stream = new ByteArrayOutputStream();
   profileImageBitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
   byte[] data = stream.toByteArray();
   String thumbName = parseUser.getUsername().replaceAll("\\s+", "");
   final ParseFile parseFile = new ParseFile(thumbName + "_thumb.jpg", data);
   // we can use saveInBackground() in this method because this data is from Fb
   // so the user must have an internet connection
   parseFile.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(ParseException e) {
           parseUser.put("profileThumb", parseFile);
           // Finally save all the user details
           parseUser.saveInBackground(
               new SaveCallback() {
                 @Override
                 public void done(ParseException e) {
                   Toast.makeText(
                           LoginActivity.this,
                           "New user: "******" Signed up",
                           Toast.LENGTH_SHORT)
                       .show();
                   // Only start the next activity after this one is done
                   startMainActivity();
                 }
               });
         }
       });
 }
示例#13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mUserName = (TextView) findViewById(R.id.user_name);
    navImg = (ImageView) findViewById(R.id.nav_profile_img);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    ParseUser currentUser = ParseUser.getCurrentUser();

    /*String hash = ChatListAdapter.MD5Util.md5Hex(currentUser.getUsername());
    Log.w("Hash ", " - " + hash);
    Picasso.with(this).load("http://www.gravatar.com/avatar" + hash).into(navImg);*/

    Picasso.with(MainActivity.this)
        .load(ChatListAdapter.getProfileUrl(currentUser.getUsername()))
        .into(navImg);

    drawerFragment =
        (FragmentDrawer)
            getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
    drawerFragment.setUp(
        R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);
    drawerFragment.setDrawerListener(this);

    // display the first navigation drawer view on app launch
    displayView(0);
  }
示例#14
0
  @Override
  public void onBindViewHolder(final MessageViewHolder contactViewHolder, int i) {
    Message m = messageList.get(i);
    ParseUser u = m.user;

    contactViewHolder.messageTV.setText(Decoder.decodeMessage(m.text));
    if (!m.saved) {
      // enable text view that message is not sent
      contactViewHolder.notSentMessageTV.setVisibility(View.VISIBLE);
    }

    if (null != u) {
      // incomming message
      UserImage.showImage(u, contactViewHolder.userIV);
      contactViewHolder.userNameTV.setText(u.getUsername());

      long timeMil = m.date.getTime();
      // timeMil = (timeMil + mGMTOffset);
      contactViewHolder.dateTV.setText(DateFormat.getDateTimeInstance().format(timeMil));
    } else {
      // my message
      UserImage.showImage(m.userId, contactViewHolder.userIV);
      contactViewHolder.userNameTV.setText(m.userName);

      // get curr time
      long timeMil = new Date().getTime();
      // timeMil = (timeMil + mGMTOffset);
      contactViewHolder.dateTV.setText(DateFormat.getDateTimeInstance().format(timeMil));
    }

    if (animate && i == messageList.size() - 1) {
      contactViewHolder.itemView.startAnimation(animToMiddle);
      animate = false;
    }
  }
  @Override
  public void onConnected(Bundle bundle) {
    Log.i(TAG, "Location services connected.");

    Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);

    if (lastLocation == null) {
      Toast.makeText(
              FullScreenMapActivity.this, "There is currently no connectivity", Toast.LENGTH_LONG)
          .show();
    } else {

      ParseGeoPoint point =
          new ParseGeoPoint(lastLocation.getLatitude(), lastLocation.getLongitude());
      ParseUser currentUser = ParseUser.getCurrentUser();
      currentUser.put("location", point);
      currentUser.saveInBackground();

      mGoogleMap.animateCamera(CameraUpdateFactory.zoomIn());

      CameraPosition cameraPosition =
          new CameraPosition.Builder()
              .target(new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()))
              .zoom(12)
              .bearing(90)
              .tilt(30)
              .build();

      mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
  }
示例#16
0
  public static void postQuestions(
      String question,
      String optionA,
      String optionB,
      final ParseObject community,
      final boolean choiceQuestion,
      final Bitmap picture) {
    final ParseObject mPost = new ParseObject(Common.OBJECT_POST);
    final ParseUser user = ParseUser.getCurrentUser();
    mPost.put(Common.OBJECT_POST_CONTENT, question);
    mPost.put(Common.OBJECT_POST_QA, optionA);
    mPost.put(Common.OBJECT_POST_QB, optionB);
    mPost.put(Common.OBJECT_POST_QA_NUM, 0);
    mPost.put(Common.OBJECT_POST_QB_NUM, 0);
    mPost.put(Common.OBJECT_POST_USER, ParseUser.getCurrentUser());
    mPost.put(Common.OBJECT_POST_CHOICE_QUESTION, choiceQuestion);
    mPost.put(Common.OBJECT_POST_COMMUNITY, community);

    mPost.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            if (community != null) {
              ParseRelation<ParseObject> relation =
                  community.getRelation(Common.OBJECT_COMMUNITY_POSTS);
              relation.add(mPost);
              community.saveInBackground();
            }
            ParseRelation<ParseObject> relation = user.getRelation(Common.OBJECT_USER_MY_QUESTIONS);
            relation.add(mPost);

            final ParseObject votedQuestion = new ParseObject(Common.OBJECT_VOTED_QUESTION);
            votedQuestion.put(Common.OBJECT_VOTED_QUESTION_QID, mPost.getObjectId());
            votedQuestion.put(Common.OBJECT_VOTED_QUESTION_OPTION, "");
            try {
              votedQuestion.save();
              ParseRelation<ParseObject> votedRelation =
                  user.getRelation(Common.OBJECT_USER_VOTED_QUESTIONS);
              votedRelation.add(votedQuestion);
            } catch (Exception e1) {
              e1.printStackTrace();
            }

            user.saveInBackground();

            if (picture != null) {
              savePictureToPostSync(mPost, picture);
            }

            getCommunityQuestions(community);

            EventBus.getDefault().post(new ShareDuringPostEvent(mPost));

            ParseObject myQuestion = new ParseObject(Common.OBJECT_MY_QUESTION);
            myQuestion.put(Common.OBJECT_MY_QUESTION_USER, user);
            myQuestion.put(Common.OBJECT_MY_QUESTION_QUESTION, mPost);
            myQuestion.saveInBackground();
          }
        });
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /** Called when the activity is first created. */
    setContentView(R.layout.stream);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser == null) {
      startActivity(new Intent(this, StartActivity.class));
    }

    ParseQuery query = new ParseQuery("Vow");
    query.whereEqualTo("user", ParseUser.getCurrentUser());
    query.findInBackground(
        new FindCallback() {
          public void done(List<ParseObject> evidence, com.parse.ParseException e) {
            if (e == null) {
              setListAdapter(new EvidenceAdapter(StreamActivity.this, evidence));
            } else {
              Log.d("Dmitrij", "Error: " + e.getMessage());
            }
          }
        });

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }
  }
示例#18
0
 public static void linkInstallationWithUser() {
   ParseInstallation installation = ParseInstallation.getCurrentInstallation();
   if (ParseUser.getCurrentUser() != null) {
     installation.put(Common.INSTALLATION_USER, ParseUser.getCurrentUser());
   }
   installation.saveInBackground();
 }
示例#19
0
  public void CreateClick(View view) throws ParseException {
    String name;
    String description;
    String date;

    EditText viewText = (EditText) findViewById(R.id.editText);
    name = viewText.getText().toString();

    viewText = (EditText) findViewById(R.id.editText2);
    description = viewText.getText().toString();

    // viewText = (EditText) findViewById(R.id.calendarView);
    // date = viewText.getText().toString();

    ParseUser user = ParseUser.getCurrentUser();
    ParseObject bulletin = new ParseObject("BulletinBoard");
    bulletin.put("DeleteDate", "Oct 31, 2015");
    bulletin.put("Notification", description);
    bulletin.put("Name", name);
    bulletin.put("Apartment", user.get("Apartment"));

    bulletin.saveInBackground();
    finish();
    viewText = (EditText) findViewById(R.id.calendarView);
    date = viewText.getText().toString();

    bulletin.put("DeleteDate", date);
    bulletin.put("Notification", description);
    bulletin.put("Name", name);
    bulletin.put("Apartment", user.get("Apartment"));
    bulletin.saveInBackground();
  }
示例#20
0
  public void post() {
    buffer = new ByteArrayOutputStream();
    scaledTakenImage.compress(Bitmap.CompressFormat.JPEG, 100, buffer);
    photoFile = new ParseFile(buffer.toByteArray());
    photoFile.saveInBackground();

    if (etFoodDesc.getText() == null
        || etFeedCap.getText() == null
        || etExp.getText() == null
        || location == null
        || photoFile == null) {
      Toast.makeText(this, "Please provide all the information", Toast.LENGTH_SHORT).show();
      return;
    }

    ParseObject parseObject = new ParseObject("FoodData");
    parseObject.put("fooddesc", etFoodDesc.getText().toString());
    parseObject.put("feedcap", etFeedCap.getText().toString());
    parseObject.put("timeexp", etExp.getText().toString());
    parseObject.put("lat", location.getLatitude());
    parseObject.put("lon", location.getLongitude());
    parseObject.put("photo", photoFile);
    parseObject.put("ownerid", ParseUser.getCurrentUser().getObjectId());
    parseObject.put("ownername", ParseUser.getCurrentUser().getUsername());
    parseObject.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            if (e == null)
              Toast.makeText(PostActivity.this, "Posted Sucessfully", Toast.LENGTH_SHORT).show();
          }
        });
  }
示例#21
0
文件: Friends.java 项目: Arielr13/L2T
 public void alreadyRequested(final ParseUser user) {
   ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends");
   query.whereEqualTo("areFriends", false);
   query.whereEqualTo("toUser", user.getObjectId() + "");
   query.whereEqualTo("fromUser", currentUser.getObjectId() + "");
   query.findInBackground(
       new FindCallback<ParseObject>() {
         public void done(List<ParseObject> list, ParseException e) {
           if (e == null && list.size() > 0) {
             new AlertDialog.Builder(Friends.this)
                 .setTitle("You Already Sent a Request to This User!")
                 .setPositiveButton(
                     "OK",
                     new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                         add.setEnabled(true);
                       }
                     })
                 .show();
           } else {
             theyRequested(user);
           }
         }
       });
 }
示例#22
0
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    ParseObject message = mMessages.get(position);
    String messageType = message.getString(ParseConstant.KEY_FILE_TYPE);
    ParseFile file = message.getParseFile(ParseConstant.KEY_FILE);
    Uri fileUri = Uri.parse(file.getUrl());

    if (messageType.equals(ParseConstant.TYPE_IMAGE)) {
      Intent intent = new Intent(getActivity(), ViewimageActivity.class);
      intent.setData(fileUri);
      startActivity(intent);
    } else {
      Intent intent = new Intent(Intent.ACTION_VIEW, fileUri);
      intent.setDataAndType(fileUri, "video/*");
      startActivity(intent);
    }

    // Delete it
    List<String> ids = message.getList(ParseConstant.KEY_RECIPIENT_IDS);
    if (ids.size() == 1) {
      // last recipients
      message.deleteInBackground();
    } else {
      ids.remove(ParseUser.getCurrentUser().getObjectId());
      ArrayList<String> idsToRemove = new ArrayList<String>();
      idsToRemove.add(ParseUser.getCurrentUser().getObjectId());

      message.removeAll(ParseConstant.KEY_RECIPIENT_IDS, idsToRemove);
      message.saveInBackground();
    }
  }
示例#23
0
文件: Friends.java 项目: Arielr13/L2T
  public void getUsers(final List<ParseObject> list, final int listSize, final int i) {
    size = listSize;
    if (i == listSize) {
      checkList();
    } else {
      if ((list.get(i).getString("toUser") + "").equals(currentUser.getObjectId() + "")) {
        friendid = list.get(i).getString("fromUser");
      } else {
        friendid = list.get(i).getString("toUser");
      }

      ParseQuery<ParseUser> query = ParseUser.getQuery();
      query.getInBackground(
          friendid,
          new GetCallback<ParseUser>() {

            @Override
            public void done(ParseUser arg0, ParseException arg1) {
              // Toast.makeText(Friends.this, arg0.getObjectId()+"", Toast.LENGTH_SHORT).show();
              addUser(arg0);
              getUsers(list, listSize, i + 1);
            }
          });
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    holder = new ViewHolder();
    if (position == 0) {
      convertView = inflater.inflate(R.layout.profile_navigation, parent, false);

      holder.name = (TextView) convertView.findViewById(R.id.name);
      holder.email = (TextView) convertView.findViewById(R.id.email);
      if (user != null) {
        holder.name.setText(user.getString("name"));
        holder.email.setText(user.getEmail());
      } else {
        holder.name.setText("Guest User");
      }

    } else {
      convertView = inflater.inflate(resourceId, parent, false);

      holder.nameTxt = (TextView) convertView.findViewById(R.id.text_navigationlist);
      holder.imageView = (ImageView) convertView.findViewById(R.id.icon_navigationlist);

      holder.nameTxt.setText(names[position]);
      holder.imageView.setImageDrawable(icons.getDrawable(position));
    }

    return convertView;
  }
示例#25
0
  public void siginUp(User user, SunshineLoginCallback callback) {

    this.callback = callback;

    parseUser = new ParseUser();
    parseUser.setEmail(user.getEmail());
    parseUser.setUsername(user.getUserName());
    parseUser.setPassword(user.getPassword());
    // prepareParseUser(parseUser, user);
    parseUser.put("name", user.getName());

    if (user.getImgPath() != null) {
      File file = new File(user.getImgPath());
      parseFile = new ParseFile(file);
      parseFile.saveInBackground(
          new SaveCallback() {
            @Override
            public void done(ParseException e) {
              if (e != null) e.printStackTrace();
              parseUser.put("img", parseFile);
              parseUser.signUpInBackground(SunshineLogin.this);
            }
          });
    } else {
      parseUser.signUpInBackground(SunshineLogin.this);
    }
  }
示例#26
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.action_sending);
    ParseUser currentUser = ParseUser.getCurrentUser();
    String[] list = getResources().getStringArray(R.array.admin_mail_address);
    item.setVisible(false);
    if (currentUser != null) {
      Log.e("Name", currentUser.getUsername());
      Log.e("Name", currentUser.getEmail());

    } else {
      Log.e("NULL USER", "NOT LOGGED IN");
    }
    if (currentUser != null) {
      for (String s : list) {
        if (currentUser.getEmail().equals(s)) {
          item.setVisible(true);
          Log.e("Vis", "TRUE");
          break;
        }
      }
    }
    super.onPrepareOptionsMenu(menu);
    return true;
  }
 /**
  * The function is called when the user presses the logout button on the activity. This signs out
  * the current user and returns the user back to the MainActivity
  *
  * @param v
  */
 public void logout(View v) {
   if (ParseUser.getCurrentUser() != null) {
     ParseUser.logOut();
     Intent intent = new Intent(this, MainActivity.class);
     startActivity(intent);
   }
 }
示例#28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.style.Theme_AppCompat);
    setContentView(R.layout.activity_main);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser == null) {
      navigateToLogin();
    }

    isChild = currentUser.getBoolean("isChild");
    System.out.println(isChild);

    if (isChild) {
      Intent intent = new Intent(this, SettingsActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
      startActivity(intent);
    }

    // Text view for displaying written result
    textView = (TextView) findViewById(R.id.textView);

    // Setup TextToSpeech
    textToSpeechMgr = new TextToSpeechMgr(this);

    bgData = updateGraph();

    drawGraph(bgData);
  }
示例#29
0
 /**
  * Create a fake restaurant for testing.
  *
  * @return a Restaurant
  * @throws ParseException if user is invalid
  */
 public static Restaurant createFakeRestaurant() throws ParseException {
   ParseUser restUser = new ParseUser();
   restUser.setUsername("testRestUser");
   restUser.setPassword("12345");
   restUser.setObjectId("_marksrest");
   return new Restaurant(restUser);
 }
示例#30
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case 0:

        // Logout the user
        ParseUser.logOut();

        Intent intent2 = new Intent(UserListActivity.this, ChatActivity.class);

        // For testing. fix later
        intent2.putExtra("chatUserEmail", "*****@*****.**");

        startActivity(intent2);

        return true;
      case 1:

        // Logout the user
        ParseUser.logOut();

        Intent intent = new Intent(UserListActivity.this, LoginActivity.class);
        startActivity(intent);

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }