Merge pull request #1048 from owncloud/shareWithYou_icon_in_fileList
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / LoadingDialog.java
1 /**
2 * ownCloud Android client application
3 *
4 * Copyright (C) 2015 ownCloud Inc.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19 package com.owncloud.android.ui.dialog;
20
21 import com.owncloud.android.R;
22
23 import android.app.Dialog;
24 import android.os.Bundle;
25 import android.support.v4.app.DialogFragment;
26 import android.view.LayoutInflater;
27 import android.view.View;
28 import android.view.ViewGroup;
29 import android.view.Window;
30 import android.widget.TextView;
31
32 public class LoadingDialog extends DialogFragment {
33
34 private String mMessage;
35
36 public LoadingDialog() {
37 super();
38 }
39
40 @Override
41 public void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
43 setRetainInstance(true);
44 setCancelable(false);
45 }
46
47 public LoadingDialog(String message) {
48 this.mMessage = message;
49 }
50
51 @Override
52 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
53 // Create a view by inflating desired layout
54 View v = inflater.inflate(R.layout.loading_dialog, container, false);
55
56 // set value
57 TextView tv = (TextView) v.findViewById(R.id.loadingText);
58 tv.setText(mMessage);
59
60 return v;
61 }
62
63 @Override
64 public Dialog onCreateDialog(Bundle savedInstanceState) {
65 Dialog dialog = super.onCreateDialog(savedInstanceState);
66 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
67 return dialog;
68 }
69
70 @Override
71 public void onDestroyView() {
72 if (getDialog() != null && getRetainInstance())
73 getDialog().setDismissMessage(null);
74 super.onDestroyView();
75 }
76 }