package edu.rutgers.css.Rutgers.model;

import android.support.annotation.NonNull;

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

import edu.rutgers.css.Rutgers.channels.dtable.model.VarTitle;
import edu.rutgers.css.Rutgers.ui.fragments.WebDisplay;

/**
 * RU Mobile channel.
 */
public class Channel {

    private VarTitle title;
    private String handle;
    private String view;
    private String api;
    private String url;
    private JSONArray data;
    private boolean canOverride;

    /** Construct channel from JSON. */
    public Channel(JSONObject channelJson) throws JSONException {
        this.title = new VarTitle(channelJson.get("title"));
        this.handle = channelJson.getString("handle");

        if (channelJson.isNull("view") && !channelJson.isNull("url")) {
            this.view = WebDisplay.HANDLE;
        } else {
            this.view = channelJson.getString("view");
        }

        this.api = channelJson.optString("api");
        this.url = channelJson.optString("url");
        this.data = channelJson.optJSONArray("data");

        this.canOverride = channelJson.optBoolean("canOverride");
    }

    public String getTitle() {
        return title.getTitle();
    }

    public String getTitle(@NonNull String homeCampus) {
        return title.getTitle(homeCampus);
    }

    public String getHandle() {
        return handle;
    }

    public String getView() {
        return view;
    }

    public String getApi() {
        return api;
    }

    public String getUrl() {
        return url;
    }

    /**
     * This channel can supersede others with the same handle.
     */
    public boolean canOverride() {
        return canOverride;
    }

    public JSONArray getData() {
        return data;
    }

}

@@ -952,24 +952,56 @@
   %7D%0A%0A       
+ if (!channelJson.isNull(%22api%22))
  this.api = 
@@ -1004,34 +1004,34 @@
 i = channelJson.
-op
+ge
 tString(%22api%22);%0A
@@ -1033,24 +1033,56 @@
 i%22);%0A       
+ if (!channelJson.isNull(%22url%22))
  this.url = 
@@ -1093,18 +1093,18 @@
 nelJson.
-op
+ge
 tString(
@@ -1114,24 +1114,57 @@
 l%22);%0A       
+ if (!channelJson.isNull(%22data%22))
  this.data =
@@ -1176,18 +1176,18 @@
 nelJson.
-op
+ge
 tJSONArr

Revert some of 785819a6e