Android Open Source - Svnit-Events Schedule J S O N Parser






From Project

Back to project page Svnit-Events.

License

The source code is released under:

MIT License

If you think the Android project Svnit-Events listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bhatt.ramani.svnitevents;
/*from w w w  .  ja  v a2 s.  c  o m*/
import com.bhatt.ramani.svnitevents.models.People;
import com.bhatt.ramani.svnitevents.models.Session;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ScheduleJSONParser {
    public static List<Session> getSchedule(String data) {
        List<Session> sessions = new ArrayList<Session>();

        try {
            JSONObject jsonObject = new JSONObject(data);
            JSONArray dayArray = jsonObject.getJSONArray("sessions");

            for (int i = 0; i < dayArray.length(); i++) {
                JSONArray sessionsArray = dayArray.getJSONObject(i).getJSONArray("sessions");
                for (int j = 0; j < sessionsArray.length(); j++) {
                    Session session = new Session();
                    JSONObject sessionJSON = sessionsArray.getJSONObject(j);
                    session.setTitle(sessionJSON.getString("title"));
                    String space = sessionJSON.getString("space");
                    space += ", NIT-Surat";

                    session.setSpace(space);
                    session.setEventSummary(sessionJSON.getString("abstract"));
                    session.setRegUrl(sessionJSON.getString("web_url"));
                    String startTimeEpoch = sessionJSON.getString("start_time_epoch");
                    long startLongEpoch = Long.parseLong(startTimeEpoch);
                    Date start = new Date(startLongEpoch * 1000);
                    session.setStartTime(start);

                    String endTimeEpoch = sessionJSON.getString("end_time_epoch");
                    long endLongEpoch = Long.parseLong(endTimeEpoch);
                    Date end = new Date(endLongEpoch * 1000);
                    session.setEndTime(end);

                    JSONArray peopleJSONArray = sessionJSON.getJSONArray("peoples");
                    List<People> peoples = PeopleJSONParser.getPeoples("{ \"peoples\":" + peopleJSONArray.toString() + "}");
                    session.setPeoples(peoples);
                    sessions.add(session);
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return sessions;
    }
}




Java Source Code List

com.android.vending.billing.IInAppBillingService.java
com.android.vending.billing.IInAppBillingService.java
com.bhatt.ramani.svnitevents.AboutUs.java
com.bhatt.ramani.svnitevents.EventHttpClient.java
com.bhatt.ramani.svnitevents.EventLruCache.java
com.bhatt.ramani.svnitevents.Form.java
com.bhatt.ramani.svnitevents.MainActivity.java
com.bhatt.ramani.svnitevents.PeopleDetailActivity.java
com.bhatt.ramani.svnitevents.PeopleJSONParser.java
com.bhatt.ramani.svnitevents.PeopleListAdapter.java
com.bhatt.ramani.svnitevents.PeopleListFragment.java
com.bhatt.ramani.svnitevents.PeopleListLoader.java
com.bhatt.ramani.svnitevents.ScheduleJSONParser.java
com.bhatt.ramani.svnitevents.ScheduleListAdapter.java
com.bhatt.ramani.svnitevents.ScheduleListFragment.java
com.bhatt.ramani.svnitevents.ScheduleListLoader.java
com.bhatt.ramani.svnitevents.SessionDetailActivity.java
com.bhatt.ramani.svnitevents.SimpleSectionedListAdapter.java
com.bhatt.ramani.svnitevents.TwitterStreamAdapter.java
com.bhatt.ramani.svnitevents.TwitterStreamFragment.java
com.bhatt.ramani.svnitevents.TwitterStreamLoader.java
com.bhatt.ramani.svnitevents.Utils.java
com.bhatt.ramani.svnitevents.models.People.java
com.bhatt.ramani.svnitevents.models.Session.java
com.jakewharton.disklrucache.DiskLruCache.java
com.jakewharton.disklrucache.StrictLineReader.java
com.jakewharton.disklrucache.Util.java
com.scringo.scringolib.BuildConfig.java
com.scringo.scringolib.BuildConfig.java