@Override
  public void onResume() {
    super.onResume();

    List<Permission> data = mAdapter.getPermissionList();
    data.clear();

    for (Permission item : mPermissions) {
      if (!item.isActive()) {
        data.add(item);
      }
    }

    // Dismiss permission dialog if there's no work for it.
    if (data.isEmpty()) {
      dismiss();
    }

    mAdapter.notifyDataSetChanged();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get permissions array
    Bundle args = getArguments();
    assert args != null;
    String[] p = args.getStringArray(KEY_PERMISSIONS);
    mPermissions = new Permission[p.length];
    for (int i = 0; i < p.length; i++) {
      final String name = p[i];
      mPermissions[i] = Permission.newInstance(getActivity(), name);
    }
  }