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