|
1
2
3
4
5
|
package com.upc.pbe.upcnews;
import android.app.Application;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
|
6
|
import android.os.Environment;
|
|
7
8
9
|
import android.preference.PreferenceManager;
import android.util.Log;
|
|
10
|
//Instanciacio de la nostra aplicacio
|
|
11
12
13
|
public class UpcApp extends Application implements OnSharedPreferenceChangeListener {
final static String TAG = "Application";
|
|
14
15
|
private SharedPreferences prefs; //Conjunt de preferencies de l'aplicacio
private String url = null;
|
|
16
|
private String desc;
|
|
17
|
private final static String localPath = Environment.getExternalStorageDirectory().getPath() + "/UPC NEWS/";
|
|
18
|
|
|
19
|
public String getLocalPath(){
|
|
20
21
|
return localPath;
}
|
|
22
23
|
public String getUrl() {
|
|
24
|
url = "http://" + prefs.getString("server", getString(R.string.defaultURL));
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
return url;
}
public void onCreate() {
super.onCreate();
//Prefs
prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
this.getUrl();
Log.d(TAG, "onCreated");
}
public SharedPreferences getPrefs() {
return prefs;
}
public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
|
|
43
|
Log.d(TAG, "onSharedPreferenceChanged for key: " + key);
|
|
44
|
}
|
|
45
46
47
48
49
50
51
52
|
public void setDesc(String s){
desc = s;
}
public String getDesc(){
return desc;
}
|
|
53
|
}
|