mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Pass fragment context to PlaceRenderer.java'
This commit is contained in:
parent
307a0acb5d
commit
6517a175cb
3 changed files with 17 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package fr.free.nrw.commons.nearby;
|
package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
import com.pedrogomez.renderers.ListAdapteeCollection;
|
import com.pedrogomez.renderers.ListAdapteeCollection;
|
||||||
import com.pedrogomez.renderers.RVRendererAdapter;
|
import com.pedrogomez.renderers.RVRendererAdapter;
|
||||||
import com.pedrogomez.renderers.RendererBuilder;
|
import com.pedrogomez.renderers.RendererBuilder;
|
||||||
|
|
@ -9,13 +11,19 @@ import java.util.List;
|
||||||
|
|
||||||
class NearbyAdapterFactory {
|
class NearbyAdapterFactory {
|
||||||
|
|
||||||
|
private Fragment fragment;
|
||||||
|
|
||||||
NearbyAdapterFactory(){
|
NearbyAdapterFactory(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NearbyAdapterFactory(Fragment fragment) {
|
||||||
|
this.fragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
.bind(Place.class, new PlaceRenderer(fragment));
|
||||||
ListAdapteeCollection<Place> collection = new ListAdapteeCollection<>(
|
ListAdapteeCollection<Place> collection = new ListAdapteeCollection<>(
|
||||||
placeList != null ? placeList : Collections.emptyList());
|
placeList != null ? placeList : Collections.emptyList());
|
||||||
return new RVRendererAdapter<>(builder, collection);
|
return new RVRendererAdapter<>(builder, collection);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class NearbyListFragment extends DaggerFragment {
|
||||||
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
||||||
recyclerView = view.findViewById(R.id.listView);
|
recyclerView = view.findViewById(R.id.listView);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
adapterFactory = new NearbyAdapterFactory();
|
adapterFactory = new NearbyAdapterFactory(this);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.nearby;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.transition.TransitionManager;
|
import android.support.transition.TransitionManager;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
@ -42,12 +43,18 @@ class PlaceRenderer extends Renderer<Place> {
|
||||||
private View view;
|
private View view;
|
||||||
private static ArrayList<LinearLayout> openedItems;
|
private static ArrayList<LinearLayout> openedItems;
|
||||||
private Place place;
|
private Place place;
|
||||||
|
private Fragment fragment;
|
||||||
|
|
||||||
|
|
||||||
PlaceRenderer(){
|
PlaceRenderer(){
|
||||||
openedItems = new ArrayList<>();
|
openedItems = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlaceRenderer(Fragment fragment) {
|
||||||
|
this.fragment = fragment;
|
||||||
|
openedItems = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) {
|
protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) {
|
||||||
view = layoutInflater.inflate(R.layout.item_place, viewGroup, false);
|
view = layoutInflater.inflate(R.layout.item_place, viewGroup, false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue