Ejemplo n.º 1
0
        private ArticleViewModel LoadOrCreateViewModel(Bundle savedInstanceState)
        {
            ArticleViewModel vm;

            if (savedInstanceState != null)
            {
                Log.Debug(TAG, "State: Fetching from bundle...");
                string serializedVM = savedInstanceState.GetString("ViewModel");
                Log.Debug(TAG, "State: Deserializing...");
                vm = ArticleViewModel.Deserialize(serializedVM);
                Log.Debug(TAG, "State: Revived article {0} from bundle", vm.Article.id);
            }
            else
            {
                vm = new ArticleViewModel(new NewsService());
            }
            vm.PropertyChanged += (sender, e) => Bind();
            return(vm);
        }