Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.14 KB | None | 0 0
  1. package com.regularticket.socke.regularticket;
  2.  
  3. import com.facebook.GraphResponse;
  4. import com.google.gson.Gson;
  5.  
  6. import org.json.JSONArray;
  7. import org.json.JSONException;
  8. import org.json.JSONObject;
  9.  
  10. import java.io.IOException;
  11. import java.text.ParseException;
  12. import java.util.ArrayList;
  13. import java.util.Date;
  14. import java.util.List;
  15.  
  16. /**
  17.  * Created by Adde on 2017-11-19.
  18.  */
  19.  
  20. public class Place {
  21.     private String name, city, country, street;
  22.     private float longitude, latitude;
  23.     int zip;
  24.  
  25.     public Place(String name, String city, String street, String country, float latitude, float longitude, int zip){
  26.         this.name        = name;
  27.         this.city        = city;
  28.         this.country     = country;
  29.         this.longitude   = longitude;
  30.         this.latitude    = latitude;
  31.         this.street      = street;
  32.         this.zip         = zip;
  33.  
  34.     }
  35.     public Place(){}
  36.     public String getName() {
  37.         return name;
  38.     }
  39.     public String getCity() {
  40.         return city;
  41.     }
  42.     public String getCountry() {
  43.         return country;
  44.     }
  45.     public String getStreet() {
  46.         return street;
  47.     }
  48.     public float getLong() {
  49.         return longitude;
  50.     }
  51.     public float getLat() {
  52.         return latitude;
  53.     }
  54.     public int getZip() {
  55.         return zip;
  56.     }
  57.  
  58.  
  59.  
  60.     public Place fetchPlace(GraphResponse place_response) throws IOException, JSONException, ParseException {
  61.         System.out.println("FetchPlace");
  62.  
  63.  
  64.         JSONObject root = place_response.getJSONObject();
  65.  
  66.         System.out.println(root);
  67.  
  68.         Gson g = new Gson();
  69.         Place place= g.fromJson(String.valueOf(root), Place.class);
  70.  
  71.         System.out.println("PLACE NAME");
  72.  
  73.         System.out.println(place.getName());
  74.  
  75.        // Place place = new Place();
  76.         return place;
  77.  
  78.  
  79.     }
  80.  
  81.  
  82. }
  83.  
  84. /*
  85.  
  86.         JSONObject root = place_response.getJSONObject();
  87.  
  88.         JSONObject data = root.getJSONObject("place");
  89.  
  90.         String name_from = jsonData.getString("name");
  91.  
  92.         JSONObject jsonData = data.getJSONObject(0);
  93.  
  94.  
  95.  
  96.  
  97.         for (int i = 0; i < data.length(); i++) {
  98.             JSONObject jsonData = data.getJSONObject(i);
  99.             String name_from = jsonData.getString("name");
  100.  
  101.             JSONObject fromObject = new JSONObject(name_from);
  102.  
  103.             String from_feed = fromObject.getString("name");
  104.  
  105.  
  106.             String event_id = jsonData.getString("id");
  107.  
  108.             //String event_message ="message";
  109.             String message_timeStamp = jsonData.getString("updated_time");
  110.  
  111.             if(jsonData.has("message")){
  112.  
  113.                 String event_message = jsonData.getString("message");
  114.                 String updated_stamp = YourEventFragment.dateConverter(message_timeStamp, "FB");
  115.                 Date message_date = YourEventFragment.stringToDate(updated_stamp);
  116.  
  117.  
  118.                 Feed feed = new Feed(from_feed, event_message, event_id, message_date);
  119.                 allFeedMessages.add(feed);
  120.             }
  121.  
  122.  
  123.  
  124.         }
  125.         //Log.v("all events!!!!!!!!!!!", allFeedMessages.get(0).getName());
  126.         return allFeedMessages;
  127. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement