mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Add Name and Desc fields, attractions->places
This commit is contained in:
parent
e7032658a2
commit
613f0bc6ad
2 changed files with 17 additions and 20 deletions
|
|
@ -3,21 +3,15 @@ package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Adapter;
|
import android.widget.Adapter;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListAdapter;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
@ -59,7 +53,7 @@ public class NearbyListFragment extends ListFragment {
|
||||||
//TODO: Original is an AttractionAdapter. Not a CursorAdapter.
|
//TODO: Original is an AttractionAdapter. Not a CursorAdapter.
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
// We pass null for the cursor, then update it in onLoadFinished()
|
// We pass null for the cursor, then update it in onLoadFinished()
|
||||||
mAdapter = new NearbyAdapter();
|
mAdapter = new NearbyAdapter(getActivity(), );
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
// Prepare the loader. Either re-connect with an existing one,
|
// Prepare the loader. Either re-connect with an existing one,
|
||||||
|
|
@ -74,29 +68,32 @@ public class NearbyListFragment extends ListFragment {
|
||||||
|
|
||||||
private class NearbyAdapter extends ArrayAdapter {
|
private class NearbyAdapter extends ArrayAdapter {
|
||||||
|
|
||||||
public List<Place> mAttractionList;
|
public List<Place> placesList;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public NearbyAdapter(Context context, List<Place> attractions) {
|
public NearbyAdapter(Context context, List<Place> places) {
|
||||||
super(context, R.layout.item_place);
|
super(context, 0);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAttractionList = attractions;
|
placesList = places;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
// Get the data item for this position
|
// Get the data item for this position
|
||||||
User user = getItem(position);
|
Place place = (Place) getItem(position);
|
||||||
// Check if an existing view is being reused, otherwise inflate the view
|
// Check if an existing view is being reused, otherwise inflate the view
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_user, parent, false);
|
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_place, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup view for data population
|
// Lookup view for data population
|
||||||
TextView tvName = (TextView) convertView.findViewById(R.id.tvName);
|
TextView tvName = (TextView) convertView.findViewById(R.id.tvName);
|
||||||
TextView tvHome = (TextView) convertView.findViewById(R.id.tvHome);
|
TextView tvDesc = (TextView) convertView.findViewById(R.id.tvDesc);
|
||||||
|
|
||||||
// Populate the data into the template view using the data object
|
// Populate the data into the template view using the data object
|
||||||
tvName.setText(user.name);
|
tvName.setText(place.name);
|
||||||
tvHome.setText(user.hometown);
|
tvDesc.setText(place.description);
|
||||||
|
|
||||||
// Return the completed view to render on screen
|
// Return the completed view to render on screen
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +107,7 @@ public class NearbyListFragment extends ListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
Attraction attraction = mAttractionList.get(position);
|
Attraction attraction = placesList.get(position);
|
||||||
|
|
||||||
holder.mTitleTextView.setText(attraction.name);
|
holder.mTitleTextView.setText(attraction.name);
|
||||||
holder.mDescriptionTextView.setText(attraction.description);
|
holder.mDescriptionTextView.setText(attraction.description);
|
||||||
|
|
@ -138,7 +135,7 @@ public class NearbyListFragment extends ListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mAttractionList == null ? 0 : mAttractionList.size();
|
return placesList == null ? 0 : placesList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Name" />
|
android:text="Name" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvHome"
|
android:id="@+id/tvDesc"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="HomeTown" />
|
android:text="Desc" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue