<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright © 2018 Damyan Ivanov.
+ ~ This file is part of Mobile-Ledger.
+ ~ Mobile-Ledger is free software: you can distribute it and/or modify it
+ ~ under the term of the GNU General Public License as published by
+ ~ the Free Software Foundation, either version 3 of the License, or
+ ~ (at your opinion), any later version.
+ ~
+ ~ Mobile-Ledger is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License terms for details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
+ -->
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.ktnx.mobileledger">
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
+ android:name="net.ktnx.mobileledger.MobileLedgerApplication"
android:theme="@style/AppTheme">
<activity
android:name=".AccountSummary"
--- /dev/null
+/*
+ * Copyright © 2018 Damyan Ivanov.
+ * This file is part of Mobile-Ledger.
+ * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * Mobile-Ledger is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger;
+
+import android.app.Application;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.Build;
+
+import net.ktnx.mobileledger.utils.Globals;
+
+public class MobileLedgerApplication extends Application {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ updateColorValues();
+ }
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ updateColorValues();
+ }
+ private void updateColorValues() {
+ Resources rm = getResources();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ Resources.Theme theme = getTheme();
+ Globals.table_row_odd_bg = rm.getColor(R.color.table_row_odd_bg, theme);
+ Globals.table_row_even_bg = rm.getColor(R.color.table_row_even_bg, theme);
+ }
+ else {
+ Globals.table_row_odd_bg = rm.getColor(R.color.table_row_odd_bg);
+ Globals.table_row_even_bg = rm.getColor(R.color.table_row_even_bg);
+ }
+ }
+}
import android.content.Context;
import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
-import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
+import net.ktnx.mobileledger.utils.Globals;
import net.ktnx.mobileledger.utils.MLDB;
import java.util.Iterator;
public void onBindViewHolder(@NonNull TransactionRowHolder holder, int position) {
LedgerTransaction tr = transactions.get(position);
Context ctx = holder.row.getContext();
- Resources rm = ctx.getResources();
+
try (SQLiteDatabase db = MLDB.getReadableDatabase(ctx.getApplicationContext())) {
tr.loadData(db);
}
if (position % 2 == 0) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row
- .setBackgroundColor(rm.getColor(R.color.table_row_even_bg, ctx.getTheme()));
- else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_even_bg));
+ holder.row.setBackgroundColor(Globals.table_row_even_bg);
}
else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row
- .setBackgroundColor(rm.getColor(R.color.table_row_odd_bg, ctx
- .getTheme()));
- else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_odd_bg));
+ holder.row.setBackgroundColor(Globals.table_row_odd_bg);
}
holder.row.setTag(R.id.POS, position);
--- /dev/null
+/*
+ * Copyright © 2018 Damyan Ivanov.
+ * This file is part of Mobile-Ledger.
+ * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * Mobile-Ledger is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.utils;
+
+import android.support.annotation.ColorInt;
+
+public final class Globals {
+ @ColorInt
+ public static int table_row_even_bg;
+ @ColorInt
+ public static int table_row_odd_bg;
+
+}
\ No newline at end of file