public static FragmentQueryResult Get()
 {
     if (instance == null)
     {
         instance = new FragmentQueryResult();
     }
     return(instance);
 }
Esempio n. 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            v          = inflater.Inflate(Resource.Layout.FragmentHome, container, false);
            Main       = (MainActivity)Activity;
            categories = new CategoriesHelper().SetCategories();
            Main.EntityModel.Ontology = "Animal";
            SearchView = v.FindViewById <Android.Support.V7.Widget.SearchView>(Resource.Id.searchViewQuery);



            recyclerView = v.FindViewById <RecyclerView>(Resource.Id.recyclerHome);
            recyclerView.SetAdapter(new FragmentHomeAdapter(categories, this));
            recyclerView.SetLayoutManager(new StaggeredGridLayoutManager(2, 1));


            RecyclerViewSub = v.FindViewById <RecyclerView>(Resource.Id.recyclerHomeSub);
            RecyclerViewSub.SetAdapter(new SubCategoryAdapter(categories, this, 0));
            RecyclerViewSub.SetLayoutManager(new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false));

            SearchView.SetBackgroundColor(Color.ParseColor(categories[0].Color));
            this.SearchView.QueryHint = categories[0].subCategories[0].Name;
            Main.EntityModel.Ontology = categories[0].Key;
            Main.EntityModel.Contains = categories[0].subCategories[0].Key;

            SearchView.QueryTextSubmit += async delegate
            {
                Main.EntityModel.Contains = SearchView.Query;
                Main.EntityModel.Entities.Clear();
                this.SearchView.ClearFocus();
                await Main.EntityModel.SetEntitiesAsync();

                FragmentTransaction transaction = FragmentManager.BeginTransaction();
                transaction.Replace(Resource.Id.fragmentContainer, FragmentQueryResult.Get());
                transaction.Commit();
            };

            P = Screen.getDisplaySize(Activity.WindowManager.DefaultDisplay);

            // Use this to return your custom view for this Fragment
            return(v);

            //return base.OnCreateView(inflater, container, savedInstanceState);
        }