Add .xml of nearby lit items

This commit is contained in:
neslihanturan 2017-12-12 21:44:31 +03:00 committed by maskara
parent a9a03e2036
commit f2edf158f6
4 changed files with 110 additions and 84 deletions

View file

@ -10,15 +10,18 @@ import java.util.Collections;
import java.util.List; import java.util.List;
class NearbyAdapterFactory { class NearbyAdapterFactory {
private PlaceRenderer.PlaceClickedListener listener; //private PlaceRenderer.PlaceClickedListener listener;
public static boolean isItemOpen = false;
NearbyAdapterFactory(@NonNull PlaceRenderer.PlaceClickedListener listener) { NearbyAdapterFactory(){
this.listener = listener; //@NonNull PlaceRenderer.PlaceClickedListener listener) {
//this.listener = listener;
} }
public RVRendererAdapter<Place> create(List<Place> placeList) { public RVRendererAdapter<Place> create(List<Place> placeList) {
RendererBuilder<Place> builder = new RendererBuilder<Place>() RendererBuilder<Place> builder = new RendererBuilder<Place>()
.bind(Place.class, new PlaceRenderer(listener)); //.bind(Place.class, new PlaceRenderer(listener));
.bind(Place.class, new PlaceRenderer());
ListAdapteeCollection<Place> collection = new ListAdapteeCollection<>( ListAdapteeCollection<Place> collection = new ListAdapteeCollection<>(
placeList != null ? placeList : Collections.<Place>emptyList()); placeList != null ? placeList : Collections.<Place>emptyList());
return new RVRendererAdapter<>(builder, collection); return new RVRendererAdapter<>(builder, collection);

View file

@ -56,7 +56,8 @@ public class NearbyListFragment extends Fragment {
View view = inflater.inflate(R.layout.fragment_nearby, container, false); View view = inflater.inflate(R.layout.fragment_nearby, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.listView); recyclerView = (RecyclerView) view.findViewById(R.id.listView);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
adapterFactory = new NearbyAdapterFactory(place -> NearbyInfoDialog.showYourself(getActivity(), place)); //adapterFactory = new NearbyAdapterFactory(place -> NearbyInfoDialog.showYourself(getActivity(), place));
adapterFactory = new NearbyAdapterFactory();
return view; return view;
} }

View file

@ -2,6 +2,8 @@ package fr.free.nrw.commons.nearby;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -20,26 +22,34 @@ import butterknife.ButterKnife;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
class PlaceRenderer extends Renderer<Place> { class PlaceRenderer extends Renderer<Place> {
//private static boolean isAnyItemOpen = false;
@BindView(R.id.tvName) TextView tvName; @BindView(R.id.tvName) TextView tvName;
@BindView(R.id.tvDesc) TextView tvDesc; @BindView(R.id.tvDesc) TextView tvDesc;
@BindView(R.id.distance) TextView distance; @BindView(R.id.distance) TextView distance;
@BindView(R.id.icon) ImageView icon; @BindView(R.id.icon) ImageView icon;
@BindView(R.id.buttonLayout) @BindView(R.id.buttonLayout) LinearLayout buttonLayout;
LinearLayout buttonLayout;
private Animation animationUp; private Animation animationUp;
private Animation animationDown; private Animation animationDown;
private final int COUNTDOWN_RUNNING_TIME = 300;
private View view;
private final int COUNTDOWN_RUNNING_TIME = 500;
private static ArrayList<LinearLayout> openedItems; private static ArrayList<LinearLayout> openedItems;
//private final PlaceClickedListener listener;
PlaceRenderer(){ PlaceRenderer(){
//@NonNull PlaceClickedListener listener) {
Log.d("nesli","renderer created");
openedItems = new ArrayList<>(); openedItems = new ArrayList<>();
//this.listener = listener;
} }
@Override @Override
protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) { protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return layoutInflater.inflate(R.layout.item_place, viewGroup, false); view = layoutInflater.inflate(R.layout.item_place, viewGroup, false);
return view;
} }
@Override @Override
@ -51,9 +61,11 @@ class PlaceRenderer extends Renderer<Place> {
@Override @Override
protected void hookListeners(View view) { protected void hookListeners(View view) {
final View.OnClickListener listener = new View.OnClickListener() { final View.OnClickListener listener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Log.d("Renderer", "clicked");
if(buttonLayout.isShown()){ if(buttonLayout.isShown()){
closeLayout(buttonLayout); closeLayout(buttonLayout);
}else { }else {
@ -76,11 +88,10 @@ class PlaceRenderer extends Renderer<Place> {
}); });
} }
private void closeLayout(LinearLayout buttonLayout) { private void closeLayout(LinearLayout buttonLayout){
//openedItems.remove(buttonLayout);
buttonLayout.startAnimation(animationUp); buttonLayout.startAnimation(animationUp);
CountDownTimer countDownTimerStatic = new CountDownTimer(COUNTDOWN_RUNNING_TIME CountDownTimer countDownTimerStatic = new CountDownTimer(COUNTDOWN_RUNNING_TIME, 16) {
, 16) {
@Override @Override
public void onTick(long millisUntilFinished) { public void onTick(long millisUntilFinished) {
} }
@ -88,6 +99,7 @@ class PlaceRenderer extends Renderer<Place> {
@Override @Override
public void onFinish() { public void onFinish() {
buttonLayout.setVisibility(View.GONE); buttonLayout.setVisibility(View.GONE);
//buttonLayout.setVisibility(View.GONE);
} }
}; };
countDownTimerStatic.start(); countDownTimerStatic.start();
@ -95,7 +107,9 @@ class PlaceRenderer extends Renderer<Place> {
private void openLayout(LinearLayout buttonLayout){ private void openLayout(LinearLayout buttonLayout){
buttonLayout.setVisibility(View.VISIBLE); buttonLayout.setVisibility(View.VISIBLE);
ViewCompat.setElevation( view, 10);
buttonLayout.startAnimation(animationDown); buttonLayout.startAnimation(animationDown);
//openedItems.add(buttonLayout);
} }
@Override @Override
@ -110,4 +124,8 @@ class PlaceRenderer extends Renderer<Place> {
distance.setText(place.distance); distance.setText(place.distance);
icon.setImageResource(place.getLabel().getIcon()); icon.setImageResource(place.getLabel().getIcon());
} }
/*interface PlaceClickedListener {
void onPlaceOpened(Place place);
}*/
} }

View file

@ -3,7 +3,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:foreground="?selectableItemBackground"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:minHeight="72dp"> android:minHeight="72dp">
@ -41,7 +40,7 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
app:srcCompat="@drawable/ic_keyboard_arrow_right_black_24dp"
/> />
<TextView <TextView
@ -81,8 +80,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/buttonLayout" android:id="@+id/buttonLayout"
android:orientation="horizontal" android:orientation="vertical"
android:visibility="visible" android:visibility="gone"
android:layout_below="@+id/icon" android:layout_below="@+id/icon"
> >
@ -92,12 +91,16 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="72dp" android:layout_marginLeft="72dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:layout_marginBottom="16dp" android:layout_marginTop="16dp"
android:textSize="16sp" android:textSize="16sp"
android:text="Description Description Description android:text="Description Description Description
Description Description Description Description Description Description
Description Description Description Description Description Description
" /> " />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout <LinearLayout
android:id="@+id/directionsButton" android:id="@+id/directionsButton"
@ -169,4 +172,5 @@ Description Description Description
/> />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout>
</RelativeLayout> </RelativeLayout>