use of de.geeksfactory.opacclient.apis.OpacApi in project opacclient by opacapp.
the class AccountFragment method prolong.
public void prolong(final String a) {
long age = System.currentTimeMillis() - refreshtime;
if (refreshing || age > MAX_CACHE_AGE) {
Toast.makeText(getActivity(), R.string.account_no_concurrent, Toast.LENGTH_LONG).show();
if (!refreshing) {
refresh();
}
return;
}
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
OpacApi api;
try {
api = app.getApi();
} catch (OpacClient.LibraryRemovedException e) {
return;
}
if (sp.getBoolean("prolong_fee_warning_ignore", false) || app.getLibrary().isSuppressFeeWarnings() || (api.getSupportFlags() & OpacApi.SUPPORT_FLAG_WARN_PROLONG_FEES) > 0) {
prolongPerform(a);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View content = getActivity().getLayoutInflater().inflate(R.layout.dialog_prolong_confirm, null);
final CheckBox check = (CheckBox) content.findViewById(R.id.check_box1);
builder.setView(content).setCancelable(false).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
}).setPositiveButton(R.string.reservation_fee_continue, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
if (check.isChecked()) {
sp.edit().putBoolean("prolong_fee_warning_ignore", true).apply();
}
prolongPerform(a);
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
use of de.geeksfactory.opacclient.apis.OpacApi in project opacclient by opacapp.
the class AccountFragment method onCreateOptionsMenu.
@SuppressLint("NewApi")
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.activity_account, menu);
OpacApi api;
try {
api = app.getApi();
} catch (OpacClient.LibraryRemovedException e) {
return;
}
if (app.getAccount() != null && (api.getSupportFlags() & OpacApi.SUPPORT_FLAG_ACCOUNT_PROLONG_ALL) != 0) {
menu.findItem(R.id.action_prolong_all).setVisible(true);
} else {
menu.findItem(R.id.action_prolong_all).setVisible(false);
}
menu.findItem(R.id.action_refresh).setVisible(supported);
super.onCreateOptionsMenu(menu, inflater);
}
use of de.geeksfactory.opacclient.apis.OpacApi in project opacclient by opacapp.
the class AccountItemDetailActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_account_item_detail, menu);
MenuItem prolong = menu.findItem(R.id.action_prolong);
MenuItem download = menu.findItem(R.id.action_download);
MenuItem cancel = menu.findItem(R.id.action_cancel);
MenuItem booking = menu.findItem(R.id.action_booking);
OpacClient app = (OpacClient) getApplication();
OpacApi api = null;
try {
api = app.getApi();
} catch (OpacClient.LibraryRemovedException e) {
e.printStackTrace();
}
if (item instanceof LentItem) {
final LentItem i = (LentItem) item;
cancel.setVisible(false);
booking.setVisible(false);
if (i.getProlongData() != null) {
prolong.setVisible(true);
// ViewCompat.setAlpha(prolong, item.isRenewable() ? 1f : 0.4f);
download.setVisible(false);
} else if (i.getDownloadData() != null && api != null && api instanceof EbookServiceApi) {
prolong.setVisible(false);
download.setVisible(true);
} else {
prolong.setVisible(false);
download.setVisible(false);
}
} else if (item instanceof ReservedItem) {
final ReservedItem i = (ReservedItem) item;
prolong.setVisible(false);
download.setVisible(false);
if (i.getBookingData() != null) {
booking.setVisible(true);
cancel.setVisible(false);
} else if (i.getCancelData() != null) {
cancel.setVisible(true);
booking.setVisible(false);
} else {
cancel.setVisible(false);
booking.setVisible(false);
}
}
return true;
}
Aggregations