mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fix style issues
This commit is contained in:
parent
78368a2c0c
commit
2204f70255
4 changed files with 34 additions and 45 deletions
|
|
@ -12,6 +12,8 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -25,14 +27,24 @@ public class NearbyFilterSearchRecyclerViewAdapter
|
|||
|
||||
private final LayoutInflater inflater;
|
||||
private Context context;
|
||||
private RecyclerView recyclerView;
|
||||
private ArrayList<Label> labels;
|
||||
private ArrayList<Label> displayedLabels;
|
||||
private ArrayList<Label> selectedLabels = new ArrayList<>();
|
||||
|
||||
public NearbyFilterSearchRecyclerViewAdapter(Context context, ArrayList<Label> labels) {
|
||||
RecyclerView.SmoothScroller smoothScroller;
|
||||
|
||||
public NearbyFilterSearchRecyclerViewAdapter(Context context, ArrayList<Label> labels, RecyclerView recyclerView) {
|
||||
this.context = context;
|
||||
this.labels = labels;
|
||||
this.displayedLabels = labels;
|
||||
this.recyclerView = recyclerView;
|
||||
smoothScroller = new
|
||||
LinearSmoothScroller(context) {
|
||||
@Override protected int getVerticalSnapPreference() {
|
||||
return LinearSmoothScroller.SNAP_TO_START;
|
||||
}
|
||||
};
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
|
|
@ -62,17 +74,24 @@ public class NearbyFilterSearchRecyclerViewAdapter
|
|||
holder.placeTypeIcon.setImageResource(label.getIcon());
|
||||
holder.placeTypeLabel.setText(label.toString());
|
||||
|
||||
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? Color.BLUE : Color.WHITE);
|
||||
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? ContextCompat.getColor(context, R.color.divider_grey) : Color.WHITE);
|
||||
holder.placeTypeLayout.setOnClickListener(view -> {
|
||||
if (label.isSelected()) {
|
||||
selectedLabels.remove(label);
|
||||
} else {
|
||||
selectedLabels.add(label);
|
||||
displayedLabels.remove(label);
|
||||
displayedLabels.add(selectedLabels.size()-1, label);
|
||||
notifyDataSetChanged();
|
||||
smoothScroller.setTargetPosition(0);
|
||||
recyclerView.getLayoutManager().startSmoothScroll(smoothScroller);
|
||||
}
|
||||
label.setSelected(!label.isSelected());
|
||||
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? Color.BLUE : Color.WHITE);
|
||||
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? ContextCompat.getColor(context, R.color.divider_grey) : Color.WHITE);
|
||||
NearbyParentFragmentPresenter.getInstance().filterByMarkerType(selectedLabels);
|
||||
});
|
||||
|
||||
//TODO: recover current location marker if selection is empty
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -125,33 +144,4 @@ public class NearbyFilterSearchRecyclerViewAdapter
|
|||
}
|
||||
};
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
if (convertView == null) {
|
||||
|
||||
convertView = inflater.inflate(R.layout.nearby_search_list_item, null);
|
||||
|
||||
viewHolder = new RecyclerViewHolder();
|
||||
viewHolder.placeTypeLabel = convertView.findViewById(R.id.place_text);
|
||||
viewHolder.placeTypeIcon = convertView.findViewById(R.id.place_icon);
|
||||
convertView.setTag(viewHolder);
|
||||
|
||||
}
|
||||
else{
|
||||
//Get viewholder we already created
|
||||
viewHolder = (RecyclerViewHolder)convertView.getTag();
|
||||
}
|
||||
|
||||
Label label = displayedLabels.get(position);
|
||||
if(label != null){
|
||||
viewHolder.placeTypeIcon.setImageResource(label.getIcon());
|
||||
viewHolder.placeTypeLabel.setText(label.toString());
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -122,7 +121,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
@BindView(R.id.choice_chip_exists) Chip chipExists;
|
||||
@BindView(R.id.choice_chip_needs_photo) Chip chipNeedsPhoto;
|
||||
@BindView(R.id.search_view) SearchView searchView;
|
||||
@BindView(R.id.search_list_view) RecyclerView searchListView;
|
||||
@BindView(R.id.search_list_view) RecyclerView recyclerView;
|
||||
@BindView(R.id.nearby_filter_list) View nearbyFilterList;
|
||||
|
||||
@Inject LocationServiceManager locationManager;
|
||||
|
|
@ -202,26 +201,26 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
|
||||
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
|
||||
if (hasFocus) {
|
||||
//Log.d("deneme33","11-"+searchListView.getAdapter().getCount());
|
||||
//Log.d("deneme33","11-"+recyclerView.getAdapter().getCount());
|
||||
nearbyFilterList.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
// Log.d("deneme33","22-"+searchListView.getAdapter().getCount());
|
||||
// Log.d("deneme33","22-"+recyclerView.getAdapter().getCount());
|
||||
nearbyFilterList.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
searchListView.setHasFixedSize(true);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
searchListView.setLayoutManager(linearLayoutManager);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
NearbyFilterSearchRecyclerViewAdapter nearbyFilterSearchRecyclerViewAdapter
|
||||
= new NearbyFilterSearchRecyclerViewAdapter(getContext(),new ArrayList<>(TEXT_TO_DESCRIPTION.values()));
|
||||
= new NearbyFilterSearchRecyclerViewAdapter(getContext(),new ArrayList<>(TEXT_TO_DESCRIPTION.values()), recyclerView);
|
||||
nearbyFilterList.getLayoutParams().width = (int) LayoutUtils.getScreenWidth(getActivity(), 0.75);
|
||||
searchListView.setAdapter(nearbyFilterSearchRecyclerViewAdapter);
|
||||
recyclerView.setAdapter(nearbyFilterSearchRecyclerViewAdapter);
|
||||
LayoutUtils.setLayoutHeightAllignedToWidth(1, nearbyFilterList);
|
||||
/*searchListView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
/*recyclerView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
Log.d("deneme33","item clicked:"+ nearbyFilterSearchRecyclerViewAdapter.get(position).toString());
|
||||
nearbyParentFragmentPresenter.filterByMarkerType(nearbyFilterSearchRecyclerViewAdapter.getItem(position).toString());
|
||||
});*/
|
||||
|
|
@ -231,7 +230,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
.debounce(500, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe( query -> {
|
||||
((NearbyFilterSearchRecyclerViewAdapter)searchListView.getAdapter()).getFilter().filter(query.toString());
|
||||
((NearbyFilterSearchRecyclerViewAdapter) recyclerView.getAdapter()).getFilter().filter(query.toString());
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/nearby_filter_list_layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:elevation="8dp"
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/search_list_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/place_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue