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); } } }); }
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); } } }); }
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); } } }); }
public void deleteMap(int position) { BeaconMap beaconMap = (BeaconMap) mGridView.getItemAtPosition(position); ParseQuery<Place> parseQueryBeacon = ParseQuery.getQuery("Place"); parseQueryBeacon.whereEqualTo(Constants.COLUMN_PLACE_MAP_ID, beaconMap.getObjectId()); try { ParseQuery<Beacon> beaconParseQuery = ParseQuery.getQuery("Beacon"); beaconParseQuery.whereEqualTo(Constants.COLUMN_BEACON_MAP_ID, beaconMap.getObjectId()); List<Beacon> beaconList = beaconParseQuery.find(); for (Beacon beacon : beaconList) { beacon.deleteInBackground(); } List<Place> placeList = parseQueryBeacon.find(); for (Place place : placeList) { ParseQuery<BeaconPower> beaconPowerParseQuery = ParseQuery.getQuery("BeaconPower"); beaconPowerParseQuery.whereEqualTo( Constants.COLUMN_BEACON_MEASURE_PLACE_ID, place.getObjectId()); List<BeaconPower> beaconPowerList = beaconPowerParseQuery.find(); for (BeaconPower beaconPower : beaconPowerList) { beaconPower.delete(); } place.deleteInBackground(); } } catch (ParseException e) { e.printStackTrace(); } beaconMap.deleteInBackground(); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // find all the views mListView = (ListView) view.findViewById(R.id.listViewApp); Lappointment.clear(); List<String> doctorID; Log.d("Chan", "Username: "******"doctorUsername")); username = getArguments().getString("doctorUsername"); List<ParseObject> list2 = new ArrayList<>(); ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Doctor"); query.whereEqualTo("Doctor", username); try { list2 = query.find(); } catch (ParseException e) { e.printStackTrace(); } for (ParseObject obj : list2) { doctorIDf = obj.getString("doctorID"); Log.d("chan", "Doctor ID : " + String.valueOf(doctorIDf)); } List<ParseObject> list = new ArrayList<>(); ParseQuery<ParseObject> query2 = ParseQuery.getQuery("Appointment"); query2.whereEqualTo("DoctorID", doctorIDf); try { list = query2.find(); } catch (ParseException e) { e.printStackTrace(); } for (ParseObject obj : list) { // Appointments appt = new Appointments(obj.getString("AppointmentID"), // obj.getString("AppointmentDate"), obj.getString("PatientID"), obj.getString("DoctorID"), // obj.getString("AppointmentTime"), obj.getString("Status")); // Lappointment.add(appt); Log.d("chan", "Status: " + obj.getString("Status")); Log.d("chan", "Status: " + obj.getString("Status")); } Log.d("chan", "Appointment size : " + String.valueOf(Lappointment.size())); // create a new instance of adapter ViewAppointmentRequest adapter = new ViewAppointmentRequest(getActivity(), R.layout.item_appointment, Lappointment); // set the adapter mListView.setAdapter(adapter); // set item click listener // handle Parse Exception here // set item click listener mListView.setOnItemClickListener(this); }
@Override public UserLikeComment getUserLikeCommentByCommentAndCurrentUser(Comment comment) throws ParseException { ParseQuery<UserLikeComment> query = ParseQuery.getQuery("UserLikeComment"); query.whereEqualTo("comment", comment); query.whereEqualTo("user", ParseUser.getCurrentUser()); query.setLimit(1); List<UserLikeComment> userLikeComments = query.find(); if (userLikeComments.size() == 1) return userLikeComments.get(0); else return null; }
public void getRelations() { ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends"); query.whereEqualTo("fromUser", currentUser.getObjectId() + ""); query.whereEqualTo("areFriends", true); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> list, ParseException e) { if (e == null) { getRelations1(list, list.size(), 0); } } }); }
public Permission getAdminPermission(Master master) { if (master == null) return null; ParseQuery<com.parse.ParseObject> query = ParseQuery.getQuery(Permission.PERMISSION_CLASS_NAME); query.fromLocalDatastore(); query.whereEqualTo(Permission.USER_ID, getId()); query.whereEqualTo(Permission.TYPE, Permission.ADMIN_PERMISSION); query.whereEqualTo(Permission.MASTER_ID, master.getId()); try { com.parse.ParseObject parsePermission = query.getFirst(); return Permission.create(parsePermission); } catch (ParseException e) { return null; } }
public void setNotifications() { notifications = (TextView) findViewById(R.id.Notifications); ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends"); query.whereEqualTo("toUser", currentUser.getObjectId() + ""); query.whereEqualTo("areFriends", false); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> list, ParseException e) { if (e == null) { notifications.setText(list.size() + ""); } } }); }
public static void userUnFollowingQuestion(final ParseUser user, final ParseObject question) { ParseQuery<ParseObject> query = ParseQuery.getQuery(Common.OBJECT_FOLLOWING); query.whereEqualTo(Common.OBJECT_FOLLOWING_USER, user); query.whereEqualTo(Common.OBJECT_FOLLOWING_QUESTION, question); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { for (ParseObject following : list) { following.deleteInBackground(); } } }); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; // reuse views if (rowView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.voice_row, parent, false); // configure view holder ViewHolder viewHolder = new ViewHolder(); viewHolder.image = (ImageView) rowView.findViewById(R.id.voice_row_image); // viewHolder.ratingBar = (RatingBar) rowView // .findViewById(R.id.voice_row_bar); viewHolder.title = (TextView) rowView.findViewById(R.id.voice_row_guidername); viewHolder.datdate = (TextView) rowView.findViewById(R.id.voice_row_date); rowView.setTag(viewHolder); } // fill data final ViewHolder holder = (ViewHolder) rowView.getTag(); Random ran = new Random(); holder.datdate.setText(mp3Path.get(position).createdTime); // holder.ratingBar.setRating(ran.nextInt(5)+1); //////柏要給我分數 ParseQuery<ParseObject> query = ParseQuery.getQuery("offline"); System.out.println("latitiude" + Globalvariable.latitude + " " + Globalvariable.longitude); // Retrieve the object by id query.whereEqualTo("latitude", Globalvariable.latitude); // 柏傳給我經緯度,我做經緯度限制 query.whereEqualTo("longitude", Globalvariable.longitude); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { // TODO Auto-generated method stub if (e == null) { System.out.println("title"); holder.title.setText((String) objects.get(0).get("userName")); } { System.out.println("ErrorCustomer"); } } }); return rowView; }
public boolean updateParseNickName(final String nickname) { String username = EMChatManager.getInstance().getCurrentUser(); ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereEqualTo(CONFIG_USERNAME, username); ParseObject pUser = null; try { pUser = pQuery.getFirst(); if (pUser == null) { return false; } pUser.put(CONFIG_NICK, nickname); pUser.save(); return true; } catch (ParseException e) { if (e.getCode() == ParseException.OBJECT_NOT_FOUND) { pUser = new ParseObject(CONFIG_TABLE_NAME); pUser.put(CONFIG_USERNAME, username); pUser.put(CONFIG_NICK, nickname); try { pUser.save(); return true; } catch (ParseException e1) { e1.printStackTrace(); EMLog.e(TAG, "parse error " + e1.getMessage()); } } e.printStackTrace(); EMLog.e(TAG, "parse error " + e.getMessage()); } return false; }
private void getCurrentUserAndStartChat(String userObjectId) { ParseQuery<SimpleUser> query = ParseQuery.getQuery("SimpleUser"); query.whereEqualTo("objectId", userObjectId); query.getFirstInBackground( new GetCallback<SimpleUser>() { public void done(SimpleUser user, com.parse.ParseException e) { if (e == null) { ChatPerson me = new ChatPerson(); me.name = user.getName(); me.objectId = user.getObjectId(); me.imageUrl = ""; ChatPerson other = new ChatPerson(); other.name = m_trainer.getName(); other.objectId = m_trainer.getObjectId(); other.imageUrl = m_trainer.getProfileImageUrl(); Intent intent = new Intent(getBaseContext(), ChatActivity.class); intent.putExtra("me", me); intent.putExtra("other", other); startActivity(intent); } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_trainer_details); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setNavigationBarColor(getResources().getColor(R.color.navigationBarColor)); } setupToolbar(); // Get the trainer object from parse and setup the view trainerId = getIntent().getStringExtra("trainerId"); ParseQuery<Trainer> query = ParseQuery.getQuery("Trainer"); query.whereEqualTo("objectId", trainerId); query.include("favorited_by"); query.findInBackground( new FindCallback<Trainer>() { @Override public void done(List<Trainer> list, com.parse.ParseException e) { Log.d("DEBUG", ((Trainer) list.get(0)).getName()); m_trainer = list.get(0); // Get the gym where the trainer goes to workout getTrainerGym(); } }); }
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()); } }
public void show1(View v) { String code = tv.getText().toString(); ParseQuery<ParseObject> query = ParseQuery.getQuery("Image"); query.whereEqualTo("Image", code); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> parseObjects, ParseException e) { ParseFile file = (ParseFile) parseObjects.get(0).get("ImageFile"); file.getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); img1.setImageBitmap(bmp); } }); } }); /*DBAdapter1 db = new DBAdapter1(this); String name = db.getbook(code); Uri muri = Uri.parse(name); s = getPath(muri); System.out.println("Image Path : " + s); img1.setImageURI(muri);*/ }
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(); } } } }); } } }); }
@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()); } } }); } }
public String uploadParseAvatar(byte[] data) { String username = EMChatManager.getInstance().getCurrentUser(); ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereEqualTo(CONFIG_USERNAME, username); ParseObject pUser = null; try { pUser = pQuery.getFirst(); if (pUser == null) { pUser = new ParseObject(CONFIG_TABLE_NAME); pUser.put(CONFIG_USERNAME, username); } ParseFile pFile = new ParseFile(data); pUser.put(CONFIG_AVATAR, pFile); pUser.save(); return pFile.getUrl(); } catch (ParseException e) { if (e.getCode() == ParseException.OBJECT_NOT_FOUND) { try { pUser = new ParseObject(CONFIG_TABLE_NAME); pUser.put(CONFIG_USERNAME, username); ParseFile pFile = new ParseFile(data); pUser.put(CONFIG_AVATAR, pFile); pUser.save(); return pFile.getUrl(); } catch (ParseException e1) { e1.printStackTrace(); EMLog.e(TAG, "parse error " + e1.getMessage()); } } else { e.printStackTrace(); EMLog.e(TAG, "parse error " + e.getMessage()); } } return null; }
public void initializeView( int newFitLogId, String workoutName, String referenceId, boolean editable, View button) { mFitLogId = newFitLogId; if (referenceId == null) { mRootFitLog = new FitLog(mFitLogId, 0); } else { ParseQuery<FitLog> refQuery = new ParseQuery<FitLog>("FitLog"); refQuery.whereEqualTo("objectId", referenceId); ParseQuery<FitLog> query = new ParseQuery<FitLog>("FitLog"); query.whereMatchesKeyInQuery("user", "user", refQuery); query.whereMatchesKeyInQuery("fitLogId", "fitLogId", refQuery); query.addAscendingOrder(FitLog.INDEX); try { List<FitLog> list = query.find(); List<FitLog> newList = new LinkedList<FitLog>(); Iterator<FitLog> it = list.iterator(); while (it.hasNext()) { newList.add(it.next().getNewFitLog(newFitLogId)); } mRootFitLog = FitLog.buildHierarchy(newList); } catch (Exception e) { // TODO e.printStackTrace(); } } mRootFitLog.put(FitLog.EXERCISE, workoutName); addView(mRootFitLog.createView(getContext(), editable)); setVisibility(View.VISIBLE); button.setVisibility(View.GONE); this.addOnLayoutChangeListener(this); }
private void getCurrentUserId(String phoneNumber) { ParseQuery<ParseObject> query = ParseQuery.getQuery("SimpleUser"); query.whereEqualTo("phone_number", phoneNumber); query.getFirstInBackground( new GetCallback<ParseObject>() { public void done(ParseObject object, ParseException e) { if (e == null) { String userId = object.getObjectId().toString(); String currentUserObjId = userId; SimpleUser.currentUserObjectId = currentUserObjId; // Write the userId in shared pref if the user successfully signed up SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor edit = pref.edit(); edit.putString("userId", userId); edit.commit(); Intent returnIntent = new Intent(); setResult(RESULT_OK, returnIntent); finish(); overridePendingTransition(R.anim.stay_in_place, R.anim.exit_to_bottom); } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
private void activePatientData() { ParseQuery<ParseObject> query = ParseQuery.getQuery("PatientDetails"); query.whereEqualTo("patientId", patientIdRemove); try { ParseObject object = query.getFirst(); object.put("status", "Active"); object.save(); } catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } /* ParseQuery<ParseObject> query3 = ParseQuery.getQuery("_User"); query3.whereEqualTo("userId", patientIdRemove); try { ParseObject object = query3.getFirst(); object.put("status", "Active"); object.save(); }catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); }*/ Toast.makeText(SearchPatientByAdmin.this, "Patient Active", Toast.LENGTH_SHORT).show(); }
private void retrieveMessages() { ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstant.CLASS_MESSAGE); query.whereEqualTo(ParseConstant.KEY_RECIPIENT_IDS, ParseUser.getCurrentUser().getObjectId()); query.addDescendingOrder(ParseConstant.KEY_CREATED_AT); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { getActivity().setProgressBarIndeterminateVisibility(false); if (mSwipeRefreshLayout.isRefreshing()) { mSwipeRefreshLayout.setRefreshing(false); } if (e == null) { // No found message mMessages = list; String[] usernames = new String[mMessages.size()]; int i = 0; for (ParseObject message : mMessages) { usernames[i] = message.getString(ParseConstant.KEY_SENDER_NAME); i++; } if (getListView().getAdapter() == null) { MessageAdapter adapter = new MessageAdapter(getListView().getContext(), mMessages); setListAdapter(adapter); } else { // refill the adapter ((MessageAdapter) getListView().getAdapter()).refill(mMessages); } } } }); }
private void retrieveMessages() { ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstants.CLASS_MESSAGES); query.whereEqualTo(ParseConstants.KEY_RECIPIENT_IDS, ParseUser.getCurrentUser().getObjectId()); query.addDescendingOrder(ParseConstants.KEY_CREATED_AT); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> messages, ParseException e) { if (mSwipe.isRefreshing()) { mSwipe.setRefreshing(false); } if (e == null) { // We found the message mMessages = messages; String[] usernames = new String[mMessages.size()]; int i = 0; for (ParseObject message : mMessages) { usernames[i] = message.getString(ParseConstants.KEY_SENDER_NAME); i++; } if (getListView().getAdapter() == null) { MessageAdapter adapter = new MessageAdapter(getListView().getContext(), mMessages); setListAdapter(adapter); } else { // Refill listview ((MessageAdapter) getListView().getAdapter()).refill(mMessages); } } } }); }
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()); } } }); }
private void startManageContent() { // if you're logged if (app.logged()) { findViewById(R.id.progress).setVisibility(View.VISIBLE); manageNotLoggedText.setVisibility(View.GONE); ParseQuery<ParseObject> query = ParseQuery.getQuery(Consts.PROTEST); query.whereEqualTo(Consts.P_ADMIN, app.getUsername()); query.orderByDescending("createdAt"); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> retrievedProtestList, ParseException e) { if (e == null) { manageProtestArrList = Protest.convertList(retrievedProtestList); manageProtestAdapter = new ProtestsAdapter(con, R.layout.row_protest, manageProtestArrList); manageProtestList.setAdapter(manageProtestAdapter); showHideNoProtestsMsg(retrievedProtestList); } else { Log.v(TAG, "Error: " + e.getMessage()); } findViewById(R.id.progress).setVisibility(View.GONE); } }); } else { notLogged("view protests you manage ", getString(R.string.unregistered_manage)); } }
private void displayInfo() { // get the info that was passed in from EventVoteActivity String eventId = getIntent().getExtras().getString("eventId"); position = getIntent().getExtras().getInt("position"); // find the Event in Parse to grab info from ParseQuery<ParseObject> query = ParseQuery.getQuery("Event"); query.whereEqualTo("objectId", eventId); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { if (e == null) { // set the text on the page to the information for that restaurant // that is stored in Parse ParseObject obj = list.get(0); restaurantName.setText((String) obj.getList("restaurants").get(position)); rating.setText((String) obj.getList("ratings").get(position)); type.setText((String) obj.getList("typeOfFood").get(position)); address.setText((String) obj.getList("addresses").get(position)); phone.setText((String) obj.getList("phoneNumbers").get(position)); } } }); }
/** 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); } }
/** This function downloads the Splash Image from the Parse Table 'Splash' */ public void downloadSplashImage() { Log.e("downloadSplashImage", "downloadSplashImage"); dialog1.setMessage("Downloading Splash Image..."); ParseQuery<ParseObject> query = ParseQuery.getQuery("Splash"); query.whereEqualTo("username", Login.USERNAME); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> objects, ParseException e) { if (e == null) { ParseFile myFile = objects.get(0).getParseFile("image"); myFile.getDataInBackground( new GetDataCallback() { public void done(byte[] data, ParseException e) { if (e == null) { // user the function writeFile() to create the file in the Internal Memory // the file name will be like someusername_splash.jpg writeFile(data, Login.USERNAME + "_splash.jpg"); // once the splash image is downloaded, we need to download the images for // the listview. downloadImages(); } else { Log.e("Something went wrong", "Something went wrong"); } } }); } else { Log.e("PARSE", "Error: " + e.getMessage()); } } }); }
public void asyncGetUserInfo(final String username, final EMValueCallBack<User> callback) { ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereEqualTo(CONFIG_USERNAME, username); pQuery.getFirstInBackground( new GetCallback<ParseObject>() { @Override public void done(ParseObject pUser, ParseException e) { if (pUser != null) { String nick = pUser.getString(CONFIG_NICK); ParseFile pFile = pUser.getParseFile(CONFIG_AVATAR); if (callback != null) { User user = UserUtils.getUserInfo(username); if (user != null) { user.setNick(nick); if (pFile != null && pFile.getUrl() != null) { user.setAvatar(pFile.getUrl()); } } callback.onSuccess(user); } } else { if (callback != null) { callback.onError(e.getCode(), e.getMessage()); } } } }); }