Android Open Source - WeatherMate Search List Adapter






From Project

Back to project page WeatherMate.

License

The source code is released under:

Apache License

If you think the Android project WeatherMate 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

package com.brightr.weathermate.adapters;
/*www  . j  a  v a 2  s .c om*/
import java.util.ArrayList;

import com.brightr.weathermate.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SearchListAdapter extends BaseAdapter {

  Activity context;
  LayoutInflater inflater;
  int[] icons;
  ArrayList<String> locations;
  ArrayList<String> latitudes;
  ArrayList<String> longitudes;
  ArrayList<String> regions;
  ArrayList<String> countries;
  ArrayList<String> populations;
  char degree = '\u00B0';

  public SearchListAdapter(Activity context, ArrayList<String> countries,
      ArrayList<String> locations, ArrayList<String> populations,
      ArrayList<String> latitudes, ArrayList<String> longitudes,
      ArrayList<String> regions) {

    this.context = context;
    this.countries = countries;
    this.populations = populations;
    this.locations = locations;
    this.latitudes = latitudes;
    this.longitudes = longitudes;
    this.regions = regions;

    inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

  }

  @Override
  public int getCount() {

    return locations.size();
  }

  @Override
  public Object getItem(int position) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;
  }

  public class ViewHolder {

    ImageView icon;
    TextView location;
    TextView latitude;
    TextView longitude;
    TextView region;
    TextView country;
    TextView population;
    View header;
    TextView headerText;
  }

  @Override
  public View getView(int pos, View convertView, ViewGroup parent) {

    ViewHolder holder;

    if (convertView == null) {

      holder = new ViewHolder();
      convertView = inflater.inflate(R.layout.search_layout_row, null);
      holder.location = (TextView) convertView
          .findViewById(R.id.tvSearchLocationName);
      holder.latitude = (TextView) convertView
          .findViewById(R.id.tvSearchLocationLatitude);
      holder.longitude = (TextView) convertView
          .findViewById(R.id.tvSearchLocationLongitude);
      holder.region = (TextView) convertView
          .findViewById(R.id.tvSearchLocationRegion);
      holder.icon = (ImageView) convertView
          .findViewById(R.id.ivSearchLocationIcon);
      holder.country = (TextView) convertView
          .findViewById(R.id.tvSearchLocationCountry);
      holder.population = (TextView) convertView
          .findViewById(R.id.tvSearchLocationPopulation);
      holder.header = (View) convertView
          .findViewById(R.id.SearchHeaderLayout);
      holder.headerText = (TextView) holder.header
          .findViewById(R.id.FlightNameHeader);
      convertView.setTag(holder);

    }

    else

      holder = (ViewHolder) convertView.getTag();
    holder.location.setText(locations.get(pos));
    holder.latitude.setText("Latitude: " + latitudes.get(pos) + degree);
    holder.longitude.setText("Longitude: " + longitudes.get(pos) + degree);
    holder.region.setText("Region: " + regions.get(pos));
    holder.icon.setBackgroundResource(R.drawable.map_icon);
    holder.country.setText("Country: " + countries.get(pos));

    if (populations.get(pos).equals("0")) {

      holder.population.setText("Population: Not available  ");
    }

    else
      holder.population.setText("Population:  " + populations.get(pos));

    // holder.population.setVisibility(View.INVISIBLE);
    holder.headerText.setText(regions.get(pos));

    return convertView;
  }

}




Java Source Code List

.PullToRefreshListView.java
com.brightr.listeners.FlingGestureListener.java
com.brightr.listeners.OnFlingGestureListener.java
com.brightr.listeners.SimpleGestureFilter.java
com.brightr.weathermate.activities.LocationMapview.java
com.brightr.weathermate.activities.MainActivity.java
com.brightr.weathermate.activities.MyFlightsActivity.java
com.brightr.weathermate.activities.NewsViewerActivity.java
com.brightr.weathermate.activities.SearchLocationsActivity.java
com.brightr.weathermate.activities.SettingsActivity.java
com.brightr.weathermate.activities.SocialMediaActivity.java
com.brightr.weathermate.activities.WebsiteViewActivity.java
com.brightr.weathermate.adapters.FlightListAdapter.java
com.brightr.weathermate.adapters.LocationListAdapter.java
com.brightr.weathermate.adapters.MenuAdapter.java
com.brightr.weathermate.adapters.MyPagerAdapter.java
com.brightr.weathermate.adapters.NewsPagerAdapter.java
com.brightr.weathermate.adapters.SavedFlightsAdapter.java
com.brightr.weathermate.adapters.SearchListAdapter.java
com.brightr.weathermate.adapters.TweetAdapter.java
com.brightr.weathermate.adapters.WeatherAdapter.java
com.brightr.weathermate.databases.FlightStorage.java
com.brightr.weathermate.databases.LocationStorage.java
com.brightr.weathermate.databases.NewsStorage.java
com.brightr.weathermate.fragments.EntertainmentNewsFragment.java
com.brightr.weathermate.fragments.GeneralNewsFragment.java
com.brightr.weathermate.fragments.MainWeatherFragment.java
com.brightr.weathermate.fragments.MenuFragment.java
com.brightr.weathermate.fragments.PoliticalNewsFragment.java
com.brightr.weathermate.fragments.SidePanelFragment.java
com.brightr.weathermate.fragments.SportsNewsFragment.java
com.brightr.weathermate.parsers.FlightTrackingParser.java
com.brightr.weathermate.parsers.JSONParser.java
com.brightr.weathermate.parsers.JSONTrafficParser.java
com.brightr.weathermate.parsers.TwitterFeedParser.java
com.brightr.weathermate.providers.FlightTrackingProvider.java
com.brightr.weathermate.providers.LocationSearchProvider.java
com.brightr.weathermate.providers.TrafficIncidentProvider.java
com.brightr.weathermate.providers.WeatherProvider.java
com.brightr.weathermate.utils.AirlineNamesCollection.java
com.brightr.weathermate.views.CustomDialogPreference.java
com.brightr.weathermate.views.CustomPreferenceCategory.java