/* * This file is part of the Remote Sensor Actuator Interface (ReSAI). * * Copyright(c) Andreas Kipp, Frederic Siepmann * http://opensource.cit-ec.de/projects/resai * * This file may be licensed under the terms of of the * GNU Lesser General Public License Version 3 (the ``LGPL''), * or (at your option) any later version. * * Software distributed under the License is distributed * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the LGPL for the specific language * governing rights and limitations. * * You should have received a copy of the LGPL along with this * program. If not, go to http://www.gnu.org/licenses/lgpl.html * or write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The development of this software was supported by the * Excellence Cluster EXC 277 Cognitive Interaction Technology. * The Excellence Cluster EXC 277 is a grant of the Deutsche * Forschungsgemeinschaft (DFG) in the context of the German * Excellence Initiative. * */ /** * Helper Class for creating several popups and Dialogs. * @author akipp */ package de.unibi.airobots.resaidroid.helper; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.Toast; public class EasyDialog { private static ProgressDialog dialog; /** * Creates a Toast message in the given context * * @param context * to show Toast on * @param message * to show */ public static void makeToast(Context context, String message) { int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, message, duration); toast.show(); } /** * Dialog with Ok Button * * @param message * text to be displayed */ public static void showInfoDialog(Context context, String message) { AlertDialog.Builder builder1 = new AlertDialog.Builder(context); builder1.setMessage(message).setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert1 = builder1.create(); alert1.show(); } /** * Creates ProgressDialog in the given context * @param context to show ProgressDialog * @param message to show */ public static void startProgressDialog(Context context, String message) { if (dialog != null) { dialog.setMessage(message); } else { dialog = ProgressDialog.show(context, "", message, true); } } /** * Change the message of the ProgressDialog * @param message to show */ public static void changeProgressDialogMessage(String message) { if (dialog != null) { dialog.setMessage(message); } } /** * Dismiss the ProgressDialog */ public static void dismissProgressDialog() { if (dialog != null) { dialog.dismiss(); dialog = null; } } }