-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
145 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.trolle.trolleapp.data | ||
|
||
data class UserRaspi( | ||
val id_user: Int, | ||
val id_raspi: Int | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/trolle/trolleapp/data/UserRaspiResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.trolle.trolleapp.data | ||
|
||
data class UserRaspiResponse( | ||
val message: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/trolle/trolleapp/data/sharedpref/SharedPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.trolle.trolleapp.data.sharedpref | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
|
||
class SharedPreference(val context: Context) { | ||
private val PREFS_NAME = "trolle_pref" | ||
val sharedPref: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) | ||
|
||
fun save(KEY_NAME: String, text: String) { | ||
|
||
val editor: SharedPreferences.Editor = sharedPref.edit() | ||
|
||
editor.putString(KEY_NAME, text) | ||
|
||
editor!!.commit() | ||
} | ||
|
||
fun save(KEY_NAME: String, value: Int) { | ||
val editor: SharedPreferences.Editor = sharedPref.edit() | ||
|
||
editor.putInt(KEY_NAME, value) | ||
|
||
editor.commit() | ||
} | ||
|
||
fun save(KEY_NAME: String, status: Boolean) { | ||
|
||
val editor: SharedPreferences.Editor = sharedPref.edit() | ||
|
||
editor.putBoolean(KEY_NAME, status!!) | ||
|
||
editor.commit() | ||
} | ||
|
||
fun getValueString(KEY_NAME: String): String? { | ||
|
||
return sharedPref.getString(KEY_NAME, null) | ||
|
||
} | ||
|
||
fun getValueInt(KEY_NAME: String): Int { | ||
|
||
return sharedPref.getInt(KEY_NAME, 0) | ||
} | ||
|
||
fun getValueBoolien(KEY_NAME: String, defaultValue: Boolean): Boolean { | ||
|
||
return sharedPref.getBoolean(KEY_NAME, defaultValue) | ||
|
||
} | ||
|
||
fun clearSharedPreference() { | ||
|
||
val editor: SharedPreferences.Editor = sharedPref.edit() | ||
|
||
//sharedPref = PreferenceManager.getDefaultSharedPreferences(context); | ||
|
||
editor.clear() | ||
editor.commit() | ||
} | ||
|
||
fun removeValue(KEY_NAME: String) { | ||
|
||
val editor: SharedPreferences.Editor = sharedPref.edit() | ||
|
||
editor.remove(KEY_NAME) | ||
editor.commit() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters