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.DialogInterface;
18 import android.os.Bundle;
19 import android.support.v4.app.DialogFragment;
20 import android.support.v4.app.FragmentActivity;
21 import android.support.v4.app.FragmentTransaction;
22 import android.view.Gravity;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 import android.view.ViewGroup;
26 import android.widget.LinearLayout;
27 import android.widget.PopupWindow;
29 import de.dhbwloe.campusapp.CampusAppContext;
30 import de.dhbwloe.campusapp.CampusAppFragment;
31 import de.dhbwloe.campusapp.R;
32 import de.dhbwloe.campusapp.search.SearchIndices;
33 import de.dhbwloe.campusapp.search.SearchTarget;
36 * Created by pk910 on 21.01.2016.
38 public class PopupFragment extends DialogFragment {
39 private CampusAppContext AppContext;
40 private CampusAppFragment oCurrentFragment;
43 public void onCreate(Bundle savedInstanceState) {
44 AppContext = CampusAppContext.getInstance();
45 super.onCreate(savedInstanceState);
49 public View onCreateView(LayoutInflater inflater, ViewGroup container,
50 Bundle savedInstanceState) {
51 View view = inflater.inflate(R.layout.content_popup, container, false);
52 getDialog().setOnCancelListener(new DialogInterface.OnCancelListener() {
54 public void onCancel(DialogInterface dialog) {
55 AppContext.getNavigationManager().closeDialog();
59 Bundle args = getArguments();
61 String targetPage = args.getString("target");
62 SearchTarget target = new SearchTarget(targetPage);
63 String targetPageName;
64 if(target.isInAppTarget())
65 targetPageName = target.getTargetUrl();
67 targetPageName = "WebBrowser";
68 args.putString("url", target.getTargetUrl());
70 CampusAppFragment fragment = AppContext.getNavigationManager().getPageFragment(targetPageName);
71 fragment.setArguments(args);
73 FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
74 transaction.add(R.id.content_container, fragment);
75 oCurrentFragment = fragment;
82 public void destroyView() {
83 if(oCurrentFragment != null) {
84 CampusAppFragment fragment = oCurrentFragment;
85 oCurrentFragment = null;
86 if(fragment.isAdded()) {
87 FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
88 transaction.remove(fragment);
91 AppContext.getMainActivity().onBackPressed();
95 public CampusAppFragment getCurrentFragment() {
96 return oCurrentFragment;