public static int getProfileIndex(MobileLedgerProfile profile) {
try (LockHolder ignored = profilesLocker.lockForReading()) {
List<MobileLedgerProfile> prList = profiles.getValue();
- if (prList == null) throw new AssertionError();
+ if (prList == null)
+ throw new AssertionError();
for (int i = 0; i < prList.size(); i++) {
MobileLedgerProfile p = prList.get(i);
- if (p.equals(profile)) return i;
+ if (p.equals(profile))
+ return i;
}
return -1;
public static int getProfileIndex(String profileUUID) {
try (LockHolder ignored = profilesLocker.lockForReading()) {
List<MobileLedgerProfile> prList = profiles.getValue();
- if (prList == null) throw new AssertionError();
+ if (prList == null)
+ throw new AssertionError();
for (int i = 0; i < prList.size(); i++) {
MobileLedgerProfile p = prList.get(i);
- if (p.getUuid().equals(profileUUID)) return i;
+ if (p.getUuid()
+ .equals(profileUUID))
+ return i;
}
return -1;
}
public static int retrieveCurrentThemeIdFromDb() {
String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null);
- if (profileUUID == null) return -1;
+ if (profileUUID == null)
+ return -1;
SQLiteDatabase db = App.getDatabase();
- try (Cursor c = db
- .rawQuery("SELECT theme from profiles where uuid=?", new String[]{profileUUID}))
+ try (Cursor c = db.rawQuery("SELECT theme from profiles where uuid=?",
+ new String[]{profileUUID}))
{
- if (c.moveToNext()) return c.getInt(0);
+ if (c.moveToNext())
+ return c.getInt(0);
}
return -1;
}
else {
int i = getProfileIndex(profileUUID);
- if (i == -1) i = 0;
+ if (i == -1)
+ i = 0;
profile = prList.get(i);
}
}
return;
}
MobileLedgerProfile pr = profile.getValue();
- if (pr == null) throw new IllegalStateException("No current profile");
+ if (pr == null)
+ throw new IllegalStateException("No current profile");
retrieveTransactionsTask =
new RetrieveTransactionsTask(new WeakReference<>(activity), profile.getValue());
retrieveTransactionsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public static synchronized void stopTransactionsRetrieval() {
- if (retrieveTransactionsTask != null) retrieveTransactionsTask.cancel(false);
+ if (retrieveTransactionsTask != null)
+ retrieveTransactionsTask.cancel(false);
}
public static void transactionRetrievalDone() {
retrieveTransactionsTask = null;
// the view will disappear when the notifications reaches the model, so by simply omitting
// the out-of-range get() call nothing bad happens - just a to-be-deleted view remains
// a bit longer
- if (item == null) return;
+ if (item == null)
+ return;
switch (item.getType()) {
case TRANSACTION:
holder.vDelimiter.setVisibility(View.GONE);
LedgerTransaction tr = item.getTransaction();
- // debug("transactions", String.format("Filling position %d with %d accounts", position,
+ // debug("transactions", String.format("Filling position %d with %d
+ // accounts", position,
// tr.getAccounts().size()));
TransactionLoader loader = new TransactionLoader();
loader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
- new TransactionLoaderParams(tr, holder, position, Data.accountFilter.getValue(),
- item.isOdd()));
+ new TransactionLoaderParams(tr, holder, position,
+ Data.accountFilter.getValue(), item.isOdd()));
// WORKAROUND what seems to be a bug in CardHolder somewhere
// when a view that was previously holding a delimiter is re-purposed
// occasionally it stays too short (not high enough)
- holder.vTransaction.measure(View.MeasureSpec
- .makeMeasureSpec(holder.itemView.getWidth(), View.MeasureSpec.EXACTLY),
+ holder.vTransaction.measure(
+ View.MeasureSpec.makeMeasureSpec(holder.itemView.getWidth(),
+ View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
break;
case DELIMITER:
Date date = item.getDate();
holder.vTransaction.setVisibility(View.GONE);
holder.vDelimiter.setVisibility(View.VISIBLE);
- holder.tvDelimiterDate.setText(DateFormat.getDateInstance().format(date));
+ holder.tvDelimiterDate.setText(DateFormat.getDateInstance()
+ .format(date));
if (item.isMonthShown()) {
GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault());
cal.setTime(date);
- holder.tvDelimiterMonth
- .setText(Globals.monthNames[cal.get(GregorianCalendar.MONTH)]);
+ holder.tvDelimiterMonth.setText(
+ Globals.monthNames[cal.get(GregorianCalendar.MONTH)]);
holder.tvDelimiterMonth.setVisibility(View.VISIBLE);
- // holder.vDelimiterLine.setBackgroundResource(R.drawable.dashed_border_8dp);
+ // holder.vDelimiterLine.setBackgroundResource(R.drawable
+ // .dashed_border_8dp);
holder.vDelimiterLine.setVisibility(View.GONE);
holder.vDelimiterThick.setVisibility(View.VISIBLE);
}
else {
holder.tvDelimiterMonth.setVisibility(View.GONE);
- // holder.vDelimiterLine.setBackgroundResource(R.drawable.dashed_border_1dp);
+ // holder.vDelimiterLine.setBackgroundResource(R.drawable
+ // .dashed_border_1dp);
holder.vDelimiterLine.setVisibility(View.VISIBLE);
holder.vDelimiterThick.setVisibility(View.GONE);
}
public TransactionRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// debug("perf", "onCreateViewHolder called");
View row = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.transaction_list_row, parent, false);
+ .inflate(R.layout.transaction_list_row, parent, false);
return new TransactionRowHolder(row);
}
return Data.transactions.size();
}
enum LoaderStep {HEAD, ACCOUNTS, DONE}
+
private static class TransactionLoader
extends AsyncTask<TransactionLoaderParams, TransactionLoaderStep, Void> {
@Override
switch (step.getStep()) {
case HEAD:
- holder.tvDescription.setText(step.getTransaction().getDescription());
+ holder.tvDescription.setText(step.getTransaction()
+ .getDescription());
- if (step.isOdd()) holder.row.setBackgroundColor(Colors.tableRowDarkBG);
- else holder.row.setBackgroundColor(Colors.tableRowLightBG);
+ if (step.isOdd())
+ holder.row.setBackgroundColor(Colors.tableRowDarkBG);
+ else
+ holder.row.setBackgroundColor(Colors.tableRowLightBG);
break;
case ACCOUNTS:
// acc.getAccountName(), acc.getAmount()));
String boldAccountName = step.getBoldAccountName();
- if ((boldAccountName != null) &&
- acc.getAccountName().startsWith(boldAccountName))
+ if ((boldAccountName != null) && acc.getAccountName()
+ .startsWith(boldAccountName))
{
accName.setTextColor(Colors.accent);
accAmount.setTextColor(Colors.accent);