mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 13:56:14 +03:00
Use correct accountId to suggest categories
This commit is contained in:
parent
bde70bd27d
commit
25357d7a2e
2 changed files with 17 additions and 19 deletions
|
@ -362,6 +362,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
|
|||
}
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(CategoryDialogFragment.PARAM_CATEGORY, note.getCategory());
|
||||
arguments.putLong(CategoryDialogFragment.PARAM_ACCOUNT_ID, note.getAccountId());
|
||||
CategoryDialogFragment categoryFragment = new CategoryDialogFragment();
|
||||
categoryFragment.setArguments(arguments);
|
||||
categoryFragment.setTargetFragment(this, 0);
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.Dialog;
|
|||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
@ -45,10 +44,14 @@ public class CategoryDialogFragment extends DialogFragment {
|
|||
void onCategoryChosen(String category);
|
||||
}
|
||||
|
||||
public static final String PARAM_ACCOUNT_ID = "account_id";
|
||||
public static final String PARAM_CATEGORY = "category";
|
||||
|
||||
private long accountId;
|
||||
|
||||
@BindView(R.id.editCategory)
|
||||
AlwaysAutoCompleteTextView textCategory;
|
||||
|
||||
private FolderArrayAdapter adapter;
|
||||
|
||||
@Override
|
||||
|
@ -57,6 +60,7 @@ public class CategoryDialogFragment extends DialogFragment {
|
|||
ButterKnife.bind(this, dialogView);
|
||||
if (savedInstanceState == null) {
|
||||
textCategory.setText(getArguments().getString(PARAM_CATEGORY));
|
||||
accountId = getArguments().getLong(PARAM_ACCOUNT_ID);
|
||||
}
|
||||
adapter = new FolderArrayAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item);
|
||||
textCategory.setAdapter(adapter);
|
||||
|
@ -65,24 +69,18 @@ public class CategoryDialogFragment extends DialogFragment {
|
|||
.setTitle(R.string.change_category_title)
|
||||
.setView(dialogView)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.action_edit_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
CategoryDialogListener listener;
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof CategoryDialogListener) {
|
||||
listener = (CategoryDialogListener) target;
|
||||
} else {
|
||||
listener = (CategoryDialogListener) getActivity();
|
||||
}
|
||||
listener.onCategoryChosen(textCategory.getText().toString());
|
||||
.setPositiveButton(R.string.action_edit_save, (dialog, which) -> {
|
||||
CategoryDialogListener listener;
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof CategoryDialogListener) {
|
||||
listener = (CategoryDialogListener) target;
|
||||
} else {
|
||||
listener = (CategoryDialogListener) getActivity();
|
||||
}
|
||||
listener.onCategoryChosen(textCategory.getText().toString());
|
||||
})
|
||||
.setNegativeButton(R.string.simple_cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// do nothing
|
||||
}
|
||||
.setNegativeButton(R.string.simple_cancel, (dialog, which) -> {
|
||||
// do nothing
|
||||
})
|
||||
.create();
|
||||
}
|
||||
|
@ -102,8 +100,7 @@ public class CategoryDialogFragment extends DialogFragment {
|
|||
@Override
|
||||
protected List<String> doInBackground(Void... voids) {
|
||||
NoteSQLiteOpenHelper db = NoteSQLiteOpenHelper.getInstance(getActivity());
|
||||
// FIXME hardcoded accountId
|
||||
List<NavigationAdapter.NavigationItem> items = db.getCategories(1);
|
||||
List<NavigationAdapter.NavigationItem> items = db.getCategories(accountId);
|
||||
List<String> categories = new ArrayList<>();
|
||||
for (NavigationAdapter.NavigationItem item : items) {
|
||||
if (!item.label.isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue