Added schedule fragment listener
This commit is contained in:
@@ -16,6 +16,7 @@ import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
|
||||
import de.sebse.fuplanner.fragments.LoginFragment;
|
||||
@@ -34,7 +35,7 @@ public class MainActivity extends AppCompatActivity
|
||||
LoginFragment.OnLoginFragmentInteractionListener,
|
||||
ModulesFragment.OnModulesFragmentInteractionListener,
|
||||
ModDetailFragment.OnModuleDetailFragmentInteractionListener,
|
||||
ScheduleFragment.OnFragmentInteractionListener {
|
||||
ScheduleFragment.OnScheduleFragmentInteractionListener {
|
||||
|
||||
FragmentManager fragmentManager;
|
||||
private GoogleAuth mGoogleAuth;
|
||||
@@ -287,7 +288,7 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScheduleFragmentInteraction(Uri uri) {
|
||||
public void onScheduleFragmentInteraction(Calendar firstVisibleDate, Calendar lastVisibleDay) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,8 +38,8 @@ import de.sebse.fuplanner.tools.ui.weekview.WeekViewEvent;
|
||||
*
|
||||
* TODO Scroll week wise (snap)
|
||||
*/
|
||||
public class ScheduleFragment extends Fragment implements WeekView.EventClickListener, MonthLoader.MonthChangeListener, WeekView.EventLongPressListener {
|
||||
private OnFragmentInteractionListener mListener;
|
||||
public class ScheduleFragment extends Fragment implements MonthLoader.MonthChangeListener, WeekView.ScrollListener {
|
||||
private OnScheduleFragmentInteractionListener mListener;
|
||||
private WeekView mWeekView;
|
||||
private Logger log = new Logger(this);
|
||||
private Modules mModules = null;
|
||||
@@ -90,27 +91,17 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
||||
// Inflate the layout for this fragment
|
||||
View v = inflater.inflate(R.layout.fragment_schedule, container, false);
|
||||
mWeekView = v.findViewById(R.id.weekView);
|
||||
mWeekView.setOnEventClickListener(this);
|
||||
mWeekView.setMonthChangeListener(this);
|
||||
mWeekView.setEventLongPressListener(this);
|
||||
mWeekView.setScrollListener(this);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onScheduleFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
if (context instanceof OnScheduleFragmentInteractionListener) {
|
||||
mListener = (OnScheduleFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
@@ -123,11 +114,6 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventClick(WeekViewEvent event, RectF eventRect) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
|
||||
ArrayList<WeekViewEvent> events = new ArrayList<>();
|
||||
@@ -157,8 +143,10 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventLongPress(WeekViewEvent event, RectF eventRect) {
|
||||
|
||||
public void onFirstVisibleDayChanged(Calendar newFirstVisibleDay, Calendar oldFirstVisibleDay) {
|
||||
Calendar newLastVisibleDay = (Calendar) newFirstVisibleDay.clone();
|
||||
newLastVisibleDay.add(Calendar.HOUR, 24*mWeekView.getNumberOfVisibleDays());
|
||||
mListener.onScheduleFragmentInteraction(newFirstVisibleDay, newLastVisibleDay);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,8 +159,8 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
public interface OnFragmentInteractionListener {
|
||||
public interface OnScheduleFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onScheduleFragmentInteraction(Uri uri);
|
||||
void onScheduleFragmentInteraction(Calendar firstVisibleDate, Calendar lastVisibleDay);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user