package com.decoding.twodtg.barcodereader2dtg;

import android.app.Activity;
import android.app.AlertDialog;
import android.util.Log;
import android.view.Gravity;

/**
 * Created by Work on 11.10.2016.
 */
public class Utils
{
  static final String Tag = "BarcodeReader_2dtg";

  public static void Trace(String msg)
  {
    Log.e(Tag, msg);
  }

  public static void Failed(Exception e)
  {
    Log.e(Tag, e.getMessage());
  }

  public static void Failed(String msg, Exception e)
  {
    Log.e(Tag, msg + "\n" + e.getMessage());
  }

  public static void MessageBox(Activity a, String msg, String caption)
  {
    try
    {

      AlertDialog alertDialog = new AlertDialog.Builder(a).create();
      alertDialog.setTitle(caption);
      alertDialog.setMessage(msg);
      alertDialog.getWindow().setGravity(Gravity.BOTTOM);
      alertDialog.show();
    }
    catch(Exception e)
    {
    }
  }

  public static void MessageBoxError(Activity a, String msg)
  {
    MessageBox(a, msg, "Error!");
  }
}
