From 32fb6da1e58c7e94872e52bbd7e38cc23d18bce3 Mon Sep 17 00:00:00 2001 From: pfent Date: Wed, 8 Nov 2017 15:00:33 +0100 Subject: [PATCH 1/3] don't close the cursor we just set to the adapter --- .../fragments/StudyRoomGroupDetailsFragment.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/fragments/StudyRoomGroupDetailsFragment.java b/app/src/main/java/de/tum/in/tumcampusapp/fragments/StudyRoomGroupDetailsFragment.java index 35e242251a..c8fe322744 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/fragments/StudyRoomGroupDetailsFragment.java +++ b/app/src/main/java/de/tum/in/tumcampusapp/fragments/StudyRoomGroupDetailsFragment.java @@ -46,13 +46,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false); - RecyclerView recyclerView; - LinearLayoutManager layoutManager; - try (Cursor studyRoomCursor = new StudyRoomGroupManager(getActivity()).getStudyRoomsFromDb(mStudyRoomGroupId)) { - recyclerView = rootView.findViewById(R.id.fragment_item_detail_recyclerview); - recyclerView.setAdapter(new StudyRoomAdapter(studyRoomCursor)); - } - layoutManager = new LinearLayoutManager(getContext()); + Cursor studyRoomCursor = new StudyRoomGroupManager(getActivity()).getStudyRoomsFromDb(mStudyRoomGroupId); + RecyclerView recyclerView = rootView.findViewById(R.id.fragment_item_detail_recyclerview); + recyclerView.setAdapter(new StudyRoomAdapter(studyRoomCursor)); + + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); recyclerView.setHasFixedSize(true); From c79be77f3795cb58567a48eb9499b8c286402ec0 Mon Sep 17 00:00:00 2001 From: pfent Date: Wed, 8 Nov 2017 15:15:36 +0100 Subject: [PATCH 2/3] make all model members variables with default values --- .../tumcampusapp/models/cafeteria/Cafeteria.kt | 6 +++++- .../models/cafeteria/CafeteriaMenu.kt | 8 +++++++- .../tumcampusapp/models/cafeteria/Location.kt | 10 +++++++++- .../tum/in/tumcampusapp/models/efa/Departure.kt | 6 +++++- .../in/tumcampusapp/models/efa/StationResult.kt | 4 +++- .../tumcampusapp/models/efa/WidgetDepartures.kt | 6 +++++- .../tum/in/tumcampusapp/models/gcm/GCMAlert.kt | 2 +- .../tum/in/tumcampusapp/models/gcm/GCMChat.kt | 4 +++- .../tumcampusapp/models/gcm/GCMNotification.kt | 9 +++++++-- .../models/gcm/GCMNotificationLocation.kt | 6 +++++- .../tum/in/tumcampusapp/models/gcm/GCMUpdate.kt | 5 ++++- .../models/tumcabe/BarrierfreeContact.kt | 8 ++++++-- .../models/tumcabe/BarrierfreeMoreInfo.kt | 4 +++- .../in/tumcampusapp/models/tumcabe/BugReport.kt | 17 ++++++++++++++--- .../models/tumcabe/BuildingsToGps.kt | 4 +++- .../models/tumcabe/ChatPublicKey.kt | 2 +- .../in/tumcampusapp/models/tumcabe/ChatRoom.kt | 2 +- .../models/tumcabe/ChatVerification.kt | 6 +++++- .../tumcampusapp/models/tumcabe/Curriculum.kt | 11 +++++++---- .../models/tumcabe/DeviceRegister.kt | 7 ++++++- .../models/tumcabe/DeviceUploadGcmToken.kt | 4 +++- .../models/tumcabe/DeviceVerification.kt | 5 ++++- .../in/tumcampusapp/models/tumcabe/Faculty.kt | 3 ++- .../tum/in/tumcampusapp/models/tumcabe/Kino.kt | 16 ++++++++++++++-- .../tum/in/tumcampusapp/models/tumcabe/News.kt | 8 +++++++- .../models/tumcabe/RoomFinderCoordinate.kt | 4 +++- .../models/tumcabe/RoomFinderMap.kt | 3 ++- .../models/tumcabe/RoomFinderRoom.kt | 10 +++++++--- .../models/tumcabe/RoomFinderSchedule.kt | 5 ++++- .../tumcampusapp/models/tumcabe/Statistics.kt | 2 +- .../in/tumcampusapp/models/tumcabe/StudyRoom.kt | 6 +++++- .../models/tumcabe/StudyRoomGroup.kt | 5 ++++- .../models/tumcabe/TUMCabeStatus.kt | 2 +- .../models/tumcabe/WifiMeasurement.kt | 9 +++++++-- 34 files changed, 164 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Cafeteria.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Cafeteria.kt index 4fd328bc4f..8c36e53657 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Cafeteria.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Cafeteria.kt @@ -9,7 +9,11 @@ package de.tum.`in`.tumcampusapp.models.cafeteria * @param latitude Coordinates of the cafeteria * @param longitude Coordinates of the cafeteria */ -data class Cafeteria(val id: Int, val name: String, val address: String, val latitude: Double, val longitude: Double) : Comparable { +data class Cafeteria(var id: Int = -1, + var name: String = "", + var address: String = "", + var latitude: Double = -1.0, + var longitude: Double = -1.0) : Comparable { // Used for ordering cafeterias var distance: Float = 0.toFloat() diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/CafeteriaMenu.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/CafeteriaMenu.kt index f1495afa6c..73d14631b5 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/CafeteriaMenu.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/CafeteriaMenu.kt @@ -13,4 +13,10 @@ import java.util.* * @param typeNr Type ID * @param name Menu name */ -data class CafeteriaMenu(val id: Int, val cafeteriaId: Int, val date: Date?, val typeShort: String?, val typeLong: String?, val typeNr: Int, val name: String?) \ No newline at end of file +data class CafeteriaMenu(var id: Int = -1, + var cafeteriaId: Int = -1, + var date: Date? = null, + var typeShort: String = "", + var typeLong: String = "", + var typeNr: Int = -1, + var name: String = "") \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Location.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Location.kt index 74c160ca57..4dda8bc1f2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Location.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/cafeteria/Location.kt @@ -13,4 +13,12 @@ package de.tum.`in`.tumcampusapp.models.cafeteria * @param remark Additional information, e.g. Tel: 089-11111 * @param url Location URL, e.g. http://stud.ub.uni-muenchen.de/ */ -data class Location(val id: Int, val category: String, val name: String, val address: String, val room: String, val transport: String, val hours: String, val remark: String, val url: String) \ No newline at end of file +data class Location(var id: Int = -1, + var category: String = "", + var name: String = "", + var address: String = "", + var room: String = "", + var transport: String = "", + var hours: String = "", + var remark: String = "", + var url: String = "") \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/efa/Departure.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/efa/Departure.kt index af8f7a5915..dd7d2324a5 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/efa/Departure.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/efa/Departure.kt @@ -2,7 +2,11 @@ package de.tum.`in`.tumcampusapp.models.efa import java.util.concurrent.TimeUnit -data class Departure(val servingLine: String, val direction: String, val symbol: String, val countDown: Int, val departureTime: Long) { +data class Departure(var servingLine: String = "", + var direction: String = "", + var symbol: String = "", + var countDown: Int = -1, + var departureTime: Long = -1) { /** * Calculates the countDown with the real departure time and the current time diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/efa/StationResult.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/efa/StationResult.kt index 49a5f4e4a6..38a0338f2b 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/efa/StationResult.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/efa/StationResult.kt @@ -1,6 +1,8 @@ package de.tum.`in`.tumcampusapp.models.efa -data class StationResult(var station: String = "", var id: String = "", var quality: Int = 0) { +data class StationResult(var station: String = "", + var id: String = "", + var quality: Int = 0) { override fun toString(): String = station } \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/efa/WidgetDepartures.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/efa/WidgetDepartures.kt index 02fe273178..733398d9a6 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/efa/WidgetDepartures.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/efa/WidgetDepartures.kt @@ -13,7 +13,11 @@ import java.util.* * @param useLocation Whether this widgets station is determined by the current location * @param autoReload If widget should update automatically, otherwise a button-press is required */ -class WidgetDepartures(station: String = "", stationId: String = "", var useLocation: Boolean = false, var autoReload: Boolean = false, var departures: MutableList = ArrayList()) { +class WidgetDepartures(station: String = "", + stationId: String = "", + var useLocation: Boolean = false, + var autoReload: Boolean = false, + var departures: MutableList = ArrayList()) { private var lastLoad: Long = 0 /** diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMAlert.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMAlert.kt index 11877a7fae..1e076ec888 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMAlert.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMAlert.kt @@ -5,7 +5,7 @@ import java.io.Serializable /** * Used for parsing the GCM json payload for the 'alert' type */ -data class GCMAlert(var silent: Boolean) : Serializable { +data class GCMAlert(var silent: Boolean = true) : Serializable { companion object { private const val serialVersionUID = 3906290674499996501L } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMChat.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMChat.kt index 36fc49245e..0cfc22c232 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMChat.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMChat.kt @@ -5,7 +5,9 @@ import java.io.Serializable /** * Used for parsing the GCM json payload for the 'chat' type */ -data class GCMChat(var room: Int = 0, var member: Int = 0, var message: Int = 0) : Serializable { +data class GCMChat(var room: Int = 0, + var member: Int = 0, + var message: Int = 0) : Serializable { companion object { private const val serialVersionUID = -3920974316634829667L } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotification.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotification.kt index f3633e0622..623f5157e1 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotification.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotification.kt @@ -2,8 +2,13 @@ package de.tum.`in`.tumcampusapp.models.gcm import java.io.Serializable -data class GCMNotification(var notification: Int = 0, var type: Int = 0, var location: GCMNotificationLocation = GCMNotificationLocation(), var title: String = "", - var description: String = "", var signature: String = "", var created: String = "") : Serializable { +data class GCMNotification(var notification: Int = 0, + var type: Int = 0, + var location: GCMNotificationLocation = GCMNotificationLocation(), + var title: String = "", + var description: String = "", + var signature: String = "", + var created: String = "") : Serializable { companion object { private const val serialVersionUID = 8643117662605459731L } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotificationLocation.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotificationLocation.kt index eaf002db8d..d91c23e578 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotificationLocation.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMNotificationLocation.kt @@ -2,7 +2,11 @@ package de.tum.`in`.tumcampusapp.models.gcm import java.io.Serializable -data class GCMNotificationLocation(var location: Int = 0, var name: String = "", var lon: Double = .0, var lat: Double = .0, var radius: Int = 0) : +data class GCMNotificationLocation(var location: Int = 0, + var name: String = "", + var lon: Double = .0, + var lat: Double = .0, + var radius: Int = 0) : Serializable { fun getRadius(): Double = radius.toDouble() diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMUpdate.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMUpdate.kt index ec19ae4faa..3cbabe72a3 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMUpdate.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/gcm/GCMUpdate.kt @@ -5,7 +5,10 @@ import java.io.Serializable /** * Used for parsing the GCM json payload for the 'update' type */ -data class GCMUpdate(var packageVersion: Int = 0, var sdkVersion: Int = 0, var releaseDate: String = "", var lowestVersion: Int = 0) : Serializable { +data class GCMUpdate(var packageVersion: Int = 0, + var sdkVersion: Int = 0, + var releaseDate: String = "", + var lowestVersion: Int = 0) : Serializable { companion object { private const val serialVersionUID = -4597228673980239217L } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeContact.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeContact.kt index d2b28f9aaa..99728f6858 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeContact.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeContact.kt @@ -5,11 +5,15 @@ import de.tum.`in`.tumcampusapp.adapters.SimpleStickyListHeadersAdapter /** * The model used to display contact infromation in barrier free page */ -data class BarrierfreeContact(val name: String?, val telephone: String, val email: String, val faculty: String, val tumID: String) : +data class BarrierfreeContact(var name: String = "", + var telephone: String = "", + var email: String = "", + var faculty: String = "", + var tumID: String = "") : SimpleStickyListHeadersAdapter.SimpleStickyListItem { val isValid: Boolean - get() = name != null && name != "null" + get() = name != "" val isHavingTumID: Boolean get() = !(tumID == "null" || tumID == "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeMoreInfo.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeMoreInfo.kt index 6f7227f04a..e898052b34 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeMoreInfo.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BarrierfreeMoreInfo.kt @@ -5,7 +5,9 @@ import de.tum.`in`.tumcampusapp.adapters.SimpleStickyListHeadersAdapter /** * The model used to display more infromation in barrier free page */ -data class BarrierfreeMoreInfo(val title: String, val category: String, val url: String) : SimpleStickyListHeadersAdapter.SimpleStickyListItem { +data class BarrierfreeMoreInfo(var title: String = "", + var category: String = "", + var url: String = "") : SimpleStickyListHeadersAdapter.SimpleStickyListItem { override fun getHeadName() = category diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BugReport.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BugReport.kt index 57213a68af..5cd4718d8f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BugReport.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BugReport.kt @@ -6,9 +6,20 @@ import de.tum.`in`.tumcampusapp.auxiliary.NetUtils import de.tum.`in`.tumcampusapp.trace.G import de.tum.`in`.tumcampusapp.trace.Util -data class BugReport(val packageName: String, val packageVersion: String, val packageVersionCode: String, val phoneModel: String, - val androidVersion: String, val networkWifi: String, val networkMobile: String, val gps: String, val screenWidth: String, - val screenHeight: String, val screenOrientation: String, val screenDpi: String, val log: String, val stacktrace: String) { +data class BugReport(var packageName: String = "", + var packageVersion: String = "", + var packageVersionCode: String = "", + var phoneModel: String = "", + var androidVersion: String = "", + var networkWifi: String = "", + var networkMobile: String = "", + var gps: String = "", + var screenWidth: String = "", + var screenHeight: String = "", + var screenOrientation: String = "", + var screenDpi: String = "", + var log: String = "", + var stacktrace: String = "") { companion object { fun getBugReport(c: Context, stacktrace: String, log: String): BugReport { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BuildingsToGps.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BuildingsToGps.kt index 7ebf0550b1..56f52b6b2c 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BuildingsToGps.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/BuildingsToGps.kt @@ -1,3 +1,5 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class BuildingsToGps(val id: String, val latitude: String, val longitude: String) +data class BuildingsToGps(var id: String = "", + var latitude: String = "", + var longitude: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatPublicKey.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatPublicKey.kt index dfb4f8d012..0b6d34c4a7 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatPublicKey.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatPublicKey.kt @@ -1,3 +1,3 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class ChatPublicKey(var key: String?) +data class ChatPublicKey(var key: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatRoom.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatRoom.kt index b5adcdc0e7..4dfc23e6f5 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatRoom.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatRoom.kt @@ -1,6 +1,6 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class ChatRoom(var name: String?) { +data class ChatRoom(var name: String = "") { var id: Int = 0 var members = -1 diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatVerification.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatVerification.kt index 40e5c92d3e..487db20a87 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatVerification.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/ChatVerification.kt @@ -7,7 +7,11 @@ import java.math.BigInteger import java.security.SecureRandom import java.util.* -data class ChatVerification(var signature: String = "", var date: String = "", var rand: String = "", var member: Int = 0, var data: Any? = null) { +data class ChatVerification(var signature: String = "", + var date: String = "", + var rand: String = "", + var member: Int = 0, + var data: Any? = null) { companion object { @Throws(NoPrivateKey::class) fun getChatVerification(c: Context, member: ChatMember): ChatVerification { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Curriculum.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Curriculum.kt index e38b93c573..cb75562efd 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Curriculum.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Curriculum.kt @@ -5,18 +5,21 @@ import de.tum.`in`.tumcampusapp.adapters.SimpleStickyListHeadersAdapter /** * Presents the faculty model that is used in fetching the facultyData from server */ -data class Curriculum(var curriculum: String?, var category: String?, var name: String?, var url: String?) : +data class Curriculum(var curriculum: String = "", + var category: String = "", + var name: String = "", + var url: String = "") : Comparable, SimpleStickyListHeadersAdapter.SimpleStickyListItem { - override fun getHeadName(): String = category!![0].toUpperCase() + category!!.substring(1, category!!.length) + override fun getHeadName(): String = category[0].toUpperCase() + category.substring(1, category.length) override fun getHeaderId() = category override fun compareTo(other: Curriculum): Int = if (category == other.category) { - name!!.compareTo(other.name!!) + name.compareTo(other.name) } else { - category!!.compareTo(other.category!!) + category.compareTo(other.category) } } \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceRegister.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceRegister.kt index 8e3af909fe..4914dac15f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceRegister.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceRegister.kt @@ -7,7 +7,12 @@ import java.math.BigInteger import java.security.SecureRandom import java.util.* -data class DeviceRegister(val signature: String, val date: String, val rand: String, val device: String, val publicKey: String, val member: ChatMember?) { +data class DeviceRegister(var signature: String = "", + var date: String = "", + var rand: String = "", + var device: String = "", + var publicKey: String = "", + var member: ChatMember? = null) { companion object { @Throws(NoPrivateKey::class) fun getDeviceRegister(c: Context, publickey: String, member: ChatMember?): DeviceRegister { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceUploadGcmToken.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceUploadGcmToken.kt index 70cb8a0b9e..3b137c1152 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceUploadGcmToken.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceUploadGcmToken.kt @@ -4,7 +4,9 @@ import android.content.Context import de.tum.`in`.tumcampusapp.auxiliary.AuthenticationManager import de.tum.`in`.tumcampusapp.exceptions.NoPrivateKey -data class DeviceUploadGcmToken(val verification: DeviceVerification, val token: String, val signature: String) { +data class DeviceUploadGcmToken(var verification: DeviceVerification? = null, + var token: String = "", + var signature: String = "") { companion object { @Throws(NoPrivateKey::class) fun getDeviceUploadGcmToken(c: Context, token: String): DeviceUploadGcmToken { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceVerification.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceVerification.kt index 5e24c7c25c..ec899a3790 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceVerification.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/DeviceVerification.kt @@ -7,7 +7,10 @@ import java.math.BigInteger import java.security.SecureRandom import java.util.* -data class DeviceVerification(val signature: String, val date: String, val rand: String, val device: String) { +data class DeviceVerification(var signature: String = "", + var date: String = "", + var rand: String = "", + var device: String = "") { companion object { @Throws(NoPrivateKey::class) fun getDeviceVerification(c: Context): DeviceVerification { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Faculty.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Faculty.kt index fe6b83d672..07b95b4815 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Faculty.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Faculty.kt @@ -4,4 +4,5 @@ package de.tum.`in`.tumcampusapp.models.tumcabe * Presents the faculty model that is used in fetching the facultyData from server * @param faculty the id of the faculty */ -data class Faculty(var faculty: String, var name: String) \ No newline at end of file +data class Faculty(var faculty: String = "", + var name: String = "") \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Kino.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Kino.kt index 0489c89a61..773b45e81f 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Kino.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Kino.kt @@ -20,6 +20,18 @@ import java.util.* * @param created Created * @param link Link */ -data class Kino(val id: String, val title: String, val year: String, val runtime: String, val genre: String, val director: String, val actors: String, - val rating: String, val description: String, val cover: String, val trailer: String, val date: Date, val created: Date, val link: String) +data class Kino(var id: String = "", + var title: String = "", + var year: String = "", + var runtime: String = "", + var genre: String = "", + var director: String = "", + var actors: String = "", + var rating: String = "", + var description: String = "", + var cover: String = "", + var trailer: String = "", + var date: Date = Date(), + var created: Date = Date(), + var link: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/News.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/News.kt index ef291793c2..4fb9eeaf29 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/News.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/News.kt @@ -12,4 +12,10 @@ import java.util.* * @param date Date * @param created Creation date */ -data class News(val id: String, val title: String, val link: String, val src: String, val image: String, val date: Date, val created: Date) \ No newline at end of file +data class News(var id: String = "", + var title: String = "", + var link: String = "", + var src: String = "", + var image: String = "", + var date: Date = Date(), + var created: Date = Date()) \ No newline at end of file diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderCoordinate.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderCoordinate.kt index a92eff8177..9e03a1ec7a 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderCoordinate.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderCoordinate.kt @@ -1,3 +1,5 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class RoomFinderCoordinate(var utm_zone: String, var utm_easting: String, var utm_northing: String) +data class RoomFinderCoordinate(var utm_zone: String = "", + var utm_easting: String = "", + var utm_northing: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderMap.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderMap.kt index f79e2c52a1..4b887f96e2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderMap.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderMap.kt @@ -3,4 +3,5 @@ package de.tum.`in`.tumcampusapp.models.tumcabe /** * This class is used as a model for maps in Roomfinder retrofit request. */ -data class RoomFinderMap(var map_id: String = "", var description: String = "") +data class RoomFinderMap(var map_id: String = "", + var description: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderRoom.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderRoom.kt index d046d93780..c3a420a9f2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderRoom.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderRoom.kt @@ -7,11 +7,15 @@ import java.io.Serializable * This class is used as a model for rooms in Roomfinder retrofit request. * @param name This is the campus name */ -data class RoomFinderRoom(val campus: String, val address: String, val info: String, val arch_id: String, val room_id: String, - private val name: String?) : SimpleStickyListItem, Serializable { +data class RoomFinderRoom(var campus: String = "", + var address: String = "", + var info: String = "", + var arch_id: String = "", + var room_id: String = "", + private val name: String = "") : SimpleStickyListItem, Serializable { fun getName(): String = - if (name == null || name == "null") + if (name == "null") "" else name diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderSchedule.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderSchedule.kt index d8a36a3638..23b7061897 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderSchedule.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/RoomFinderSchedule.kt @@ -1,3 +1,6 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class RoomFinderSchedule(val start: String, val end: String, val event_id: Long, val title: String) +data class RoomFinderSchedule(var start: String = "", + var end: String = "", + var event_id: Long = -1, + var title: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Statistics.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Statistics.kt index c8aaa2562c..377506d42d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Statistics.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/Statistics.kt @@ -1,3 +1,3 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class Statistics(val data: String) +data class Statistics(var data: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoom.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoom.kt index 9664db213a..072f33d3d0 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoom.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoom.kt @@ -5,6 +5,10 @@ import java.util.* /** * Representation of a study room. */ -data class StudyRoom(val id: Int, var code: String = "", var name: String = "", var location: String = "", val occupiedTill: Date) { +data class StudyRoom(var id: Int = -1, + var code: String = "", + var name: String = "", + var location: String = "", + var occupiedTill: Date = Date()) { override fun toString() = code } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoomGroup.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoomGroup.kt index 339ef80a55..90f3b7aec2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoomGroup.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/StudyRoomGroup.kt @@ -3,7 +3,10 @@ package de.tum.`in`.tumcampusapp.models.tumcabe /** * Representation of a study room group */ -data class StudyRoomGroup(val id: Int, var name: String = "", var details: String = "", val rooms: List) : Comparable { +data class StudyRoomGroup(var id: Int = -1, + var name: String = "", + var details: String = "", + var rooms: List = mutableListOf()) : Comparable { override fun toString() = name diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/TUMCabeStatus.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/TUMCabeStatus.kt index 7e16b7526c..2b63b1bfda 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/TUMCabeStatus.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/TUMCabeStatus.kt @@ -1,3 +1,3 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class TUMCabeStatus(var status: String?) +data class TUMCabeStatus(var status: String = "") diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/WifiMeasurement.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/WifiMeasurement.kt index bae2040ac9..3e89a03041 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/WifiMeasurement.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumcabe/WifiMeasurement.kt @@ -1,4 +1,9 @@ package de.tum.`in`.tumcampusapp.models.tumcabe -data class WifiMeasurement(val date: String, val ssid: String, val bssid: String, val dBm: Int, var accuracyInMeters: Float, - var latitude: Double, var longitude: Double) +data class WifiMeasurement(var date: String = "", + var ssid: String = "", + var bssid: String = "", + var dBm: Int = -1, + var accuracyInMeters: Float = -1f, + var latitude: Double = -1.0, + var longitude: Double = -1.0) From 0c3235fd98e74fe893012653c48905997b818e50 Mon Sep 17 00:00:00 2001 From: pfent Date: Wed, 8 Nov 2017 15:20:40 +0100 Subject: [PATCH 3/3] Employee image can actually be null --- .../main/java/de/tum/in/tumcampusapp/models/tumo/Employee.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/de/tum/in/tumcampusapp/models/tumo/Employee.kt b/app/src/main/java/de/tum/in/tumcampusapp/models/tumo/Employee.kt index c672216dbe..dc077cdb4d 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/models/tumo/Employee.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/models/tumo/Employee.kt @@ -47,7 +47,7 @@ data class Employee(@field:Element(name = "geschlecht", required = false) val groups: List? get() = groupList?.groups - val image: Bitmap + val image: Bitmap? get() { val imageAsBytes = Base64.decode(imageData.toByteArray(Charsets.UTF_8), Base64.DEFAULT) return BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.size)