- package com.example.nemophila;
-
- import android.app.Application;
- import android.content.SharedPreferences;
-
- import com.example.nemophila.entities.Shop;
-
- public class Nemophila extends Application {
- private String name;
- private String uid;
- private String token;
- private Shop currentShop;
- private double currentLongitude;
- private double currentLatitude;
- private Shop dummyShop;
-
- //Getter
-
- public String getName() {
- if(name == null){
- SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE);
- name = preferences.getString("name", null);
- }
- return name;
- }
- public String getUid() {
- if(uid == null){
- SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE);
- uid = preferences.getString("uid", null);
- }
- return uid;
- }
- public String getToken() {
- if(token == null){
- SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE);
- token = preferences.getString("token", null);
- }
- return token;
- }
- public Shop getCurrentShop() {
- return currentShop;
- }
- public double getCurrentLongitude() {
- return currentLongitude;
- }
- public double getCurrentLatitude() {
- return currentLatitude;
- }
- public Shop getDummyShop() {
- return dummyShop;
- }
-
- //Setter
- public void setName(String name) {
- SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("name", name);
- this.name = name;
- editor.commit();
- }
- public void setUid(String uid) {
- SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("uid", uid);
- this.uid = uid;
- editor.commit();
- }
- public void setToken(String token) {
- SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("token", token);
- this.token = token;
- editor.commit();
- }
- public void setCurrentShop(Shop currentShop) {
- this.currentShop = currentShop;
- }
- public void setCurrentLongitude(double currentLongitude) {
- this.currentLongitude = currentLongitude;
- }
- public void setCurrentLatitude(double currentLatitude) {
- this.currentLatitude = currentLatitude;
- }
- public void setDummyShop(Shop dummyShop) {
- this.dummyShop = dummyShop;
- }
- }