Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. public class Contact {
  2.  
  3. private int CTC_ID;
  4. public Bitmap CTC_IMAGE;
  5. public String CTC_NOM;
  6. public String CTC_NUMERO;
  7.  
  8. public Contact(){
  9. }
  10.  
  11. public Contact(Bitmap CTC_IMAGE, String CTC_NOM, String CTC_NUMERO){
  12. this.CTC_IMAGE = CTC_IMAGE;
  13. this.CTC_NOM = CTC_NOM;
  14. this.CTC_NUMERO = CTC_NUMERO;
  15. }
  16. public Contact(String CTC_NOM, String CTC_NUMERO){
  17. this.CTC_NOM = CTC_NOM;
  18. this.CTC_NUMERO = CTC_NUMERO;
  19. }
  20.  
  21. public int getCTC_ID(){
  22. return CTC_ID;
  23. }
  24. public Bitmap getCTC_IMAGE(){return CTC_IMAGE; }
  25. public String getCTC_NOM() {
  26. return CTC_NOM;
  27. }
  28. public String getCTC_NUMERO() {
  29. return CTC_NUMERO;
  30. }
  31.  
  32. public void setCTC_ID(int CTC_ID) {
  33. this.CTC_ID = CTC_ID;
  34. }
  35. public void setCTC_IMAGE(Bitmap CTC_IMAGE) {
  36. this.CTC_IMAGE = CTC_IMAGE;
  37. }
  38. public void setCTC_NOM(String CTC_NOM) {
  39. this.CTC_NOM = CTC_NOM;
  40. }
  41. public void setCTC_NUMERO(String CTC_NUMERO) {
  42. this.CTC_NUMERO = CTC_NUMERO;
  43. }
  44.  
  45.  
  46. public String toString(){
  47. return "ID : "+CTC_ID+"nimage : "+CTC_IMAGE+"nnom : "+CTC_NOM+"nnumero : "+CTC_NUMERO;
  48. }
  49. }
  50.  
  51. public ArrayList<Contact> fetchAllContactDetail() throws SQLException {
  52. SQLiteDatabase db = this.getWritableDatabase();
  53. Cursor mCursor = db.query(TABLE_CONTACT, new String[]{"CTC_ID _id", KEY_CTC_IMAGE, KEY_CTC_IMAGE, KEY_CTC_NOM, KEY_CTC_NUMERO}, null, null, null, null, null);
  54.  
  55. if (mCursor.moveToFirst()) {
  56. do {
  57. byte[] blob = mCursor.getBlob(mCursor.getColumnIndex(KEY_CTC_IMAGE));
  58. String name = mCursor.getString(mCursor.getColumnIndex(KEY_CTC_NOM));
  59. String numero = mCursor.getString(mCursor.getColumnIndex(KEY_CTC_NUMERO));
  60. contactListe.add(new Contact(Utility.getPhoto(blob), name, numero));
  61. } while (mCursor.moveToNext());
  62. }
  63. return contactListe;
  64. }
  65.  
  66. public class ContactAdapter extends BaseAdapter {
  67.  
  68. private Context mContext;
  69. ArrayList<Contact> contactList = new ArrayList<Contact>();
  70.  
  71. // Constructor
  72. public ContactAdapter(Context c, ArrayList<Contact> contactList) {
  73. mContext = c;
  74. this.contactList = contactList;
  75. }
  76.  
  77.  
  78. @Override
  79. public int getCount() {
  80. return contactList.size();
  81.  
  82. }
  83.  
  84. @Override
  85. public Object getItem(int position) {
  86. return contactList.get(position);
  87. }
  88.  
  89. @Override
  90. public long getItemId(int position) {
  91. return 0;
  92. }
  93.  
  94. @Override
  95. public View getView(int position, View convertView, ViewGroup parent) {
  96. LayoutInflater layoutInflater;
  97. layoutInflater = LayoutInflater.from(mContext);
  98.  
  99. convertView= layoutInflater.inflate(R.layout.contact_item, null);
  100.  
  101. // Lookup view for data population
  102. ImageView img = (ImageView) convertView.findViewById(R.id.img);
  103. TextView name = (TextView) convertView.findViewById(R.id.name);
  104.  
  105. // Populate the data into the template view using the data object
  106. img.setImageBitmap(contactList.get(position).getCTC_IMAGE());
  107. name.setText(contactList.get(position).getCTC_NUMERO());
  108. // Return the completed view to render on screen
  109. return convertView;
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement