ScheduleFragment init working; ScheduleFragment cleaned up
This commit is contained in:
@@ -138,7 +138,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
case R.id.nav_schedule:
|
case R.id.nav_schedule:
|
||||||
log.d("Stundenplan");
|
log.d("Stundenplan");
|
||||||
fragmentTransaction = fragmentManager.beginTransaction();
|
fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
fragmentTransaction.replace(R.id.fragcontainer, ScheduleFragment.newInstance("bla","bla"));
|
fragmentTransaction.replace(R.id.fragcontainer, ScheduleFragment.newInstance());
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
break;
|
break;
|
||||||
case R.id.nav_share:
|
case R.id.nav_share:
|
||||||
|
|||||||
@@ -42,20 +42,9 @@ import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
|
|||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
public class ScheduleFragment extends Fragment implements WeekView.EventClickListener, MonthLoader.MonthChangeListener, WeekView.EventLongPressListener {
|
public class ScheduleFragment extends Fragment implements WeekView.EventClickListener, MonthLoader.MonthChangeListener, WeekView.EventLongPressListener {
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
private OnFragmentInteractionListener mListener;
|
||||||
private WeekView mWeekView;
|
private WeekView mWeekView;
|
||||||
private Logger log = new Logger(this);
|
private Logger log = new Logger(this);
|
||||||
private ArrayList<WeekViewEvent> a = new ArrayList<>();
|
|
||||||
private HashSet<Integer> addedIds = new HashSet<>();
|
|
||||||
private Modules mModules = null;
|
private Modules mModules = null;
|
||||||
|
|
||||||
public ScheduleFragment() {
|
public ScheduleFragment() {
|
||||||
@@ -66,16 +55,12 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
|||||||
* Use this factory method to create a new instance of
|
* Use this factory method to create a new instance of
|
||||||
* this fragment using the provided parameters.
|
* this fragment using the provided parameters.
|
||||||
*
|
*
|
||||||
* @param param1 Parameter 1.
|
|
||||||
* @param param2 Parameter 2.
|
|
||||||
* @return A new instance of fragment ScheduleFragment.
|
* @return A new instance of fragment ScheduleFragment.
|
||||||
*/
|
*/
|
||||||
// TODO: Rename and change types and number of parameters
|
// TODO: Rename and change types and number of parameters
|
||||||
public static ScheduleFragment newInstance(String param1, String param2) {
|
public static ScheduleFragment newInstance() {
|
||||||
ScheduleFragment fragment = new ScheduleFragment();
|
ScheduleFragment fragment = new ScheduleFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
@@ -83,34 +68,19 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
a.add(new WeekViewEvent(1,"Das ist Test und der wird hoffentlich nicht doppelt", 2018, 10, 3,15,00,2018, 10, 3, 20,00));
|
|
||||||
a.add(new WeekViewEvent(1,"Das ist Test und der wird hoffentlich nicht doppelt", 2018, 7, 3,15,00,2018, 7, 3, 20,00));
|
|
||||||
|
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
KVV kvv = ((MainActivity) getActivity()).getKVV();
|
KVV kvv = ((MainActivity) getActivity()).getKVV();
|
||||||
kvv.getModuleList((Modules success) -> {
|
kvv.getModuleList((Modules success) -> {
|
||||||
mModules = success;
|
mModules = success;
|
||||||
log.d("Modules in onCreate", mModules.size());
|
|
||||||
final int[] i = {0};
|
final int[] i = {0};
|
||||||
Iterator<Modules.Module> it = mModules.iterator();
|
for (Modules.Module module: mModules) {
|
||||||
while (it.hasNext()) {
|
|
||||||
|
|
||||||
Modules.Module module = it.next();
|
|
||||||
log.d("onCreate Module gefunden", module.toString());
|
|
||||||
kvv.getModuleEvents(module, success1 -> {
|
kvv.getModuleEvents(module, success1 -> {
|
||||||
log.d("getModuleEvents gefunden");
|
|
||||||
i[0]++;
|
i[0]++;
|
||||||
log.d("mModules.size() und i", mModules.size(), i[0]);
|
|
||||||
if (i[0] >= mModules.size()) {
|
if (i[0] >= mModules.size()) {
|
||||||
if (mWeekView != null) {
|
if (mWeekView != null) {
|
||||||
log.d("refreshDrawableState");
|
|
||||||
|
|
||||||
mWeekView.invalidate();
|
mWeekView.invalidate();
|
||||||
mWeekView.refreshDrawableState();
|
mWeekView.notifyDatasetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,24 +91,13 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
Bundle savedInstanceState) {
|
|
||||||
|
|
||||||
|
|
||||||
// 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);
|
||||||
// Get a reference for the week view in the layout.
|
mWeekView = v.findViewById(R.id.weekView);
|
||||||
mWeekView = (WeekView) v.findViewById(R.id.weekView);
|
mWeekView.setOnEventClickListener(this);
|
||||||
|
mWeekView.setMonthChangeListener(this);
|
||||||
// Set an action when any event is clicked.
|
mWeekView.setEventLongPressListener(this);
|
||||||
mWeekView.setOnEventClickListener(this::onEventClick);
|
|
||||||
|
|
||||||
// The week view has infinite scrolling horizontally. We have to provide the events of a
|
|
||||||
// month every time the month changes on the week view.
|
|
||||||
mWeekView.setMonthChangeListener(this::onMonthChange);
|
|
||||||
|
|
||||||
// Set long press listener for events.
|
|
||||||
mWeekView.setEventLongPressListener(this::onEventLongPress);
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@@ -176,46 +135,28 @@ public class ScheduleFragment extends Fragment implements WeekView.EventClickLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
|
public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
|
||||||
//log.d("onMonthChange aufgerufen", mModules != null);
|
|
||||||
ArrayList<WeekViewEvent> events = new ArrayList<>();
|
ArrayList<WeekViewEvent> events = new ArrayList<>();
|
||||||
if (mModules != null){
|
if (mModules != null){
|
||||||
|
for (Modules.Module mod: mModules) {
|
||||||
Iterator<Modules.Module> it = mModules.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Modules.Module mod = it.next();
|
|
||||||
//log.d("null vieleicht", mod.events);
|
|
||||||
if (mod.events != null) {
|
if (mod.events != null) {
|
||||||
|
|
||||||
|
|
||||||
//log.d("mod in onMonthChange", mod.events.toString());
|
|
||||||
|
|
||||||
Iterator<Event> it_modEvents = mod.events.getEventsOfMonth(newYear, newMonth);
|
Iterator<Event> it_modEvents = mod.events.getEventsOfMonth(newYear, newMonth);
|
||||||
while (it_modEvents.hasNext()) {
|
while (it_modEvents.hasNext()) {
|
||||||
Event e = it_modEvents.next();
|
Event e = it_modEvents.next();
|
||||||
//log.d("Event in while", e.toString());
|
|
||||||
|
|
||||||
Calendar ende = Calendar.getInstance();
|
Calendar ende = Calendar.getInstance();
|
||||||
ende.setTimeInMillis(e.getEndDate());
|
ende.setTimeInMillis(e.getEndDate());
|
||||||
Calendar start = Calendar.getInstance();
|
Calendar start = Calendar.getInstance();
|
||||||
start.setTimeInMillis(e.getStartDate());
|
start.setTimeInMillis(e.getStartDate());
|
||||||
|
|
||||||
|
|
||||||
//log.d("Event?%:", startDate.toString(), "aufgeteilt",start.get(Calendar.YEAR), start.get(Calendar.MONTH)+1, start.get(Calendar.DAY_OF_MONTH), start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE) );
|
|
||||||
//log.d("Event?%:ende", endDate.toString(), "aufgeteilt",ende.get(Calendar.YEAR), ende.get(Calendar.MONTH)+1, ende.get(Calendar.DAY_OF_MONTH), ende.get(Calendar.HOUR_OF_DAY), ende.get(Calendar.MINUTE) );
|
|
||||||
//LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
||||||
events.add(new WeekViewEvent(1, e.getTitle(), start.get(Calendar.YEAR), start.get(Calendar.MONTH) + 1, start.get(Calendar.DAY_OF_MONTH), start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE), ende.get(Calendar.YEAR), ende.get(Calendar.MONTH) + 1, ende.get(Calendar.DAY_OF_MONTH), ende.get(Calendar.HOUR_OF_DAY), ende.get(Calendar.MINUTE)));
|
events.add(new WeekViewEvent(1, e.getTitle(), start.get(Calendar.YEAR), start.get(Calendar.MONTH) + 1, start.get(Calendar.DAY_OF_MONTH), start.get(Calendar.HOUR_OF_DAY), start.get(Calendar.MINUTE), ende.get(Calendar.YEAR), ende.get(Calendar.MONTH) + 1, ende.get(Calendar.DAY_OF_MONTH), ende.get(Calendar.HOUR_OF_DAY), ende.get(Calendar.MINUTE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d("onMonthChange_aufgerufen", newYear, newMonth);
|
return events;
|
||||||
|
//(List<? extends WeekViewEvent>) new WeekViewEvent(l,"Test", 2018, 7, 3,15,00,2018, 7, 3, 20,00);
|
||||||
//a.add(new WeekViewEvent(2,"Das ist Test und der wird hoffentlich nicht doppelt", 2018, 7, 3,15,00,2018, 7, 3, 20,00));
|
//int id, String title, int startYear, int startMonth, int startDay, int startHour, int startMinute, int endYear, int endMonth, int endDay, int endHour, int endMinute
|
||||||
|
|
||||||
return events;//(List<? extends WeekViewEvent>) new WeekViewEvent(l,"Test", 2018, 7, 3,15,00,2018, 7, 3, 20,00);
|
|
||||||
//int startYear, int startMonth, int startDay, int startHour, int startMinute, int endYear, int endMonth, int endDay, int endHour, int endMinute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user