Skip to content

Commit

Permalink
Merge pull request #28 from ranobe-org/feat/search-ui
Browse files Browse the repository at this point in the history
updated the search bar ui
  • Loading branch information
ap-atul authored Aug 2, 2023
2 parents be067f5 + f9c600d commit 83d6561
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
.cxx
local.properties
/app/release/
.idea
.idea
beta/
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions app/src/main/java/org/ranobe/ranobe/ui/search/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Search extends Fragment implements NovelAdapter.OnNovelItemClickListener {
private FragmentSearchBinding binding;
Expand All @@ -54,7 +55,7 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = FragmentSearchBinding.inflate(inflater, container, false);
binding.submit.setOnClickListener(v -> searchNovels());
binding.searchView.setEndIconOnClickListener(v -> searchNovels());
binding.resultList.setLayoutManager(new LinearLayoutManager(requireActivity()));

results = new LinkedHashMap<>();
Expand Down Expand Up @@ -107,11 +108,11 @@ public void onNovelItemClick(Novel item) {
}

public class SearchResultAdapter extends RecyclerView.Adapter<SearchResultAdapter.MyViewHolder> {
private final HashMap<DataSource, List<Novel>> results;
private final Map<DataSource, List<Novel>> results;
private final NovelAdapter.OnNovelItemClickListener listener;
private final SpacingDecorator spacingDecorator = new SpacingDecorator(10);

public SearchResultAdapter(HashMap<DataSource, List<Novel>> results, Search listener) {
public SearchResultAdapter(Map<DataSource, List<Novel>> results, Search listener) {
this.results = results;
this.listener = listener;
}
Expand All @@ -130,7 +131,7 @@ public void onBindViewHolder(@NonNull SearchResultAdapter.MyViewHolder holder, i

List<Novel> novels = results.get(source);
if (novels == null) return;
if (novels.size() > 0) {
if (!novels.isEmpty()) {
holder.binding.rootLayout.setVisibility(View.VISIBLE);
}

Expand Down
16 changes: 7 additions & 9 deletions app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:baselineAligned="false"
android:orientation="horizontal">

<com.google.android.material.textfield.TextInputLayout
Expand All @@ -27,6 +28,12 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:boxCornerRadiusTopStart="@dimen/radius"
app:boxCornerRadiusTopEnd="@dimen/radius"
app:boxCornerRadiusBottomStart="@dimen/radius"
app:boxCornerRadiusBottomEnd="@dimen/radius"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_search"
app:helperText="what are you looking for?"
app:placeholderText="@string/start_typing">

Expand All @@ -39,15 +46,6 @@
android:lines="1" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/submit"
style="@style/Widget.Material3.Button.IconButton.Outlined"
android:layout_width="55dp"
android:layout_height="55dp"
app:cornerRadius="5dp"
app:icon="@drawable/ic_search"
app:iconGravity="textStart" />

</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<dimen name="text_med">14sp</dimen>
<dimen name="text_big">15sp</dimen>
<dimen name="text_head">18sp</dimen>
<dimen name="radius">10dp</dimen>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
<string name="new_version_available">A new version of the app is available</string>
<string name="update">Update</string>
<string name="swipe_tip">Tip: Swipe to mark as read/unread</string>
<string name="marking_as_read_toast">Marking as read</string>
<string name="marking_as_unread_toast">Marking as unread</string>
<string name="continue_btn">Continue</string>

</resources>

0 comments on commit 83d6561

Please sign in to comment.