Added README.txt and GPL Header to Source Files
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / CampusAppFragment.java
1 /* CampusAppFragment.java
2  *
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.
7  *
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.
12  *
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/>.
15  */
16 package de.dhbwloe.campusapp;
17
18 import android.os.Bundle;
19 import android.support.v4.app.Fragment;
20 import android.view.View;
21
22 import java.lang.reflect.Field;
23
24 import de.dhbwloe.campusapp.search.SearchIndices;
25
26 /**
27  * Created by pk910 on 19.01.2016.
28  */
29 public abstract class CampusAppFragment extends Fragment {
30     protected CampusAppContext AppContext;
31     protected View oFragmentView;
32
33     @Override
34     public void onCreate(Bundle savedInstanceState) {
35         AppContext = CampusAppContext.getInstance();
36         super.onCreate(savedInstanceState);
37     }
38
39     public static SearchIndices[] GetSearchIndices() {
40         return new SearchIndices[0];
41     }
42
43     @Override
44     public void onDetach() {
45         super.onDetach();
46
47         try {
48             Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager");
49             childFragmentManager.setAccessible(true);
50             childFragmentManager.set(this, null);
51
52         } catch (NoSuchFieldException e) {
53             throw new RuntimeException(e);
54         } catch (IllegalAccessException e) {
55             throw new RuntimeException(e);
56         }
57     }
58
59 }