コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.circuit_breaker_fragment, null);

            _circuitbreakerPanel6LinearLayout    = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel6LinearLayout);
            _circuitbreakerPanel61LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel61LinearLayout);
            _circuitbreakerPanel62LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel62LinearLayout);
            _circuitbreakerPanel63LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel63LinearLayout);
            _circuitbreakerPanel64LinearLayout   = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel64LinearLayout);
            _circuitbreakerPanel611LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel611LinearLayout);
            _circuitbreakerPanel612LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel612LinearLayout);
            _circuitbreakerPanel180LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel180LinearLayout);
            _circuitbreakerPanel181LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel181LinearLayout);
            _circuitbreakerPanel182LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel182LinearLayout);
            _circuitbreakerPanel183LinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.circuitbreakerPanel183LinearLayout);
            _circuitbreakerEECompartmentTextView = view.FindViewById <TextView>(Resource.Id.circuitbreakerEECompartmentTextView);
            _circuitbreakerSearchView            = view.FindViewById <Android.Widget.SearchView>(Resource.Id.circuitbreakerSearchView);
            _circuitBreakerRecyclerView          = view.FindViewById <RecyclerView>(Resource.Id.circuitBreakerRecyclerView);
            var layoutManager = new LinearLayoutManager(Context);
            var circuitBreakerItemDecorator = new CircuitBreakerItemDecorator(Context);

            _circuitBreakerRecyclerViewAdapter = new CircuitBreakerRecyclerViewAdapter(_circuitBreakers);
            _circuitBreakerRecyclerView.SetLayoutManager(layoutManager);
            _circuitBreakerRecyclerView.SetAdapter(_circuitBreakerRecyclerViewAdapter);
            _circuitBreakerRecyclerView.AddItemDecoration(circuitBreakerItemDecorator);
            _circuitbreakerSearchView.Click += (s, e) =>
            {
                (s as Android.Widget.SearchView).SetIconifiedByDefault(false);
                //InputMethodManager inputMethodManager = Activity.GetSystemService(Context.InputMethodService) as InputMethodManager;
                //inputMethodManager.ShowSoftInput(view, ShowFlags.Forced);
                //inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
            };
            _circuitbreakerSearchView.QueryTextChange += (s, e) =>
            {
                if (String.IsNullOrEmpty(e.NewText) || String.IsNullOrWhiteSpace(e.NewText))
                {
                    ResetHighLightedSelectedPanel();
                }
                _circuitBreakers.Clear();
                _circuitBreakerService.Search(e.NewText.Trim()).ForEach(x => _circuitBreakers.Add(x));
                _circuitBreakerRecyclerViewAdapter.NotifyDataSetChanged();
            };

            _circuitBreakerRecyclerViewAdapter.ItemClick += (s, e) =>
            {
                if (_previousItemId == -1 || _previousItemId == e.Item2)
                {
                    ((View)e.Item1).SetBackgroundColor(Color.ParseColor("#80388e3c"));
                }
                else
                {
                    _previousView.SetBackgroundColor(Color.Transparent);
                    ((View)e.Item1).SetBackgroundColor(Color.ParseColor("#80388e3c"));
                }
                var circuitBreaker = (CircuitBreaker)_circuitBreakerRecyclerViewAdapter.GetItem(e.Item2);
                ResetHighLightedSelectedPanel();
                if (circuitBreaker.Panel.Equals("P6"))
                {
                    _panel = Panel.P6;
                }
                if (circuitBreaker.Panel.Equals("P6-1"))
                {
                    _panel = Panel.P61;
                }
                if (circuitBreaker.Panel.Equals("P6-2"))
                {
                    _panel = Panel.P62;
                }
                if (circuitBreaker.Panel.Equals("P6-3"))
                {
                    _panel = Panel.P63;
                }
                if (circuitBreaker.Panel.Equals("P6-4"))
                {
                    _panel = Panel.P64;
                }
                if (circuitBreaker.Panel.Equals("P6-11"))
                {
                    _panel = Panel.P611;
                }
                if (circuitBreaker.Panel.Equals("P6-12"))
                {
                    _panel = Panel.P612;
                }
                if (circuitBreaker.Panel.Equals("P18-0"))
                {
                    _panel = Panel.P180;
                }
                if (circuitBreaker.Panel.Equals("P18-1"))
                {
                    _panel = Panel.P181;
                }
                if (circuitBreaker.Panel.Equals("P18-2"))
                {
                    _panel = Panel.P182;
                }
                if (circuitBreaker.Panel.Equals("P18-3"))
                {
                    _panel = Panel.P183;
                }
                if (circuitBreaker.Panel.Equals("P91") | circuitBreaker.Panel.Equals("P92"))
                {
                    _panel = Panel.P9X;
                }
                HighLightSelectedPanel();
                _previousView   = (View)e.Item1;
                _previousItemId = e.Item2;
            };

            /*_circuitbreakerPanel6LinearLayout.Click += (s, e) =>
             * {
             *  if (_panel == Panel.P6)
             *  {
             *      Bundle bundle = new Bundle();
             *      bundle.PutInt("Panel", (int)_panel );
             *      bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
             *      var fragmentTransaction = FragmentManager.BeginTransaction();
             *      var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
             *      circuitBreakerPanelDialogFragment.Arguments = bundle;
             *      circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
             *  }
             * };*/

            _circuitbreakerPanel61LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P61)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel62LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P62)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel63LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P63)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel64LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P64)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel611LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P611)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel612LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P612)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            /*_circuitbreakerPanel180LinearLayout.Click += (s, e) =>
             * {
             *  if (_panel == Panel.P180)
             *  {
             *      Bundle bundle = new Bundle();
             *      bundle.PutInt("Panel", (int)_panel);
             *      bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
             *      var fragmentTransaction = FragmentManager.BeginTransaction();
             *      var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
             *      circuitBreakerPanelDialogFragment.Arguments = bundle;
             *      circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
             *  }
             * };*/

            _circuitbreakerPanel181LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P181)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel182LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P182)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            _circuitbreakerPanel183LinearLayout.Click += (s, e) =>
            {
                if (_panel == Panel.P183)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutInt("Panel", (int)_panel);
                    bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
                    var fragmentTransaction = FragmentManager.BeginTransaction();
                    var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
                    circuitBreakerPanelDialogFragment.Arguments = bundle;
                    circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
                }
            };

            /*_circuitbreakerEECompartmentTextView.Click += (s, e) =>
             * {
             *  if (_panel == Panel.P9X)
             *  {
             *      Bundle bundle = new Bundle();
             *      bundle.PutInt("Panel", (int)_panel);
             *      bundle.PutString("Location", _circuitBreakers[_previousItemId].Location);
             *      var fragmentTransaction = FragmentManager.BeginTransaction();
             *      var circuitBreakerPanelDialogFragment = CircuitBreakerPanelDialogFragment.NewInstance();
             *      circuitBreakerPanelDialogFragment.Arguments = bundle;
             *      circuitBreakerPanelDialogFragment.Show(fragmentTransaction, "CircuitBreakerPanelDialogFragment");
             *  }
             * };*/

            return(view);
        }
コード例 #2
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     _circuitBreakerService = ServiceLocator.Current.GetInstance <ICircuitBreakerService>("CircuitBreakerService");
     _circuitBreakers       = _circuitBreakerService.Search(null);
 }