mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +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); | ||||
|     }*/ | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 neslihanturan
						neslihanturan