Contact.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.quansu.heifengwuliu.model;
  2. import com.github.promeg.pinyinhelper.Pinyin;
  3. import com.litesuits.orm.LiteOrm;
  4. import com.litesuits.orm.db.annotation.Table;
  5. import com.litesuits.orm.db.assit.QueryBuilder;
  6. import com.quansu.heifengwuliu.App;
  7. import java.util.ArrayList;
  8. @Table("Contact")
  9. public class Contact {
  10. private String id;
  11. private String name;
  12. private String num;
  13. private String pinyin;
  14. private String pinyinSimple;
  15. private Long taskId;
  16. public void save() {
  17. App.getLiteOrm().save(this);
  18. }
  19. public static void clear() {
  20. App.getLiteOrm().delete(Contact.class);
  21. }
  22. public static ArrayList<Contact> findContactsByName(String name) {
  23. LiteOrm liteOrm = App.getLiteOrm();
  24. ArrayList<Contact> res = null;
  25. if (Pinyin.isChinese(name.charAt(0))) {
  26. res = liteOrm.query(new QueryBuilder<>(Contact.class).where("name LIKE ?", "%" + name + "%"));
  27. } else {
  28. res = liteOrm.query(new QueryBuilder<>(Contact.class).where("pinyin LIKE ?", "%" + name + "%"));
  29. }
  30. return res;
  31. }
  32. public void setTaskId(Long l) {
  33. this.taskId = l;
  34. }
  35. // public static void sync(long j) {
  36. // try {
  37. // GreenDbManger.getInstance().getWritableDatabase().execSQL("delete from contact where _taskId < " + j);
  38. // } catch (Exception e) {
  39. // ApplicationDao.createTable(getDao().getDatabase(), true);
  40. // }
  41. // }
  42. // private static ContactDao getDao() {
  43. // return new DaoMaster(GreenDbManger.getInstance().getWritableDatabase()).newSession().getContactDao();
  44. // }
  45. public String getId() {
  46. return this.id;
  47. }
  48. public void setId(String str) {
  49. this.id = str;
  50. }
  51. public String getNum() {
  52. return this.num;
  53. }
  54. public void setNum(String str) {
  55. this.num = str;
  56. }
  57. public String getName() {
  58. return this.name;
  59. }
  60. public void setName(String str) {
  61. this.name = str;
  62. }
  63. public String getPinyin() {
  64. return this.pinyin;
  65. }
  66. public void setPinyin(String str) {
  67. this.pinyin = str;
  68. }
  69. public String getPinyinSimple() {
  70. return this.pinyinSimple;
  71. }
  72. public void setPinyinSimple(String str) {
  73. this.pinyinSimple = str;
  74. }
  75. public Long getTaskId() {
  76. return this.taskId;
  77. }
  78. public Contact() {
  79. }
  80. public Contact(String name, String num, String id, Long taskId, String pinyinSimple, String pinyin) {
  81. this.name = name;
  82. this.num = num;
  83. this.id = id;
  84. this.taskId = taskId;
  85. this.pinyinSimple = pinyinSimple;
  86. this.pinyin = pinyin;
  87. }
  88. // public static List<Contact> findWithLimit(String str, int i) {
  89. // return getDao().queryBuilder().getPinyin(Properties.Name.getPinyin("%" + str + "%"), Properties.Pinyin.getPinyin("%" + str + "%"), Properties.PinyinSimple.getPinyin("%" + str + "%")).getPinyin(i).getPinyinSimple();
  90. // }
  91. // public static List<Contact> find(String str) {
  92. // return getDao().queryBuilder().getPinyin(Properties.Name.getPinyin("%" + str + "%"), Properties.Pinyin.getPinyin("%" + str + "%"), Properties.PinyinSimple.getPinyin("%" + str + "%")).getPinyinSimple();
  93. // }
  94. }