Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean code step 3 for old model cat:subcat #1947

Merged
merged 6 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,21 @@ public class CategoryExpandableListAdapter

public CategoryExpandableListAdapter(Context context, int layout,
List<Category> categories,
HashMap<Category,
List<QueryCategorySubCategory>> 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,
boolean showSelector,
Boolean source) {
mContext = context;
mLayout = layout;
mCategories = categories;
mSubCategories = subCategories;
mShowSelector = showSelector;
mUseNestedCategory = source;
}
Expand All @@ -74,8 +67,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 +77,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 +100,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 Expand Up @@ -298,4 +245,4 @@ private void closeFragment() {
private Context getContext() {
return mContext;
}
}
}
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 Expand Up @@ -429,7 +433,7 @@ public CategoryExpandableListAdapter getAdapter(Cursor data) {

boolean showSelector = mAction.equals(Intent.ACTION_PICK);
CategoryExpandableListAdapter adapter = new CategoryExpandableListAdapter(getActivity(),
mLayout, mCategories, mSubCategories, showSelector);
mLayout, mCategories, showSelector);
adapter.setIdChildChecked(mIdGroupChecked, mIdChildChecked);
return adapter;
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public CategoryExpandableListAdapter getAdapter(Cursor data) {

boolean showSelector = mAction.equals(Intent.ACTION_PICK);
CategoryExpandableListAdapter adapter = new CategoryExpandableListAdapter(getActivity(),
mLayout, mCategories, null, showSelector, true);
mLayout, mCategories, showSelector, true);
return adapter;
}

Expand Down
Loading