+ private void update_accounts(boolean force) {
+ long now = new Date().getTime();
+ if ((now > (account_list_last_updated + (24 * 3600*1000))) || force) {
+ Log.d("db", "accounts last updated at " + account_list_last_updated+" and now is " + now+". re-fetching");
+ update_accounts();
+ }
+ }
+
+ private void update_accounts() {
+ Resources rm = getResources();
+
+ ProgressBar pb = findViewById(R.id.progressBar);
+ pb.setVisibility(View.VISIBLE);
+ TextView pt = findViewById(R.id.textProgress);
+ pt.setVisibility(View.VISIBLE);
+ pb.setIndeterminate(true);
+
+ RetrieveAccountsTask task = new RetrieveAccountsTask() {
+ @Override
+ protected void onProgressUpdate(Integer... values) {
+ if ( values[0] == 0 )
+ pt.setText(R.string.progress_connecting);
+ else
+ pt.setText(String.format(getResources().getString(R.string.progress_N_accounts_loaded), values[0]));
+ }
+
+ @Override
+ protected void onPostExecute(Void result) {
+ pb.setVisibility(GONE);
+ pt.setVisibility(GONE);
+ if (this.error != 0)
+ Snackbar.make(drawer, rm.getString(this.error), Snackbar.LENGTH_LONG );
+ else
+ set_option_value("last_refresh", new Date().getTime() );
+ }
+ };