@Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    adapter.swapCursor(cursor);
    if (isDualPane) {
      if (cursor.moveToFirst()) {
        /** If list is not empty, trying to restore previously displayed details. */
        restoreHandler.sendEmptyMessage(0);
      } else {
        /** If list became empty, removing previously displayed details */
        removeDetailsHandler.sendEmptyMessage(0);
      }
    }

    /** If there is no sync going and list is empty, refreshing list. */
    Account account = AccountService.getAccount();
    if (account != null) {
      boolean syncActive = ContentResolver.isSyncActive(account, Contract.CONTENT_AUTHORITY);
      boolean syncPending = ContentResolver.isSyncPending(account, Contract.CONTENT_AUTHORITY);
      if (!cursor.moveToFirst() && firstLoad && !(syncActive || syncPending)) {
        refreshList();
      }
    }
    firstLoad = false;
    setRefreshIndicationState(updateManager.isUpdating(UpdateManager.UpdateType.ALARMS));
  }
 @Override
 public void onLoaderReset(Loader<Cursor> loader) {
   adapter.swapCursor(null);
 }