Esempio n. 1
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();

    // Inflate and set the layouts for the dialog
    final View customDialogView = inflater.inflate(R.layout.dialog_about, null);
    final View customDialogTitle = inflater.inflate(R.layout.dialog_about_title, null);

    final TextView tvUser = (TextView) customDialogView.findViewById(R.id.tv_about_user);
    final TextView tvServer = (TextView) customDialogView.findViewById(R.id.tv_about_server);

    User currentUser = InfoWallApplication.getCurrentUser();

    tvUser.setText(currentUser.getEmailAddress());
    tvServer.setText(currentUser.getServerURL());

    // Pass null as the parent view because its going in the dialog layout
    builder
        .setView(customDialogView)
        // Set title
        .setCustomTitle(customDialogTitle)
        // Add action buttons
        .setNegativeButton(
            R.string.cancelDialog,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                Log.i("FragmentAlertDialog", "Negative Button");
              }
            });
    return builder.create();
  }
Esempio n. 2
0
 @Override
 public boolean deleteByID(long Id) {
   boolean ok = false;
   try {
     InfoWallApplication.getInstance().getDatabaseHelper().getFeedReaderDAO().deleteById(Id);
     ok = true;
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return ok;
 }
Esempio n. 3
0
 private Feed assignUnusedId(Feed feed) {
   try {
     if (!InfoWallApplication.getInstance()
         .getDatabaseHelper()
         .getFeedReaderDAO()
         .idExists(feed.getFeedReaderID())) return feed;
     else feed.setFeedReaderID(feed.getFeedReaderID() + 1);
     feed = assignUnusedId(feed);
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return feed;
 }
Esempio n. 4
0
  @Override
  public Object queryForId(long iD) {
    Feed feed = null;
    try {
      DBFeed dbFeed =
          InfoWallApplication.getInstance().getDatabaseHelper().getFeedReaderDAO().queryForId(iD);
      feed = mapDBFeedToFeed(dbFeed);

    } catch (SQLException e) {
      e.printStackTrace();
    }
    return feed;
  }
Esempio n. 5
0
 @Override
 public boolean update(Object object) {
   boolean ok = false;
   try {
     InfoWallApplication.getInstance()
         .getDatabaseHelper()
         .getFeedReaderDAO()
         .createOrUpdate(mapFeedToDBFeed((Feed) object));
     ok = true;
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return ok;
 }
Esempio n. 6
0
 @Override
 public ArrayList queryForAll() {
   ArrayList<Feed> feeds = new ArrayList<>();
   ;
   try {
     List<DBFeed> dbFeeds =
         InfoWallApplication.getInstance().getDatabaseHelper().getFeedReaderDAO().queryForAll();
     for (DBFeed dbFeed : dbFeeds) {
       feeds.add(mapDBFeedToFeed(dbFeed));
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return feeds;
 }
Esempio n. 7
0
  public boolean createOrUpdate(Object object) {
    boolean ok = false;
    if (object == null) return ok;
    try {
      Dao<DBFeed, Long> feedDAO =
          InfoWallApplication.getInstance().getDatabaseHelper().getFeedReaderDAO();
      Feed feed = (Feed) object;
      feedDAO.createOrUpdate(mapFeedToDBFeed(feed));

      ok = true;
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return ok;
  }
Esempio n. 8
0
 @Override
 public boolean create(Object object) {
   boolean ok = false;
   try {
     Feed feed = (Feed) object;
     feed = assignUnusedId(feed);
     InfoWallApplication.getInstance()
         .getDatabaseHelper()
         .getFeedReaderDAO()
         .create(mapFeedToDBFeed(feed));
     ok = true;
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return ok;
 }
Esempio n. 9
0
  public ArrayList<Feed> getUnsyncedItems() throws SQLException {
    Dao<DBFeed, Long> feedReaderDAO =
        InfoWallApplication.getInstance().getDatabaseHelper().getFeedReaderDAO();
    // get our query builder from the DAO
    QueryBuilder<DBFeed, Long> queryBuilder = feedReaderDAO.queryBuilder();
    queryBuilder.where().eq(DBFeed.SYNCSTATUS_FIELD_NAME, false);
    PreparedQuery<DBFeed> preparedQuery = queryBuilder.prepare();
    List<DBFeed> dbFeeds = feedReaderDAO.query(preparedQuery);

    ArrayList<Feed> unsycedFeeds = new ArrayList<Feed>();
    if (dbFeeds != null || !dbFeeds.isEmpty()) {
      for (DBFeed dbFeed : dbFeeds) {
        unsycedFeeds.add(mapDBFeedToFeed(dbFeed));
      }
    }
    return unsycedFeeds;
  }