|
38 | 38 | import com.dreamteam.app.commons.SectionHelper;
|
39 | 39 | import com.dreamteam.app.commons.SeriaHelper;
|
40 | 40 | import com.dreamteam.app.commons.UIHelper;
|
| 41 | +import com.dreamteam.app.dao.SectionDAO; |
41 | 42 | import com.dreamteam.app.db.DbConstant;
|
42 | 43 | import com.dreamteam.app.db.DbManager;
|
43 | 44 | import com.dreamteam.app.entity.ItemListEntity;
|
@@ -498,40 +499,42 @@ private void outSectionEdit()
|
498 | 499 |
|
499 | 500 | private ArrayList<Section> readSections(int page) throws Exception
|
500 | 501 | {
|
501 |
| - ArrayList<Section> sections = null; |
502 |
| - int len = 0;// 表长 |
503 |
| - int start = 0;// 其实读 |
504 |
| - int end = 0;// 结尾 |
505 |
| - Log.i(tag, "page = " + page); |
506 |
| - // 从数据库读数据 |
507 |
| - DbManager mgr = new DbManager(Main.this, DbManager.DB_NAME, null, 1); |
508 |
| - SQLiteDatabase db = mgr.getWritableDatabase(); |
509 |
| - Cursor cursor = db.query(DbConstant.SECTION_TABLE_NAME, |
510 |
| - null, null, null, null, null, null); |
511 |
| - len = cursor.getCount(); |
512 |
| - db.close(); |
513 |
| - |
514 |
| - start = page * Main.PAGE_SECTION_SIZE; |
515 |
| - if (cursor.moveToPosition(start)) |
516 |
| - { |
517 |
| - sections = new ArrayList<Section>(); |
518 |
| - |
519 |
| - int offset = start + Main.PAGE_SECTION_SIZE; |
520 |
| - end = len < offset ? len : offset; |
521 |
| - for (int i = start; i < end; i++) |
522 |
| - { |
523 |
| - Section s = new Section(); |
524 |
| - String title = cursor.getString(cursor.getColumnIndex("title")); |
525 |
| - String url = cursor.getString(cursor.getColumnIndex("url")); |
526 |
| - String tableName = cursor.getString(cursor.getColumnIndex("table_name")); |
527 |
| - s.setTitle(title); |
528 |
| - s.setUrl(url); |
529 |
| - s.setTableName(tableName); |
530 |
| - sections.add(s); |
531 |
| - cursor.moveToNext(); |
532 |
| - } |
533 |
| - } |
534 |
| - return sections; |
| 502 | + SectionDAO sd = new SectionDAO(); |
| 503 | + return sd.getList(this, page); |
| 504 | +// ArrayList<Section> sections = null; |
| 505 | +// int len = 0;// 表长 |
| 506 | +// int start = 0;// 其实读 |
| 507 | +// int end = 0;// 结尾 |
| 508 | +// Log.i(tag, "page = " + page); |
| 509 | +// // 从数据库读数据 |
| 510 | +// DbManager mgr = new DbManager(Main.this, DbManager.DB_NAME, null, 1); |
| 511 | +// SQLiteDatabase db = mgr.getWritableDatabase(); |
| 512 | +// Cursor cursor = db.query(DbConstant.SECTION_TABLE_NAME, |
| 513 | +// null, null, null, null, null, null); |
| 514 | +// len = cursor.getCount(); |
| 515 | +// db.close(); |
| 516 | +// |
| 517 | +// start = page * Main.PAGE_SECTION_SIZE; |
| 518 | +// if (cursor.moveToPosition(start)) |
| 519 | +// { |
| 520 | +// sections = new ArrayList<Section>(); |
| 521 | +// |
| 522 | +// int offset = start + Main.PAGE_SECTION_SIZE; |
| 523 | +// end = len < offset ? len : offset; |
| 524 | +// for (int i = start; i < end; i++) |
| 525 | +// { |
| 526 | +// Section s = new Section(); |
| 527 | +// String title = cursor.getString(cursor.getColumnIndex("title")); |
| 528 | +// String url = cursor.getString(cursor.getColumnIndex("url")); |
| 529 | +// String tableName = cursor.getString(cursor.getColumnIndex("table_name")); |
| 530 | +// s.setTitle(title); |
| 531 | +// s.setUrl(url); |
| 532 | +// s.setTableName(tableName); |
| 533 | +// sections.add(s); |
| 534 | +// cursor.moveToNext(); |
| 535 | +// } |
| 536 | +// } |
| 537 | +// return sections; |
535 | 538 | }
|
536 | 539 |
|
537 | 540 | @Override
|
|
0 commit comments