If you think the Android project JBoss-Admin-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* JBoss Admin//fromwww.java2s.com
* Copyright 2013, Christos Vasilakis, and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package org.cvasilak.jboss.mobile.app.fragments.dialogs;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;
publicclass ProgressDialogFragment extends DialogFragment {
publicstaticfinal String TAG = ProgressDialogFragment.class.getSimpleName();
publicstatic ProgressDialogFragment newInstance(int msgId) {
ProgressDialogFragment f = new ProgressDialogFragment();
Bundle args = new Bundle();
args.putInt("message", msgId);
f.setArguments(args);
return f;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setMessage(getActivity().getString(getArguments().getInt("message")));
dialog.setIndeterminate(true);
dialog.setCancelable(false);
// Disable the back button
DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() {
@Override
publicboolean onKey(DialogInterface dialog, int keyCode,
KeyEvent event) {
return (keyCode == KeyEvent.KEYCODE_BACK);
}
};
dialog.setOnKeyListener(keyListener);
return dialog;
}
publicstaticvoid showDialog(FragmentActivity activity, int msgId) {
FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
ProgressDialogFragment dialog = ProgressDialogFragment.newInstance(msgId);
dialog.show(ft, TAG);
}
publicstaticvoid dismissDialog(FragmentActivity activity) {
ProgressDialogFragment dialog =
(ProgressDialogFragment) activity.getSupportFragmentManager().findFragmentByTag(TAG);
if (dialog != null) {
FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
ft.remove(dialog);
ft.commitAllowingStateLoss();
}
}
}