From 5d3018c61302e0c971064012bf665109c5b80ec3 Mon Sep 17 00:00:00 2001 From: "Emmanuele (WolfSolver)" Date: Tue, 3 Dec 2024 18:39:14 +0100 Subject: [PATCH] Clean code for nestedcategory Step 3a prepare for remove unused code #1792 --- .../money/manager/ex/MmxContentProvider.java | 2 - .../CategoryExpandableListAdapter.java | 57 +------------------ .../ex/common/CategoryListFragment.java | 4 ++ .../ex/database/QueryCategorySubCategory.java | 3 + .../money/manager/ex/home/MainActivity.java | 1 - 5 files changed, 10 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/com/money/manager/ex/MmxContentProvider.java b/app/src/main/java/com/money/manager/ex/MmxContentProvider.java index c3c8ebd95..192832d7a 100644 --- a/app/src/main/java/com/money/manager/ex/MmxContentProvider.java +++ b/app/src/main/java/com/money/manager/ex/MmxContentProvider.java @@ -34,7 +34,6 @@ import com.money.manager.ex.database.QueryAccountBills; import com.money.manager.ex.database.QueryAllData; import com.money.manager.ex.database.QueryBillDeposits; -import com.money.manager.ex.database.QueryCategorySubCategory; import com.money.manager.ex.database.QueryReportIncomeVsExpenses; import com.money.manager.ex.database.SQLDataSet; import com.money.manager.ex.database.ViewMobileData; @@ -117,7 +116,6 @@ public boolean onCreate() { new StockRepository(context), new StockHistoryRepository(context), new QueryAccountBills(context), - new QueryCategorySubCategory(context), new QueryAllData(context), new QueryBillDeposits(context), new QueryReportIncomeVsExpenses(context), diff --git a/app/src/main/java/com/money/manager/ex/adapter/CategoryExpandableListAdapter.java b/app/src/main/java/com/money/manager/ex/adapter/CategoryExpandableListAdapter.java index d4e9e2207..4b53a352a 100644 --- a/app/src/main/java/com/money/manager/ex/adapter/CategoryExpandableListAdapter.java +++ b/app/src/main/java/com/money/manager/ex/adapter/CategoryExpandableListAdapter.java @@ -29,7 +29,6 @@ import com.money.manager.ex.common.CategoryListActivity; import com.money.manager.ex.common.CategoryListFragment; -import com.money.manager.ex.database.QueryCategorySubCategory; import com.money.manager.ex.domainmodel.Category; import com.money.manager.ex.nestedcategory.NestedCategoryListFragment; @@ -43,27 +42,23 @@ public class CategoryExpandableListAdapter public CategoryExpandableListAdapter(Context context, int layout, List categories, - HashMap> subCategories, + Object subCategories, boolean showSelector) { mContext = context; mLayout = layout; mCategories = categories; - mSubCategories = subCategories; mShowSelector = showSelector; mUseNestedCategory = false; } public CategoryExpandableListAdapter(Context context, int layout, List categories, - HashMap> subCategories, + Object subCategories, boolean showSelector, Boolean source) { mContext = context; mLayout = layout; mCategories = categories; - mSubCategories = subCategories; mShowSelector = showSelector; mUseNestedCategory = source; } @@ -74,8 +69,6 @@ public CategoryExpandableListAdapter(Context context, int layout, private final List mCategories; - private final HashMap> mSubCategories; - private long mIdGroupChecked = ListView.INVALID_POSITION; private long mIdChildChecked = ListView.INVALID_POSITION; @@ -86,13 +79,6 @@ public CategoryExpandableListAdapter(Context context, int layout, @Override public Object getChild(int groupPosition, int childPosition) { - if (groupPosition < mCategories.size()) { - Category category = mCategories.get(groupPosition); - List categorySubCategories = mSubCategories.get(category); - if (childPosition < categorySubCategories.size()) { - return categorySubCategories.get(childPosition); - } - } return null; } @@ -116,49 +102,12 @@ public View getChildView(int groupPosition, int childPosition, boolean isLastChi holder = (CategoryListItemViewHolderChild) convertView.getTag(); } - QueryCategorySubCategory entity = (QueryCategorySubCategory) getChild(groupPosition, childPosition); - if (entity == null) { - return convertView; - } - - holder.text1.setText(entity.getSubcategoryName()); - - holder.text2.setText(entity.getCategName()); - holder.text2.setTextColor(getContext().getResources().getColor(android.R.color.darker_gray)); - - // Selector. Always hidden on subcategories. - -// if (mShowSelector) { -// holder.selector.setVisibility(View.VISIBLE); -// // set the tag to be the group position -// holder.selector.setTag(entity.getCategId() + ":" + entity.getSubCategId()); -// -// holder.selector.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// String tag = v.getTag().toString(); -// String[] ids = tag.split(":"); -// Long groupId = Integer.parseInt(ids[0]); -// Long childId = Integer.parseInt(ids[1]); -// setIdChildChecked(groupId, childId); -// // close -// closeFragment(); -// } -// }); -// } else { - holder.selector.setVisibility(View.GONE); -// } - - // indent subcategory - holder.indent.setVisibility(View.VISIBLE); - return convertView; } @Override public int getChildrenCount(int groupPosition) { - if (mSubCategories == null) { return 0; } - return mSubCategories.get(mCategories.get(groupPosition)).size(); + return 0; } @Override diff --git a/app/src/main/java/com/money/manager/ex/common/CategoryListFragment.java b/app/src/main/java/com/money/manager/ex/common/CategoryListFragment.java index 2912c5166..69da9f9d7 100644 --- a/app/src/main/java/com/money/manager/ex/common/CategoryListFragment.java +++ b/app/src/main/java/com/money/manager/ex/common/CategoryListFragment.java @@ -16,6 +16,10 @@ */ package com.money.manager.ex.common; +// TODO: Issue #1792 +// This file need to be deleted after code clean for NestedCategory +// replaced by NestedCategoryListFragment + import android.app.Activity; import android.app.AlertDialog; import android.content.ContentValues; diff --git a/app/src/main/java/com/money/manager/ex/database/QueryCategorySubCategory.java b/app/src/main/java/com/money/manager/ex/database/QueryCategorySubCategory.java index c764c11c2..4755e5337 100644 --- a/app/src/main/java/com/money/manager/ex/database/QueryCategorySubCategory.java +++ b/app/src/main/java/com/money/manager/ex/database/QueryCategorySubCategory.java @@ -15,6 +15,9 @@ * along with this program. If not, see . */ package com.money.manager.ex.database; +// TODO: Issue #1792 +// This file need to be deleted after code clean for NestedCategory +// replaced by QueryNestedCategory import android.content.Context; import android.database.Cursor; diff --git a/app/src/main/java/com/money/manager/ex/home/MainActivity.java b/app/src/main/java/com/money/manager/ex/home/MainActivity.java index 8c785f1f4..8dc995e15 100644 --- a/app/src/main/java/com/money/manager/ex/home/MainActivity.java +++ b/app/src/main/java/com/money/manager/ex/home/MainActivity.java @@ -61,7 +61,6 @@ import com.money.manager.ex.account.AccountListFragment; import com.money.manager.ex.account.AccountTransactionListFragment; import com.money.manager.ex.budget.BudgetsActivity; -import com.money.manager.ex.common.CategoryListFragment; import com.money.manager.ex.common.MmxBaseFragmentActivity; import com.money.manager.ex.core.Core; import com.money.manager.ex.core.InfoKeys;