Android Open Source - ls-vertretungsplan Schule






From Project

Back to project page ls-vertretungsplan.

License

The source code is released under:

GNU General Public License

If you think the Android project ls-vertretungsplan 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

/*  Vertretungsplan - Android-App fr Vertretungsplne von Schulen
    Copyright (C) 2014  Johan v. Forstner
//from w  ww .  j  a va  2s  .c  om
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see [http://www.gnu.org/licenses/]. */

package com.johan.vertretungsplan.objects;

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

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

public class Schule {
  private String id;
  private String name;
  private String city;
  private String api;
  private List<String> additionalInfos;
  private JSONObject data;
  private boolean usesPush;
  private int userCount;
  private double[] geo;
  private double distance;
  private boolean requiresLogin;
  private String login;
  
  public static Schule fromJSON(String id, JSONObject json) throws JSONException {
    Schule schule = new Schule();
    schule.setId(id);
    schule.setCity(json.getString("city"));
    schule.setName(json.getString("name"));
    schule.setApi(json.getString("api"));
    schule.setUsesPush(json.optBoolean("uses-push"));
    if(json.has("geo")) {
      JSONArray geoArray = json.getJSONArray("geo");
      double[] geo = new double[]{geoArray.getDouble(0), geoArray.getDouble(1)};
      schule.setGeo(geo);
    }
    
    JSONArray infosJson = json.optJSONArray("additional_info");
    List<String> additionalInfos = new ArrayList<String>();
    if(infosJson != null) {
      for (int i = 0; i < infosJson.length(); i++) {
        additionalInfos.add(infosJson.getString(i));
      }
    }
    schule.setAdditionalInfos(additionalInfos);
    
    schule.setData(json.getJSONObject("data"));
    return schule;
  }
  
  public static Schule fromServerJSON(JSONObject json) throws JSONException {
    Schule schule = new Schule();
    schule.setId(json.getString("id"));
    schule.setCity(json.getString("city"));
    schule.setName(json.getString("name"));
    schule.setUserCount(json.getInt("user_count"));
    schule.setRequiresLogin(json.getBoolean("requiresLogin"));
    schule.setLogin(json.optString("login", null));
    if(json.has("geo")) {
      JSONArray geoArray = json.getJSONArray("geo");
      double[] geo = new double[]{geoArray.getDouble(0), geoArray.getDouble(1)};
      schule.setGeo(geo);
    }
    return schule;
  }
  
  /**
   * @return the id
   */
  public String getId() {
    return id;
  }
  /**
   * @param id the id to set
   */
  public void setId(String id) {
    this.id = id;
  }
  /**
   * @return the name
   */
  public String getName() {
    return name;
  }
  /**
   * @param name the name to set
   */
  public void setName(String name) {
    this.name = name;
  }
  /**
   * @return the city
   */
  public String getCity() {
    return city;
  }
  /**
   * @param city the city to set
   */
  public void setCity(String city) {
    this.city = city;
  }
  /**
   * @return the api
   */
  public String getApi() {
    return api;
  }
  /**
   * @param api the api to set
   */
  public void setApi(String api) {
    this.api = api;
  }
  /**
   * @return the additionalInfos
   */
  public List<String> getAdditionalInfos() {
    return additionalInfos;
  }
  /**
   * @param additionalInfos the additionalInfos to set
   */
  public void setAdditionalInfos(List<String> additionalInfos) {
    this.additionalInfos = additionalInfos;
  }
  /**
   * @return the data
   */
  public JSONObject getData() {
    return data;
  }
  /**
   * @param data the data to set
   */
  public void setData(JSONObject data) {
    this.data = data;
  }
  public boolean usesPush() {
    return usesPush;
  }
  public void setUsesPush(boolean usesPush) {
    this.usesPush = usesPush;
  }
  public int getUserCount() {
    return userCount;
  }
  public void setUserCount(int userCount) {
    this.userCount = userCount;
  }

  public double[] getGeo() {
    return geo;
  }

  public void setGeo(double[] geo) {
    this.geo = geo;
  }

  public double getDistance() {
    return distance;
  }

  public void setDistance(double distance) {
    this.distance = distance;
  }

  /**
   * @return the requiresLogin
   */
  public boolean requiresLogin() {
    return requiresLogin;
  }

  /**
   * @param requiresLogin the requiresLogin to set
   */
  public void setRequiresLogin(boolean requiresLogin) {
    this.requiresLogin = requiresLogin;
  }

  /**
   * @return the login
   */
  public String getLogin() {
    return login;
  }

  /**
   * @param login the login to set
   */
  public void setLogin(String login) {
    this.login = login;
  }
}




Java Source Code List

com.joejernst.http.Message.java
com.joejernst.http.Request.java
com.joejernst.http.Response.java
com.johan.vertretungsplan.GCMIntentService.java
com.johan.vertretungsplan.LoginDialogFragment.java
com.johan.vertretungsplan.NachrichtenFragment.java
com.johan.vertretungsplan.SettingsActivity.java
com.johan.vertretungsplan.SettingsFragment.java
com.johan.vertretungsplan.StartActivity.java
com.johan.vertretungsplan.VertretungFragment.java
com.johan.vertretungsplan.VertretungsplanApplication.java
com.johan.vertretungsplan.VertretungsplanFragment.java
com.johan.vertretungsplan.additionalinfo.BaseAdditionalInfoParser.java
com.johan.vertretungsplan.additionalinfo.WinterShParser.java
com.johan.vertretungsplan.background.VertretungsplanService.java
com.johan.vertretungsplan.comparators.AlphabeticalSchoolComparator.java
com.johan.vertretungsplan.comparators.DistanceSchoolComparator.java
com.johan.vertretungsplan.objects.AdditionalInfo.java
com.johan.vertretungsplan.objects.KlassenVertretungsplan.java
com.johan.vertretungsplan.objects.Schule.java
com.johan.vertretungsplan.objects.Vertretung.java
com.johan.vertretungsplan.objects.VertretungsplanTag.java
com.johan.vertretungsplan.objects.Vertretungsplan.java
com.johan.vertretungsplan.parser.BackendConnectParser.java
com.johan.vertretungsplan.parser.BaseParser.java
com.johan.vertretungsplan.ui.LinkAlertDialog.java
com.johan.vertretungsplan.ui.TabSwipeActivity.java
com.johan.vertretungsplan.ui.WebViewAlertDialog.java
com.johan.vertretungsplan.utils.Animations.java
com.johan.vertretungsplan.utils.Utils.java
com.johan.vertretungsplan.widget.VertretungsplanWidgetProvider.java
com.johan.vertretungsplan.widget.VertretungsplanWidgetService.java