Android Open Source - open311-android Servers Adapter From Project Back to project page open311-android .
License The source code is released under:
GNU General Public License
If you think the Android project open311-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code /**
* @copyright 2012 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/gpl.txt GNU/GPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/ / / w w w . j a v a 2 s . c o m
package gov.in.bloomington.georeporter.adapters;
import gov.in.bloomington.georeporter.R;
import gov.in.bloomington.georeporter.models.Open311;
import gov.in.bloomington.georeporter.models.Preferences;
import gov.in.bloomington.georeporter.util.json.JSONArray;
import gov.in.bloomington.georeporter.util.json.JSONObject;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RadioButton;
import android.widget.TextView;
public class ServersAdapter extends BaseAdapter {
private JSONArray mServers;
private static LayoutInflater mInflater;
private String mCurrentServerName;
public ServersAdapter(JSONArray d, Context c) {
mServers = d;
mInflater = LayoutInflater.from(c);
JSONObject currentServer = Preferences.getCurrentServer(c);
mCurrentServerName = currentServer==null ? "" : currentServer.optString(Open311.NAME);
}
@Override
public int getCount() {
return (mServers == null) ? 0 : mServers.length();
}
@Override
public JSONObject getItem(int position) {
return mServers.optJSONObject(position);
}
@Override
public long getItemId(int position) {
return position;
}
private static class ViewHolder {
public TextView name, url;
public RadioButton radio;
}
/* (non-Javadoc)
* @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_servers, null);
holder = new ViewHolder();
holder.name = (TextView)convertView.findViewById(android.R.id.text1);
holder.url = (TextView)convertView.findViewById(android.R.id.text2);
holder.radio = (RadioButton)convertView.findViewById(R.id.radio);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
String name = mServers.optJSONObject(position).optString(Open311.NAME);
String url = mServers.optJSONObject(position).optString(Open311.URL);
if (name.equals(mCurrentServerName)) {
holder.radio.setChecked(true);
}
else {
holder.radio.setChecked(false);
}
holder.name.setText(name);
holder.url .setText(url);
return convertView;
}
}
Java Source Code List android.UnusedStub.java gov.in.bloomington.georeporter.activities.AboutActivity.java gov.in.bloomington.georeporter.activities.AttributeEntryActivity.java gov.in.bloomington.georeporter.activities.BaseActivity.java gov.in.bloomington.georeporter.activities.ChooseLocationActivity.java gov.in.bloomington.georeporter.activities.DataEntryActivity.java gov.in.bloomington.georeporter.activities.MainActivity.java gov.in.bloomington.georeporter.activities.ReportActivity.java gov.in.bloomington.georeporter.activities.SavedReportsActivity.java gov.in.bloomington.georeporter.activities.SettingsActivity.java gov.in.bloomington.georeporter.adapters.GroupsAdapter.java gov.in.bloomington.georeporter.adapters.PersonalInfoAdapter.java gov.in.bloomington.georeporter.adapters.SavedReportsAdapter.java gov.in.bloomington.georeporter.adapters.ServersAdapter.java gov.in.bloomington.georeporter.adapters.ServiceRequestAdapter.java gov.in.bloomington.georeporter.adapters.ServicesAdapter.java gov.in.bloomington.georeporter.fragments.ChooseGroupFragment.java gov.in.bloomington.georeporter.fragments.ChooseServiceFragment.java gov.in.bloomington.georeporter.fragments.PersonalInfoFragment.java gov.in.bloomington.georeporter.fragments.ReportFragment.java gov.in.bloomington.georeporter.fragments.SavedReportViewFragment.java gov.in.bloomington.georeporter.fragments.SavedReportsListFragment.java gov.in.bloomington.georeporter.fragments.ServersFragment.java gov.in.bloomington.georeporter.models.Open311Exception.java gov.in.bloomington.georeporter.models.Open311.java gov.in.bloomington.georeporter.models.Preferences.java gov.in.bloomington.georeporter.models.ServiceRequest.java gov.in.bloomington.georeporter.util.Media.java gov.in.bloomington.georeporter.util.Open311Parser.java gov.in.bloomington.georeporter.util.Open311XmlParser.java gov.in.bloomington.georeporter.util.Util.java gov.in.bloomington.georeporter.util.json.CDL.java gov.in.bloomington.georeporter.util.json.CookieList.java gov.in.bloomington.georeporter.util.json.Cookie.java gov.in.bloomington.georeporter.util.json.HTTPTokener.java gov.in.bloomington.georeporter.util.json.HTTP.java gov.in.bloomington.georeporter.util.json.JSONArray.java gov.in.bloomington.georeporter.util.json.JSONException.java gov.in.bloomington.georeporter.util.json.JSONML.java gov.in.bloomington.georeporter.util.json.JSONObject.java gov.in.bloomington.georeporter.util.json.JSONString.java gov.in.bloomington.georeporter.util.json.JSONStringer.java gov.in.bloomington.georeporter.util.json.JSONTokener.java gov.in.bloomington.georeporter.util.json.JSONWriter.java gov.in.bloomington.georeporter.util.json.XMLTokener.java gov.in.bloomington.georeporter.util.json.XML.java