@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    action_bar_title_txtv.setText(getString(R.string.payment));

    List<StoreCoinItemEntity> storeItemEntities = new ArrayList<StoreCoinItemEntity>();

    // StoreCoinItemDomain storeCoinItemDomain = new StoreCoinItemDomain();
    // storeCoinItemDomain.setImageResId(R.drawable.store_coin);
    // storeCoinItemDomain.setHowManyCoins("1000");
    // storeCoinItemDomain.setHowMuchRmb("1");
    // storeCoinItemDomain.setName("金幣");
    // storeCoinItemDomain.setDesc("可以用來購買道具");
    // storeItemEntities.add(storeCoinItemDomain);

    try {
      storeItemEntities =
          BeginApplication.dbUtils.findAll(
              Selector.from(StoreCoinItemEntity.class).where("PD_key", "=", "Money"));
    } catch (DbException e) {
      e.printStackTrace();
    }

    // try {
    // storeItemEntities = BeginApplication.dbUtils.findAll(Selector.from(StoreItemEntity.class));
    // } catch (DbException e) {
    // e.printStackTrace();
    // }

    storeCoinListAdapter = new ExchangeCoinListAdapter(this);
    storeCoinListAdapter.setStoreCoinItemList(storeItemEntities);

    store_coin_lstv.setAdapter(storeCoinListAdapter);
  }
Example #2
0
  private static synchronized DbUtils getInstance(DaoConfig daoConfig) {
    DbUtils dao = daoMap.get(daoConfig.getDbName());
    if (dao == null) {
      dao = new DbUtils(daoConfig);
      daoMap.put(daoConfig.getDbName(), dao);
    } else {
      dao.daoConfig = daoConfig;
    }

    // update the database if needed
    SQLiteDatabase database = dao.database;
    int oldVersion = database.getVersion();
    int newVersion = daoConfig.getDbVersion();
    if (oldVersion != newVersion) {
      if (oldVersion != 0) {
        DbUpgradeListener upgradeListener = daoConfig.getDbUpgradeListener();
        if (upgradeListener != null) {
          upgradeListener.onUpgrade(dao, oldVersion, newVersion);
        } else {
          try {
            dao.dropDb();
          } catch (DbException e) {
            LogUtils.e(e.getMessage(), e);
          }
        }
      }
      database.setVersion(newVersion);
    }

    return dao;
  }
 public static void saveHotel(Context context, List<Hotel> hotelList) {
   DbUtils db = DbUtils.create(context);
   try {
     db.saveOrUpdateAll(hotelList);
   } catch (DbException e) {
     e.printStackTrace();
   }
 }
Example #4
0
 public static NotificationEO queryLastNotify() {
   try {
     return FinanceFundsApp.getDB()
         .findFirst(Selector.from(NotificationEO.class).orderBy("CreateTime", true));
   } catch (DbException e) {
     e.printStackTrace();
   }
   return null;
 }
 public static List<Banquet> getBanquetsByHotelId(Context context, String hotelId) {
   DbUtils db = DbUtils.create(context);
   try {
     return db.findAll(Selector.from(Banquet.class).where("hotelId", "=", hotelId));
   } catch (DbException e) {
     e.printStackTrace();
     return null;
   }
 }
  public List<Comment> query(int page) {
    try {
      List<Comment> list = db.findAll(Selector.from(Comment.class).limit(20 * page));
      return list;
    } catch (DbException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return null;
  }
Example #7
0
 private void saveDoc(DocInfoBean docInfoBean) {
   // TODO Auto-generated method stub
   // DbUtils dbUtils = new DbUtils(null);
   DbUtils db = DBUtilsHelper.getInstance().getDb();
   try {
     db.createTableIfNotExist(DocInfoBean.class);
     db.save(docInfoBean);
   } catch (DbException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Example #8
0
 // 获取商品的第一页数据
 public List<Product> getIndexProduct(int index) {
   List<Product> list = new ArrayList<>();
   int startIndex = (index - 1) * 20;
   int endIndex = index * 20 + 1;
   try {
     list =
         db.findAll(
             Selector.from(Product.class).where("id", ">", startIndex).and("id", "<", endIndex));
   } catch (DbException e) {
     e.printStackTrace();
   }
   return list == null ? new ArrayList<Product>() : list;
 }
 @OnItemClick(R.id.fg_lines_listView)
 protected void lvOnItemClick(AdapterView<?> parent, View view, int position, long id) {
   /*-1 因为headerView*/
   Cursor c = (Cursor) historyListAdapter.getItem(position - 1);
   try {
     BusLineBean busBeanfromCursor = BusDBManager.getInstance(context).getBusLineBeanfromCursor(c);
     Intent intent = new Intent(context, BusLineInfoActivity.class);
     intent.putExtra("busLine", busBeanfromCursor);
     context.startActivity(intent);
   } catch (DbException e) {
     e.printStackTrace();
   }
 }
Example #10
0
 public static List<NotificationEO> queryNotifyList(Integer pageNum, Integer pageSize) {
   Log.d(TAG, "queryNotifyList()");
   try {
     return FinanceFundsApp.getDB()
         .findAll(
             Selector.from(NotificationEO.class)
                 .orderBy("CreateTime", true)
                 .limit(pageSize)
                 .offset(pageSize * pageNum));
   } catch (DbException e) {
     e.printStackTrace();
   }
   return null;
 }
Example #11
0
 /*package*/ DownloadManager(Context appContext) {
   ColumnConverterFactory.registerColumnConverter(
       HttpHandler.State.class, new HttpHandlerStateConverter());
   mContext = appContext;
   db = DbUtils.create(mContext);
   try {
     downloadInfoList = db.findAll(Selector.from(DownloadInfo.class));
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (downloadInfoList == null) {
     downloadInfoList = new ArrayList<DownloadInfo>();
   }
 }
Example #12
0
 // 搜索数据
 public List<Product> getSearchData(String codeOrName, int cateId) {
   List<Product> list = new ArrayList<>();
   try {
     list =
         db.findAll(
             Selector.from(Product.class)
                 .where("ProductId", "=", codeOrName)
                 .or("ProductName", "=", codeOrName)
                 .or("CategoryId", "=", cateId));
   } catch (DbException e) {
     e.printStackTrace();
   }
   return list == null ? new ArrayList<Product>() : list;
 }
Example #13
0
 @Override
 public void onFailure(HttpException error, String msg) {
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null) {
     downloadInfo.setState(handler.getState());
   }
   try {
     db.saveOrUpdate(downloadInfo);
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (baseCallBack != null) {
     baseCallBack.onFailure(error, msg);
   }
 }
Example #14
0
 @Override
 public void onSuccess(ResponseInfo<File> responseInfo) {
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null) {
     downloadInfo.setState(handler.getState());
   }
   try {
     db.saveOrUpdate(downloadInfo);
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (baseCallBack != null) {
     baseCallBack.onSuccess(responseInfo);
   }
 }
 /**
  * 以一天缓存一次策略,判断当天是否缓存过
  *
  * @param context
  * @param tag 页面名称
  * @return true:已经缓存过, 不需要再缓存 false:未缓存过,需要缓存操作
  */
 public static boolean todayChecked(Context context, String tag) {
   DbUtils db = DbUtils.create(context);
   try {
     Cache cache = db.findFirst(Selector.from(Cache.class).where("pageName", "=", tag));
     if (cache == null) return false;
     String todayStr = getToday();
     if (todayStr.equals(cache.getDate())) {
       return true;
     } else {
       return false;
     }
   } catch (DbException e) {
     e.printStackTrace();
     return false;
   }
 }
Example #16
0
 @Override
 public void onLoading(long total, long current, boolean isUploading) {
   HttpHandler<File> handler = downloadInfo.getHandler();
   if (handler != null) {
     downloadInfo.setState(handler.getState());
   }
   downloadInfo.setFileLength(total);
   downloadInfo.setProgress(current);
   try {
     db.saveOrUpdate(downloadInfo);
   } catch (DbException e) {
     LogUtils.e(e.getMessage(), e);
   }
   if (baseCallBack != null) {
     baseCallBack.onLoading(total, current, isUploading);
   }
 }
Example #17
0
 // 获取商品列表的数据
 private List<Category> getSpData() {
   List<Category> list = new ArrayList<>();
   Category category = new Category();
   category.categoryid = 0;
   category.name = "未分类";
   list.add(category);
   try {
     List<Category> categoryList = db.findAll(Selector.from(Category.class));
     if (categoryList == null) {
       return new ArrayList<Category>();
     }
     list.addAll(categoryList);
   } catch (DbException e) {
     e.printStackTrace();
   }
   return list;
 }
 public void insert(List<Comment> list) {
   try {
     for (int i = 0; i < list.size(); i++) {
       Comment commentItem = list.get(i);
       Comment findItem =
           db.findFirst(
               Selector.from(Comment.class).where("commentId", "=", commentItem.getCommentId()));
       if (findItem != null) {
         db.update(commentItem, WhereBuilder.b("commentId", "=", commentItem.getCommentId()));
       } else {
         db.save(commentItem);
       }
     }
   } catch (DbException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 // Quit Unity
 @Override
 protected void onDestroy() {
   System.out.println("---UnityonDestroy");
   DbUtils dbUtils = DbUtils.create(this);
   LocalPlay localPlay = new LocalPlay();
   localPlay.setNowplayUrl("");
   localPlay.setQingxidu("");
   localPlay.setSdurl("");
   localPlay.setHdrul("");
   localPlay.setUhdrul("");
   localPlay.setType("");
   localPlay.setUnityJump(true);
   try {
     dbUtils.saveOrUpdate(localPlay);
   } catch (DbException e) {
     e.printStackTrace();
   }
   mUnityPlayer.quit();
   super.onDestroy();
 }
 private void initData() {
   try {
     List<Mp3Info> list =
         CrashAppliacation.dbUtils.findAll(
             Selector.from(Mp3Info.class)
                 .where("playTime", "!=", 0)
                 .orderBy("playTime", true)
                 .limit(Constant.PLAY_RECORD_NUM));
     if (list == null || list.size() == 0) {
       record_tv.setVisibility(View.VISIBLE);
       record_lv.setVisibility(View.GONE);
     } else {
       record_tv.setVisibility(View.GONE);
       record_lv.setVisibility(View.VISIBLE);
       mp3Infos = (ArrayList<Mp3Info>) list;
       adapter = new MyMusicListAdapter(this, mp3Infos);
       record_lv.setAdapter(adapter);
     }
   } catch (DbException e) {
     e.printStackTrace();
   }
 }
Example #21
0
  @Override
  public void setValue2Entity(Object entity, Cursor cursor, int index) {
    Object value = null;
    Class<?> columnType = columnField.getType();
    Object finderValue =
        TableUtils.getColumnOrId(entity.getClass(), this.valueColumnName).getColumnValue(entity);
    if (columnType.equals(FinderLazyLoader.class)) {
      value = new FinderLazyLoader(this, finderValue);
    } else if (columnType.equals(List.class)) {
      try {
        value = new FinderLazyLoader(this, finderValue).getAllFromDb();
      } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
      }
    } else {
      try {
        value = new FinderLazyLoader(this, finderValue).getFirstFromDb();
      } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
      }
    }

    if (setMethod != null) {
      try {
        setMethod.invoke(entity, value);
      } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
      }
    } else {
      try {
        this.columnField.setAccessible(true);
        this.columnField.set(entity, value);
      } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
      }
    }
  }
Example #22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat_comment);
    dbUtils = DBUtilsHelper.getInstance().getDb();
    Intent i = getIntent();
    if (null != i) {
      subjectID = i.getExtras().getString("subjectId");
      try {
        chatInfoBean =
            dbUtils.findFirst(Selector.from(ChatInfoBean.class).where("SubjectID", "=", subjectID));

        if (null != chatInfoBean) {
          subjectType = chatInfoBean.getSubjectType();
        }
      } catch (DbException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    initView();
    initListener();
    listenET();
  }
Example #23
0
  private void testDb() {

    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    Parent parent = new Parent();
    parent.name = "测试";
    parent.isVIP = false;
    parent.setAdmin(true);
    parent.setEmail("*****@*****.**");

    /*Parent parent2 = new Parent();
    parent2.name = "测试2";
    parent2.isVIP = false;*/

    try {

      DbUtils db = DbUtils.create(this);
      db.configAllowTransaction(true);

      Child child = new Child();
      child.name = "child name";
      // db.saveBindingId(parent);
      // child.parent = new SQLiteLazyLoader<Parent>(Child.class, "parentId", parent.getId());
      child.parent = parent;

      try {
        Parent test = db.findFirst(parent); // 通过entity的属性查找
        LogUtils.d("wyouflf :" + test);
      } catch (Exception e) {
        LogUtils.e(e.getMessage(), e);
      }

      parent.setTime(new Date());
      parent.setTime2(new java.sql.Date(new Date().getTime()));

      db.saveBindingId(child); // 保存对象关联数据库生成的id

      List<Child> children = db.findAll(Selector.from(Child.class));
      LogUtils.d("wyouflf size:" + children.size());
      if (children.size() > 0) {
        LogUtils.d("wyouflf child:" + children.get(children.size() - 1).parent);
      }

      List<Parent> list =
          db.findAll(
              Selector.from(Parent.class)
                  .where(WhereBuilder.b("id", "<", 54))
                  .orderBy("id")
                  .limit(10));
      LogUtils.d("wyouflf size:" + list.size());
      if (list.size() > 0) {
        LogUtils.d("wyouflf parent:" + list.get(list.size() - 1).toString());
      }

      // parent.name = "hahaha123";
      // db.update(parent);

      Parent entity = db.findById(Parent.class, parent.getId());
      LogUtils.d("wyouflf parent:" + entity.toString());

      List<DbModel> dbModels =
          db.findDbModelAll(
              Selector.from(Parent.class).groupBy("name").select("name", "count(name)"));
      LogUtils.d("wyouflf:" + dbModels.size());

    } catch (DbException e) {
      LogUtils.e(e.getMessage(), e);
    }
  }