Skip to content

Commit

Permalink
Clean code for nestedcategory
Browse files Browse the repository at this point in the history
Step 3a prepare for remove unused code #1792
  • Loading branch information
wolfsolver committed Dec 3, 2024
1 parent f83094a commit 5d3018c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,27 +42,23 @@ public class CategoryExpandableListAdapter

public CategoryExpandableListAdapter(Context context, int layout,
List<Category> categories,
HashMap<Category,
List<QueryCategorySubCategory>> subCategories,
Object subCategories,
boolean showSelector) {
mContext = context;
mLayout = layout;
mCategories = categories;
mSubCategories = subCategories;
mShowSelector = showSelector;
mUseNestedCategory = false;
}

public CategoryExpandableListAdapter(Context context, int layout,
List<Category> categories,
HashMap<Category,
List<QueryCategorySubCategory>> subCategories,
Object subCategories,
boolean showSelector,
Boolean source) {
mContext = context;
mLayout = layout;
mCategories = categories;
mSubCategories = subCategories;
mShowSelector = showSelector;
mUseNestedCategory = source;
}
Expand All @@ -74,8 +69,6 @@ public CategoryExpandableListAdapter(Context context, int layout,

private final List<Category> mCategories;

private final HashMap<Category, List<QueryCategorySubCategory>> mSubCategories;

private long mIdGroupChecked = ListView.INVALID_POSITION;
private long mIdChildChecked = ListView.INVALID_POSITION;

Expand All @@ -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<QueryCategorySubCategory> categorySubCategories = mSubCategories.get(category);
if (childPosition < categorySubCategories.size()) {
return categorySubCategories.get(childPosition);
}
}
return null;
}

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5d3018c

Please sign in to comment.