mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-07-10 05:30:29 +03:00
Fix issue #1131 - User search suggestions have duplicates
This commit is contained in:
parent
7b2e44c407
commit
28021b5047
2 changed files with 18 additions and 9 deletions
|
@ -1527,14 +1527,14 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
int[] to = new int[]{R.id.account_pp, R.id.account_un};
|
int[] to = new int[]{R.id.account_pp, R.id.account_un};
|
||||||
String searchGroup = matcherMention.group();
|
String searchGroup = matcherMention.group();
|
||||||
AccountsVM accountsVM = new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class);
|
AccountsVM accountsVM = new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class);
|
||||||
MatrixCursor cursor = new MatrixCursor(new String[]{BaseColumns._ID,
|
accountsVM.searchAccounts(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, searchGroup, 10, false, false)
|
||||||
SearchManager.SUGGEST_COLUMN_ICON_1,
|
|
||||||
SearchManager.SUGGEST_COLUMN_TEXT_1});
|
|
||||||
accountsVM.searchAccounts(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, searchGroup, 5, false, false)
|
|
||||||
.observe(BaseMainActivity.this, accounts -> {
|
.observe(BaseMainActivity.this, accounts -> {
|
||||||
if (accounts == null) {
|
if (accounts == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MatrixCursor cursor = new MatrixCursor(new String[]{BaseColumns._ID,
|
||||||
|
SearchManager.SUGGEST_COLUMN_ICON_1,
|
||||||
|
SearchManager.SUGGEST_COLUMN_TEXT_1});
|
||||||
AccountsSearchTopBarAdapter cursorAdapter = new AccountsSearchTopBarAdapter(BaseMainActivity.this, accounts, R.layout.drawer_account_search, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
AccountsSearchTopBarAdapter cursorAdapter = new AccountsSearchTopBarAdapter(BaseMainActivity.this, accounts, R.layout.drawer_account_search, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
||||||
binding.toolbarSearch.setSuggestionsAdapter(cursorAdapter);
|
binding.toolbarSearch.setSuggestionsAdapter(cursorAdapter);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
@ -1562,8 +1562,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
String[] from = new String[]{SearchManager.SUGGEST_COLUMN_TEXT_1};
|
String[] from = new String[]{SearchManager.SUGGEST_COLUMN_TEXT_1};
|
||||||
int[] to = new int[]{R.id.tag_name};
|
int[] to = new int[]{R.id.tag_name};
|
||||||
String searchGroup = matcherTag.group();
|
String searchGroup = matcherTag.group();
|
||||||
MatrixCursor cursor = new MatrixCursor(new String[]{BaseColumns._ID,
|
|
||||||
SearchManager.SUGGEST_COLUMN_TEXT_1});
|
|
||||||
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, searchGroup, null,
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, searchGroup, null,
|
||||||
"hashtags", false, true, false, 0,
|
"hashtags", false, true, false, 0,
|
||||||
null, null, 10).observe(BaseMainActivity.this,
|
null, null, 10).observe(BaseMainActivity.this,
|
||||||
|
@ -1571,6 +1570,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
if (results == null || results.hashtags == null) {
|
if (results == null || results.hashtags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MatrixCursor cursor = new MatrixCursor(new String[]{BaseColumns._ID,
|
||||||
|
SearchManager.SUGGEST_COLUMN_TEXT_1});
|
||||||
TagSearchTopBarAdapter cursorAdapter = new TagSearchTopBarAdapter(BaseMainActivity.this, results.hashtags, R.layout.drawer_tag_search, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
TagSearchTopBarAdapter cursorAdapter = new TagSearchTopBarAdapter(BaseMainActivity.this, results.hashtags, R.layout.drawer_tag_search, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
||||||
binding.toolbarSearch.setSuggestionsAdapter(cursorAdapter);
|
binding.toolbarSearch.setSuggestionsAdapter(cursorAdapter);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
|
@ -14,6 +14,7 @@ package app.fedilab.android.mastodon.ui.drawer;
|
||||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
@ -30,6 +31,7 @@ import java.util.List;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.mastodon.activities.HashTagActivity;
|
import app.fedilab.android.mastodon.activities.HashTagActivity;
|
||||||
import app.fedilab.android.mastodon.client.entities.api.Tag;
|
import app.fedilab.android.mastodon.client.entities.api.Tag;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,9 +65,15 @@ public class TagSearchTopBarAdapter extends SimpleCursorAdapter {
|
||||||
if (tags != null && tags.size() > position) {
|
if (tags != null && tags.size() > position) {
|
||||||
Intent intent = new Intent(context, HashTagActivity.class);
|
Intent intent = new Intent(context, HashTagActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString(Helper.ARG_SEARCH_KEYWORD, tags.get(position).name.trim());
|
String tag = tags.get(position).name.trim().replace("#","");
|
||||||
intent.putExtras(b);
|
b.putString(Helper.ARG_SEARCH_KEYWORD, tag.trim());
|
||||||
context.startActivity(intent);
|
new CachedBundle(context).insertBundle(b, Helper.getCurrentAccount(context), bundleId -> {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
context.startActivity(intent);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue