11 |
import android.content.Intent; |
import android.content.Intent; |
12 |
import android.content.SharedPreferences; |
import android.content.SharedPreferences; |
13 |
import android.database.Cursor; |
import android.database.Cursor; |
14 |
|
import android.net.ConnectivityManager; |
15 |
|
import android.net.NetworkInfo; |
16 |
import android.os.Bundle; |
import android.os.Bundle; |
17 |
import android.os.Handler; |
import android.os.Handler; |
18 |
import android.os.Message; |
import android.os.Message; |
52 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
53 |
setContentView(R.layout.main); |
setContentView(R.layout.main); |
54 |
|
|
55 |
|
|
56 |
peopleDB = new PeopleDatabase(this); |
peopleDB = new PeopleDatabase(this); |
57 |
|
|
58 |
|
|
171 |
SharedPreferences settings = getSharedPreferences(PREFS, 0); |
SharedPreferences settings = getSharedPreferences(PREFS, 0); |
172 |
StringBuffer message = new StringBuffer(); |
StringBuffer message = new StringBuffer(); |
173 |
message.append("Grundfos People v0.1\n"); |
message.append("Grundfos People v0.1\n"); |
174 |
message.append("By Torben Hørup Nielsen\n"); |
message.append("By Torben Hørup Nielsen\n"); |
175 |
message.append("Database size: ").append(peopleDB.getPeopleCount()).append("\n"); |
message.append("Database size: ").append(peopleDB.getPeopleCount()).append("\n"); |
176 |
message.append("Last DB update: ").append( settings.getString(PREF_LAST_DB_UPDATE, " - never -")); |
message.append("Last DB update: ").append( settings.getString(PREF_LAST_DB_UPDATE, " - never -")); |
177 |
|
|
191 |
.show(); |
.show(); |
192 |
|
|
193 |
} |
} |
194 |
|
|
195 |
public void loadDatabase() |
public void loadDatabase() |
196 |
{ |
{ |
197 |
|
ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); |
198 |
|
if (cm.getActiveNetworkInfo().getType() != ConnectivityManager.TYPE_WIFI) { |
199 |
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
200 |
|
builder.setMessage("You are not connected to a WiFi network. It is not recommended to load a DB via mobile network") |
201 |
|
.setCancelable(false) |
202 |
|
.setPositiveButton("Continue", new DialogInterface.OnClickListener() { |
203 |
|
public void onClick(DialogInterface dialog, int id) { |
204 |
|
dialog.dismiss(); |
205 |
|
startLoadDatabase(); |
206 |
|
} |
207 |
|
}) |
208 |
|
.setNegativeButton("Abort", new DialogInterface.OnClickListener() { |
209 |
|
public void onClick(DialogInterface dialog, int id) { |
210 |
|
dialog.cancel(); |
211 |
|
} |
212 |
|
}) |
213 |
|
.show(); |
214 |
|
} else { |
215 |
|
startLoadDatabase(); |
216 |
|
} |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
|
public void startLoadDatabase() |
221 |
|
{ |
222 |
dialog = new ProgressDialog(this); |
dialog = new ProgressDialog(this); |
223 |
((ProgressDialog)dialog).setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); |
((ProgressDialog)dialog).setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); |
224 |
((ProgressDialog)dialog).setMessage("Loading..."); |
((ProgressDialog)dialog).setMessage("Loading..."); |