use of kogvet.eye.MainActivity in project Eye by tommyolsson.
the class FragmentCreateEvent method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inf = inflater.inflate(R.layout.fragment_create_event, container, false);
// Changes title to the subject name
((MainActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.newActivity));
((MainActivity) getActivity()).showBackButton();
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
subjectEditText = (EditText) inf.findViewById(R.id.subjectEditText);
locationEditText = (EditText) inf.findViewById(R.id.locationEditText);
dateEditText = (EditText) inf.findViewById(R.id.dateEditText);
startEditText = (EditText) inf.findViewById(R.id.startEditText);
endEditText = (EditText) inf.findViewById(R.id.endEditText);
dateEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// To show current date in the datepicker
final Calendar mCalendar = Calendar.getInstance();
int mYear = mCalendar.get(Calendar.YEAR);
int mMonth = mCalendar.get(Calendar.MONTH);
int mDay = mCalendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog mDatePicker = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
// TODO Auto-generated method stub
/* Set picked date in textedit */
String myFormat = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.getDefault());
mCalendar.set(Calendar.YEAR, selectedyear);
mCalendar.set(Calendar.MONTH, selectedmonth);
mCalendar.set(Calendar.DAY_OF_MONTH, selectedday);
dateEditText.setText(sdf.format(mCalendar.getTime()));
}
}, mYear, mMonth, mDay);
mDatePicker.getDatePicker().setCalendarViewShown(false);
mDatePicker.setTitle("Select date");
mDatePicker.show();
}
});
startEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
startEditText.setText(String.format("%02d:%02d", selectedHour, selectedMinute));
}
}, hour, minute, // Yes 24 hour time
true);
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
});
endEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
endEditText.setText(String.format("%02d:%02d", selectedHour, selectedMinute));
}
}, hour, minute, // Yes 24 hour time
true);
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
});
checkBox = inf.findViewById(R.id.checkBox);
checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (((CheckBox) v).isChecked()) {
// Disables editText for time if event is all day
startEditText.setEnabled(false);
endEditText.setEnabled(false);
isAllDay = true;
} else {
startEditText.setEnabled(true);
endEditText.setEnabled(true);
isAllDay = false;
}
}
});
createButton = inf.findViewById(R.id.createButton);
createButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String subject = subjectEditText.getText().toString();
String location = locationEditText.getText().toString();
String date = dateEditText.getText().toString();
String start = startEditText.getText().toString();
String end = endEditText.getText().toString();
Log.i("Ämne", subject);
Log.i("Plats", location);
Log.i("Datum", date);
Log.i("Start", start);
Log.i("Slut", end);
Log.i("Heldag", Boolean.toString(isAllDay));
if (subject.matches("")) {
Toast.makeText(getContext(), "Namn på aktivitet saknas", Toast.LENGTH_SHORT).show();
} else {
if (isAllDay) {
LocalDate ld = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String endDate = ld.plusDays(1).toString();
((MainActivity) getActivity()).createEventGraphAPI(subject, location, date, endDate, "00", "00", isAllDay);
} else {
((MainActivity) getActivity()).createEventGraphAPI(subject, location, date, date, start, end, isAllDay);
}
Toast.makeText(getContext(), "Aktivitet skapad", Toast.LENGTH_SHORT).show();
getActivity().onBackPressed();
}
}
});
return inf;
}
use of kogvet.eye.MainActivity in project Eye by tommyolsson.
the class FragmentOpenEvent method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inf = inflater.inflate(R.layout.fragment_open_event, container, false);
setText(inf);
// Changes title to the subject name
((MainActivity) getActivity()).setActionBarTitle(event.getSubject());
((MainActivity) getActivity()).showBackButton();
// Buttons
checkBox = inf.findViewById(R.id.checkBox);
showBox();
checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String id = event.getId();
String url = "https://graph.microsoft.com/beta/me/events/" + id;
String importance = event.getImportance();
((MainActivity) getActivity()).patchGraphAPI(url, importance);
}
});
return inf;
}
use of kogvet.eye.MainActivity in project Eye by tommyolsson.
the class FragmentHome method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
((MainActivity) getActivity()).getSupportActionBar().show();
((MainActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.menu_home));
((MainActivity) getActivity()).showBackButton();
TextView currentDate = view.findViewById(R.id.dateToday);
currentDate.setText(getCurrentDate());
mSwipeRefreshLayout = view.findViewById(R.id.swiperefresh);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
myUpdateOperation();
}
});
return view;
}
use of kogvet.eye.MainActivity in project Eye by tommyolsson.
the class FragmentOpenMeeting method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inf = inflater.inflate(R.layout.fragment_open_meeting, container, false);
setText(inf);
// Buttons
bookButton = inf.findViewById(R.id.bookButton);
cancelButton = inf.findViewById(R.id.cancelButton);
showButton();
bookButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String id = event.getId();
String url = "https://graph.microsoft.com/beta/me/events/" + id + "/accept";
((MainActivity) getActivity()).postGraphAPI(url);
event.getResponseStatus().setResponse("accepted");
recreateFragment();
Toast.makeText(getContext(), "Bokat", Toast.LENGTH_SHORT).show();
}
});
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String id = event.getId();
String url = "https://graph.microsoft.com/beta/me/events/" + id + "/tentativelyAccept";
((MainActivity) getActivity()).postGraphAPI(url);
event.getResponseStatus().setResponse("tentativelyAccepted");
recreateFragment();
Toast.makeText(getContext(), "Avbokat", Toast.LENGTH_SHORT).show();
}
});
// Changes title to the subject name
((MainActivity) getActivity()).setActionBarTitle(event.getSubject());
((MainActivity) getActivity()).showBackButton();
return inf;
}
use of kogvet.eye.MainActivity in project Eye by tommyolsson.
the class TabFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tab_layout, container, false);
((MainActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.menu_calendar));
((MainActivity) getActivity()).showBackButton();
final TabLayout tabLayout = view.findViewById(R.id.tabLayout);
DayOfWeek weekDay = LocalDateTime.now().getDayOfWeek();
tabLayout.addTab(tabLayout.newTab().setText(weekDay.getDisplayName(TextStyle.FULL, Locale.getDefault())));
LocalDate date = LocalDate.now();
TemporalField woy = WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear();
int weekNumber = date.get(woy);
tabLayout.addTab(tabLayout.newTab().setText("Vecka " + weekNumber));
viewPager = view.findViewById(R.id.viewpager);
PagerAdapter pagerAdapter = new PagerAdapter(getChildFragmentManager(), allEvents);
viewPager.setAdapter(pagerAdapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return view;
}
Aggregations