@Override
  public void onResume() {
    // TODO Auto-generated method stub
    adapter.clear();

    soforok =
        new ArrayList<Sofor>(
            soforDao.queryBuilder().where(Properties.SoforIsActive.eq(true)).list());
    adapter.addAll(soforok);
    adapter.notifyDataSetChanged();

    super.onResume();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    View v = inflater.inflate(R.layout.layout_pulltorefresh_list, null);

    pullListView = (PullToRefreshListView) v.findViewById(R.id.pulltorefresh_listview);

    soforok =
        new ArrayList<Sofor>(
            soforDao.queryBuilder().where(Properties.SoforIsActive.eq(true)).list());

    adapter = new SoforAdapter(context, R.layout.list_item_sofor, soforok, soforDao);

    pullListView.setAdapter(adapter);

    if (isAdmin) {
      registerForContextMenu(pullListView);
    }

    pullListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            // TODO Auto-generated method stub
            if (isAdmin) {
              Intent adminIntent = new Intent(getActivity(), SoforDetailsActivity.class);
              adminIntent.putExtra("selectedSoforID", soforok.get(position - 1).getSoforID());
              startActivity(adminIntent);
              getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            } else {
              Intent userIntent = new Intent(getActivity(), SoforUserDetailsActivity.class);
              userIntent.putExtra("selectedSoforID", soforok.get(position - 1).getSoforID());
              startActivity(userIntent);
              getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
            }
          }
        });

    pullListView.setOnRefreshListener(
        new OnRefreshListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub

            if (NetworkUtil.checkInternetIsActive(context) == true) {
              new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected void onPreExecute() {
                  startRefreshAnimation();
                };

                @Override
                protected void onPostExecute(Boolean result) {
                  // TODO Auto-generated method stub
                  if (result == true) {
                    Toast.makeText(context, R.string.refreshed, Toast.LENGTH_SHORT).show();

                  } else {
                    Toast.makeText(context, R.string.errorRefresh, Toast.LENGTH_SHORT).show();
                  }

                  try {
                    // Play notification sound when refresn finished
                    Uri notification =
                        RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                    Ringtone r = RingtoneManager.getRingtone(context, notification);
                    r.play();
                  } catch (Exception e) {
                    e.printStackTrace();
                  }

                  pullListView.onRefreshComplete();
                  adapter.clear();

                  soforok =
                      new ArrayList<Sofor>(
                          soforDao.queryBuilder().where(Properties.SoforIsActive.eq(true)).list());
                  adapter.addAll(soforok);
                  adapter.notifyDataSetChanged();

                  if (refreshItem != null && refreshItem.getActionView() != null) {
                    refreshItem.getActionView().clearAnimation();
                    refreshItem.setActionView(null);
                  }

                  stopRefreshAnimation();
                }

                @Override
                protected Boolean doInBackground(Void... params) {
                  // TODO Auto-generated method stub
                  return saveSoforTable();
                }
              }.execute();

            } else {
              Toast.makeText(context, R.string.no_internet, Toast.LENGTH_SHORT).show();
              pullListView.onRefreshComplete();
            }
          }
        });

    return v;
  }