use of de.geeksfactory.opacclient.OpacClient in project opacclient by opacapp.
the class SnoozeDatePickerActivity method onTimeSet.
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
dt = dt.withHourOfDay(hourOfDay).withMinuteOfHour(minute);
long alarmId = getIntent().getLongExtra(ReminderBroadcastReceiver.EXTRA_ALARM_ID, -1);
AccountDataSource adata = new AccountDataSource(this);
Alarm alarm = adata.getAlarm(alarmId);
if (alarm == null) {
throw new DataIntegrityException("Trying to snooze unknown alarm ID " + alarmId);
}
alarm.notified = false;
alarm.notificationTime = dt;
adata.updateAlarm(alarm);
// dismiss notification
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel((int) alarm.id);
// reschedule alarms
new ReminderHelper((OpacClient) getApplication()).scheduleAlarms();
finish();
}
use of de.geeksfactory.opacclient.OpacClient in project opacclient by opacapp.
the class AccountEditActivity method save.
private void save() {
AccountDataSource data = new AccountDataSource(AccountEditActivity.this);
data.update(account);
if (((OpacClient) getApplication()).getAccount().getId() == account.getId()) {
((OpacClient) getApplication()).resetCache();
}
}
use of de.geeksfactory.opacclient.OpacClient in project opacclient by opacapp.
the class ReminderBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
this.context = context;
this.intent = intent;
this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
adata = new AccountDataSource(context);
alarm = adata.getAlarm(intent.getLongExtra(EXTRA_ALARM_ID, -1));
if (alarm == null) {
return;
}
switch(intent.getAction()) {
case ACTION_SHOW_NOTIFICATION:
showNotification();
break;
case ACTION_NOTIFICATION_DELETED:
notificationDeleted();
break;
case ACTION_NOTIFICATION_SNOOZE:
notificationSnooze();
break;
case ACTION_NOTIFICATION_CLICK:
notificationClick();
break;
case ACTION_NOTIFICATION_DONT_REMIND_AGAIN:
notificationDontRemindAgain();
break;
}
// reschedule alarms
new ReminderHelper((OpacClient) context.getApplicationContext()).scheduleAlarms();
}
use of de.geeksfactory.opacclient.OpacClient in project opacclient by opacapp.
the class CoverDownloadTask method getImage.
protected byte[] getImage() throws IOException {
try {
OpacApi api = ((OpacClient) context.getApplicationContext()).getApi();
if (api instanceof ApacheBaseApi) {
return getImageApacheClient(((ApacheBaseApi) api).http_client);
} else if (api instanceof OkHttpBaseApi) {
return getImageOkHttpClient(((OkHttpBaseApi) api).http_client);
}
} catch (OpacClient.LibraryRemovedException e) {
}
HttpClient httpClient;
httpClient = new AndroidHttpClientFactory().getNewApacheHttpClient(false, true, false, false);
return getImageApacheClient(httpClient);
}
use of de.geeksfactory.opacclient.OpacClient in project opacclient by opacapp.
the class LibraryConfigUpdateService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
WebService service = WebServiceManager.getInstance();
PreferenceDataSource prefs = new PreferenceDataSource(this);
File filesDir = new File(getFilesDir(), LIBRARIES_DIR);
filesDir.mkdirs();
try {
int count = ((OpacClient) getApplication()).getUpdateHandler().updateConfig(service, prefs, new FileOutput(filesDir), new JsonSearchFieldDataSource(this));
if (!BuildConfig.DEBUG) {
DateTime lastUpdate = prefs.getLastLibraryConfigUpdate();
ACRA.getErrorReporter().putCustomData("data_version", lastUpdate != null ? lastUpdate.toString() : "null");
}
if (BuildConfig.DEBUG) {
Log.d("LibraryConfigUpdate", "updated config for " + String.valueOf(count) + " libraries");
}
Intent broadcast = new Intent(ACTION_SUCCESS).putExtra(EXTRA_UPDATE_COUNT, count);
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
((OpacClient) getApplication()).resetCache();
} catch (IOException e) {
Intent broadcast = new Intent(ACTION_FAILURE);
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
} catch (JSONException e) {
Intent broadcast = new Intent(ACTION_FAILURE);
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
ErrorReporter.handleException(e);
}
}
Aggregations