<commit_before>﻿using System;

using Android.Content;
using Android.OS;
using Android.Views;
using Android.Widget;
using Android.Support.V4.App;
using SimpleWeather.WeatherData;
using SimpleWeather.Droid.Controls;
using Android.Support.V7.App;
using SimpleWeather.Controls;
using SimpleWeather.Droid.Utils;
using SimpleWeather.Utils;
using System.Collections.Generic;
using Com.Nostra13.Universalimageloader.Core;
using System.Threading.Tasks;
using Android.Graphics.Drawables;

namespace SimpleWeather.Droid
{
    public class WeatherNowFragment : Fragment, IWeatherLoadedListener
    {
        private Context context;
        private Pair<int, string> pair;
        private bool loaded = false;

        WeatherDataLoader wLoader = null;
        WeatherNowViewModel weatherView = null;

        // Views
        private View mainView;
        private View contentView;
        private ProgressBar progressBar;
        // Condition
        private TextView locationName;
        private TextView updateTime;
        private WeatherIcon weatherIcon;
        private TextView weatherCondition;
        private WeatherIcon weatherTemp;
        // Details
        private LinearLayout detailsPanel;
        private TextView humidity;
        private WeatherIcon pressureState;
        private TextView pressure;
        private TextView visiblity;
        private TextView feelslike;
        private WeatherIcon windDirection;
        private TextView windSpeed;
        private TextView sunrise;
        private TextView sunset;

        private ImageLoader loader = ImageLoader.Instance;

        private String fahrenheit = App.Context.GetString(Resource.String.wi_fahrenheit);
        private String celsius = App.Context.GetString(Resource.String.wi_celsius);

        public void OnWeatherLoaded(int locationIdx, Weather weather)
        {
            if (weather != null)
            {
                if (weatherView == null)
                    weatherView = new WeatherNowViewModel(weather);
                else
                    weatherView.UpdateView(weather);

                this.SetView(weatherView);
            }

            this.Activity.RunOnUiThread(() => progressBar.Visibility = ViewStates.Gone);
        }

        public WeatherNowFragment()
        {
            // Required empty public constructor
        }

        /**
         * Use this factory method to create a new instance of
         * this fragment using the provided parameters.
         *
         * @param query Weather query.
         * @param index Location index.
         * @return A new instance of fragment WeatherNowFragment.
         */
        public static WeatherNowFragment NewInstance(Pair<int, string> pair)
        {
            WeatherNowFragment fragment = new WeatherNowFragment();
            if (pair != null)
            {
                Bundle args = new Bundle();
                args.PutString("pair", JSONParser.Serializer(pair, typeof(Pair<int, string>)));
                fragment.Arguments = args;
            }
            return fragment;
        }

        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your fragment here
            if (Arguments != null)
            {
                pair = Task.Run(() => JSONParser.DeserializerAsync<Pair<int, string>>(Arguments.GetString("pair"))).Result;
<commit_msg>SimpleWeather.Android: initialize WeatherNow viewmodel at start<commit_after>﻿using System;

using Android.Content;
using Android.OS;
using Android.Views;
using Android.Widget;
using Android.Support.V4.App;
using SimpleWeather.WeatherData;
using SimpleWeather.Droid.Controls;
using Android.Support.V7.App;
using SimpleWeather.Controls;
using SimpleWeather.Droid.Utils;
using SimpleWeather.Utils;
using System.Collections.Generic;
using Com.Nostra13.Universalimageloader.Core;
using System.Threading.Tasks;
using Android.Graphics.Drawables;

namespace SimpleWeather.Droid
{
    public class WeatherNowFragment : Fragment, IWeatherLoadedListener
    {
        private Context context;
        private Pair<int, string> pair;
        private bool loaded = false;

        WeatherDataLoader wLoader = null;
        WeatherNowViewModel weatherView = null;

        // Views
        private View mainView;
        private View contentView;
        private ProgressBar progressBar;
        // Condition
        private TextView locationName;
        private TextView updateTime;
        private WeatherIcon weatherIcon;
        private TextView weatherCondition;
        private WeatherIcon weatherTemp;
        // Details
        private LinearLayout detailsPanel;
        private TextView humidity;
        private WeatherIcon pressureState;
        private TextView pressure;
        private TextView visiblity;
        private TextView feelslike;
        private WeatherIcon windDirection;
        private TextView windSpeed;
        private TextView sunrise;
        private TextView sunset;

        private ImageLoader loader = ImageLoader.Instance;

        private String fahrenheit = App.Context.GetString(Resource.String.wi_fahrenheit);
        private String celsius = App.Context.GetString(Resource.String.wi_celsius);

        public void OnWeatherLoaded(int locationIdx, Weather weather)
        {
            if (weather != null)
            {
                weatherView.UpdateView(weather);
                SetView(weatherView);
            }

            this.Activity.RunOnUiThread(() => progressBar.Visibility = ViewStates.Gone);
        }

        public WeatherNowFragment()
        {
            // Required empty public constructor
            weatherView = new WeatherNowViewModel();
        }

        /**
         * Use this factory method to create a new instance of
         * this fragment using the provided parameters.
         *
         * @param query Weather query.
         * @param index Location index.
         * @return A new instance of fragment WeatherNowFragment.
         */
        public static WeatherNowFragment NewInstance(Pair<int, string> pair)
        {
            WeatherNowFragment fragment = new WeatherNowFragment();
            if (pair != null)
            {
                Bundle args = new Bundle();
                args.PutString("pair", JSONParser.Serializer(pair, typeof(Pair<int, string>)));
                fragment.Arguments = args;
            }
            return fragment;
        }

        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your fragment here
            if (Arguments != null)
            {
                pair = Task.Run(() => JSONParser.DeserializerAsync<Pair<int, string>>(Arguments.GetString("pair"))).Result;

{'fraction_non_alphanumeric': 0.07181671317374064, 'fraction_numerical': 0.001174915552944632, 'mean_word_length': 2.2521489971346704, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '5314319', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1600, 'n_words': 451}