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; //Getter public String getName() { if(name == null){ SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); name = preferences.getString("name", ""); } return name; } public String getUid() { if(uid == null){ SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); uid = preferences.getString("uid", ""); } return uid; } public String getToken() { if(token == null){ SharedPreferences preferences = getSharedPreferences("prefData", MODE_PRIVATE); token = preferences.getString("token", ""); } return token; } public Shop getCurrentShop() { return currentShop; } public double getCurrentLongitude() { return currentLongitude; } public double getCurrentLatitude() { return currentLatitude; } //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; } }