Search in sources :

Example 6 with MainActivity

use of app.insti.activity.MainActivity in project IITB-App by wncc.

the class CalendarFragment method showFab.

/**
 * Show the fab if we can make events
 */
private void showFab() {
    if (((MainActivity) getActivity()).createEventAccess()) {
        fab.show();
        NestedScrollView nsv = view.findViewById(R.id.calendar_nsv);
        nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                if (scrollY > oldScrollY)
                    fab.hide();
                else
                    fab.show();
            }
        });
        // Handle fab click
        fab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                CalendarDay day = ((MaterialCalendarView) view.findViewById(R.id.simpleCalendarView)).getSelectedDate();
                String date = day.getYear() + "-" + day.getMonth() + "-" + day.getDay();
                WebViewFragment webViewFragment = (new WebViewFragment()).withDate(date);
                Bundle bundle = new Bundle();
                bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_ADD_EVENT);
                webViewFragment.setArguments(bundle);
                ((MainActivity) getActivity()).updateFragment(webViewFragment);
            }
        });
    }
}
Also used : Bundle(android.os.Bundle) MainActivity(app.insti.activity.MainActivity) NestedScrollView(androidx.core.widget.NestedScrollView) CalendarDay(com.prolificinteractive.materialcalendarview.CalendarDay) NestedScrollView(androidx.core.widget.NestedScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MaterialCalendarView(com.prolificinteractive.materialcalendarview.MaterialCalendarView) TextView(android.widget.TextView)

Aggregations

MainActivity (app.insti.activity.MainActivity)6 Bundle (android.os.Bundle)4 View (android.view.View)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)3 Point (android.graphics.Point)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 NestedScrollView (androidx.core.widget.NestedScrollView)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 GenericAdapter (app.insti.adapter.GenericAdapter)2 CardInterface (app.insti.interfaces.CardInterface)2 ArrayList (java.util.ArrayList)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 Intent (android.content.Intent)1