3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp.fragments;
17 import android.content.Context;
18 import android.os.Bundle;
19 import android.support.v4.app.Fragment;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.view.inputmethod.InputMethodManager;
24 import android.widget.ArrayAdapter;
25 import android.widget.AutoCompleteTextView;
26 import android.widget.Button;
27 import android.widget.EditText;
29 import de.dhbwloe.campusapp.CampusAppFragment;
30 import de.dhbwloe.campusapp.R;
31 import de.dhbwloe.campusapp.coursenames.CourseName;
34 * A simple {@link Fragment} subclass.
36 public class FirstRun extends CampusAppFragment {
40 public View onCreateView(LayoutInflater inflater, ViewGroup container,
41 Bundle savedInstanceState) {
42 view = inflater.inflate(R.layout.fragment_first_run, container, false);
43 AppContext.setTitle("Campus App");
44 final FirstRun that = this;
46 Button startAppBtn = (Button)view.findViewById(R.id.startAppBtn);
47 startAppBtn.setOnClickListener(new View.OnClickListener() {
49 public void onClick(View v) {
54 Button courseSendBtn = (Button)view.findViewById(R.id.courseSubmitBtn);
55 courseSendBtn.setOnClickListener(new View.OnClickListener() {
57 public void onClick(View v) {
63 AutoCompleteTextView courseInput = (AutoCompleteTextView )view.findViewById(R.id.courseInput);
64 CourseName names[] = AppContext.getDatabaseManager().getCourseNames();
65 String courseNames[] = new String[names.length];
66 for(int i = 0; i < names.length; i++) {
67 courseNames[i] = names[i].getName();
70 ArrayAdapter<String> adapter = new ArrayAdapter<String>(AppContext.getMainActivity(), android.R.layout.simple_list_item_1, courseNames);
71 courseInput.setAdapter(adapter);
76 private void startApp() {
77 AppContext.getDatabaseManager().setRuntimeCache("AppStartCounter", "1");
78 AppContext.getNavigationManager().navigatePage("SplashScreen", null, false);
80 InputMethodManager imm = (InputMethodManager)AppContext.getMainActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
81 imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
84 private boolean setCourse() {
85 AutoCompleteTextView courseInput = (AutoCompleteTextView )view.findViewById(R.id.courseInput);
86 String courseName = courseInput.getText().toString();
87 if(courseName.length() <= 3)
90 AppContext.getDatabaseManager().setRuntimeCache("CourseName", courseName);