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.search;
18 import android.os.Bundle;
20 import java.net.URLDecoder;
21 import java.net.URLEncoder;
23 import de.dhbwloe.campusapp.NavigationManager;
26 * Created by pk910 on 19.01.2016.
28 public class SearchTarget {
29 private boolean bInAppTarget = false;
30 private String sTargetUrl = null;
31 private Bundle oArguments = new Bundle();
33 public SearchTarget(String target) {
34 if(target.startsWith("#")) { // InApp Navigation
36 target = target.substring(1);
38 String[] parts = target.split("#", 2);
40 sTargetUrl = parts[0];
41 if(parts.length > 1) {
43 String[] args = parts[1].split("&");
44 for(int i = 0; i < args.length; i++) {
45 String[] arg = args[i].split("=");
48 oArguments.putString(URLDecoder.decode(arg[0], "UTF-8"), URLDecoder.decode(arg[1], "UTF-8"));
50 oArguments.putBoolean(URLDecoder.decode(arg[0], "UTF-8"), true);
51 } catch(Exception e) {}
57 public SearchTarget() {
60 public boolean isInAppTarget() {
64 public void setInAppTarget(boolean inAppTarget) {
65 bInAppTarget = inAppTarget;
68 public String getTargetUrl() {
72 public void setTargetUrl(String url) {
76 public void setArgument(String name, String value) {
77 oArguments.putString(name, value);
80 public void navigate(NavigationManager navigationManager) {
81 Bundle args = oArguments;
83 navigationManager.navigatePage(sTargetUrl, args);
85 args.putString("url", sTargetUrl);
86 navigationManager.navigatePage("WebBrowser", args, false);