Ejemplo n.º 1
0
 public void addClientUser(TwitterSession twitterSession, CreateCompletedListener addedListener) {
   ConnectionSource connectionSource = null;
   try {
     DataBaseHelper helper = new DataBaseHelper(Global.getInstance().getApplicationContext());
     connectionSource = helper.getConnectionSource();
     TableUtils.createTableIfNotExists(connectionSource, ClientUserTable.class);
     Dao<ClientUserTable, String> dao = helper.getDao(ClientUserTable.class);
     ClientUserTable table1 = dao.queryForId("" + twitterSession.getUserId());
     if (table1 == null) {
       ClientUserTable table = new ClientUserTable(twitterSession);
       dao.createOrUpdate(table);
       new ClientUser(
           clientUsers.size(),
           twitterSession,
           clientUser -> {
             clientUsers.add(clientUser);
             addedListener.completed(clientUser);
           },
           TwitterException::printStackTrace);
     } else {
       addedListener.completed(null);
     }
   } catch (SQLException e) {
     e.printStackTrace();
     throw new RuntimeException(e);
   } finally {
     if (connectionSource != null) {
       try {
         connectionSource.close();
       } catch (SQLException e) {
         e.printStackTrace();
       }
     }
   }
 }
Ejemplo n.º 2
0
 public ClientUserTable(TwitterSession twitterSession) {
   userId = twitterSession.getUserId();
   userName = twitterSession.getUserName();
   authToken = twitterSession.getAuthToken().token;
   authTokenSecret = twitterSession.getAuthToken().secret;
 }