Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Barashkov committed Dec 20, 2020
2 parents 80225ff + 88546b0 commit ddbf434
Show file tree
Hide file tree
Showing 14 changed files with 2,302 additions and 2,319 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ android {
applicationId "com.handydev.financier"
minSdkVersion 21
targetSdkVersion 29
versionCode 212
versionName "2.0.12"
versionCode 213
versionName "2.0.13"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/assets/whatsnew.htm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
</head>
<body>

<p><b>2.0.13</b></p>
<p>
[*] Categories filter in transaction now shows nested categories correctly. <br/>
</p>

<p><b>2.0.12</b></p>
<p>
[*] Nested categories in Transaction are now displayed in a more informative way. <br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public AbstractTransactionActivity() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
db.updateCategoriesCache(false);

df = DateUtils.getLongDateFormat(this);
tf = DateUtils.getTimeFormat(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.widget.*
import android.widget.AdapterView.OnItemClickListener
import com.handydev.financier.R
import com.handydev.financier.activity.ActivityLayout.FilterNode
import com.handydev.financier.db.CategoriesCache
import com.handydev.financier.db.DatabaseAdapter
import com.handydev.financier.db.DatabaseHelper
import com.handydev.financier.model.*
Expand Down Expand Up @@ -227,9 +228,10 @@ class CategorySelector<A : AbstractActivity?> @JvmOverloads constructor(private
if (listener != null) listener!!.onCategorySelected(null, false)
} else {
if (selectedCategoryId != categoryId) {
val category = db.getCategoryWithParent(categoryId)
db.updateCategoriesCache(false)
val category = CategoriesCache.getCategory(categoryId)
if (category != null) {
categoryText!!.text = category.getTitle(db) //Category.getTitle(category.title, category.level)
categoryText!!.text = category.getNestedTitle() //Category.getTitle(category.title, category.level)
showHideMinusBtn(true)
}
selectedCategoryId = categoryId
Expand Down Expand Up @@ -305,19 +307,21 @@ class CategorySelector<A : AbstractActivity?> @JvmOverloads constructor(private
return AttributeViewFactory.createViewForAttribute(activity, attribute)
}

fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK) {
when (requestCode) {
CategorySelectorActivity.CATEGORY_ADD -> {
categoryCursor!!.requery()
val categoryId = data.getLongExtra(DatabaseHelper.CategoryColumns._id.name, -1)
if (categoryId != -1L) {
val categoryId = data?.getLongExtra(DatabaseHelper.CategoryColumns._id.name, -1)
if (categoryId != null && categoryId != -1L) {
selectCategory(categoryId)
}
}
CategorySelectorActivity.CATEGORY_PICK -> {
val categoryId = data.getLongExtra(CategorySelectorActivity.SELECTED_CATEGORY_ID, 0)
selectCategory(categoryId)
val categoryId = data?.getLongExtra(CategorySelectorActivity.SELECTED_CATEGORY_ID, 0)
if(categoryId != null) {
selectCategory(categoryId)
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/handydev/financier/db/CategoriesCache.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.handydev.financier.db

import com.handydev.financier.model.Category

object CategoriesCache {
var categoriesList = ArrayList<Category>()
fun updateCache(categories: ArrayList<Category>) {
categoriesList = categories
}

fun getCategory(id: Long): Category? {
return categoriesList.firstOrNull { it.id == id }
}
}
Loading

0 comments on commit ddbf434

Please sign in to comment.