/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.talonso.sunshine;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Date;

public class ForecastAdapter extends CursorAdapter {
    public ForecastAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
    }

    /*
        Remember that these views are reused as needed.
     */
    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.list_item_forecast, parent, false);

        return view;
    }

    /*
        This is where we fill-in the views with the contents of the cursor.
     */
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        // Read weather icon ID from cursor
        int weatherId = cursor.getInt(ForecastFragment.COL_WEATHER_ID);
        // Use placeholder image for now
        ImageView iconView = (ImageView) view.findViewById(R.id.list_item_icon);
        iconView.setImageResource(R.drawable.ic_launcher);

        // Read date from cursor
        long dateinMillis = cursor.getLong(ForecastFragment.COL_WEATHER_DATE);
        // Find TextView and set formatted date on it
        TextView dateView = (TextView) view.findViewById(R.id.list_item_date_textview);
        dateView.setText(Utility.getFriendlyDayString(context, dateinMillis));

        // Read weather forecast from cursor
        String description = cursor.getString(ForecastFragment.COL_WEATHER_DESC);
        // Find TextView and set weather forecast on it
        TextView descriptionView = (TextView) view.findViewById(R.id.list_item_forecast_textview);
        descriptionView.setText(description);

        // Read user preference for metric or imperial temperature units
        boolean isMetric = Utility.isMetric(context);

        // Read high temperature from cursor
        double high = cursor.getDouble(ForecastFragment.COL_WEATHER_MAX_TEMP);
        TextView highView = (TextView) view.findViewById(R.id.list_item_high_textview);
        highView.setText(Utility.formatTemperature(high, isMetric));
    }
}
@@ -1027,24 +1027,121 @@
 rAdapter %7B%0D%0A
+%0D%0A    private final int VIEW_TYPE_TODAY = 0;%0D%0A    private final int VIEW_TYPE_FUTURE_DAY = 1;%0D%0A%0D%0A
     public F
@@ -1232,32 +1232,178 @@
 ags);%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A    public int getItemViewType(int position) %7B%0D%0A        return (position == 0) ? VIEW_TYPE_TODAY : VIEW_TYPE_FUTURE_DAY;%0D%0A    %7D%0D%0A%0D%0A
     /*%0D%0A        
@@ -1564,124 +1564,404 @@
     
-View view = LayoutInflater.from(context).inflate(R.layout.list_item_forecast, parent, false);%0D%0A%0D%0A        return view
+// Choose the layout type%0D%0A        int viewType = getItemViewType(cursor.getPosition());%0D%0A        int layoutId = -1;%0D%0A%0D%0A        View view = null;%0D%0A        if (viewType == 0) %7B%0D%0A            layoutId = R.layout.list_item_forecast_today;%0D%0A        %7D else %7B%0D%0A            layoutId = R.layout.list_item_forecast;%0D%0A        %7D%0D%0A%0D%0A        return LayoutInflater.from(context).inflate(layoutId, parent, false)
 ;%0D%0A 

Add an ability to define multiple layouts.