mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Search drafts (#574)
Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts Merge branch 'master' into search-drafts # Conflicts: # app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java search drafts Co-authored-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/574 Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
parent
e00fcd846a
commit
e6109ef36d
@ -125,4 +125,11 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
public void updateList(List<DraftWithRepository> list) {
|
||||
|
||||
draftsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,13 @@ import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@ -131,8 +134,49 @@ public class DraftsFragment extends Fragment {
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
((SearchView) searchView).setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
filter(newText);
|
||||
return false;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<DraftWithRepository> arr = new ArrayList<>();
|
||||
|
||||
for(DraftWithRepository d : draftsList_) {
|
||||
|
||||
if(d == null || d.getRepositoryOwner() == null || d.getRepositoryName() == null || d.getDraftText() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(d.getRepositoryOwner().toLowerCase().contains(text) || d.getRepositoryName().toLowerCase().contains(text)
|
||||
|| d.getDraftText().toLowerCase().contains(text) || String.valueOf(d.getIssueId()).contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user