<commit_before>package com.example.assafg.sunshine.app;

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 com.example.assafg.sunshine.app.Utility.Utility;

/**
 * {@link ForecastAdapter} exposes a list of weather forecasts
 * from a {@link Cursor} to a {@link android.widget.ListView}.
 */
public class ForecastAdapter extends CursorAdapter {

  private static final int VIEW_TYPE_TODAY = 0;
  private static final int VIEW_TYPE_FUTURE_DAY = 1;
  private static final int VIEW_TYPE_COUNT = 2;
  private boolean mShouldUseTodayLayout;

  @Override
  public int getItemViewType(int position) {
    return position == 0 && mShouldUseTodayLayout ? VIEW_TYPE_TODAY : VIEW_TYPE_FUTURE_DAY;
  }

  public void setShouldUseTodayLayout(boolean shuoldUseTodayLayout) {
    mShouldUseTodayLayout = shuoldUseTodayLayout;
  }

  @Override
  public int getViewTypeCount() {
    return VIEW_TYPE_COUNT;
  }

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

  /**
   * Copy/paste note: Replace existing newView() method in ForecastAdapter with this one.
   */
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
    // Choose the layout type
    int viewType = getItemViewType(cursor.getPosition());
    int layoutId;

    if (viewType == VIEW_TYPE_TODAY) {
      layoutId = R.layout.list_item_forecast_today;
    } else {
      layoutId = R.layout.list_item_forecast;
    }

    View view = LayoutInflater.from(context).inflate(layoutId, parent, false);
    ViewHolder viewHolder = new ViewHolder(view);
    view.setTag(viewHolder);
    return view;
  }

  @Override
  public void bindView(View view, Context context, Cursor cursor) {

    ViewHolder viewHolder = (ViewHolder) view.getTag();

    // Read weather icon ID from cursor
    int weatherId = cursor.getInt(ForecastFragment.COL_WEATHER_ID);

    float high = cursor.getFloat(ForecastFragment.COL_WEATHER_MAX_TEMP);
    float low = cursor.getFloat(ForecastFragment.COL_WEATHER_MIN_TEMP);
    // Read user preference for metric or imperial temperature units
    boolean isMetric = Utility.isMetric(context);
    String highTemp = Utility.formatTemperature(context, high, isMetric);
    String lowtemp = Utility.formatTemperature(context, low, isMetric);

    if (getItemViewType(cursor.getPosition()) == VIEW_TYPE_TODAY) {
      viewHolder.iconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));
      viewHolder.dateView.setContentDescription(context.getString(R.string.today_temperature_content_description, highTemp, lowtemp));
    } else {
      viewHolder.iconView.setImageResource(Utility.getIconResourceForWeatherCondition(weatherId));
    }

    // Read date from cursor
    String dateString = cursor.getString(ForecastFragment.COL_WEATHER_DATE);
    // Find TextView and set formatted date on it
    viewHolder.dateView.setText(Utility.getFriendlyDayString(context, dateString));<commit_msg>Fixed a little graphic problem<commit_after>package com.example.assafg.sunshine.app;

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 com.example.assafg.sunshine.app.Utility.Utility;

/**
 * {@link ForecastAdapter} exposes a list of weather forecasts
 * from a {@link Cursor} to a {@link android.widget.ListView}.
 */
public class ForecastAdapter extends CursorAdapter {

  private static final int VIEW_TYPE_TODAY = 0;
  private static final int VIEW_TYPE_FUTURE_DAY = 1;
  private static final int VIEW_TYPE_COUNT = 2;
  private boolean mShouldUseTodayLayout;

  @Override
  public int getItemViewType(int position) {
    return position == 0 && mShouldUseTodayLayout ? VIEW_TYPE_TODAY : VIEW_TYPE_FUTURE_DAY;
  }

  public void setShouldUseTodayLayout(boolean shuoldUseTodayLayout) {
    mShouldUseTodayLayout = shuoldUseTodayLayout;
  }

  @Override
  public int getViewTypeCount() {
    return VIEW_TYPE_COUNT;
  }

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

  /**
   * Copy/paste note: Replace existing newView() method in ForecastAdapter with this one.
   */
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
    // Choose the layout type
    int viewType = getItemViewType(cursor.getPosition());
    int layoutId;

    if (viewType == VIEW_TYPE_TODAY) {
      layoutId = R.layout.list_item_forecast_today;
    } else {
      layoutId = R.layout.list_item_forecast;
    }

    View view = LayoutInflater.from(context).inflate(layoutId, parent, false);
    ViewHolder viewHolder = new ViewHolder(view);
    view.setTag(viewHolder);
    return view;
  }

  @Override
  public void bindView(View view, Context context, Cursor cursor) {

    ViewHolder viewHolder = (ViewHolder) view.getTag();

    // Read weather icon ID from cursor
    int weatherId = cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID);

    float high = cursor.getFloat(ForecastFragment.COL_WEATHER_MAX_TEMP);
    float low = cursor.getFloat(ForecastFragment.COL_WEATHER_MIN_TEMP);
    // Read user preference for metric or imperial temperature units
    boolean isMetric = Utility.isMetric(context);
    String highTemp = Utility.formatTemperature(context, high, isMetric);
    String lowtemp = Utility.formatTemperature(context, low, isMetric);

    if (getItemViewType(cursor.getPosition()) == VIEW_TYPE_TODAY) {
      viewHolder.iconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));
      viewHolder.dateView.setContentDescription(context.getString(R.string.today_temperature_content_description, highTemp, lowtemp));
    } else {
      viewHolder.iconView.setImageResource(Utility.getIconResourceForWeatherCondition(weatherId));
    }

    // Read date from cursor
    String dateString = cursor.getString(ForecastFragment.COL_WEATHER_DATE);
    // Find TextView and set formatted date on it
    viewHolder.dateView.setText(Utility.getFriendlyDayString(context, dateString));
{'fraction_non_alphanumeric': 0.08759580791490693, 'fraction_numerical': 0.001564210855623338, 'mean_word_length': 4.564838990426458, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5528552', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1867, 'n_words': 443}