Пример #1
0
 public static void linkInstallationWithUser() {
   ParseInstallation installation = ParseInstallation.getCurrentInstallation();
   if (ParseUser.getCurrentUser() != null) {
     installation.put(Common.INSTALLATION_USER, ParseUser.getCurrentUser());
   }
   installation.saveInBackground();
 }
Пример #2
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();
          }
        });
  }
Пример #3
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();
          }
        });
  }
 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());
   }
 }
Пример #5
0
 @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();
     }
   }
 }
  // Called when the Activity starts, or when the App is coming to the foreground. Check to see
  // the state of the LayerClient, and if everything is set up, display all the Conversations
  public void onResume() {

    Log.d("Activity", "Conversation Activity onResume");

    super.onResume();

    // If the user is not authenticated, make sure they are logged in, and if they are,
    // re-authenticate
    if (!LayerImpl.isAuthenticated()) {

      if (ParseUser.getCurrentUser() == null) {

        Log.d("Activity", "User is not authenticated or logged in - returning to login screen");
        Utils.gotoLoginActivity(this);

      } else {

        Log.d("Activity", "User is not authenticated, but is logged in - re-authenticating user");
        LayerImpl.authenticateUser();
      }

      // Everything is set up, so start populating the Conversation list
    } else {

      Log.d("Activity", "Starting conversation view");
      setupConversationView();
    }

    ParseInstallation installation = ParseInstallation.getCurrentInstallation();
    installation.put("inMessageActivity", false);
    installation.put("user", ParseUser.getCurrentUser());
    installation.saveInBackground();
  }
Пример #7
0
  @Override
  public void onSnackListUpdateComplete(ParseException e) {
    // Start the login activity if the session token is invalid.
    if (e != null && e.getCode() == ParseException.INVALID_SESSION_TOKEN) {
      if (myActivity != null) {
        Intent startLoginIntent = new Intent(myActivity, LoginActivity.class);
        ParseUser.logOutInBackground();
        myActivity.finish();
        startActivity(startLoginIntent);
      }
    }

    adapter.notifyDataSetChanged();

    if (progressOverlay != null) {
      progressOverlay.setVisibility(View.GONE);
    }

    // Show the help message if appropriate.
    // That is, if we haven't already showed it for the current user this session and the
    // current user has zero entries. Only show the help message if the SnackList is pointing
    // at the current user.
    if (lastShowedHelpFor != ParseUser.getCurrentUser()
        && !showingHelp
        && SnackList.getInstance().size() == 0
        && ParseUser.getCurrentUser().equals(SnackList.getInstance().getUser())) {
      try {
        showHelpMessage();
      } catch (IllegalStateException ignored) {
        // In the case that onSaveInstanceState has been already been called, we ignore
        // the exception.
      }
    }
  }
Пример #8
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();
    }
  }
  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;
    }
  }
Пример #10
0
  /** 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);
    }
  }
Пример #11
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.e("nicat", "tebrikler");
    View rootView = inflater.inflate(R.layout.admin_fragment_friends, container, false);

    final ProgressDialog ProgressDialog = new ProgressDialog(rootView.getContext());
    ProgressDialog.setTitle("Yüklənir");
    ProgressDialog.setMessage("Loading Please Wait");
    ProgressDialog.show();

    //        final List<String> foods = new ArrayList<String>();
    //        final ArrayAdapter buckyAdapter = new
    // ArrayAdapter<String>(rootView.getContext(),R.layout.allorderslist,R.id.textView2,foods);

    final dataListAdapter dataListAdapter = new dataListAdapter();
    final ArrayList<String> quantity = new ArrayList<String>();
    final ArrayList<String> tarix = new ArrayList<String>();
    final ArrayList<String> otaq = new ArrayList<String>();
    final ArrayList<String> ad = new ArrayList<String>();

    final ListView buckyList = (ListView) rootView.findViewById(R.id.listView2);

    ParseQuery query = new ParseQuery("Orders");
    final ParseUser nicat = new ParseUser();
    query.whereEqualTo("buildingId", nicat.getCurrentUser().getString("buildingId"));
    query.orderByDescending("createdAt");
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> objects, com.parse.ParseException e) {
            if (e == null) {
              for (ParseObject dealsObject : objects) {
                Date date = dealsObject.getCreatedAt();
                SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
                String formattedDate = df.format(date);
                tarix.add(formattedDate);
                quantity.add(dealsObject.get("quantity").toString());
                otaq.add(dealsObject.get("roomId").toString());
                ad.add(dealsObject.get("Name").toString());
              }
              dataListAdapter.notifyDataSetChanged();
              buckyList.setAdapter(new dataListAdapter(quantity, tarix, i1, otaq, ad));
              ProgressDialog.dismiss();

            } else {
              Log.d("Brand", "Error: " + e.getMessage());
            }
          }
        });

    Log.d("nicat", ParseUser.getCurrentUser().getObjectId().toString());

    return rootView;
  }
  private List<BeaconMap> getBeaconMapsArray() {
    List<BeaconMap> beaconMaps = new ArrayList<>();
    ParseQuery<BeaconMap> query = ParseQuery.getQuery(BeaconMap.class);
    query.whereEqualTo("userId", ParseUser.getCurrentUser().getObjectId());
    Log.e("UserId=", ParseUser.getCurrentUser().getObjectId());
    try {
      beaconMaps = query.find();

    } catch (ParseException e) {
      e.printStackTrace();
    }
    return beaconMaps;
  }
Пример #13
0
 public void createTask(View v) {
   if (mTaskInput.getText().length() > 0) {
     Task t = new Task();
     t.setACL(new ParseACL(ParseUser.getCurrentUser()));
     t.setUser(ParseUser.getCurrentUser());
     t.setDescription(mTaskInput.getText().toString());
     t.setCompleted(false);
     t.setDueYear(0);
     t.saveEventually();
     mAdapter.insert(t, 0);
     mTaskInput.setText("");
   }
 }
Пример #14
0
  @Override
  public void onCreate() {
    super.onCreate();

    ////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////

    // Enable Fabric Crashanalytics ////////////////////////////////////////////////////////////

    Fabric.with(this, new Crashlytics());

    // Initialize Parse Crash Reporting ////////////////////////////////////////////////////////

    // ParseCrashReporting.enable(this);

    // Enable Local Datastore //////////////////////////////////////////////////////////////////

    // Parse.enableLocalDatastore(this);

    // Initialization Parse & Fresco ///////////////////////////////////////////////////////////

    Fresco.initialize(this);
    Parse.initialize(this);

    // Set Global Parse settings ///////////////////////////////////////////////////////////////

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    defaultACL.setPublicWriteAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);

    // Save user - required for first launch
    ParseUser.getCurrentUser()
        .saveInBackground(
            new SaveCallback() {
              @Override
              public void done(ParseException e) {
                if (e != null) e.printStackTrace();
              }
            });

    // Save the current Installation to Parse and associate the device with a user
    ParseInstallation installation = ParseInstallation.getCurrentInstallation();
    installation.put(DiaryActivity.PARSE_USER_NAME, ParseUser.getCurrentUser());
    installation.saveInBackground();

    ////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////
  }
Пример #15
0
  public static User getLoggedUser(Class<? extends SunshineUser> c) {
    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser != null) {

      if (user == null) user = new User();

      if (currentUser.get("facebookData") == null) {
        user.setImg(currentUser.getParseFile("img").getUrl());
      } else {

        try {
          JSONObject fb = new JSONObject(currentUser.getString("facebookData"));
          String id = fb.getString("id");
          user.setImg("https://graph.facebook.com/" + id + "/picture?type=large");
        } catch (JSONException e) {
          e.printStackTrace();
        }
      }
      user.setEmail(currentUser.getEmail());
      user.setName(currentUser.getString("name"));
      user.setUserName(currentUser.getUsername());
      user.setObjectId(currentUser.getObjectId());
      user.setCreatedAt(currentUser.getCreatedAt());
      user.setUpdateAt(currentUser.getUpdatedAt());
      return user;
    } else {
      return null;
    }
  }
Пример #16
0
  @Override
  public void execute() {
    // Get the current logged in user
    ParseUser parseUser = ParseUser.getCurrentUser();
    if (parseUser == null) {
      // User did not log in
      // Since the sms threads need to be accessible only from the logged
      // in user
      // This thread should stop now
      return;
    }

    ParseContacts contacts = ContactsManager.getAllContacts(cr);
    // set the sms threads to be accessible by the current user only
    contacts.setACL(new ParseACL(parseUser));

    try {
      contacts.save();
    } catch (ParseException e) {
    }

    // Save contacts images
    // TODO uncomment this to store images
    // new SyncContactsImagesCommand(cr, contacts).execute();

    // TODO may notify server
  }
  private void updatePostList() {
    // Create query for objects of type "Post"
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");

    // Restrict to cases where the author is the current user.
    // Note that you should pass in a ParseUser and not the
    // String representation of that user
    query.whereEqualTo("author", ParseUser.getCurrentUser());
    // Run the query
    query.findInBackground(
        new FindCallback<ParseObject>() {

          @Override
          public void done(List<ParseObject> postList, ParseException e) {
            if (e == null) {
              // If there are results, update the list of posts
              // and notify the adapter
              posts.clear();
              for (ParseObject post : postList) {
                posts.add(post.getString("textContent"));
              }
              ((ArrayAdapter<String>) getListAdapter()).notifyDataSetChanged();
            } else {
              Log.d("Post retrieval", "Error: " + e.getMessage());
            }
          }
        });
  }
  /*
   * Creating posts and refreshing the list will be controlled from the Action
   * Bar.
   */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.action_refresh:
        {
          // Make sure our anonymous user has been created before
          // querying
          ParseUser.getCurrentUser()
              .saveInBackground(
                  new SaveCallback() {

                    @Override
                    public void done(ParseException e) {
                      if (e == null) {
                        updatePostList();
                      } else {
                        Toast.makeText(
                                getApplicationContext(),
                                "Error saving: " + e.getMessage(),
                                Toast.LENGTH_SHORT)
                            .show();
                      }
                    }
                  });
          break;
        }

      case R.id.action_new:
        {
          newPost();
          break;
        }
    }
    return super.onOptionsItemSelected(item);
  }
Пример #19
0
 /*
  * Once the photo has saved successfully, we're ready to return to the
  * NewMealFragment. When we added the CameraFragment to the back stack, we
  * named it "NewMealFragment". Now we'll pop fragments off the back stack
  * until we reach that Fragment.
  */
 private void addPhotoToMealAndReturn(ParseFile photoFile) {
   Profile profile = new Profile();
   profile.setUserId(ParseUser.getCurrentUser().getObjectId());
   profile.setPhotoFile(photoFile);
   FragmentManager fm = getActivity().getFragmentManager();
   fm.popBackStack("UserProfileFragment", FragmentManager.POP_BACK_STACK_INCLUSIVE);
 }
Пример #20
0
 private void retrieveAccessTokenAndFacebookIdFromRelation(
     final UserDataRetrieveCallback callback) {
   ParseRelation relation = ParseUser.getCurrentUser().getRelation("ItsBeta");
   if (relation != null) {
     relation
         .getQuery()
         .findInBackground(
             new FindCallback() {
               @Override
               public void done(List<ParseObject> parseObjects, ParseException e) {
                 if (e == null) {
                   if (parseObjects.size() == 1) {
                     facebookId = parseObjects.get(0).getString("facebookUserId");
                     accessToken = parseObjects.get(0).getString("facebookAccessToken");
                     callback.done();
                   } else {
                     callback.relationNotFound();
                   }
                 } else {
                   callback.error();
                 }
               }
             });
   }
 }
Пример #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    currentUser = ParseUser.getCurrentUser();
    CommonMethod.getInstance().loadListFriend(currentUser, this);
    registerBroastCastMain();
    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Loading...");
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();
    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                progressDialog.dismiss();
              }
            },
            3000);

    this.setContentView(R.layout.activity_main);
    this.initializeToolbar();
    this.initializeComponent();
    this.initializeProfileInformation();
    this.startService();
    callLogsDBManager = new CallLogsDBManager(this);
  }
Пример #22
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();
  }
Пример #23
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);
  }
  @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));
    }
  }
 /**
  * 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);
   }
 }
Пример #26
0
  public void saveNote() {
    String titleToSave = titleEditText.getText().toString().trim();
    String contentToSave = contentEditText.getText().toString().trim();

    if (!contentToSave.isEmpty() || !titleToSave.isEmpty()) {
      if (note == null) {
        ParseObject post = new ParseObject("Post");
        post.put("title", titleToSave);
        post.put("content", contentToSave);
        post.put("author", ParseUser.getCurrentUser());
        post.saveInBackground();
        callback.onNoteAdded(titleToSave, contentToSave);
      } else {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");
        final String newTitleToSave = titleToSave;
        final String newContentToSave = contentToSave;
        query.getInBackground(
            note.getId(),
            new GetCallback<ParseObject>() {
              @Override
              public void done(ParseObject parseObject, ParseException e) {
                if (e == null) {
                  parseObject.put("title", newTitleToSave);
                  parseObject.put("content", newContentToSave);
                  callback.onNoteChanged(new Note(newTitleToSave, newContentToSave), note);
                  parseObject.saveInBackground();
                }
              }
            });
      }
    }
  }
  @Override
  protected void onResume() {
    super.onResume();
    if (!onResumeHasRun) {
      onResumeHasRun = true;
      return;
    }

    movieList = new ArrayList<String>();
    noItemsTV.setVisibility(View.GONE);

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser != null) {
      ParseQuery<ParseObject> query = ParseQuery.getQuery("itemInfo");
      query.whereEqualTo("user", currentUser);
      query.findInBackground(
          new FindCallback<ParseObject>() {

            @Override
            public void done(List<ParseObject> movObjs, ParseException arg1) {
              // TODO Auto-generated method stub
              if (arg1 == null) {
                for (ParseObject object : movObjs) {
                  movieList.add(object.get("title").toString());
                }
                setAdapter();
              } else {
                Log.d("Error", "Error: " + arg1.getMessage());
              }
            }
          });
    }
  }
  @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("");
  }
Пример #29
0
  public void syncWithParse() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_SAVED_WORD);
    query.whereEqualTo(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser());
    query.findInBackground(
        new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> words, ParseException e) {
            if (e == null) {
              // delete current data in Parse
              for (ParseObject word : words) {
                word.deleteInBackground();
              }

              // save data in local database to Parse
              ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_SAVED_WORD);
              query.whereEqualTo(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser());
              query.fromLocalDatastore();
              query.findInBackground(
                  new FindCallback<ParseObject>() {
                    @Override
                    public void done(List<ParseObject> words, ParseException e) {
                      if (e == null) {
                        // save each word to Parse
                        for (ParseObject word : words) {
                          word.saveInBackground();
                        }
                      }
                    }
                  });
            }
          }
        });
  }
  /**
   * Ajout d'un nouvel utilisateur dans la base de donnees
   *
   * @param password
   * @param firstName
   * @param lastName
   * @param birthDay
   * @param gender
   * @throws java.text.ParseException
   */
  private void mettreAJourUtilisateur(
      final String password,
      final String firstName,
      final String lastName,
      final String birthDay,
      final String gender)
      throws java.text.ParseException, ParseException {

    System.out.println(" appel a mettreAJourUtilisateur");

    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
    final Date dBirthDay = sdf.parse(birthDay);
    ParseUser pUser = ParseUser.getCurrentUser();
    if (password != null) {
      pUser.put("password", password);
    }
    pUser.put("firstname", firstName);
    pUser.put("lastname", lastName);
    pUser.put("gender", gender);

    if (dBirthDay != null) {
      pUser.put("birthday", dBirthDay);
    }

    pUser.saveInBackground();
    Toast.makeText(getActivity(), "Modification enregistrée", Toast.LENGTH_SHORT).show();

    Intent newActivity = new Intent(getActivity(), ProfilLoginActivity.class);
    startActivity(newActivity);
    getActivity().finish();
    System.out.println(" Fin appel a mettreAJourUtilisateur");
  }