City.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.ysnows.sultra.model;
  2. import android.text.TextUtils;
  3. import com.github.promeg.pinyinhelper.Pinyin;
  4. import com.litesuits.orm.LiteOrm;
  5. import com.litesuits.orm.db.annotation.Table;
  6. import com.litesuits.orm.db.assit.QueryBuilder;
  7. import com.ysnows.sultra.App;
  8. import java.util.ArrayList;
  9. @Table("city")
  10. public class City {
  11. public String City_ID;
  12. public String City_EN;
  13. public String City_EN_SIMPLE;
  14. public String City_CN;
  15. public String Country_code;
  16. public String Country_EN;
  17. public String Country_EN_SIMPLE;
  18. public String Country_CN;
  19. public String Province_EN;
  20. public String Province_EN_SIMPLE;
  21. public String Province_CN;
  22. public String Latitude;
  23. public String Longitude;
  24. public String AD_code;
  25. public static City findCityByName(String name) {
  26. if (TextUtils.isEmpty(name)) {
  27. return null;
  28. }
  29. LiteOrm liteOrm = App.getConfigOrm();
  30. ArrayList<City> res = null;
  31. if (Pinyin.isChinese(name.charAt(0))) {
  32. res = liteOrm.query(new QueryBuilder<>(City.class).where("City_CN = ?", name));
  33. } else {
  34. res = liteOrm.query(new QueryBuilder<>(City.class).where("City_EN = ?", name));
  35. }
  36. if (res != null && res.size() > 0) {
  37. return res.get(0);
  38. }
  39. return null;
  40. }
  41. }