Blame view

src/com/upc/pbe/upcnews/UpcApp.java 1.4 KB
Imanol-Mikel Barba Sabariego authored
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;
Imanol-Mikel Barba Sabariego authored
7
8
9
import android.preference.PreferenceManager;
import android.util.Log;
Imanol-Mikel Barba Sabariego authored
10
//Instanciacio de la nostra aplicacio
Imanol-Mikel Barba Sabariego authored
11
12
13
public class UpcApp extends Application implements OnSharedPreferenceChangeListener {

	final static String TAG = "Application";
Imanol-Mikel Barba Sabariego authored
14
15
	private SharedPreferences prefs; //Conjunt de preferencies de l'aplicacio
	private String url = null; 
16
	private String desc;
Imanol-Mikel Barba Sabariego authored
17
	private final static String localPath = Environment.getExternalStorageDirectory().getPath() + "/UPC NEWS/";
18
Imanol-Mikel Barba Sabariego authored
19
	public String getLocalPath(){
20
21
		return localPath;
	}
Imanol-Mikel Barba Sabariego authored
22
23

	public String getUrl() {
Imanol-Mikel Barba Sabariego authored
24
		url = "http://" + prefs.getString("server", getString(R.string.defaultURL));
Imanol-Mikel Barba Sabariego authored
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) {
Imanol-Mikel Barba Sabariego authored
43
		Log.d(TAG, "onSharedPreferenceChanged for key: " + key);	
Imanol-Mikel Barba Sabariego authored
44
	}
45
46
47
48
49
50
51
52

	public void setDesc(String s){
		desc = s;
	}

	public String getDesc(){
		return desc;
	}
Imanol-Mikel Barba Sabariego authored
53
}