@Override protected void onPreExecute() { pDialog = new SweetAlertDialog(context, SweetAlertDialog.PROGRESS_TYPE); pDialog.getProgressHelper().setBarColor(context.getResources().getColor(R.color.primary)); pDialog.setTitleText("Loading"); pDialog.setCancelable(false); pDialog.show(); }
@Override public void showProgress(String message) { mProgressdialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); mProgressdialog.getProgressHelper().setBarColor(getResources().getColor(R.color.colorPrimary)); mProgressdialog.setTitleText(message); mProgressdialog.setCancelable(false); mProgressdialog.show(); }
public void showLoadingDialog() { if (mLoadingDialog == null) { mLoadingDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); mLoadingDialog.setCancelable(false); mLoadingDialog.setTitleText("数据加载中..."); } mLoadingDialog.show(); }
@Override protected void onPreExecute() { super.onPreExecute(); connection = new ConnectionDetector(context); prefs = AppPreferences.getInstance(context); pDialog = new SweetAlertDialog(context, SweetAlertDialog.PROGRESS_TYPE).setTitleText("Loading"); pDialog.show(); pDialog.setCancelable(false); pDialog.setCanceledOnTouchOutside(false); }
public void showErrorDialog( String title, String content, SweetAlertDialog.OnSweetClickListener listener) { mErrorDialog = new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE) .setConfirmText("确定") .setTitleText(title) .setContentText(content) .setConfirmClickListener(listener); mErrorDialog.show(); }
public void showWarningDialog( String title, String content, SweetAlertDialog.OnSweetClickListener listener) { mWarningDialog = new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE) .setTitleText(title) .setContentText(content) .setConfirmText("确定") .setCancelText("取消") .setConfirmClickListener(listener); mWarningDialog.show(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.fragment_latest, container, false); mContext = getActivity(); mActivity = getActivity(); initializeViews(); MainActivity.tabs.setVisibility(View.VISIBLE); MainActivity.layout_user_profle.setVisibility(View.GONE); if (NetworkUtils.isOnline(getActivity())) { mDialog = Utils.showSweetProgressDialog( getActivity(), getResources().getString(R.string.progress_loading), SweetAlertDialog.PROGRESS_TYPE); mDialog.setCancelable(true); getLatestFeeds(); } else { Utils.showSweetProgressDialog( getActivity(), getActivity().getResources().getString(R.string.check_your_internet_connection), SweetAlertDialog.WARNING_TYPE); } list_latest_feeds.setHasFixedSize(true); list_latest_feeds.setLayoutManager(new LinearLayoutManager(getActivity())); mLatestFeedsAdapter = new LatestFeedsAdapter(getActivity(), latestFeedList, list_latest_feeds); list_latest_feeds.setAdapter(mLatestFeedsAdapter); mLatestFeedsAdapter.setOnLoadMoreListener( new OnLoadMoreListener() { @Override public void onLoadMore() { if (hasMoreItems) { latestFeedList.add(null); if (latestFeedList.size() >= 10) { mLatestFeedsAdapter.notifyItemInserted(latestFeedList.size() - 1); refreshItems(); } } else { } } }); return mView; }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.btn_login: loading = Utils.showLoading(this); loading.show(); String mail = etMail.getText().toString(); String password = etPass.getText().toString(); if (mail.length() > 0 && password.length() > 0) { login(mail, password); } else { showError("Verifier vos parametres de connection. \nmerci :)"); } break; case R.id.btn_skip: goToFirst(null); break; } }
@Override public void hideProgress() { if (mProgressdialog != null) { mProgressdialog.dismiss(); } }
protected void onPostExecute(String result) { super.onPostExecute(result); try { if (!result.equals("") && !result.equals("null") && result.equals("success")) { dialog = new SweetAlertDialog(context, SweetAlertDialog.SUCCESS_TYPE) .setTitleText("Successfully") .setContentText(myresult) .setConfirmText("ok") .setConfirmClickListener( new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { Intent intent = new Intent(context, ApproveTimeSheet.class); context.startActivity(intent); ((Activity) context).finish(); dialog.dismiss(); } }); dialog.show(); pDialog.dismiss(); } else if (result.equals("fail")) { new SweetAlertDialog(context, SweetAlertDialog.NORMAL_TYPE) .setTitleText("Oops...") .setContentText(myresult) .show(); pDialog.dismiss(); } else if (!connection.isConnectingToInternet()) { new SweetAlertDialog(context, SweetAlertDialog.ERROR_TYPE) .setTitleText("Oops...") .setContentText("Internet Connection not available!") .show(); pDialog.dismiss(); } else { pDialog.dismiss(); if (flag == 1) { flag = 0; dialog = new SweetAlertDialog(context, SweetAlertDialog.WARNING_TYPE) .setTitleText("Oops") .setContentText("Server Connection Problem.") .setConfirmText("ok") .setConfirmClickListener( new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { Intent intent = new Intent(context, NavigationActivity.class); context.startActivity(intent); ((Activity) context).finish(); sDialog.dismiss(); } }); dialog.show(); } else { dialog = new SweetAlertDialog(context, SweetAlertDialog.WARNING_TYPE) .setTitleText("Oops") .setContentText("Server Connection Problem.") .setConfirmText("ok") .setConfirmClickListener( new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { Intent intent = new Intent(context, NavigationActivity.class); context.startActivity(intent); ((Activity) context).finish(); sDialog.dismiss(); } }); dialog.show(); } } } catch (Exception e) { e.printStackTrace(); } }
@Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); pDialog.dismissWithAnimation(); try { if (exceptionToBeThrown != null) { if (exceptionToBeThrown instanceof HttpHostConnectException) { MessageCustomDialogDTO messageCustomDialogDTO = new MessageCustomDialogDTO(); messageCustomDialogDTO.setTitle(context.getResources().getString(R.string.oops)); messageCustomDialogDTO.setButton(context.getResources().getString(R.string.ok)); messageCustomDialogDTO.setMessage( context.getResources().getString(R.string.login_activity_no_internet)); messageCustomDialogDTO.setContext(context); SnackBar.show(context, messageCustomDialogDTO); } else if (exceptionToBeThrown instanceof UnknownHostException) { MessageCustomDialogDTO messageCustomDialogDTO = new MessageCustomDialogDTO(); messageCustomDialogDTO.setTitle(context.getResources().getString(R.string.oops)); messageCustomDialogDTO.setButton(context.getResources().getString(R.string.ok)); messageCustomDialogDTO.setMessage( context.getResources().getString(R.string.login_activity_no_internet)); messageCustomDialogDTO.setContext(context); SnackBar.show(context, messageCustomDialogDTO); } else { MessageCustomDialogDTO messageCustomDialogDTO = new MessageCustomDialogDTO(); messageCustomDialogDTO.setTitle(context.getResources().getString(R.string.oops)); messageCustomDialogDTO.setButton(context.getResources().getString(R.string.ok)); messageCustomDialogDTO.setContext(context); messageCustomDialogDTO.setMessage( context.getResources().getString(R.string.error_message)); SnackBar.show(context, messageCustomDialogDTO); } } else { JSONObject jsonObject = new JSONObject(result); if (statusCode >= 200 && statusCode <= 299) { Gson gson = new Gson(); SellerDTO sellerDTO = gson.fromJson(jsonObject.getString("response"), SellerDTO.class); Bundle bundle = new Bundle(); bundle.putString("sellerDTO", new Gson().toJson(sellerDTO)); Intent intent = new Intent(context, ResetPasswordActivity.class); intent.putExtras(bundle); context.startActivity(intent); ((ActionBarActivity) context).finish(); } else { ErrorDTO errorDTO = new Gson().fromJson(jsonObject.getString("error"), ErrorDTO.class); MessageCustomDialogDTO messageCustomDialogDTO = new MessageCustomDialogDTO(); messageCustomDialogDTO.setTitle(errorDTO.getName()); messageCustomDialogDTO.setButton(context.getResources().getString(R.string.ok)); messageCustomDialogDTO.setMessage(errorDTO.getMessage()); messageCustomDialogDTO.setContext(context); SnackBar.show(context, messageCustomDialogDTO); } } } catch (Exception e) { MessageCustomDialogDTO messageCustomDialogDTO = new MessageCustomDialogDTO(); messageCustomDialogDTO.setTitle(context.getResources().getString(R.string.oops)); messageCustomDialogDTO.setButton(context.getResources().getString(R.string.ok)); messageCustomDialogDTO.setContext(context); messageCustomDialogDTO.setMessage(context.getResources().getString(R.string.error_message)); SnackBar.show(context, messageCustomDialogDTO); } }
public void dismissLoadingDialog() { if (mLoadingDialog != null) { mLoadingDialog.dismiss(); } }