protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.activity_navigation); Bundle data = Intent.GetBundleExtra("data"); BottomNavigationView navigationView = FindViewById <BottomNavigationView>(Resource.Id.TopNavBar); navigationView.SetOnNavigationItemSelectedListener(this); transaction = FragmentManager.BeginTransaction(); hList = JsonConvert.DeserializeObject <List <Data> >(Intent.GetStringExtra("ListItem")); id = data.GetInt("photoid") - 1; bool staus = false; string url = "https://10.0.2.2:5001/api/Agencies"; string response = APIConnect.Get(url); agencies = JsonConvert.DeserializeObject <List <Agency> >(response); for (int i = 0; i < agencies.Count; i++) { if (agencies[i].agencyname == hList[id].agencyname) { hagency.Add(agencies[i]); } } HousedetailFragment sFrag = new HousedetailFragment(hList, hagency); sFrag.getph(data.GetInt("photoid")); navigationView.SelectedItemId = Resource.Id.menu1; }
public bool OnNavigationItemSelected(IMenuItem item) { FrameLayout navFragContainer = FindViewById <FrameLayout>(Resource.Id.navFragContainer); Bundle data = Intent.GetBundleExtra("data"); switch (item.ItemId) { case Resource.Id.menu1: HousedetailFragment sFrag = new HousedetailFragment(hList, hagency); sFrag.getph(data.GetInt("photoid")); transaction = FragmentManager.BeginTransaction(); transaction.Replace(Resource.Id.navFragContainer, sFrag, "Hd"); //transaction.AddToBackStack("Hd"); transaction.Commit(); return(true); case Resource.Id.menu2: navFragContainer.RemoveAllViewsInLayout(); AgencydetailFragment aFrag = new AgencydetailFragment(agencies, hList, data.GetString("uname"), data.GetString("uphone"), data.GetString("hlocation")); transaction = FragmentManager.BeginTransaction(); transaction.Replace(Resource.Id.navFragContainer, aFrag, "Ad"); transaction.Commit(); return(true); } return(false); }
public bool OnNavigationItemSelected(IMenuItem item) { FrameLayout navFragContainer = FindViewById <FrameLayout>(Resource.Id.navFragContainer); FragmentTransaction transaction; Bundle data = Intent.GetBundleExtra("data"); Bundle user = Intent.GetBundleExtra("user"); int id = user.GetInt("id"); switch (item.ItemId) { case Resource.Id.menu1: navFragContainer.RemoveAllViewsInLayout(); HousedetailFragment sFrag = new HousedetailFragment(heading, numberofroom, numberoftoilet, rentfee, location, agencyname, description); transaction = FragmentManager.BeginTransaction(); transaction.Replace(Resource.Id.navFragContainer, sFrag); transaction.Commit(); return(true); //call the agency number /* bool status = false; * string url = "https://10.0.2.2:5001/api/Agency"; * string response = APIConnect.Get(url); * List<Agency> agencies = JsonConvert.DeserializeObject<List<Agency>>(response); * * * foreach (Agency agency in agencies) * { * if (agency.agencyname == data.GetString("agencyname")) * { * //need to call user name * status = true; * navFragContainer.RemoveAllViewsInLayout(); * * HousedetailFragment sFrag = new HousedetailFragment(heading, numberofroom, numberoftoilet, rentfee, location, agencyname, description,agency.agencylocation); * transaction = FragmentManager.BeginTransaction(); * transaction.Replace(Resource.Id.navFragContainer, sFrag); * transaction.Commit(); * * break; * } * } * * * return true;*/ //return true; case Resource.Id.menu2: bool staus = false; string url = "https://10.0.2.2:5001/api/Agencies"; string response = APIConnect.Get(url); List <Agency> agencies = JsonConvert.DeserializeObject <List <Agency> >(response); foreach (Agency agency in agencies) { if (agency.agencyname == data.GetString("agencyname")) { navFragContainer.RemoveAllViewsInLayout(); AgencydetailFragment aFrag = new AgencydetailFragment(agency.agencyname, agency.agencyphonenumber, agency.agencyemail, agency.agencylocation); //, user.GetString("")); transaction = FragmentManager.BeginTransaction(); transaction.Replace(Resource.Id.Aname, aFrag, agency.agencyname); transaction.Replace(Resource.Id.APhonenumber, aFrag, agency.agencyphonenumber); transaction.Replace(Resource.Id.Aemail, aFrag, agency.agencyemail); transaction.Replace(Resource.Id.Alocation, aFrag, agency.agencylocation); transaction.Commit(); break; } } return(true); /* * //need to change users to agency (not list agency) * navFragContainer.RemoveAllViewsInLayout(); * //sFrag = new HousedetailFragment(heading, numberofroom, numberoftoilet, rentfee, location, agencyname, description); * * status = false; * url = "https://10.0.2.2:5001/api/Users" + "/" + id; * response = APIConnect.Get(url); * User ausers = JsonConvert.DeserializeObject<User>(response); * * status = false; * url = "https://10.0.2.2:5001/api/Agency"; * response = APIConnect.Get(url); * agencies = JsonConvert.DeserializeObject<List<Agency>>(response); * * * foreach (Agency agency in agencies) * { * if (agency.agencyname == data.GetString("agencyname")&&ausers.id == data.GetInt("id")&&agency.agencyname ==agencyname) * { * //need to call house location and * status = true; * navFragContainer.RemoveAllViewsInLayout(); * AgencydetailFragment aFrag = new AgencydetailFragment(agency.agencyname, agency.agencyphonenumber, agency.agencyemail, agency.agencyphonenumber, location, ausers.name); * * transaction = FragmentManager.BeginTransaction(); * transaction.Replace(Resource.Id.navFragContainer, aFrag); * transaction.Commit(); * * break; * } * } * return status; */ } return(false); }