private void cadastrarUsuario() { //Cria objeto usuario ParseUser usuario = new ParseUser(); usuario.setUsername(textoUsuario.getText().toString()); usuario.setEmail(textoEmail.getText().toString()); usuario.setPassword(textoSenha.getText().toString()); //salva dados do usuario usuario.signUpInBackground(new SignUpCallback() { @Override public void done(ParseException e) { if (e == null) {//sucesso ao salvar Toast.makeText(CadastroActivity.this, "Cadastro feito com sucesso!", Toast.LENGTH_LONG).show(); abrirLoginUsuario(); } else {//erro ao salvar ParseErros parseErros = new ParseErros(); String erro = parseErros.getErro(e.getCode()); Toast.makeText(CadastroActivity.this, erro, Toast.LENGTH_LONG).show(); } } }); }
private void verificarLogin(String usuario, String senha) { ParseUser.logInInBackground(usuario, senha, new LogInCallback() { @Override public void done(ParseUser user, ParseException e) { if (e == null) {//sucesso no login Toast.makeText(LoginActivity.this, "Login realizado com sucesso!!", Toast.LENGTH_LONG).show(); abrirAreaPrincipal(); } else {//erro ao logar ParseErros parseErros = new ParseErros(); String erro = parseErros.getErro(e.getCode()); Toast.makeText(LoginActivity.this, erro, Toast.LENGTH_LONG).show(); } } }); }
private void localQuery(){ ParseQuery<Kid> lQuery = ParseQuery.getQuery(Kid.class).fromLocalDatastore(); lQuery.orderByAscending("createdAt"); lQuery.findInBackground(new FindCallback<Kid>() { @Override public void done(List<Kid> list, ParseException e) { if (e == null) { kidArrayList.clear(); kidArrayList.addAll(list); fillHashMap(); adapter = new AddAttendanceAdapter(AddAttendance.this,kidArrayList,activityMap); listView.setAdapter(adapter); listView.invalidate(); } } }); }
private void saveMethod(){ //will save the data if(dateText.getText().toString().equals("") || dateText.getText().toString().equals(" ") || dateText.getText() == null){ //but before saving we will make sure that date is there Toast.makeText(getApplicationContext(), "Attendance date is required",Toast.LENGTH_SHORT).show(); // Snackbar.make(findViewById(R.id.activity_add_attendance), // "Attendance date is required", Snackbar.LENGTH_SHORT).show(); }else{ List<String> kidsIds = new ArrayList<>(); for (int i = 0; i < adapter.map.size() ; i++) { if (adapter.map.get(kidArrayList.get(i))){ kidsIds.add(kidArrayList.get(i).getObjectId()); } } attendance.setDate(dateText.getText().toString()); attendance.setKidsIds(kidsIds); attendance.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null){ Toast.makeText(getApplicationContext(),"Saved successfully.",Toast.LENGTH_LONG).show(); end(); } } }); } }
private void logIn() { prefs = getSharedPreferences("prefFile", 0); String userName = prefs.getString("userName",null); String password = prefs.getString("password",null); user.logInInBackground(userName, password, new LogInCallback() { @Override public void done(ParseUser parseUser, @Nullable ParseException e) { if (e == null){ toaster("Login successful!","l"); }else { toaster("Failed to connect!","l"); } } }); }
private void localQuery(){ ParseQuery<Kid> query = ParseQuery.getQuery(Kid.class).fromLocalDatastore(); query.orderByAscending("createdAt"); query.findInBackground(new FindCallback<Kid>() { @Override public void done(List<Kid> list, @Nullable ParseException e) { if (e == null && list.size()!=0) { kidArrayList.clear(); kidArrayList.addAll(list); applyAttendanceToKids(); adapter.notifyDataSetChanged(); listView.invalidate(); } } }); }
private void serverQuery() { ParseQuery<Kid> query = ParseQuery.getQuery(Kid.class); query.orderByAscending("createdAt"); query.findInBackground(new FindCallback<Kid>() { @Override public void done(List<Kid> list, @Nullable ParseException e) { if (e == null){ kidArrayList.clear(); kidArrayList.addAll(list); Kid.pinAllInBackground(kidArrayList); applyAttendanceToKids(); adapter.notifyDataSetChanged(); listView.invalidate(); }else if(checkConnection()){ toaster("Error getting data from Server\nWorking offline!","l"); } } }); }
public void autoLogin(){ if (checkConnection()){ String userName = prefs.getString("userName",null); String password = prefs.getString("password",null); user.logInInBackground(userName, password, new LogInCallback() { @Override public void done(ParseUser parseUser, @Nullable ParseException e) { if (e == null){ isLoggedIn = true; splash(1500); Snackbar.make(findViewById(R.id.activity_splash),"Login successful..",Snackbar.LENGTH_LONG).show(); } } }); }else { isLoggedIn = false; splash(4000); Snackbar.make(findViewById(R.id.activity_splash),"You are offline, Working on local data",Snackbar.LENGTH_LONG).show();} }
private void incrementNumberOfVisits(){ int i; if(myKid.getNumberOfVisits() == null){ i = 0; }else{ i = Integer.parseInt(myKid.getNumberOfVisits());} i++; myKid.setNumberOfVisits(String.valueOf(i)); myKid.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null){ Toast.makeText(getApplicationContext(),"Saved successfully",Toast.LENGTH_LONG).show(); }else { Toast.makeText(getApplicationContext(),"Error calculating the number of visits!",Toast.LENGTH_LONG).show(); } } }); }
@Kroll.method public void start() { setState(STATE_RUNNING); // App opens analytics ParseAnalytics.trackAppOpenedInBackground(TiApplication.getAppRootOrCurrentActivity().getIntent()); ParseInstallation.getCurrentInstallation().put("androidId", getAndroidId()); ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() { public void done(ParseException e) { if (e != null) { Log.e(TAG, "Installation initialization failed: " + e.getMessage()); } // fire event try { JSONObject pnData = new JSONObject(); pnData.put("objectId", getObjectId()); pnData.put("installationId", getCurrentInstallationId()); KrollDict data = new KrollDict(pnData); module.fireEvent("installationId", data); } catch (JSONException e1) { Log.e(TAG, "InstallationId event failed: " + e1.getMessage()); } } }); }
@Override public List<Anime> getAnimeListByUrl(String url) { ArrayList<Anime> animeList = new ArrayList<>(); ParseQuery<AnimeRecord> query = AnimeRecord.getQuery(); try { List<AnimeRecord> animeRecords = query.whereContains("url", url).find(); for (AnimeRecord record : animeRecords) { Anime anime = AnimeRecord.toAnime(record); if (anime != null) animeList.add(anime); } } catch (ParseException e) { WriteLog.appendLogException(TAG, "getAnimeListByUrl(" + url + ") failed", e); } return animeList; }
@Override public List<Anime> getAnimeListByTitle(String title) { ArrayList<Anime> animeList = new ArrayList<>(); ParseQuery<AnimeRecord> query = AnimeRecord.getQuery(); try { List<AnimeRecord> animeRecords = query.whereContains("title", title).find(); for (AnimeRecord record : animeRecords) { Anime anime = AnimeRecord.toAnime(record); if (anime != null) animeList.add(anime); } } catch (ParseException e) { WriteLog.appendLogException(TAG, "getAnimeListByTitle(" + title + ") failed", e); } return animeList; }
public void getContactInfos(List<String> usernames, final EMValueCallBack<List<EaseUser>> callback) { ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereContainedIn(CONFIG_USERNAME, usernames); pQuery.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> arg0, ParseException arg1) { if (arg0 != null) { List<EaseUser> mList = new ArrayList<EaseUser>(); for (ParseObject pObject : arg0) { EaseUser user = new EaseUser(pObject.getString(CONFIG_USERNAME)); ParseFile parseFile = pObject.getParseFile(CONFIG_AVATAR); if (parseFile != null) { user.setAvatar(parseFile.getUrl()); } user.setNick(pObject.getString(CONFIG_NICK)); EaseCommonUtils.setUserInitialLetter(user); mList.add(user); } callback.onSuccess(mList); } else { callback.onError(arg1.getCode(), arg1.getMessage()); } } }); }
private void signUp(){ ParseUser user = new ParseUser(); user.setUsername(USER_NAME); user.setPassword(PASSWORD); user.setEmail(EMAIL); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { login(); Toast.makeText(getApplicationContext(), "Login cadastrado com sucesso", Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(getApplicationContext(), "Erro ao cadastrar login", Toast.LENGTH_SHORT).show(); } } }); }
public static void setUpParse(Context context) { Parse.enableLocalDatastore(context); Parse.initialize(context, "SUA_APPLICATION_ID", "SUA CLIENT_KEY"); ParseInstallation.getCurrentInstallation().saveInBackground(); ParseUser.enableAutomaticUser(); ParseACL defaultACL = new ParseACL(); defaultACL.setPublicReadAccess(true); defaultACL.setPublicWriteAccess(true); ParsePush.subscribeInBackground(Constants.CHANNEL, new SaveCallback() { @Override public void done(ParseException error) { if (error == null) { Log.i(Constants.TAG, "Successfully subscribed to Parse!"); }else{ Log.i(Constants.TAG, "Error subscribed to Parse!"); } } }); }
public static void retreiveprofile(String username , final Context context) { ParseQuery<ParseObject> query= ParseQuery.getQuery("Profile"); query.whereEqualTo("user",username); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { if(parseObject!=null && e==null) { ParseFile file = (ParseFile) parseObject.get("image"); String url = "http://wwww.webianks.com"; if (file != null) { url = file.getUrl().toString(); } MainActivity.retriveProfileCallback(context, url); }else{ //canntretrivee file } } }); }
public static void retreivetimelineprofile(String username , final Context context) { ParseQuery<ParseObject> query= ParseQuery.getQuery("Profile"); query.whereEqualTo("user",username); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { if(parseObject!=null && e==null) { ParseFile file = (ParseFile) parseObject.get("image"); String url = "http://wwww.webianks.com"; if (file != null) { url = file.getUrl().toString(); } Profile.retriveTimelineProfileCallback(context, url); }else{ //canntretrivee file } } }); }
private void runUpdate(final Event event, ArrayList<String> locations, String tag) { Log.d("FAC", tag); for (String location : locations) { String venue = event.getVenue(); venue = venue.replaceAll("\n", " "); event.setVenue(venue); if (venue.toLowerCase().contains(location)) { event.setFacultyTag(tag); event.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { Log.e("Saved:", event.getType()); } }); break; } } }
@Override public void login(String username, String password) { //Make sure parse is initialized in the Application class of the main app ParseUser.logInInBackground(username, password, new LogInCallback() { @Override public void done(ParseUser user, ParseException e) { if (e == null){ //User exist and authenticated, send user to Welcome.class EventBus.getDefault().post(new LoginCallbackEvent(true,null)); } else { EventBus.getDefault().post(new LoginCallbackEvent(false, e.getMessage())); } } }); }
private void verifyOrganization(){ final String enteredText = orgName.getText().toString().trim(); final RefreshingDialog rd = new RefreshingDialog(this); rd.createRefreshingDialog(); ParseQuery<Organization> query = ParseQuery.getQuery(Organization.class); query.whereEqualTo("name", enteredText); query.findInBackground(new FindCallback<Organization>() { @Override public void done(List<Organization> objects, ParseException e) { if(objects.isEmpty()){//new group createGroupAlert(enteredText); rd.stop(); }else{ joinGroupAlert(objects.get(0)); rd.stop(); } } }); }
private void userAcceptedGroup(Object org){ if(org instanceof String){ final Organization newOrg = new Organization((String)org); newOrg.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if(e == null){ //save worked saveAndContinue(newOrg); }else{ Toast.makeText(CreateOrganization.this, "Error creating organization, please try again", Toast.LENGTH_SHORT).show(); } } }); }else{ saveAndContinue((Organization)org); } }
private void loadData() { ParseQuery<UserInfo> query = ParseQuery.getQuery(UserInfo.class); query.orderByDescending("score").setLimit(10); query.findInBackground(new FindCallback<UserInfo>() { @Override public void done(List<UserInfo> objects, ParseException e) { list.addAll(objects); runOnUiThread(new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); } }); }
private void requestSessionToken(String authorizationCode) { HashMap<String, Object> params = new HashMap<>(); params.put("authorizationCode", authorizationCode); ParseCloud.callFunctionInBackground("requestSessionToken", params, new FunctionCallback<String>() { @Override public void done(String sessionToken, ParseException e) { if (e == null) { Log.d("cloud", "Got back: " + sessionToken); becomeUser(sessionToken); } else { Toast.makeText(LoginActivity.this, "Login failed", Toast.LENGTH_LONG).show(); Log.d("error", e.toString()); } } }); }
public <T> Observable<T> callFunctionForList(@NonNull String functionName, @NonNull Map<String, ?> params) { Log.d(TAG, "Calling function: " + functionName + ", with params: " + params); return Observable.create(new ParseRequest<List<T>, T>("Exception while calling method " + functionName) { @NonNull @Override protected List<T> networkCall() throws ParseException { return ParseCloud.callFunction(functionName, params); } @Override protected void publishResult(@NonNull Subscriber<? super T> subscriber, @NonNull List<T> results) { for (T result : results) { subscriber.onNext(result); } } }); }
public Observable<ParseUser> signUp(@NonNull String userName, @NonNull String password, @NonNull Map<String, ?> params) { Log.d(TAG, "Running sign up"); return Observable.create(new SimpleParseRequest<ParseUser>("Exception while calling signUp") { @NonNull @Override protected ParseUser networkCall() throws ParseException { final ParseUser user = new ParseUser(); user.setUsername(userName); user.setPassword(password); for (Map.Entry<String, ?> param : params.entrySet()) { user.put(param.getKey(), param.getValue()); } user.signUp(); return user; } }); }
@Override public void call(Subscriber<? super T> subscriber) { if (!mCallCompleted) { synchronized (this) { if (!mCallCompleted) { try { mResult = networkCall(); } catch (ParseException e) { mParseException = e; } mCallCompleted = true; } } } if (mResult != null) { publishResult(subscriber, mResult); } else if (mParseException != null) { publishError(subscriber, mParseException); return; } // As we might not have a result for example where the return type is void, onCompleted needs to occur outside of the result // if statement. subscriber.onCompleted(); }
@Override public void onCreate() { super.onCreate(); Parse.enableLocalDatastore(this); Parse.initialize(this, "b6M7rAxtdYoUgGMgGkzmYmpDWiN2T6M8c2RTJ5Zg", "Xsqyd44kUtgiOMMvwP8gyVjmdZLvXLxuynmGqqNX"); ParsePush.subscribeInBackground("Apro_2016", new SaveCallback() { @Override public void done(ParseException e) { Log.e(TAG, "Successfully subscribed to Parse!"); } }); Log.d(TAG, "not rgtd."); }
public void localTeamList() { // Query backend ParseQuery<ParseObject> query = ParseQuery.getQuery("T" + teamNumber); query.fromLocalDatastore().findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { // No exception, query successful if (e == null) { teams.clear(); Collections.reverse(list); for (ParseObject object : list) { if (object.getString("team").equals("")) continue; Team team = new Team(object.getString("team"), object.getString("region"), object.getString("school"), object.getString("teamName"), object.getObjectId()); teams.add(team); } } adapter.notifyDataSetChanged(); refresh.setRefreshing(false); } }); }
public void getNodes(final Callback<List<Node>> cb) { if (nodes == null) { getNodeRelation() .getQuery() .orderByAscending(KEY_ORDER) .findInBackground(new FindCallback<Node>() { @Override public void done(List<Node> objects, ParseException e) { if (e != null) { cb.error(new Error(e.getMessage(), e.getCode())); e.printStackTrace(); } else { nodes = objects; cb.done(nodes); } } }); } else { cb.done(nodes); } }
public Bitmap getPic(){ ParseFile picFile=null; if(parseEntry!=null){ if(parseEntry.getParseFile("ProfilePic")!=null){ picFile = parseEntry.getParseFile("ProfilePic"); }; } if(picFile == null){ return null; } try { byte[] image = picFile.getData(); Bitmap pic = BitmapFactory.decodeByteArray(image, 0, image.length); return pic; } catch (ParseException e) { e.printStackTrace(); return null; } }
public void showFavorites() { ParseQuery<Trainer> query = ParseQuery.getQuery("Trainer"); query.include("favorited_by"); query.whereEqualTo("favorited_by", SimpleUser.currentUserObject); query.findInBackground(new FindCallback<Trainer>() { public void done(List<Trainer> trainers, ParseException e) { hideProgressWheel(); if (e == null) { Log.d("DEBUG", "Retrieved " + trainers.size() + " trainers"); refreshFragment(trainers); } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
public void autorization(){ ParseUser.logInInBackground(entLogin.getText().toString(), entPassword.getText().toString(), new LogInCallback(){ public void done(ParseUser user, ParseException e) { if (user != null) { loginOk(); } else { Toast toast = Toast.makeText(getApplicationContext(), "Incorect login or password", duration); toast.show(); // Signup failed. Look at the ParseException to see what happened. } } }); }
public void addCommentTask(){ ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB"); query.whereEqualTo("phone", Phone); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { Log.d("TAG","Done Loading Detail!"); String NewComment = AddComment.getText().toString(); List<String> CommentsList = parseObject.getList("comments"); if(CommentsList==null){ CommentsList = new ArrayList<String>(); } CommentsList.add(NewComment+"["+GUID+"]"); parseObject.put("comments",CommentsList); parseObject.saveInBackground(); loadDetail(); } }); }
public void addCommentTask(String Number, final String Comment, final String GUID){ ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB"); query.whereEqualTo("phone", Number); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { Log.d("TAG", "Done Loading Detail!"); List<String> CommentsList = parseObject.getList("comments"); if(CommentsList==null){ CommentsList = new ArrayList<String>(); } CommentsList.add(Comment+"["+GUID+"]"); parseObject.put("comments",CommentsList); parseObject.saveInBackground(); } }); }
public void addBullshITBank(final String NewNumber){ if(NewNumber.length()<6){ Toast.makeText(mContext, getResources().getString(R.string.too_short), Toast.LENGTH_LONG).show(); }else{ ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB"); query.whereStartsWith("phone", NewNumber); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> parseObjects, ParseException e) { if (parseObjects.size() > 0) { Toast.makeText(mContext, getResources().getString(R.string.duplicate), Toast.LENGTH_LONG).show(); } else { FragmentManager fragmentManager = getSupportFragmentManager(); DialogFragment ConfirmDialog = AddNewConfirmDialog.newInstance(NewNumber,GUID); ConfirmDialog.show(fragmentManager,"confirmdialog"); } } }); } }
public void setUsersImageToParse(String username, final File image){ ParseQuery<ParseUser> query = ParseUser.getQuery(); query.whereEqualTo("username", username); query.getFirstInBackground(new GetCallback<ParseUser>() { public void done(ParseUser UsersClass, ParseException e) { if (UsersClass == null) { Log.d("score", "no success setUsersImageToParse"); } else { //success UsersClass.put("ProfilePic", image); UsersClass.saveInBackground(); pullParseAndSetOtherUsersDatainBackground(); } } }); }
public static void getMatches(final ActionDataCallbacks callbacks) { ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(TABLE_NAME); query.whereEqualTo(COLUMN_BY_USER, ParseUser.getCurrentUser().getObjectId()); query.whereEqualTo(COLUMN_TYPE, TYPE_MATCHED); query.orderByDescending(COLUMN_UPDATED_AT); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { if(e == null) { List<String> ids = new ArrayList<String>(); for(ParseObject object : list) { ids.add(object.getString(COLUMN_TO_USER)); } if(callbacks != null) { callbacks.onFetchedMatches(ids); } } } }); }
private void getFacebookInfo() { Bundle parameters = new Bundle(); parameters.putString("fields", "picture, first_name, id"); new GraphRequest(AccessToken.getCurrentAccessToken(), "/me", parameters, HttpMethod.GET, new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse graphResponse) { JSONObject user = graphResponse.getJSONObject(); ParseUser currentUser = ParseUser.getCurrentUser(); currentUser.put("firstName", user.optString("first_name")); currentUser.put("facebookId", user.optString("id")); currentUser.put("pictureURL", user.optJSONObject("picture").optJSONObject("data").optString("url")); currentUser.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if(e == null) { Log.i(TAG, "User saved"); setResult(RESULT_OK); finish(); } } }); } }).executeAsync(); }
/** * This is where the bulk of our work is done. This function is * called in a background thread and should generate a new set of * data to be published by the loader. */ @Override @SuppressWarnings("unchecked") public List<T> loadInBackground() { if (mParseQuery == null) { return Collections.emptyList(); } try { return mForceLoadEverything ? findAll(mParseQuery) : loadObjects(mPageToLoad); } catch (ParseException e) { if (BuildConfig.DEBUG) { Log.w(TAG, "Load interrupted with ParseException " + e.getCode() + ": " + e.getMessage()); } return Collections.emptyList(); } }