public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            swipeLayout = (SwipeDismissFrameLayout)inflater.Inflate(Resource.Layout.activity_settings, container, false);

            swipeLayout.Swipeable    = true;
            swipeCallback            = new SwipeDismissCallback();
            swipeCallback.Dismissed += (layout) =>
            {
                Activity.OnBackPressed();
            };
            swipeLayout.AddCallback(swipeCallback);

            return(swipeLayout);
        }
Beispiel #2
0
        private void SetupRecyclerView()
        {
            // Touch listeners.
            itemTouchListener = new ItemTouchListener(recyclerView, this);
            recyclerView.AddOnItemTouchListener(itemTouchListener);

            var touchCallback = new SwipeDismissCallback(ItemTouchHelper.Up | ItemTouchHelper.Down, ItemTouchHelper.Left, this);
            var touchHelper   = new ItemTouchHelper(touchCallback);

            touchHelper.AttachToRecyclerView(recyclerView);

            // Decorations.
            dividerDecoration = new DividerItemDecoration(Activity, DividerItemDecoration.VerticalList);
            shadowDecoration  = new ShadowItemDecoration(Activity);
            recyclerView.AddItemDecoration(dividerDecoration);
            recyclerView.AddItemDecoration(shadowDecoration);

            recyclerView.GetItemAnimator().SupportsChangeAnimations = false;
        }
Beispiel #3
0
        private void SetupRecyclerView(LogTimeEntriesViewModel viewModel)
        {
            // Touch listeners.
            itemTouchListener = new ItemTouchListener(recyclerView, this);
            recyclerView.AddOnItemTouchListener(itemTouchListener);

            // Scroll listener
            recyclerView.AddOnScrollListener(
                new ScrollListener((LinearLayoutManager)recyclerView.GetLayoutManager(), viewModel));

            var touchCallback = new SwipeDismissCallback(ItemTouchHelper.Up | ItemTouchHelper.Down, ItemTouchHelper.Left, this);
            var touchHelper   = new ItemTouchHelper(touchCallback);

            touchHelper.AttachToRecyclerView(recyclerView);

            // Decorations.
            dividerDecoration = new DividerItemDecoration(Activity, DividerItemDecoration.VerticalList);
            shadowDecoration  = new ShadowItemDecoration(Activity);
            recyclerView.AddItemDecoration(dividerDecoration);
            recyclerView.AddItemDecoration(shadowDecoration);
            recyclerView.GetItemAnimator().SupportsChangeAnimations = false;
        }
Beispiel #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState) as SwipeDismissFrameLayout;

            // Inflate the layout for this fragment
            inflater.Inflate(Resource.Layout.fragment_location_search, view, true);

            swipeViewLayout          = view.FindViewById <SwipeDismissFrameLayout>(Resource.Id.recycler_view_layout);
            swipeCallback            = new SwipeDismissCallback();
            swipeCallback.Dismissed += (layout) =>
            {
                layout.Visibility = ViewStates.Gone;
                //layout.Reset();
            };
            swipeViewLayout.AddCallback(swipeCallback);
            keyboardButton        = view.FindViewById <FloatingActionButton>(Resource.Id.keyboard_button);
            keyboardButton.Click += (sender, e) =>
            {
                mSearchView.Visibility = ViewStates.Visible;
                mSearchView.RequestFocus();
                ShowInputMethod(mSearchView);
            };
            voiceButton        = view.FindViewById <FloatingActionButton>(Resource.Id.voice_button);
            voiceButton.Click += (sender, e) =>
            {
                mSearchView.Visibility = ViewStates.Gone;
                mSearchView.Text       = String.Empty;
                view.RequestFocus();
                Intent intent = new Intent(RecognizerIntent.ActionRecognizeSpeech)
                                .PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm)
                                .PutExtra(RecognizerIntent.ExtraPrompt, mActivity.GetString(Resource.String.location_search_hint));
                StartActivityForResult(intent, REQUEST_CODE_VOICE_INPUT);
            };

            mProgressBar             = view.FindViewById <ProgressBar>(Resource.Id.progressBar);
            mSearchView              = view.FindViewById <EditText>(Resource.Id.search_view);
            mSearchView.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                // If we're using searchfragment
                // make sure gps feature is off
                if (Settings.FollowGPS)
                {
                    Settings.FollowGPS = false;
                }
            };
            mSearchView.FocusChange += (object sender, View.FocusChangeEventArgs e) =>
            {
                View v = sender as View;

                if (e.HasFocus)
                {
                    ShowInputMethod(v.FindFocus());
                }
                else
                {
                    HideInputMethod(v);
                }
            };
            mSearchView.EditorAction += (object sender, TextView.EditorActionEventArgs e) =>
            {
                if (e.ActionId == ImeAction.Search)
                {
                    DoSearchAction();

                    // If we're using searchfragment
                    // make sure gps feature is off
                    if (Settings.FollowGPS)
                    {
                        Settings.FollowGPS = false;
                    }

                    e.Handled = true;
                }
                e.Handled = false;
            };

            mRecyclerView = view.FindViewById <WearableRecyclerView>(Resource.Id.recycler_view);

            // use this setting to improve performance if you know that changes
            // in content do not change the layout size of the RecyclerView
            mRecyclerView.HasFixedSize = true;

            // To align the edge children (first and last) with the center of the screen
            mRecyclerView.EdgeItemsCenteringEnabled = true;

            // use a linear layout manager
            mLayoutManager = new WearableLinearLayoutManager(mActivity);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            // specify an adapter (see also next example)
            mAdapter            = new LocationQueryAdapter(new List <LocationQueryViewModel>());
            mAdapter.ItemClick += ClickListener;
            mRecyclerView.SetAdapter(mAdapter);

            return(view);
        }