Back to project page SeeKampf.
The source code is released under:
GNU General Public License
If you think the Android project SeeKampf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.avedo.seekampf.fragments; /*from w ww.j a v a 2 s . c om*/ import net.avedo.seekampf.R; import net.avedo.seekampf.R.id; import net.avedo.seekampf.R.layout; import net.avedo.seekampf.R.string; import net.avedo.seekampf.core.CustomAdapter; import net.avedo.seekampf.core.RestDetailsActivity; import net.avedo.seekampf.models.Island; import net.avedo.seekampf.utils.Constants; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.TextView; public class IslandListFragment extends RestListFragment<Island> { public static final String TAG = "IslandList"; @Override protected String fetchServiceTag() { return TAG; } @Override protected void fetchServiceAdapter(Island[] islands) { adapter = new IslandAdapter(getActivity(), R.layout.island_row, islands); } @Override protected Class<Island[]> fetchServiceObjClass() { return Island[].class; } @Override protected String fetchServiceUrl() { return "https://www.seekampf.de/api/api2.php?server=" + settings.getString(res.getString(R.string.prefs_server_key), "1") + "&typ=inseln&orderby=punkte&dir=desc&free=false"; } @Override public void onListItemClick(ListView list, View view, int position, long id) { Intent intent = new Intent(getActivity(), RestDetailsActivity.class); intent.putExtra(Constants.INTENT_EXTRA_ID, id); intent.putExtra(Constants.INTENT_EXTRA_FRAGMENT, Constants.FRAGMENT_ISLAND_DETAILS); getActivity().startActivity(intent); } private class IslandAdapter extends CustomAdapter<Island> { public IslandAdapter(Context context, int resId, Island[] islands) { super(context, resId, islands); } @Override public View getView(int position, View convertView, ViewGroup parent) { super.getView(position, convertView, parent); if (convertView == null) { // Fetch the layout inflater ... LayoutInflater li = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // ... and load the island row layout. convertView = li.inflate(R.layout.island_row, null); } // Fetch the current island. Island island = getItem(position); // Fetch the island name field ... TextView islandName = (TextView) convertView.findViewById(R.id.islandName); // ... and initialize it.+ islandName.setText(island.getInselname()); // Fetch the island coordinates field ... TextView islandCoordinates = (TextView) convertView.findViewById(R.id.islandCoordinates); // ... and initialize it.+ islandCoordinates.setText(island.getKoordinaten()); // Fetch the island points field ... TextView islandPoints = (TextView) convertView.findViewById(R.id.islandPoints); // ... and initialize it.+ islandPoints.setText("" + island.getPunkte()); return convertView; } } }