void ActionBarButtonClicked(int id) { if (id == 65) { ((Main)this.Activity).ToggleMenu(); } else if (id == ControlIds.INVOICE_ADD_BUTTON) { try { RelativeLayout f1 = this.Activity.FindViewById <RelativeLayout>(Resource.Id.fragment1); RelativeLayout f3 = this.Activity.FindViewById <RelativeLayout>(Resource.Id.fragment3); var ft = FragmentManager.BeginTransaction(); InvoiceInfoFragment invoiceFragment = InvoiceInfoFragment.NewInstance(0); if (f3 != null) { ft.Replace(Resource.Id.fragment3, invoiceFragment); } else { ft.Replace(Resource.Id.fragment1, invoiceFragment); } ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); invoiceFragment.InvoiceSaved += new InvoiceInfoFragment.InvoiceSavedDelegate(InvoiceSaved); ft.Commit(); } catch (Exception ex) { Log.Error("exception", ex.Message); } } }
public TransDetAdapter(Android.Support.V4.App.FragmentActivity context, TransDetList list, InvoiceInfoFragment baseFragment) : base(context, Resource.Layout.TransDetRow, list) { this.context = context; dataSource = list; parentView = baseFragment; }
public static InvoiceInfoFragment NewInstance(long objId) { var detailsFrag = new InvoiceInfoFragment { Arguments = new Bundle() }; detailsFrag.Arguments.PutLong("ObjectId", objId); return(detailsFrag); }
public static InvoiceTabDetails NewInstance(InvoiceInfoFragment parentView) { var detailsFrag = new InvoiceTabDetails { Arguments = new Bundle() }; detailsFrag.Arguments.PutLong("ObjectId", parentView.ObjectId); detailsFrag.invoiceParentView = parentView; return(detailsFrag); }
void ActionBarButtonClicked(int id) { switch (id) { case ControlIds.INVOICE_SAVE_BUTTON: try { Save(); } catch (Exception ex) { Log.Error("ActionBarButtonClicked SAVE_BUTTON", "ActionBarButtonClicked SAVE_BUTTON " + ex.Message); } break; case ControlIds.INVOICE_ADD_BUTTON: try { var ft = FragmentManager.BeginTransaction(); //ft.Replace(Resource.Id.detailInfo_fragment, InvoiceFragment.NewInstance(invoiceId)); InvoiceInfoFragment invoiceFragment = InvoiceInfoFragment.NewInstance(0); ft.Replace(Resource.Id.detailInfo_fragment, invoiceFragment); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); invoiceFragment.InvoiceSaved += new InvoiceInfoFragment.InvoiceSavedDelegate(InvoiceSaved); ft.Commit(); } catch (Exception ex) { Log.Error("exception", ex.Message); } break; case ControlIds.INVOICE_MAINMENU_BUTTON: ((Main)Activity).ToggleMenu(); /*if (isTablet) * { * RelativeLayout popupMenu = this.Activity.FindViewById<RelativeLayout>(Resource.Id.popup_mainmenu_inner); * popupMenu.Visibility = popupMenu.Visibility == ViewStates.Visible ? ViewStates.Gone : ViewStates.Visible; * } * else * { * var ft = this.Activity.SupportFragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.actionbar_phone_fragment, new RetailMobile.Fragments.ActionBar(), "ActionBarMain"); * ft.Replace(Resource.Id.content_phone_fragment, new MainMenuFragment()); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * }*/ break; } }
void btnAddInvoice_Click(object sender, EventArgs e) { if (isTablet) { var ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.detailInfo_fragment, InvoiceInfoFragment.NewInstance(0)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); this.Activity.FindViewById <FrameLayout>(Resource.Id.details_fragment).Visibility = ViewStates.Gone; } else { var ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.content_phone_fragment, InvoiceInfoFragment.NewInstance(0)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); AndroidEnvironment.UnhandledExceptionRaiser += (sender, e) => { RetailMobile.Error.LogError(this, e.Exception.Message, e.Exception.StackTrace); }; PreferencesUtil.LoadSettings(this); Sync.GenerateDatabase(this); SetContentView(Resource.Layout.main); pbLoadingLayout = FindViewById <RelativeLayout>(Resource.Id.pbLoadingLayout); RelativeLayout layoutFragment1 = FindViewById <RelativeLayout>(Resource.Id.fragment1); RelativeLayout layoutFragment2 = FindViewById <RelativeLayout>(Resource.Id.fragment2); RelativeLayout layoutFragment3 = FindViewById <RelativeLayout>(Resource.Id.fragment3); LinearLayout layout2 = FindViewById <LinearLayout>(Resource.Id.layout2); mainActionBar = (RetailMobile.Fragments.ItemActionBar)SupportFragmentManager.FindFragmentById(Resource.Id.ActionBar1); bool isLoggedIn = false; if (layoutFragment1 != null) { if (!string.IsNullOrEmpty(PreferencesUtil.Username) && !string.IsNullOrEmpty(PreferencesUtil.Password) && LoginFragment.Login(this, PreferencesUtil.Username, PreferencesUtil.Password)) { isLoggedIn = true; if (layoutFragment2 == null && layoutFragment3 == null) { fragmentInvoice = new InvoiceInfoFragment(); var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment1, fragmentInvoice); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.AddToBackStack("Invoice"); ft.Commit(); } else { fragmentMainMenu = new MainMenuFragment(); var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment1, fragmentMainMenu); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.AddToBackStack("MainMenu"); ft.Commit(); } } else { isLoggedIn = false; LoginFragment fragmentLogin = new LoginFragment(); var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment1, fragmentLogin); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.AddToBackStack("Login"); ft.Commit(); } } if (layoutFragment2 != null && layoutFragment3 != null) { if (isLoggedIn) { layout2.Visibility = ViewStates.Visible; fragmentDetails = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment2, fragmentDetails); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); fragmentInvoice = InvoiceInfoFragment.NewInstance(0); ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment3, fragmentInvoice); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } else { layoutFragment3.Visibility = ViewStates.Gone; layoutFragment2.Visibility = ViewStates.Gone; } } if (layoutFragment2 == null && layoutFragment3 == null) { menu = new Com.Jeremyfeinstein.Slidingmenu.Lib.SlidingMenu(this); menu.Mode = 0; menu.TouchModeAbove = SlidingMenu.TouchmodeNone; menu.SetShadowWidthRes(Resource.Dimension.shadow_width); menu.SetShadowDrawable(Resource.Drawable.shadow); menu.SetBehindOffsetRes(Resource.Dimension.slidingmenu_offset); menu.SetFadeDegree(0.35f); menu.AttachToActivity(this, Com.Jeremyfeinstein.Slidingmenu.Lib.SlidingMenu.SlidingContent); menu.SetMenu(Resource.Layout.FragmentMainMenu); } SupportFragmentManager.ExecutePendingTransactions(); System.Threading.Tasks.Task.Factory.StartNew(() => Sync.SyncUsers(this)).ContinueWith(task => this.RunOnUiThread(() => HideProgressBar())); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); /*AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((o,e)=> * { * Android.Util.Log.Debug("e : ",e.ToString() ); * Android.Util.Log.Debug("e.ExceptionObject: ",e.ExceptionObject.ToString() ); * Crashlytics.Android.Crashlytics1.Log(e.ToString()); * Crashlytics.Android.Crashlytics1.Log(e.ExceptionObject.ToString()); * });*/ AndroidEnvironment.UnhandledExceptionRaiser += (sender, e) => { RetailMobile.Error.LogError(this, e.Exception.Message, e.Exception.StackTrace); }; PreferencesUtil.LoadSettings(this); Sync.GenerateDatabase(this); Crashlytics.Android.Crashlytics1.Start(this); SetContentView(Resource.Layout.MainMenu); bool isTablet = Common.isTabletDevice(this); if (isTablet) { myActionBar = (RetailMobile.Fragments.ActionBar)SupportFragmentManager.FindFragmentById(Resource.Id.ActionBarMain); myActionBar.SyncClicked += new Fragments.ActionBar.SyncCLickedDelegate(MyActionBar_SyncClicked); myActionBar.MenuClicked += new RetailMobile.Fragments.ActionBar.MenuClickedDelegate(MenuClicked); myActionBar.SettingsClicked += new RetailMobile.Fragments.ActionBar.SettingsCLickedDelegate(SettingsClicked); ShowProgressBar(); if (Common.isPortrait(this)) { // MainMenuPopup.InitPopupMenu(this, myActionBar.Id); InitPopupMenu(); } } System.Threading.Tasks.Task.Factory.StartNew(() => Sync.SyncUsers(this)).ContinueWith(task => this.RunOnUiThread(() => HideProgressBar())); if (!string.IsNullOrEmpty(PreferencesUtil.Username) && !string.IsNullOrEmpty(PreferencesUtil.Password) && LoginFragment.Login(this, PreferencesUtil.Username, PreferencesUtil.Password)) { if (isTablet) { this.FindViewById <LinearLayout>(Resource.Id.layoutList).Visibility = ViewStates.Visible; this.FindViewById <FrameLayout>(Resource.Id.details_fragment).Visibility = ViewStates.Visible; this.FindViewById <LinearLayout>(Resource.Id.layoutDetails).Visibility = ViewStates.Visible; var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.details_fragment, DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.detailInfo_fragment, InvoiceInfoFragment.NewInstance(0)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); if (this.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape) { this.FindViewById <LinearLayout>(Resource.Id.LayoutMenu).Visibility = ViewStates.Visible; } else { myActionBar.ButtonMenuVisibility = ViewStates.Visible; myActionBar.ButtonSettingsVisibility = ViewStates.Gone; } } else { // var intent = new Android.Content.Intent(); // intent.SetClass(this, typeof(TransactionFragmentActivity)); // StartActivity(intent); var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.actionbar_phone_fragment, new RetailMobile.Fragments.ItemActionBar(), "ItemActionBar"); ft.Replace(Resource.Id.content_phone_fragment, InvoiceInfoFragment.NewInstance(0)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } } else { if (isTablet) { myActionBar.ButtonMenuVisibility = ViewStates.Gone; var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.detailInfo_fragment, new LoginFragment()); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } else { myActionBar = new RetailMobile.Fragments.ActionBar(); var ft = SupportFragmentManager.BeginTransaction(); ft.Replace(Resource.Id.actionbar_phone_fragment, myActionBar);//new RetailMobile.Fragments.ActionBar() ft.Replace(Resource.Id.content_phone_fragment, new LoginFragment()); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); myActionBar.SyncClicked += new Fragments.ActionBar.SyncCLickedDelegate(MyActionBar_SyncClicked); myActionBar.MenuClicked += new RetailMobile.Fragments.ActionBar.MenuClickedDelegate(MenuClicked); myActionBar.SettingsClicked += new RetailMobile.Fragments.ActionBar.SettingsCLickedDelegate(SettingsClicked); ShowProgressBar(); } } }
public void ShowDetails(int index) { if (index == -1) { return; } // We can display everything in place with fragments. // Have the list highlight this item and show the data. ListView.SetItemChecked(index, true); int currentFragmentID = 0; var detailFragment = (BaseFragment)FragmentManager.FindFragmentById(Resource.Id.fragment3); currentFragmentID = Resource.Id.fragment3; if (detailFragment == null) { detailFragment = (BaseFragment)FragmentManager.FindFragmentById(Resource.Id.fragment1); currentFragmentID = Resource.Id.fragment1; } switch (ParentObjId) { case (int)MainMenu.MenuItems.Items: long itemId = ((ItemsInfoAdapter)ListAdapter).GetItem(index).ItemId; // long itemId = (long)((Library.ItemInfoList)_list)[index].ItemId; if (detailFragment == null || detailFragment.ObjectId != itemId) { var ft = FragmentManager.BeginTransaction(); ft.Replace(currentFragmentID, ItemFragment.NewInstance(itemId)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } break; case (int)MainMenu.MenuItems.Customers: long custId = (long)((Library.CustomerInfoList)_list)[index].CustID; if (detailFragment == null || detailFragment.ObjectId != custId) { Library.CustomerInfoList custList = (Library.CustomerInfoList)_list; System.Collections.Generic.List <string> custNamesList = new System.Collections.Generic.List <string>(custList.Count); custList.ForEach(c => custNamesList.Add(c.Name)); var ft = FragmentManager.BeginTransaction(); ft.Replace(currentFragmentID, CustomerFragment.NewInstance(custId, custNamesList.ToArray())); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } break; case (int)MainMenu.MenuItems.Invoices: //long invoiceId = (long)((Library.TransHedList)_list)[index].HtrnId;//? long invoiceId = (long)((TransHedAdapter)this.ListView.Adapter).GetItem(index).HtrnId; if (detailFragment == null || detailFragment.ObjectId != invoiceId) { var ft = FragmentManager.BeginTransaction(); //ft.Replace(Resource.Id.detailInfo_fragment, InvoiceFragment.NewInstance(invoiceId)); InvoiceInfoFragment invoiceFragment = InvoiceInfoFragment.NewInstance(invoiceId); ft.Replace(currentFragmentID, invoiceFragment); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); invoiceFragment.InvoiceSaved += new InvoiceInfoFragment.InvoiceSavedDelegate(InvoiceSaved); } break; } }
void btnLogin_Click(object sender, EventArgs e) { string username = this.tbUsername.Text; string password = this.tbPassword.Text; if (LoginFragment.Login(this.Activity, username, password)) { RelativeLayout f1 = this.Activity.FindViewById <RelativeLayout>(Resource.Id.fragment1); RelativeLayout f2 = this.Activity.FindViewById <RelativeLayout>(Resource.Id.fragment2); RelativeLayout f3 = this.Activity.FindViewById <RelativeLayout>(Resource.Id.fragment3); LinearLayout l2 = this.Activity.FindViewById <LinearLayout>(Resource.Id.layout2); LinearLayout l3 = this.Activity.FindViewById <LinearLayout>(Resource.Id.layout3); if (f2 != null && f3 != null) { f2.Visibility = ViewStates.Visible; f3.Visibility = ViewStates.Visible; l2.Visibility = ViewStates.Visible; l3.Visibility = ViewStates.Visible; var ft = FragmentManager.BeginTransaction(); ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment1, new MainMenuFragment()); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); DetailsFragment details = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment2, details); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment3, InvoiceInfoFragment.NewInstance(0)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } else { var ft = FragmentManager.BeginTransaction(); ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment1, InvoiceInfoFragment.NewInstance(0)); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } InputMethodManager imm = (InputMethodManager)Activity.GetSystemService( Android.Content.Context.InputMethodService); imm.HideSoftInputFromWindow(tbPassword.WindowToken, 0); imm.HideSoftInputFromWindow(tbUsername.WindowToken, 0); /*if (isTablet) * { * this.Activity.FindViewById<LinearLayout>(Resource.Id.layoutList).Visibility = ViewStates.Visible; * this.Activity.FindViewById<FrameLayout>(Resource.Id.details_fragment).Visibility = ViewStates.Visible; * this.Activity.FindViewById<LinearLayout>(Resource.Id.layoutDetails).Visibility = ViewStates.Visible; * * DetailsFragment details = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); * var ft = FragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.details_fragment, details); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * * ft = FragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.detailInfo_fragment, InvoiceInfoFragment.NewInstance(0)); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * * if (this.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape) * { * View layoutMenu = this.Activity.FindViewById<LinearLayout>(Resource.Id.LayoutMenu); * if(layoutMenu != null) * layoutMenu.Visibility = ViewStates.Visible; * } * else * { * RetailMobile.Fragments.ActionBar myActionBar = (RetailMobile.Fragments.ActionBar)Activity.SupportFragmentManager.FindFragmentById(Resource.Id.ActionBarMain); * * myActionBar.ButtonMenuVisibility = ViewStates.Visible; * myActionBar.ButtonSettingsVisibility = ViewStates.Gone; * } * } * else * { * // var intent = new Android.Content.Intent(); * // intent.SetClass(this.Activity, typeof(TransactionFragmentActivity)); * // StartActivity(intent); * * var ft = this.Activity.SupportFragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.actionbar_phone_fragment, new RetailMobile.Fragments.ItemActionBar(), "ItemActionBar"); * ft.Replace(Resource.Id.content_phone_fragment, InvoiceInfoFragment.NewInstance(0)); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * }*/ } else { Toast.MakeText(Activity.ApplicationContext, Activity.GetString(Resource.String.InvalidUserOrPass), ToastLength.Short).Show(); } }
void btnListInvoices_Click(object sender, EventArgs e) { LinearLayout l2 = this.Activity.FindViewById <LinearLayout>(Resource.Id.layout2); l2.Visibility = ViewStates.Visible; RelativeLayout f1 = Activity.FindViewById <RelativeLayout>(Resource.Id.fragment1); RelativeLayout f2 = Activity.FindViewById <RelativeLayout>(Resource.Id.fragment2); RelativeLayout f3 = Activity.FindViewById <RelativeLayout>(Resource.Id.fragment3); if (f2 != null && f3 != null) { DetailsFragment fragmentDetails = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); var ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment2, fragmentDetails); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); InvoiceInfoFragment fragmentInvoice = InvoiceInfoFragment.NewInstance(0); ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment3, fragmentInvoice); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); fragmentInvoice.InvoiceSaved += new InvoiceInfoFragment.InvoiceSavedDelegate(fragmentDetails.InvoiceSaved); } else { DetailsFragment fragmentDetails = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); var ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.fragment1, fragmentDetails); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); } /*if (isTablet) * { * DetailsFragment details = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); * var ft = FragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.details_fragment, details); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * * InvoiceInfoFragment detailsInfo = InvoiceInfoFragment.NewInstance(0); * ft = FragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.detailInfo_fragment, detailsInfo); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * detailsInfo.InvoiceSaved += new InvoiceInfoFragment.InvoiceSavedDelegate(details.InvoiceSaved); * * this.Activity.FindViewById<FrameLayout>(Resource.Id.details_fragment).Visibility = ViewStates.Visible; * this.Activity.FindViewById<LinearLayout>(Resource.Id.layoutDetails).Visibility = ViewStates.Visible; * this.Activity.FindViewById<LinearLayout>(Resource.Id.layoutList).Visibility = ViewStates.Visible; * * if (isPopupMenu) * { * this.Activity.FindViewById<RelativeLayout>(Resource.Id.popup_mainmenu_inner).Visibility = ViewStates.Gone; * } * } * else * { * DetailsFragment details = DetailsFragment.NewInstance((int)MainMenu.MenuItems.Invoices); * var ft = FragmentManager.BeginTransaction(); * ft.Replace(Resource.Id.actionbar_phone_fragment, new RetailMobile.Fragments.ItemActionBar(), "ItemActionBar"); * ft.Replace(Resource.Id.content_phone_fragment, details); * ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); * ft.Commit(); * }*/ }