mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Add .xml of nearby lit items
This commit is contained in:
parent
31c31d7458
commit
a1b6b76101
4 changed files with 113 additions and 86 deletions
|
|
@ -10,17 +10,20 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
class NearbyAdapterFactory {
|
||||
private PlaceRenderer.PlaceClickedListener listener;
|
||||
//private PlaceRenderer.PlaceClickedListener listener;
|
||||
public static boolean isItemOpen = false;
|
||||
|
||||
NearbyAdapterFactory(@NonNull PlaceRenderer.PlaceClickedListener listener) {
|
||||
this.listener = listener;
|
||||
NearbyAdapterFactory(){
|
||||
//@NonNull PlaceRenderer.PlaceClickedListener listener) {
|
||||
//this.listener = listener;
|
||||
}
|
||||
|
||||
public RVRendererAdapter<Place> create(List<Place> placeList) {
|
||||
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<>(
|
||||
placeList != null ? placeList : Collections.<Place>emptyList());
|
||||
return new RVRendererAdapter<>(builder, collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby;
|
|||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -16,13 +17,12 @@ import java.lang.reflect.Type;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import dagger.android.support.DaggerFragment;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.utils.UriDeserializer;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class NearbyListFragment extends DaggerFragment {
|
||||
public class NearbyListFragment extends Fragment {
|
||||
private static final Type LIST_TYPE = new TypeToken<List<Place>>() {
|
||||
}.getType();
|
||||
private static final Type CUR_LAT_LNG_TYPE = new TypeToken<LatLng>() {
|
||||
|
|
@ -48,7 +48,8 @@ public class NearbyListFragment extends DaggerFragment {
|
|||
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.listView);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -71,4 +72,4 @@ public class NearbyListFragment extends DaggerFragment {
|
|||
|
||||
recyclerView.setAdapter(adapterFactory.create(placeList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package fr.free.nrw.commons.nearby;
|
|||
|
||||
import android.os.CountDownTimer;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -20,26 +22,34 @@ import butterknife.ButterKnife;
|
|||
import fr.free.nrw.commons.R;
|
||||
|
||||
class PlaceRenderer extends Renderer<Place> {
|
||||
//private static boolean isAnyItemOpen = false;
|
||||
|
||||
@BindView(R.id.tvName) TextView tvName;
|
||||
@BindView(R.id.tvDesc) TextView tvDesc;
|
||||
@BindView(R.id.distance) TextView distance;
|
||||
@BindView(R.id.icon) ImageView icon;
|
||||
@BindView(R.id.buttonLayout)
|
||||
LinearLayout buttonLayout;
|
||||
@BindView(R.id.buttonLayout) LinearLayout buttonLayout;
|
||||
private Animation animationUp;
|
||||
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 final PlaceClickedListener listener;
|
||||
|
||||
PlaceRenderer(){
|
||||
//@NonNull PlaceClickedListener listener) {
|
||||
Log.d("nesli","renderer created");
|
||||
openedItems = new ArrayList<>();
|
||||
//this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
|
@ -51,9 +61,11 @@ class PlaceRenderer extends Renderer<Place> {
|
|||
|
||||
@Override
|
||||
protected void hookListeners(View view) {
|
||||
|
||||
final View.OnClickListener listener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.d("Renderer", "clicked");
|
||||
if(buttonLayout.isShown()){
|
||||
closeLayout(buttonLayout);
|
||||
}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);
|
||||
CountDownTimer countDownTimerStatic = new CountDownTimer(COUNTDOWN_RUNNING_TIME
|
||||
, 16) {
|
||||
CountDownTimer countDownTimerStatic = new CountDownTimer(COUNTDOWN_RUNNING_TIME, 16) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
}
|
||||
|
|
@ -88,6 +99,7 @@ class PlaceRenderer extends Renderer<Place> {
|
|||
@Override
|
||||
public void onFinish() {
|
||||
buttonLayout.setVisibility(View.GONE);
|
||||
//buttonLayout.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
countDownTimerStatic.start();
|
||||
|
|
@ -95,7 +107,9 @@ class PlaceRenderer extends Renderer<Place> {
|
|||
|
||||
private void openLayout(LinearLayout buttonLayout){
|
||||
buttonLayout.setVisibility(View.VISIBLE);
|
||||
ViewCompat.setElevation( view, 10);
|
||||
buttonLayout.startAnimation(animationDown);
|
||||
//openedItems.add(buttonLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -109,5 +123,10 @@ class PlaceRenderer extends Renderer<Place> {
|
|||
tvDesc.setText(descriptionText);
|
||||
distance.setText(place.distance);
|
||||
icon.setImageResource(place.getDescription().getIcon());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*interface PlaceClickedListener {
|
||||
void onPlaceOpened(Place place);
|
||||
}*/
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:foreground="?selectableItemBackground"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minHeight="72dp">
|
||||
|
||||
|
|
@ -41,7 +40,7 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_right_black_24dp"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
|
|
@ -81,8 +80,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/buttonLayout"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:layout_below="@+id/icon"
|
||||
>
|
||||
|
||||
|
|
@ -92,81 +91,86 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="16sp"
|
||||
android:text="Description Description Description
|
||||
Description Description Description
|
||||
Description Description Description
|
||||
" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/directionsButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/ic_directions_black_48dp" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="DIRECTIONS"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/wikidataButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/ic_wikidata_logo_48dp" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="WIKI DATA"
|
||||
/>
|
||||
</LinearLayout>
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/wikipediaButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/directionsButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/ic_wikipedia_logo_48dp"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/ic_directions_black_48dp" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="DIRECTIONS"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/wikidataButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="WIKIPEDIA"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/ic_wikidata_logo_48dp" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="WIKI DATA"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
/>
|
||||
<LinearLayout
|
||||
android:id="@+id/wikipediaButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/ic_wikipedia_logo_48dp"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="WIKIPEDIA"
|
||||
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue