@Override
  public View getView(int position, View view, ViewGroup parent) {
    // Index in cities list
    int index = position * 2;
    if (index < 0 || index >= mCitiesList.length) {
      return null;
    }

    if (view == null) {
      view = mInflater.inflate(R.layout.world_clock_list_item, parent, false);
    }
    // The world clock list item can hold two world clocks
    View rightClock = view.findViewById(R.id.city_right);
    updateView(view.findViewById(R.id.city_left), (CityObj) mCitiesList[index]);
    if (index + 1 < mCitiesList.length) {
      rightClock.setVisibility(View.VISIBLE);
      updateView(rightClock, (CityObj) mCitiesList[index + 1]);
    } else {
      // To make sure the spacing is right , make sure that the right clock style is selected
      // even if the clock is invisible.
      DigitalClock dclock = (DigitalClock) (rightClock.findViewById(R.id.digital_clock));
      AnalogClock aclock = (AnalogClock) (rightClock.findViewById(R.id.analog_clock));
      if (mClockStyle.equals("analog")) {
        dclock.setVisibility(View.GONE);
        aclock.setVisibility(View.INVISIBLE);
      } else {
        dclock.setVisibility(View.INVISIBLE);
        aclock.setVisibility(View.GONE);
      }
      rightClock.setVisibility(View.INVISIBLE);
    }

    return view;
  }
  private void updateView(View clock, CityObj cityObj) {
    View nameLayout = clock.findViewById(R.id.city_name_layout);
    TextView name = (TextView) (nameLayout.findViewById(R.id.city_name));
    TextView dayOfWeek = (TextView) (nameLayout.findViewById(R.id.city_day));
    DigitalClock dclock = (DigitalClock) (clock.findViewById(R.id.digital_clock));
    AnalogClock aclock = (AnalogClock) (clock.findViewById(R.id.analog_clock));

    if (mClockStyle.equals("analog")) {
      dclock.setVisibility(View.GONE);
      aclock.setVisibility(View.VISIBLE);
      aclock.setTimeZone(cityObj.mTimeZone);
      aclock.enableSeconds(false);
    } else {
      dclock.setVisibility(View.VISIBLE);
      aclock.setVisibility(View.GONE);
      dclock.setTimeZone(cityObj.mTimeZone);
    }
    CityObj cityInDb = mCitiesDb.get(cityObj.mCityId);
    // Home city or city not in DB , use data from the save selected cities list
    name.setText(Utils.getCityName(cityObj, cityInDb));

    final Calendar now = Calendar.getInstance();
    now.setTimeZone(TimeZone.getDefault());
    int myDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
    // Get timezone from cities DB if available
    String cityTZ = (cityInDb != null) ? cityInDb.mTimeZone : cityObj.mTimeZone;
    now.setTimeZone(TimeZone.getTimeZone(cityTZ));
    int cityDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
    if (myDayOfWeek != cityDayOfWeek) {
      dayOfWeek.setText(
          mContext.getString(
              R.string.world_day_of_week_label,
              now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault())));
      dayOfWeek.setVisibility(View.VISIBLE);
    } else {
      dayOfWeek.setVisibility(View.GONE);
    }
  }