Builds and shows a non-blocking connect-progress dialog. Subsequent calls replace any previously shown progress dialog.
223 {
225
226 int pad = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24,
227 activity.getResources().getDisplayMetrics());
228 LinearLayout content = new LinearLayout(activity);
229 content.setOrientation(LinearLayout.HORIZONTAL);
230 content.setPadding(pad, pad, pad, pad);
231 content.setGravity(Gravity.CENTER_VERTICAL);
232
233 ProgressBar progressBar = new ProgressBar(activity);
234 progressBar.setIndeterminate(true);
235 content.addView(progressBar,
236 new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
237 ViewGroup.LayoutParams.WRAP_CONTENT));
238
239 TextView messageView = new TextView(activity);
240 messageView.setText(R.string.dlg_msg_connecting);
241 LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(
242 ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
243 textParams.leftMargin = pad;
244 content.addView(messageView, textParams);
245
246 progressDialog = new AlertDialog.Builder(activity)
247 .setTitle(title)
248 .setView(content)
249 .setNegativeButton(android.R.string.cancel,
250 (dialog, which) -> {
251 if (listener != null)
252 listener.onConnectCancel();
253 })
254 .setCancelable(false)
255 .create();
256 progressDialog.show();
257 }