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