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 Object getData(Object... params) throws JSONException, SQLException, NullPointerException, RestException, ClassCastException, ParseException { ParseQuery<ParseObject> query = (ParseQuery<ParseObject>) params[0]; return query.find(); }
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); }
@Override protected Void doInBackground(Void... params) { // Create the array photoarraylist = new ArrayList<PhotoList>(); try { // Locate the class table named "ImageUpload" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("ImageUpload"); // Locate the column named "position" in Parse.com and order list // by descending order of created. query.orderByDescending("createdAt"); query.setLimit(15); ob = query.find(); for (ParseObject po : ob) { // retrieve objectID and Title String stringTitle = (String) po.get("Title"); String stringObjectID = po.getObjectId(); // retrieve the image file ParseFile image = (ParseFile) po.get("Photo"); PhotoList map = new PhotoList(); map.setPhoto(image.getUrl()); map.setObjectID(stringObjectID); map.setTitle(stringTitle); photoarraylist.add(map); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override protected String doInBackground(String... params) { // Notify Parse Analytics that the app has been opened ParseAnalytics.trackAppOpenedInBackground(getIntent()); CardDbHelper cardDbHelper = new CardDbHelper(getBaseContext()); SQLiteDatabase db = cardDbHelper.getWritableDatabase(); cardDbHelper.onCreate(db); try { ParseQuery<ParseObject> query = ParseQuery.getQuery("Card"); query.setLimit(1000); query.selectKeys(Arrays.asList("")); List<ParseObject> results = query.find(); Iterator<ParseObject> iterator = results.iterator(); // Writing values to DB ContentValues values = new ContentValues(); while (iterator.hasNext()) { ParseObject next = iterator.next(); values.put("cardId", next.getObjectId().toString()); db.insert(CardDbHelper.TABLE_NAME, "null", values); } } catch (ParseException e) { e.printStackTrace(); } return ""; }
@Override protected Void doInBackground(Void... params) { // Create the array soaplist = new ArrayList<WorldPopulation>(); try { ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Product"); // query.orderByAscending("Product"); ob = query.find(); for (ParseObject Product : ob) { // Locate images in Picture column ParseFile image = (ParseFile) Product.get("Picture"); WorldPopulation map = new WorldPopulation(); if (Product.get("Category").equals("soaps and shampoos")) { map.setPrice((String) Product.get("Price")); map.setProduct((String) Product.get("Product")); map.setCategory((String) Product.get("Category")); map.setQuantity(Integer.parseInt(Product.get("qty").toString())); map.setPicture(image.getUrl()); soaplist.add(map); } } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override protected Void doInBackground(Void... params) { // Create the array menulista = new ArrayList<MenuSetGet>(); try { // Locate the class table named "Country" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("computadoras"); // Locate the column named "ranknum" in Parse.com and order list // by ascending query.orderByAscending("orden"); ob = query.find(); for (ParseObject country : ob) { // Locate images in flag column ParseFile image = (ParseFile) country.get("imagen"); MenuSetGet map = new MenuSetGet(); map.setNombre((String) country.get("nombre")); map.setDetalle((String) country.get("Detalle")); map.setPrecio((String) country.get("precio")); map.setImagen(image.getUrl()); menulista.add(map); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override protected Void doInBackground(Void... params) { // Create the array userProfileList = new ArrayList<UserProfile>(); try { // Locate the class table named "Country" in Parse.com ParseQuery<ParseUser> query = ParseUser.getQuery(); Log.d("UserListActivity", "In asynctask.. username - " + currentUser.getUsername()); query.whereNotEqualTo("username", currentUser.getUsername()); // by ascending LastName query.orderByAscending("lastName"); ob = query.find(); for (ParseObject userProfile : ob) { UserProfile map = new UserProfile(); map.setFirstName((String) userProfile.get("firstName")); map.setLastName((String) userProfile.get("lastName")); map.setDepartment((String) userProfile.get("department")); map.setUsername((String) userProfile.get("username")); userProfileList.add(map); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
private void prepareListData() { listDataHeader = new ArrayList<String>(); listDataChild = new HashMap<String, List<String>>(); listDataChildObject = new HashMap<String, List<ParseObject>>(); // Adding child data ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Category"); List<ParseObject> listHeaders = null; try { listHeaders = query1.find(); } catch (Exception e) { } for (ParseObject x : listHeaders) { listDataHeader.add((String) x.get("category_name")); } int n = listDataHeader.size(); // Adding child data for (int i = 0; i < n; i++) { String s = listDataHeader.get(i); ParseObject obj = listHeaders.get(i); List<String> list = new ArrayList<String>(); List<ParseObject> listObject = new ArrayList<ParseObject>(); ParseQuery<ParseObject> query = ParseQuery.getQuery("Menu_Item").whereEqualTo("category", obj); List<ParseObject> matches = null; try { matches = query.find(); } catch (Exception e) { } for (ParseObject a : matches) { // if(isActive(a)) { list.add((String) a.get("item_name")); listObject.add(a); // } } listDataChild.put(s, list); listDataChildObject.put(s, listObject); } }
@Override public List<UserLikeComment> getMostRecentlyLikedComments( ParseUser user, int numberOfRetunredRows) throws ParseException { ParseQuery<UserLikeComment> query = ParseQuery.getQuery("UserLikeComment"); query.whereEqualTo("user", user); query.setLimit(numberOfRetunredRows); query.orderByDescending("createdAt"); return query.find(); }
@Override protected HashMap<String, Object> doInBackground(String... params) { try { ArrayList<Job> jobsOnMarket = new ArrayList<Job>(); ArrayList<Job> myJobs = new ArrayList<Job>(); queryFlyer = new ParseQuery("Flyer"); queryMarketJob = new ParseQuery("Job"); queryMyJob = new ParseQuery("Job"); queryUser = new ParseQuery("User"); queryMarketJob.whereContains("AssignedTo", "Nobody"); queryMarketJob.whereContains("City", "Toronto"); jobsMarketParse = (ArrayList<ParseObject>) queryMarketJob.find(); queryMyJob.whereContains("AssignedTo", myId); jobsMyParse = (ArrayList<ParseObject>) queryMyJob.find(); // Get the Flyers for each job String jobId; for (Iterator iter = (Iterator<ParseObject>) jobsMarketParse.iterator(); iter.hasNext(); ) { jobId = ((ParseObject) iter.next()).getObjectId(); queryFlyer.whereContains("JobId", jobId); } map.put("MarketJobs", jobsMarketParse); map.put("MyJobs", jobsMyParse); Log.d("PosterPalActivity", "queryFlyer " + queryFlyer.toString()); Log.d("PosterPalActivity", "queryJob " + queryMarketJob.toString()); Log.d("PosterPalActivity", "queryUser " + queryUser.toString()); } catch (Exception parse) { Log.d("PosterPalActivity", parse.getMessage()); } return map; }
@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 static <T extends ParseObject> List<T> findAllParseObjects(ParseQuery<T> query) throws ParseException { List<T> result = new ArrayList<T>(); query.setLimit(DEFAULT_PARSE_QUERY_LIMIT); List<T> chunk = null; do { chunk = query.find(); result.addAll(chunk); query.setSkip(query.getSkip() + query.getLimit()); } while (chunk.size() == query.getLimit()); return result; }
public List<Farm> getAllFarm(Farmer farmer) { try { ParseQuery<Farm> queryFarm = ParseQuery.getQuery(Farm.class); queryFarm.whereEqualTo("farmer", farmer); return queryFarm.find(); } catch (Exception e) { e.printStackTrace(); } // end try catch return null; } // end getAllFarm
@Override protected Void doInBackground(Void... params) { // Locate the class table named "Country" in Parse.com ParseQuery<ParseObject> ironItems = new ParseQuery<ParseObject>("IronItems"); try { ironItemsObject = ironItems.find(); } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
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; }
public List<User> resolveAll() throws ParseException { if (cachedAll != null) return cachedAll; else { ParseQuery<ParseObject> query = ParseQuery.getQuery(className); List<ParseObject> parseObjects = query.find(); List<User> users = new ArrayList<User>(); for (ParseObject object : parseObjects) { users.add(new User(object)); } UserRepository.cachedAll = users; return users; } }
@Override public Cartelera obtenerCartelera() { Cartelera c = new Cartelera(); ParseQuery<ParseObject> query; List<ParseObject> list; try { query = ParseQuery.getQuery("Cartelera"); list = query.find(); if (list.size() == 0) { return null; } } catch (ParseException e) { e.printStackTrace(); } return c; }
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); List<ParseObject> ob; try { // Locate the class table named "stansbeers" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<>("capitolbeers").fromLocalDatastore(); // Locate the column named "name" in Parse.com and order list // by ascending query.orderByAscending("name").whereEqualTo("group", "IMPORT_BOTTLES_CANS"); ob = query.find(); beerObject = new ArrayList<>(); for (ParseObject beers : ob) { // Locate images in flag column // ParseFile image = (ParseFile) stansbeers.get("image"); BeerListObject beer = new BeerListObject(); beer.setBeerName((String) beers.get("name")); beer.setBeerWhereFrom((String) beers.get("wherefrom")); beer.setBeerAbv(beers.getDouble("abvinteger")); beer.setBeerGroup((String) beers.get("group")); beer.setBeerAbout((String) beers.get("about")); beer.setBeerPrice((String) beers.get("price")); beer.setBeerSize((String) beers.get("size")); // beer.setBeerImage(image.getUrl()); beerObject.add(beer); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } adapter = new BeersListViewAdapter(getActivity(), beerObject); setListAdapter(adapter); }
public static Professor getProfessor(String name) { ParseQuery<Professor> professorParseQuery = ParseQuery.getQuery(Professor.class); professorParseQuery.whereEqualTo("name", name); Professor professor = null; try { List<Professor> professors = professorParseQuery.find(); for (Professor p : professors) { p.fetchIfNeeded(); if (p.getName().equals(name)) { professor = p; break; } } } catch (ParseException e) { e.printStackTrace(); } return professor; }
public Boolean isUserExists(String email) { boolean checkUser = false; List<BikeSpotUser> list = null; if (email != null) { try { ParseQuery<BikeSpotUser> query = ParseQuery.getQuery("BikeSpotUser"); // BikeSpotUser.class query.whereEqualTo("email", email); list = query.find(); int count = list.size(); if (count > 0) checkUser = true; } catch (ParseException e) { return false; } } return checkUser; }
public Boolean isBikeSpotExists(ParseGeoPoint location) { boolean checkUser = false; List<BikeSpot> list = null; if (location != null) { try { ParseQuery<BikeSpot> query = ParseQuery.getQuery("BikeSpot"); // BikeSpotUser.class query.whereEqualTo("location", location); list = query.find(); int count = list.size(); if (count > 0) checkUser = true; } catch (ParseException e) { return false; } } return checkUser; }
public Boolean isBikeSpotExists(String fullAddress) { boolean checkUser = false; List<BikeSpot> list = null; if (fullAddress != null) { try { ParseQuery<BikeSpot> query = ParseQuery.getQuery("BikeSpot"); // BikeSpotUser.class query.whereEqualTo("fullAddress", fullAddress); list = query.find(); int count = list.size(); if (count > 0) checkUser = true; } catch (ParseException e) { return false; } } return checkUser; }
public void loadLists() { groups = new ArrayList<Group>(); ParseQuery<Group> query = Group.getQuery(); query.fromLocalDatastore(); try { groups = query.find(); } catch (ParseException e) { e.printStackTrace(); } Group inbox = new Group(); inbox.setName("Inbox"); groups.add(0, inbox); // if(TaskDAO.getTasksTodayCount()!=0){ Group today = new Group(); today.setName("Today"); groups.add(1, today); // } // if(TaskDAO.getTasksNextDaysCount()!=0){ Group tomorrow = new Group(); tomorrow.setName("In 7 Days"); groups.add(2, tomorrow); // } Group create = new Group(); create.setName("Create list"); groups.add(groups.size(), create); todayAdapter = new ListAdapter(groups, this); todayRecyclerView.setAdapter(todayAdapter); RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this, LinearLayoutManager.VERTICAL); // todayRecyclerView.addItemDecoration(itemDecoration); }
@Override protected Void doInBackground(Void... params) { // Create the array try { // Locate the class table named "Country" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("r" + route); // Locate the column named "ranknum" in Parse.com and order list // by ascending query.orderByAscending("s_name"); ob = query.find(); for (ParseObject student : ob) { // Locate images in flag column name[count] = student.get("s_name").toString(); numbers[count] = student.get("phone_no").toString(); count++; /*ParseQuery<ParseObject> query1 = ParseQuery.getQuery("User"); query1.whereEqualTo("username", Route_info.teachuser); query1.getFirstInBackground(new GetCallback<ParseObject>() { public void done(ParseObject object, ParseException e) { if (object == null) { Toast.makeText(getApplicationContext(),"Failed",Toast.LENGTH_SHORT).show(); Log.d("score", "The getFirst request failed."); } else { teachpass = object.getString("password"); //Log.d("score", "Retrieved the object."); } } });*/ } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }
@Override protected Void doInBackground(Void... arg0) { if (isHoneycomb) { final ParseQuery query = new ParseQuery(Preferences.PARSE_TABLE_SMS); // Sort the Parse Object so only the username of the current // user can be accessed. query.whereEqualTo(Preferences.PARSE_USERNAME_ROW, Util.getUsernameString()); // The most recent message added will be on top. query.orderByDescending("createdAt"); // Only need to get one message from the server, each message // will be from a push query.setLimit(1); try { List<ParseObject> messageList = query.find(); for (ParseObject messageObject : messageList) { // Open up the database // Get the parse object id String objectId = messageObject.objectId(); // with the objectid you can query the server ParseObject message = query.get(objectId); // Get the time the message was added to the server Date time = message.createdAt(); // Format the time to (Fri Jan 13 12:00) SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd hh:mm"); String formatedTime = sdf.format(time); String timeDB = formatedTime.toString(); String addressDB = message.getString("address"); String bodyDB = message.getString("body"); int readDB = message.getInt("read"); int smsIdDB = message.getInt("smsId"); String subjectDB = message.getString("subject"); int threadIdDB = message.getInt("threadId"); int typeDB = message.getInt("type"); int onDeviceDB = message.getInt("onDevice"); String usernameDB = message.getString("username"); // Display the total message queryed for // logging String totalMessage = "Sent: " + timeDB + "\n" + "Address: " + addressDB + "\n" + "Message : " + bodyDB + "\n"; Log.d(TAG, "New message is: " + totalMessage); // Get the MessageItem object so you can // create the db entry. MessageItem item = new MessageItem( timeDB, addressDB, bodyDB, readDB, smsIdDB, subjectDB, threadIdDB, typeDB, onDeviceDB, usernameDB); // Insert the MessageItem into the sms2honeycomb.db. dbAdapter.insertMessageItem(item); // TODO update the listadapter to display the new // message via an intent/ service? String intentString = "com.asa.texttotab.UPDATE_LIST"; Intent updateIntent = new Intent(); updateIntent.setAction(intentString); mContext.sendBroadcast(updateIntent); // TODO NOTICIFATIONS } } catch (ParseException e) { // TODO - Handle situation where querying server failed dbAdapter.close(); Log.e(TAG, "querying server failed"); e.printStackTrace(); } } else { Log.e(TAG, "The device is not honeycomb is its a phone."); // If the device is not a tablet it is a phone so you pull from // the // server, but then send a sms message from the data recived. // We want to query the sms table final ParseQuery query = new ParseQuery(Preferences.PARSE_TABLE_SMS); // Sort the Parse Object so only the username of the current // user // can be accessed. query.whereEqualTo(Preferences.PARSE_USERNAME_ROW, Util.getUsernameString()); // The most recent message added will be on top. query.orderByDescending("createdAt"); // Only need to get one message from the server, each message // will be from a push query.setLimit(1); try { List<ParseObject> messageList = query.find(); // For the ParseObjects quering get all that needs // to be done. for (ParseObject messageObject : messageList) { // Get the parse object id String objectId = messageObject.objectId(); // with the objectid you can query the // server ParseObject message = query.get(objectId); // Get the time the message was created at // for // logging, do not need a time to send a // message. Date time = message.createdAt(); String timeString = time.toString(); // Get who the message is coming from // (phonenumber). String address = message.getString(Preferences.PARSE_SMS_ADDRESS); // Get the body of the message String body = message.getString(Preferences.PARSE_SMS_BODY); // Display the total message queryed for // logging String totalMessage = "Sent: " + timeString + "\n" + "To: " + address + "\n" + "Message : " + body + "\n"; Log.d(TAG, "New message is: " + totalMessage); // get the smsmanager as sms SmsManager sms = SmsManager.getDefault(); // If the message is over the 160 Char limit // it // will be choped up. if (body.length() > 160) { // Chops up the message sms.divideMessage(body); // Send the sms message in its parts sms.sendMultipartTextMessage(address, null, sms.divideMessage(body), null, null); } else { // Sends the message without cutting it sms.sendTextMessage(address, null, body, null, null); } } } catch (ParseException e) { // TODO - Handle situation where querying server failed e.printStackTrace(); } } return null; }
@Override public void setSemester(String sem) { this.semester = sem; Toast.makeText(this, semester, Toast.LENGTH_LONG).show(); ParseQuery<ParseObject> query = ParseQuery.getQuery("Course"); query.selectKeys(Arrays.asList("courseId", "courseName")); query.whereEqualTo("semester", semester); try { List<ParseObject> result = query.find(); for (int i = 0; i < result.size(); i++) { coursesDetails.put( result.get(i).getString("courseId"), result.get(i).getString("courseName")); courses.add( result.get(i).getString("courseId") + " " + result.get(i).getString("courseName")); chk_box_course.put( result.get(i).getString("courseId") + " " + result.get(i).getString("courseName"), false); } } catch (ParseException e) { e.printStackTrace(); } ListView listView = (ListView) findViewById(R.id.list); dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, courses); // Assign adapter to ListView listView.setAdapter(dataAdapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text String course = parent.getItemAtPosition(position).toString(); ParseObject student_course = ParseObject.create("Student_Course"); String[] cou = course.split(" "); String cid = cou[0]; student_course.put("courseId", cid); student_course.put("studentId", sid); student_course.put("attendance", 0); student_course.saveInBackground(); // Log.i("cid",cid); // Log.i("sid",sid); ParsePush.subscribeInBackground( cid, new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { // Log.d("com.parse.push", "successfully subscribed to the broadcast // channel."); } else { // Log.e("com.parse.push", "failed to subscribe for push", e); } } }); Toast.makeText(getApplicationContext(), cid + " Added!", Toast.LENGTH_LONG).show(); Bundle extras = new Bundle(); extras.putString("id", sid); Intent intentStudent = new Intent(AddCourseStudent.this, StudentHome.class); intentStudent.putExtras(extras); startActivity(intentStudent); } }); }
@Override public void onListItemClick(ListView l, View v, int position, long id) { x = x + 1; if (x == 6) { x = 0; } String[] toastSort = new String[8]; toastSort[0] = "Sorted by name Ascending"; toastSort[1] = "by name descending"; toastSort[2] = "by A.B.V ascending"; toastSort[3] = "by A.B.V descending"; toastSort[4] = "by where from ascending"; toastSort[5] = "by where from descending"; String tm = toastSort[x]; Toast sort = Toast.makeText(getActivity(), tm, Toast.LENGTH_LONG); sort.setGravity(Gravity.CENTER, 0, 0); sort.show(); List<ParseObject> ob; try { // Locate the class table named "stansbeers" in Parse.com ParseQuery<ParseObject> query = new ParseQuery<>("capitolbeers").fromLocalDatastore(); // Locate the column named "name" in Parse.com and order list // by ascending query.orderByAscending("name").whereEqualTo("group", "IMPORT_BOTTLES_CANS"); switch (x) { case 0: query.orderByAscending("name"); break; case 1: query.orderByDescending("name"); break; case 2: query.orderByAscending("abvinteger"); break; case 3: query.orderByDescending("abvinteger"); break; case 4: query.orderByAscending("wherefrom"); break; case 5: query.orderByDescending("wherefrom"); break; } ob = query.find(); beerObject = new ArrayList<>(); for (ParseObject beers : ob) { // Locate images in flag column // ParseFile image = (ParseFile) stansbeers.get("image"); BeerListObject beer = new BeerListObject(); beer.setBeerName((String) beers.get("name")); beer.setBeerWhereFrom((String) beers.get("wherefrom")); beer.setBeerAbv(beers.getDouble("abvinteger")); beer.setBeerGroup((String) beers.get("group")); beer.setBeerAbout((String) beers.get("about")); beer.setBeerPrice((String) beers.get("price")); beer.setBeerSize((String) beers.get("size")); beerObject.add(beer); } } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } adapter = new BeersListViewAdapter(getActivity(), beerObject); setListAdapter(adapter); adapter.notifyDataSetChanged(); }
protected List<ReplyItem> doInBackground(String... args) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Reply"); query.whereEqualTo("belongTo", post); try { replyList = query.find(); } catch (ParseException e) { e.printStackTrace(); } ArrayList<ReplyItem> shortList = new ArrayList<>(); if (replyList != null) { ReplyItem replyItem; for (ParseObject obj : replyList) { Reply r = (Reply) obj; replyItem = new ReplyItem(); replyItem.setReplyContent(r.getReplyContent()); replyItem.setTime(Util.dateFormTransfer(r.getCreatedAt(), getActivity())); try { r.getAuthor().fetchIfNeeded(); } catch (ParseException e) { e.printStackTrace(); } replyItem.setAuthor(r.getAuthor().getUsername()); replyItem.setUserID(r.getAuthor().getObjectId()); replyItem.setPostResponseID(r.getObjectId()); if (r.getReplyTo() != null && r.getReplyTo().isDataAvailable()) { replyItem.setPostLastResponseID(r.getReplyTo().getObjectId()); try { r.getReplyTo().getAuthor().fetchIfNeeded(); } catch (ParseException e) { e.printStackTrace(); } replyItem.setSponsor(r.getReplyTo().getAuthor().getUsername()); replyItem.setReplyFrom(r.getReplyTo().getReplyContent()); } // replyItem shortList.add(replyItem); } } // for (ReplyItem item : shortList) { // if (item.getPostLastResponseID() != 0) { // for (ReplyItem it : shortList) { // if (item.getPostLastResponseID() == it // .getPostResponseID()) { // item.setReplyFrom(it.getReplyContent()); // item.setSponsor(it.getAuthor()); // } // } // } // } return shortList; // resultArray = HttpHelper.getPostResponse(StaticResource.item // .getPostId()); // JSONObject jo; // ReplyItem content; // try { // ArrayList<ReplyItem> shortList = new ArrayList<>(); // for (int i = 0; i < resultArray.length(); i++) { // content = new ReplyItem(); // jo = resultArray.getJSONObject(i); // content.setReplyContent(jo.get("content").toString());// // content.setTime(Util.dateFormTransfer( // jo.get("postResponseDate").toString(), getActivity())); // content.setAuthor(jo.getJSONObject("userID").getString( // "userName")); // if (jo.getJSONObject("userID").has("userID")) { // content.setUserID(jo.getJSONObject("userID").getString( // "userID")); // } // if (jo.has("postLastResponseID")) { // content.setPostLastResponseID(jo // .getInt("postLastResponseID")); // } // content.setPostResponseID(jo.getInt("postResponseID")); // if (jo.has("marked")) { // if (jo.getInt("marked") == 0) { // content.setMarked(false); // } else { // content.setMarked(true); // } // // } // shortList.add(content); // } // return shortList; // } catch (Exception e) { // e.printStackTrace(); // return null; // } }