Commit e0a8c8bc authored by Robert Hitt's avatar Robert Hitt

Updated API version

- Also changed some model files to Kotlin
parent b18d3456
......@@ -8,10 +8,12 @@ buildscript {
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
apply plugin: 'realm-android'
......@@ -72,4 +74,5 @@ dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true;
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
package srct.whatsopen.model;
import com.google.gson.annotations.SerializedName;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
public class Facility extends RealmObject {
public Facility(String name, String location, MainSchedule mainSchedule,
RealmList<SpecialSchedule> specialSchedules, boolean isOpen,
boolean isFavorited, String statusDuration) {
mName = name;
mLocation = location;
mMainSchedule = mainSchedule;
mSpecialSchedules = specialSchedules;
this.isOpen = isOpen;
this.isFavorited = isFavorited;
this.statusDuration = statusDuration;
}
public Facility() {
}
@PrimaryKey
@SerializedName("name")
private String mName;
@SerializedName("location")
private String mLocation;
@SerializedName("main_schedule")
private MainSchedule mMainSchedule;
@SerializedName("special_schedules")
private RealmList<SpecialSchedule> mSpecialSchedules;
private boolean isOpen;
private boolean isFavorited;
private String statusDuration;
public String getStatusDuration() {
return statusDuration;
}
public void setStatusDuration(String statusDuration) {
this.statusDuration = statusDuration;
}
public RealmList<SpecialSchedule> getSpecialSchedules() {
return mSpecialSchedules;
}
public void setSpecialSchedules(RealmList<SpecialSchedule> specialSchedules) {
mSpecialSchedules = specialSchedules;
}
public boolean isOpen() {
return isOpen;
}
public void setOpen(boolean open) {
isOpen = open;
}
public String getName() {
return mName;
}
public void setName(String name) {
this.mName = name;
}
public boolean isFavorited() {
return isFavorited;
}
public void setFavorited(boolean favorited) {
isFavorited = favorited;
}
public String getLocation() {
return mLocation;
}
public void setLocation(String location) {
mLocation = location;
}
public MainSchedule getMainSchedule() {
return mMainSchedule;
}
public void setMainSchedule(MainSchedule mainSchedule) {
mMainSchedule = mainSchedule;
}
}
package srct.whatsopen.model
import com.google.gson.annotations.SerializedName
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Facility : RealmObject {
@PrimaryKey
@SerializedName("facility_name")
var name: String? = null
@SerializedName("facility_location")
var location: Location? = null
@SerializedName("main_schedule")
var mainSchedule: MainSchedule? = null
@SerializedName("special_schedules")
var specialSchedules: RealmList<SpecialSchedule>? = null
var isOpen: Boolean = false
var isFavorited: Boolean = false
var statusDuration: String? = null
constructor(name: String, location: Location, mainSchedule: MainSchedule,
specialSchedules: RealmList<SpecialSchedule>, isOpen: Boolean,
isFavorited: Boolean, statusDuration: String) {
this.name = name
this.location = location
this.mainSchedule = mainSchedule
this.specialSchedules = specialSchedules
this.isOpen = isOpen
this.isFavorited = isFavorited
this.statusDuration = statusDuration
}
constructor() {}
}
package srct.whatsopen.model
import com.google.gson.annotations.SerializedName
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Location(
@PrimaryKey @SerializedName("building") var building: String = ""
) : RealmObject()
package srct.whatsopen.model;
import com.google.gson.annotations.SerializedName;
import io.realm.RealmList;
import io.realm.RealmObject;
public class MainSchedule extends RealmObject implements Schedule{
public MainSchedule(RealmList<OpenTimes> openTimesList, String validStart, String validEnd) {
mOpenTimesList = openTimesList;
this.validStart = validStart;
this.validEnd = validEnd;
}
public MainSchedule() {
}
@SerializedName("open_times")
private RealmList<OpenTimes> mOpenTimesList;
@SerializedName("valid_start")
private String validStart;
@SerializedName("valid_end")
private String validEnd;
public String getValidStart() {
return validStart;
}
public void setValidStart(String validStart) {
this.validStart = validStart;
}
public String getValidEnd() {
return validEnd;
}
public void setValidEnd(String validEnd) {
this.validEnd = validEnd;
}
public RealmList<OpenTimes> getOpenTimesList() {
return mOpenTimesList;
}
public void setOpenTimesList(RealmList<OpenTimes> openTimesList) {
mOpenTimesList = openTimesList;
}
}
package srct.whatsopen.model
import com.google.gson.annotations.SerializedName
import io.realm.RealmList
import io.realm.RealmObject
open class MainSchedule : RealmObject, Schedule {
@SerializedName("open_times")
private var mOpenTimesList: RealmList<OpenTimes>? = null
@SerializedName("valid_start")
var validStart: String? = null
@SerializedName("valid_end")
private var validEnd: String? = null
@SerializedName("twenty_four_hours")
var openTwentyFourHours: Boolean? = null
constructor(openTimesList: RealmList<OpenTimes>, validStart: String, validEnd: String) {
mOpenTimesList = openTimesList
this.validStart = validStart
this.validEnd = validEnd
}
constructor() {}
override fun getValidEnd(): String? {
return validEnd
}
fun setValidEnd(validEnd: String) {
this.validEnd = validEnd
}
override fun getOpenTimesList(): RealmList<OpenTimes>? {
return mOpenTimesList
}
fun setOpenTimesList(openTimesList: RealmList<OpenTimes>) {
mOpenTimesList = openTimesList
}
}
package srct.whatsopen.model;
import com.google.gson.annotations.SerializedName;
import io.realm.RealmObject;
public class OpenTimes extends RealmObject {
public OpenTimes(int startDay, int endDay, String startTime, String endTime) {
this.startDay = startDay;
this.endDay = endDay;
this.startTime = startTime;
this.endTime = endTime;
}
public OpenTimes() {
}
@Override
public String toString() {
return "OpenTimes{" +
"startDay=" + startDay +
", endDay=" + endDay +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
'}';
}
@SerializedName("start_day")
private int startDay;
@SerializedName("end_day")
private int endDay;
@SerializedName("start_time")
private String startTime;
@SerializedName("end_time")
private String endTime;
public int getEndDay() {
return endDay;
}
public void setEndDay(int endDay) {
this.endDay = endDay;
}
public int getStartDay() {
return startDay;
}
public void setStartDay(int startDay) {
this.startDay = startDay;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}
package srct.whatsopen.model
import com.google.gson.annotations.SerializedName
import io.realm.RealmObject
open class OpenTimes : RealmObject {
@SerializedName("start_day")
var startDay: Int = 0
@SerializedName("end_day")
var endDay: Int = 0
@SerializedName("start_time")
var startTime: String? = null
@SerializedName("end_time")
var endTime: String? = null
constructor(startDay: Int, endDay: Int, startTime: String, endTime: String) {
this.startDay = startDay
this.endDay = endDay
this.startTime = startTime
this.endTime = endTime
}
constructor() {}
override fun toString(): String {
return "OpenTimes{" +
"startDay=" + startDay +
", endDay=" + endDay +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
'}'
}
}
package srct.whatsopen.model;
import com.google.gson.annotations.SerializedName;
import io.realm.RealmList;
import io.realm.RealmObject;
public class SpecialSchedule extends RealmObject implements Schedule {
public SpecialSchedule(RealmList<OpenTimes> openTimesList, String validStart, String validEnd) {
mOpenTimesList = openTimesList;
this.validStart = validStart;
this.validEnd = validEnd;
}
public SpecialSchedule() {
}
@SerializedName("open_times")
private RealmList<OpenTimes> mOpenTimesList;
@SerializedName("valid_start")
private String validStart;
@SerializedName("valid_end")
private String validEnd;
public String getValidStart() {
return validStart;
}
public void setValidStart(String validStart) {
this.validStart = validStart;
}
public String getValidEnd() {
return validEnd;
}
public void setValidEnd(String validEnd) {
this.validEnd = validEnd;
}
public RealmList<OpenTimes> getOpenTimesList() {
return mOpenTimesList;
}
public void setOpenTimesList(RealmList<OpenTimes> openTimesList) {
mOpenTimesList = openTimesList;
}
}
package srct.whatsopen.model
import com.google.gson.annotations.SerializedName
import io.realm.RealmList
import io.realm.RealmObject
open class SpecialSchedule : RealmObject, Schedule {
@SerializedName("open_times")
private var mOpenTimesList: RealmList<OpenTimes>? = null
@SerializedName("valid_start")
var validStart: String? = null
@SerializedName("valid_end")
private var validEnd: String? = null
constructor(openTimesList: RealmList<OpenTimes>, validStart: String, validEnd: String) {
mOpenTimesList = openTimesList
this.validStart = validStart
this.validEnd = validEnd
}
constructor() {}
override fun getValidEnd(): String? {
return validEnd
}
fun setValidEnd(validEnd: String) {
this.validEnd = validEnd
}
override fun getOpenTimesList(): RealmList<OpenTimes>? {
return mOpenTimesList
}
fun setOpenTimesList(openTimesList: RealmList<OpenTimes>) {
mOpenTimesList = openTimesList
}
}
......@@ -59,7 +59,7 @@ public class FacilityPresenter {
realm.executeTransactionAsync(bgRealm -> {
// have to re-query for the object as it was created on a separate thread
Facility f = bgRealm.where(Facility.class)
.equalTo("mName", facilityName).findFirst();
.equalTo("name", facilityName).findFirst();
f.setFavorited(status);
editor.putBoolean(facilityName+"FavoriteStatus", status);
......
......@@ -123,7 +123,7 @@ public class MainPresenter {
private void removeFacilityFromRealm(Facility facility) {
final String name = facility.getName();
mRealm.executeTransactionAsync((bgRealm) -> {
RealmResults<Facility> results = bgRealm.where(Facility.class).equalTo("mName", name)
RealmResults<Facility> results = bgRealm.where(Facility.class).equalTo("name", name)
.findAll();
results.deleteAllFromRealm();
......
......@@ -19,7 +19,7 @@ public class WhatsOpenService {
private static volatile Retrofit sRetrofit = null;
private static WhatsOpenApi mService;
private static final String BASE_URL = "https://whatsopen.gmu.edu/api/";
private static final String BASE_URL = "https://api.srct.gmu.edu/whatsopen/v2/";
public WhatsOpenService() {
}
......
......@@ -164,7 +164,7 @@ public class DetailActivity extends AppCompatActivity implements FacilityView,
// Queries Realm for the facility matching the key
private void getFacility(String key) {
mFacility = mRealm.where(Facility.class).equalTo("mName", key).findFirst();
mFacility = mRealm.where(Facility.class).equalTo("name", key).findFirst();
}
// Configures the toolbar title, actions, etc
......@@ -203,7 +203,7 @@ public class DetailActivity extends AppCompatActivity implements FacilityView,
openDurationTextView.setText(mFacility.getStatusDuration());
locationTextView.setText(mFacility.getLocation());
locationTextView.setText(mFacility.getLocation().getBuilding());
Calendar now = Calendar.getInstance();
Schedule currentSchedule = mPresenter.getActiveSchedule(mFacility, now);
......
......@@ -161,7 +161,7 @@ public class FacilityListAdapter extends
if(constraint != null && getData() != null) {
RealmResults<Facility> results = getData().where()
.contains("mName", constraint.toString(), Case.INSENSITIVE)
.contains("name", constraint.toString(), Case.INSENSITIVE)
.findAll();
updateData(results);
}
......
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
jcenter()
......@@ -12,6 +13,7 @@ buildscript {
classpath 'io.realm:realm-gradle-plugin:3.0.0'
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment