Added README.txt and GPL Header to Source Files
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / CampusApp.java
index 719d8297de7f21498f58eac011adf7bf844441f5..654a4dc1f708a187ec7a35c948ed201f059f16b4 100644 (file)
@@ -1,3 +1,18 @@
+/* CampusApp.java
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
 package de.dhbwloe.campusapp;
 
 import android.content.Context;
@@ -54,12 +69,14 @@ public class CampusApp extends FragmentActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_campus_app);
 
+        // Erstelle neuen AppContext, wenn keiner existiert
         AppContext = CampusAppContext.getInstance();
         if(AppContext == null)
             AppContext = new CampusAppContext(this, R.id.fragment_container);
         else
             AppContext.setMainActivity(this);
 
+        // Wenn die App aus dem Ruhezustand (oder auch Orientation change) reaktiviert wird soll nicht zuerst der Splashscreen angezeigt werden.
         boolean instantRestore = false;
         if(savedInstanceState != null) {
             long lastrun = savedInstanceState.getLong("lastrun");
@@ -68,6 +85,7 @@ public class CampusApp extends FragmentActivity {
             if(lastrun < 30) {
                 instantRestore = true;
 
+                // restore previous Title
                 AppContext.setTitle(savedInstanceState.getString("activetitle"));
             }
 
@@ -92,6 +110,7 @@ public class CampusApp extends FragmentActivity {
     @Override
     public void onSaveInstanceState(Bundle savedInstanceState) {
         Log.i("CampusApp", "Event: onSaveInstanceState");
+
         // Save instance state during "restarts" due to orientation changes.
         // We don't want to see the splash screen everytime the orientation changes ;)
         savedInstanceState.putLong("lastrun", (new Date()).getTime() / 1000);
@@ -104,8 +123,6 @@ public class CampusApp extends FragmentActivity {
 
         // Always call the superclass so it can save the view hierarchy state
         super.onSaveInstanceState(savedInstanceState);
-
-        AppContext = null; // simulate GC
     }
 
     public void prepareMainUi() {
@@ -177,6 +194,7 @@ public class CampusApp extends FragmentActivity {
         EditText edtSearchInput = (EditText) findViewById(R.id.search_input);
         TextView txtTitle = (TextView) findViewById(R.id.title);
 
+        // EventListener für Suchfunktion
         btnOpenSearch.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {