예제 #1
0
 /*
  * TODO Remove Toasts from this class and replace them with something useful
  * This is a hack more than anything else. We shouldn't use Toasts if we're going to change the message all the time
  */
 private void showToast(int resourceId, boolean error) {
   if (error) {
     ToastUtil.showError(getActivity().getApplicationContext(), resourceId);
   } else {
     ToastUtil.showSuccess(getActivity().getApplicationContext(), resourceId);
   }
 }
예제 #2
0
    @Override
    public void onReceivedError(
        WebView view, int errorCode, String description, String failingUrl) {
      ConnectivityManager cm =
          (ConnectivityManager) getBaseContext().getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
      boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

      int errorMessage;
      if (!isConnected) {
        errorMessage = R.string.error_internet_connection;
      } else {
        errorMessage = R.string.error_unknown_error;
      }
      ToastUtil.showError(getBaseContext(), errorMessage);
      finish();
    }