Commits

Yang Zhang committed e0d817a

change class package

Comments (0)

Files changed (37)

android/AndroidManifest.xml

         <activity android:name="me.yangblog.manmanpa.reader.ComicReaderActivity"
         	android:label="@string/title_activity_main" />
         <!-- ChapterListActivity -->
-        <activity android:name="me.yangblog.manmanpa.ChapterListActivity" 
+        <activity android:name=".ChapterListActivity" 
         	android:label="@string/title_activity_main" />
         
         

android/src/me/yangblog/manmanpa/BookArrayAdapter.java

-package me.yangblog.manmanpa;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Stack;
-
-import me.yangblog.manmanpa.model.Book;
-
-import android.app.Activity;
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-public class BookArrayAdapter<String> extends ArrayAdapter<String> {
-	protected final Activity context;
-	protected String[] names;
-	protected LinkedList<Book> bookList;
-	protected Stack<Book> newBook;
-	public BookArrayAdapter(Activity context, LinkedList<Book> bookList) {
-		super(context, R.layout.book_list);
-		this.bookList = bookList;
-		this.context = context;
-		List<String> bookStrings = new LinkedList<String>();
-		for (Book book : bookList) {
-			bookStrings.add((String) book.toString());
-		}
-		this.names = (String[]) bookStrings.toArray();
-		super.addAll(this.names);
-		newBook = new Stack<Book>();
-	}
-
-/*
-	public void setList(List<Book> bookList) {
-		List<String> bookStrings = new LinkedList<String>();
-		for(Book book:bookList){
-			this.bookList.addFirst(book);
-		}
-		for (Book book : bookList) {
-			bookStrings.add((String) book.toString());
-		}
-		this.names = (String[]) bookStrings.toArray();
-		//super.clear();
-		super.addAll(this.names);
-	}
-*/
-	public void addBook(Book book) {
-		
-		newBook.add(book);
-	}
-	
-	@SuppressWarnings("unchecked")
-	public void update(){
-		for(Book book:newBook){
-			super.add((String) book.getName());
-			bookList.add(book);
-		}
-		newBook.clear();
-	}
-
-	@Override
-	public View getView(int position, View convertView, ViewGroup parent) {
-		 LayoutInflater inflater = (LayoutInflater) context
-	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-	    View row = inflater.inflate(R.layout.book_list, parent, false);
-
-
-	    ImageView image = (ImageView) row.findViewById(R.id.imgIcon);
-		TextView titleText = (TextView) row.findViewById(R.id.txtTitle);
-		TextView authorText = (TextView) row.findViewById(R.id.author);
-		TextView lastCh = (TextView) row.findViewById(R.id.lastchapter);
-		Book book = bookList.get(position);
-        titleText.setText(book.getName());
-        authorText.setText("����:"+book.getAuthor());
-        lastCh.setText("������"+book.getLastChapter());
-        if(book.getCoverImage() == null){
-        	image.setImageResource(R.drawable.ic_launcher);
-        }else{
-        	image.setImageBitmap(book.getCoverImage());
-        }
-		//row.setTag(holder);
-
-		return row;
-	}
-
-}

android/src/me/yangblog/manmanpa/ChapterAdapter.java

-package me.yangblog.manmanpa;
-
-import java.util.List;
-
-import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.model.Chapter;
-import me.yangblog.manmanpa.reader.ComicReaderActivity;
-import android.content.Context;
-import android.content.Intent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-
-public class ChapterAdapter extends BaseAdapter {
-	protected ChapterListActivity context;
-	protected List<Chapter> chapterList;
-	protected Book book;
-	public ChapterAdapter(ChapterListActivity context, Book book) {
-		this.context = context;
-		this.chapterList = book.getChapterList();
-		this.book = book;
-
-	}
-
-	@Override
-	public int getCount() {
-		return this.chapterList.size();
-	}
-
-	@Override
-	public Object getItem(int position) {
-		return null;
-	}
-
-	@Override
-	public long getItemId(int position) {
-		return 0;
-	}
-
-	@Override
-	public View getView(final int position, View convertView, ViewGroup parent) {
-		Button button = new Button(context);
-		button.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
-		button.setMinLines(2);
-		button.setText(this.chapterList.get(position).getName());
-		button.setOnClickListener(new OnClickListener() {
-			
-			@Override
-			public void onClick(View v) {
-				context.getHs().saveHistoryorUpdate(book, chapterList.get(position));
-				Intent intent = new Intent(context, ComicReaderActivity.class);
-				intent.putExtra("bookname", book.getName());
-				ChapterAdapter.this.chapterList.get(position).saveToIntent(intent);
-				context.startActivity(intent);					
-			}
-		});
-
-		return button;
-	}
-
-}

android/src/me/yangblog/manmanpa/ChapterListActivity.java

 
 import java.util.LinkedList;
 
+import me.yangblog.manmanpa.adapter.ChapterAdapter;
+import me.yangblog.manmanpa.adapter.DownloadChapterAdapter;
 import me.yangblog.manmanpa.model.Book;
 import me.yangblog.manmanpa.model.Chapter;
-import me.yangblog.manmanpa.network.JSONParser;
 import me.yangblog.manmanpa.reader.ComicReaderActivity;
 import me.yangblog.manmanpa.sql.DownloadSource;
 import me.yangblog.manmanpa.sql.HistorySource;
+import me.yangblog.manmanpa.util.GlobalVariable;
+import me.yangblog.manmanpa.util.JSONNeedParser;
+import me.yangblog.manmanpa.util.JSONParser;
 
 import org.json.JSONArray;
 import org.json.JSONException;

android/src/me/yangblog/manmanpa/DownloadAdapter.java

-package me.yangblog.manmanpa;
-
-import java.util.LinkedList;
-
-import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.model.Chapter;
-import me.yangblog.manmanpa.reader.ComicReaderActivity;
-import me.yangblog.manmanpa.sql.DownloadSource;
-import me.yangblog.manmanpa.sql.HistorySource;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.Message;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.BaseExpandableListAdapter;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import android.graphics.LightingColorFilter;
-import android.graphics.PorterDuff;
-public class DownloadAdapter extends BaseExpandableListAdapter {
-
-	private Context context;
-	private LinkedList<Book> bookList;
-	public DownloadAdapter(Context context, LinkedList<Book> bookList) {
-		this.context = context;
-		this.bookList = bookList;
-	}
-
-	@Override
-	public Object getChild(int groupPosition, int childPosition) {
-		// TODO Auto-generated method stub
-		return bookList.get(groupPosition).getChapterList().get(childPosition);
-	}
-
-	@Override
-	public long getChildId(int groupPosition, int childPosition) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public View getChildView(final int groupPosition, final int childPosition,
-			boolean isLastChild, View convertView, final ViewGroup parent) {
-		LayoutInflater inflater = (LayoutInflater) context
-				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-		convertView = inflater.inflate(R.layout.download_shower, parent, false);
-		Chapter ch = bookList.get(groupPosition).getChapterList()
-				.get(childPosition);
-		TextView tvName = (TextView) convertView.findViewById(R.id.chapterName);
-		tvName.setText(ch.getName());
-		final TextView tvNumberShower = (TextView) convertView
-				.findViewById(R.id.downloadNumberShower);
-		tvNumberShower.setText(ch.getDownloadedNumber() + "/" + ch.getLength());
-		final ProgressBar pb = (ProgressBar) convertView
-				.findViewById(R.id.downloadProgressBar);
-		pb.setMax(ch.getLength());
-		pb.setProgress(ch.getDownloadedNumber());
-		if (ch.equals(GlobalVariable.downloader.getCurrentDownloadingChapter())) {
-			final Chapter downloaCh = GlobalVariable.downloader.getCurrentDownloadingChapter();
-			final Handler handler = new Handler();
-			new Thread(new Runnable() {
-				public void run() {
-					while (!downloaCh.isDownloaded()) {
-						try {
-							Thread.sleep(400);
-						} catch (InterruptedException e) {
-							e.printStackTrace();
-						}
-						handler.post(new Runnable() {
-							@Override
-							public void run() {
-								tvNumberShower.setText(downloaCh.getDownloadedNumber()
-										+ "/" + downloaCh.getLength());
-								pb.setProgress(downloaCh.getDownloadedNumber());
-							}
-						});
-						
-
-					}
-					handler.post(new Runnable() {
-						@Override
-						public void run() {
-							TextView stateText = (TextView) parent
-									.findViewById(R.id.downloadState);
-							Button stopOrResumeButton = (Button) parent
-									.findViewById(R.id.stopOrResume);
-							stateText.setText("�����");
-							stopOrResumeButton.setText("���");
-							stopOrResumeButton.setEnabled(false);
-							DownloadAdapter.this.notifyDataSetChanged();
-						}
-					});
-
-				}
-			}).start();
-
-		}
-		
-		Button readButton = (Button) convertView.findViewById(R.id.read);
-		readButton.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
-		readButton.setOnClickListener(new OnClickListener() {
-			
-			@Override
-			public void onClick(View v) {
-//				context.getHs().saveHistoryorUpdate(book, chapterList.get(position));
-				DownloadAdapter.this.notifyDataSetChanged();
-				Intent intent = new Intent(context, ComicReaderActivity.class);
-				Book book = bookList.get(groupPosition);
-				Chapter ch = book.getChapterList().get(childPosition);
-				intent.putExtra("bookname", book.getName());
-				new HistorySource(context).saveHistoryorUpdate(book, ch);
-				ch.saveToIntent(intent);
-				context.startActivity(intent);					
-				
-			}
-		});
-		return convertView;
-	}
-
-	@Override
-	public int getChildrenCount(int groupPosition) {
-		// TODO Auto-generated method stub
-		return bookList.get(groupPosition).getChapterList().size();
-	}
-
-	@Override
-	public Object getGroup(int groupPosition) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public int getGroupCount() {
-		// TODO Auto-generated method stub
-		return bookList.size();
-	}
-
-	@Override
-	public long getGroupId(int groupPosition) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public View getGroupView(int groupPosition, boolean isExpanded, View row,
-			ViewGroup parent) {
-
-		LayoutInflater inflater = (LayoutInflater) context
-				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-		row = inflater.inflate(R.layout.download_book_list, parent, false);
-
-		ImageView image = (ImageView) row.findViewById(R.id.imgIcon);
-		TextView titleText = (TextView) row.findViewById(R.id.txtTitle);
-		TextView stateText = (TextView) row.findViewById(R.id.downloadState);
-		
-		Button stopOrResumeButton = (Button) row
-				.findViewById(R.id.stopOrResume);
-		Button deleteButton = (Button) row
-		.findViewById(R.id.delete);
-		deleteButton.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
-		stopOrResumeButton.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
-		Book book = bookList.get(groupPosition);
-		titleText.setText(book.getName());
-		if (book.isDownloading() && GlobalVariable.downloader.isRunning()) {
-			setDownloadingState(stopOrResumeButton, stateText, groupPosition);
-		} else if (GlobalVariable.downloader.isBookWaitForDownload(book)) {
-			setWaitState(stopOrResumeButton, stateText, groupPosition);
-		} else if (book.isDownloadFinish()) {
-			stateText.setText("�����");
-			stopOrResumeButton.setText("���");
-			stopOrResumeButton.setEnabled(false);
-		} else {
-			setResumeState(stopOrResumeButton, stateText, groupPosition);
-		}
-
-		if (book.getCoverImage() == null) {
-			image.setImageResource(R.drawable.ic_launcher);
-		} else {
-			image.setImageBitmap(book.getCoverImage());
-		}
-		// row.setTag(holder);
-		return row;
-	}
-
-	private void setDownloadingState(final Button button, final TextView tv,
-			final int groupPosition) {
-		tv.setText("��������");
-		button.setText("��ͣ");
-		final Book book = bookList.get(groupPosition);
-		button.setOnClickListener(new OnClickListener() {
-
-			@Override
-			public void onClick(View v) {
-				GlobalVariable.downloader.stopDownloadBook(book);
-				setResumeState(button, tv, groupPosition);
-			}
-		});
-	}
-
-	private void setResumeState(final Button button, final TextView tv,
-			final int groupPosition) {
-		button.setText("�ָ�");
-		tv.setText("��ͣ");
-		final Book book = bookList.get(groupPosition);
-		button.setOnClickListener(new OnClickListener() {
-
-			@Override
-			public void onClick(View v) {
-				GlobalVariable.downloader.setDs(new DownloadSource(context));
-				GlobalVariable.downloader.resume(book);
-
-				if (!GlobalVariable.downloader.isRunning()) {
-					new Thread(GlobalVariable.downloader).start();
-					setDownloadingState(button, tv, groupPosition);
-					DownloadAdapter.this.notifyDataSetChanged();
-					return;
-				}
-				setWaitState(button, tv, groupPosition);
-			}
-		});
-	}
-
-	private void setWaitState(final Button button, final TextView tv,
-			final int groupPosition) {
-		tv.setText("�ȴ�����");
-		button.setText("ȡ��");
-		final Book book = bookList.get(groupPosition);
-		button.setOnClickListener(new OnClickListener() {
-
-			@Override
-			public void onClick(View v) {
-				GlobalVariable.downloader.stopDownloadBook(book);
-				setResumeState(button, tv, groupPosition);
-			}
-		});
-	}
-
-	@Override
-	public boolean hasStableIds() {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public boolean isChildSelectable(int groupPosition, int childPosition) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-}

android/src/me/yangblog/manmanpa/DownloadChapterAdapter.java

-package me.yangblog.manmanpa;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-
-import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.model.Chapter;
-import android.content.Context;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-import android.widget.ToggleButton;
-
-public class DownloadChapterAdapter extends ChapterAdapter {
-	private Set<Chapter> downloadChapters = new HashSet<Chapter>();
-	private Context context;
-	private boolean selectAll = false;
-
-	public DownloadChapterAdapter(ChapterListActivity context, Book book) {
-		super(context, book);
-		this.context = context;
-	}
-
-	@Override
-	public View getView(final int position, View convertView, ViewGroup parent) {
-
-		ToggleButton button = new ToggleButton(context);
-		button.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
-		button.setMinLines(2);
-		final Chapter currentCh = this.chapterList.get(position);
-		button.setText(currentCh.getName());
-		button.setTextOff(currentCh.getName());
-		button.setTextOn(currentCh.getName());
-		if (selectAll) {
-			button.setChecked(true);
-		}
-
-		button.setOnCheckedChangeListener(new OnCheckedChangeListener() {
-
-			@Override
-			public void onCheckedChanged(CompoundButton buttonView,
-					boolean isChecked) {
-				if (isChecked) {
-					downloadChapters.add(currentCh);
-				} else if (downloadChapters.contains(currentCh)) {
-					downloadChapters.remove(currentCh);
-				}
-			}
-		});
-
-		button.setOnClickListener(new OnClickListener() {
-
-			@Override
-			public void onClick(View v) {
-
-			}
-		});
-
-		return button;
-	}
-
-	public void selectALl() {
-		selectAll = true;
-		notifyDataSetChanged();
-	}
-
-	public void unSelectAll() {
-		selectAll = false;
-		notifyDataSetChanged();
-	}
-
-	public LinkedList<Chapter> getSelectChapter() {
-		LinkedList<Chapter> tempList = new LinkedList<Chapter>();
-		tempList.addAll(downloadChapters);
-		return tempList;
-	}
-
-}

android/src/me/yangblog/manmanpa/GlobalVariable.java

-package me.yangblog.manmanpa;
-
-import android.graphics.LightingColorFilter;
-import me.yangblog.manmanpa.download.Downloader;
-import me.yangblog.manmanpa.sql.DownloadSource;
-import me.yangblog.manmanpa.sql.HistorySource;
-
-public class GlobalVariable {
-	private static final String ROOT_URL = "http://m.megamh.com";
-	public static final String BOOKLIST_URL = ROOT_URL + "/api/json/booklist/";
-	public static final String CHAPTER_URL = ROOT_URL + "/api/json/chapters/";
-	public static final String PAGE_URL = ROOT_URL + "/api/json/pages/";
-	public static final String COVER_URL = ROOT_URL + "/static/covers/";
-	public static final String SEARCH_URL = ROOT_URL + "/api/json/search/";
-	public static final String LABEL_URL = ROOT_URL + "/api/json/label/";
-	
-	
-
-	//
-	public static Downloader downloader = new Downloader();
-	public static LightingColorFilter BUTTON_COLOR = new LightingColorFilter(
-			0xFFFFFFFF, 0xAA565555);
-
-}

android/src/me/yangblog/manmanpa/Helper.java

-package me.yangblog.manmanpa;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.List;
-
-import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.model.Page;
-
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.GradientDrawable.Orientation;
-import android.os.Environment;
-import android.widget.ListView;
-
-public class Helper {
-	public static void createFolderIfNotExsist(String pathString) {
-		File direct = new File(Environment.getExternalStorageDirectory()
-				+ pathString);
-		if (!direct.exists()) {
-			direct.mkdir();
-		}
-
-	}
-
-	public static void createFolderIfNotExsist(List<String> pathStrings) {
-		String thepathe = "";
-		for (String pathString : pathStrings) {
-			thepathe += "/" + pathString;
-			createFolderIfNotExsist(thepathe);
-		}
-	}
-
-	public static void createFolderInMegaIfNotExsist(String pathString) {
-		File direct = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/" + pathString);
-		if (!direct.exists()) {
-			direct.mkdir();
-		}
-
-	}
-
-	public static boolean isFolderExist(int bookid, int chapterid) {
-		File direct = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/" + bookid + "/" + chapterid);
-		return direct.exists();
-	}
-
-	public static boolean isPageCached(Page page) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/" + page.getChapterid() + "/" + page.getId());
-		createFolderInMegaIfNotExsist("" + page.getChapterid());
-		return file.exists() && file.isFile();
-	}
-
-	public static File getCachedPage(Page page) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/" + page.getChapterid() + "/" + page.getId());
-		return file;
-	}
-
-	public static File getCachedFile(String filename) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/cache/" + filename);
-		return file;
-	}
-
-	public static boolean isChapterJsonFileCached(String filename) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/cache/" + filename);
-		return file.exists() && file.isFile();
-	}
-
-	public static File getCachedChapterJsonFile(String filename) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/cache/" + filename);
-		return file;
-	}
-
-	public static boolean isBookCoverCached(Book book) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/cache/" + book.getId() + ".cover");
-		return file.exists() && file.isFile();
-	}
-
-	public static File getCachedBookCover(Book book) {
-		File file = new File(Environment.getExternalStorageDirectory()
-				+ "/Megamh/cache/" + book.getId() + ".cover");
-		return file;
-	}
-
-	public static void createAllTableIfNotExist() {
-
-	}
-
-	public static String readContentFromFile(File f) {
-		StringBuilder text = new StringBuilder();
-
-		try {
-			BufferedReader br = new BufferedReader(new FileReader(f));
-			String line;
-
-			while ((line = br.readLine()) != null) {
-				text.append(line);
-				text.append('\n');
-			}
-		} catch (IOException e) {
-			// You'll need to add proper error handling here
-		}
-		return text.toString();
-	}
-
-	public static String convertStreamToString(InputStream is)
-			throws IOException {
-		Writer writer = new StringWriter();
-
-		char[] buffer = new char[2048];
-		try {
-			Reader reader = new BufferedReader(new InputStreamReader(is,
-					"UTF-8"));
-			int n;
-			while ((n = reader.read(buffer)) != -1) {
-				writer.write(buffer, 0, n);
-			}
-		} finally {
-			is.close();
-		}
-		String text = writer.toString();
-		return text;
-	}
-	
-	
-	
-	
-	public static void setListViewDivid(ListView listView){
-		int[] colors = {0xFFFFEEEE, 0xFFDD4B37, 0xFFFFEEEE};
-		listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
-		listView.setDividerHeight(2);
-	}
-	
-	
-
-}

android/src/me/yangblog/manmanpa/JSONNeedParser.java

-package me.yangblog.manmanpa;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public interface JSONNeedParser extends NotifyAble{
-	void parseJSON(JSONObject jObj) throws JSONException;
-	void notifyDataChange();
-}

android/src/me/yangblog/manmanpa/MainActivity.java

 import me.yangblog.manmanpa.listener.RankListener;
 import me.yangblog.manmanpa.sql.DownloadSource;
 import me.yangblog.manmanpa.sql.HistorySource;
+import me.yangblog.manmanpa.util.GlobalVariable;
+import me.yangblog.manmanpa.util.Helper;
 import android.app.ActionBar;
 import android.app.AlertDialog;
 import android.content.DialogInterface;

android/src/me/yangblog/manmanpa/MyBookArrayAdapter.java

-package me.yangblog.manmanpa;
-
-import java.util.LinkedList;
-
-import me.yangblog.manmanpa.model.Book;
-
-import android.app.Activity;
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-public class MyBookArrayAdapter extends BookArrayAdapter {
-
-	public MyBookArrayAdapter(Activity context, LinkedList bookList) {
-		super(context, bookList);
-	}
-	
-	@Override
-	public int getCount (){
-		return bookList.size();
-	}
-
-	@Override
-	public View getView(int position, View convertView, ViewGroup parent) {
-		 LayoutInflater inflater = (LayoutInflater) context
-	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-	    View row = inflater.inflate(R.layout.mybook_list, parent, false);
-
-
-	    ImageView image = (ImageView) row.findViewById(R.id.imgIcon);
-		TextView titleText = (TextView) row.findViewById(R.id.txtTitle);
-		TextView lastCh = (TextView) row.findViewById(R.id.lastchapter);
-		Book book = (Book) bookList.get(position);
-        titleText.setText(book.getName());
-        lastCh.setText("�Ķ���"+book.getLastReadChapter().getName()+"��"+book.getLastReadNumber()+"ҳ");
-        if(book.getCoverImage() == null){
-        	image.setImageResource(R.drawable.ic_launcher);
-        }else{
-        	image.setImageBitmap(book.getCoverImage());
-        }
-		//row.setTag(holder);
-
-		return row;
-	}
-	
-}

android/src/me/yangblog/manmanpa/NotifyAble.java

-package me.yangblog.manmanpa;
-
-public interface NotifyAble {
-	void notifyDataChange();
-}

android/src/me/yangblog/manmanpa/adapter/BookArrayAdapter.java

+package me.yangblog.manmanpa.adapter;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Stack;
+
+import me.yangblog.manmanpa.R;
+import me.yangblog.manmanpa.R.drawable;
+import me.yangblog.manmanpa.R.id;
+import me.yangblog.manmanpa.R.layout;
+import me.yangblog.manmanpa.model.Book;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class BookArrayAdapter<String> extends ArrayAdapter<String> {
+	protected final Activity context;
+	protected String[] names;
+	protected LinkedList<Book> bookList;
+	protected Stack<Book> newBook;
+	public BookArrayAdapter(Activity context, LinkedList<Book> bookList) {
+		super(context, R.layout.book_list);
+		this.bookList = bookList;
+		this.context = context;
+		List<String> bookStrings = new LinkedList<String>();
+		for (Book book : bookList) {
+			bookStrings.add((String) book.toString());
+		}
+		this.names = (String[]) bookStrings.toArray();
+		super.addAll(this.names);
+		newBook = new Stack<Book>();
+	}
+
+/*
+	public void setList(List<Book> bookList) {
+		List<String> bookStrings = new LinkedList<String>();
+		for(Book book:bookList){
+			this.bookList.addFirst(book);
+		}
+		for (Book book : bookList) {
+			bookStrings.add((String) book.toString());
+		}
+		this.names = (String[]) bookStrings.toArray();
+		//super.clear();
+		super.addAll(this.names);
+	}
+*/
+	public void addBook(Book book) {
+		
+		newBook.add(book);
+	}
+	
+	@SuppressWarnings("unchecked")
+	public void update(){
+		for(Book book:newBook){
+			super.add((String) book.getName());
+			bookList.add(book);
+		}
+		newBook.clear();
+	}
+
+	@Override
+	public View getView(int position, View convertView, ViewGroup parent) {
+		 LayoutInflater inflater = (LayoutInflater) context
+	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+	    View row = inflater.inflate(R.layout.book_list, parent, false);
+
+
+	    ImageView image = (ImageView) row.findViewById(R.id.imgIcon);
+		TextView titleText = (TextView) row.findViewById(R.id.txtTitle);
+		TextView authorText = (TextView) row.findViewById(R.id.author);
+		TextView lastCh = (TextView) row.findViewById(R.id.lastchapter);
+		Book book = bookList.get(position);
+        titleText.setText(book.getName());
+        authorText.setText("����:"+book.getAuthor());
+        lastCh.setText("������"+book.getLastChapter());
+        if(book.getCoverImage() == null){
+        	image.setImageResource(R.drawable.ic_launcher);
+        }else{
+        	image.setImageBitmap(book.getCoverImage());
+        }
+		//row.setTag(holder);
+
+		return row;
+	}
+
+}

android/src/me/yangblog/manmanpa/adapter/ChapterAdapter.java

+package me.yangblog.manmanpa.adapter;
+
+import java.util.List;
+
+import me.yangblog.manmanpa.ChapterListActivity;
+import me.yangblog.manmanpa.model.Book;
+import me.yangblog.manmanpa.model.Chapter;
+import me.yangblog.manmanpa.reader.ComicReaderActivity;
+import me.yangblog.manmanpa.util.GlobalVariable;
+import android.content.Context;
+import android.content.Intent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+
+public class ChapterAdapter extends BaseAdapter {
+	protected ChapterListActivity context;
+	protected List<Chapter> chapterList;
+	protected Book book;
+	public ChapterAdapter(ChapterListActivity context, Book book) {
+		this.context = context;
+		this.chapterList = book.getChapterList();
+		this.book = book;
+
+	}
+
+	@Override
+	public int getCount() {
+		return this.chapterList.size();
+	}
+
+	@Override
+	public Object getItem(int position) {
+		return null;
+	}
+
+	@Override
+	public long getItemId(int position) {
+		return 0;
+	}
+
+	@Override
+	public View getView(final int position, View convertView, ViewGroup parent) {
+		Button button = new Button(context);
+		button.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
+		button.setMinLines(2);
+		button.setText(this.chapterList.get(position).getName());
+		button.setOnClickListener(new OnClickListener() {
+			
+			@Override
+			public void onClick(View v) {
+				context.getHs().saveHistoryorUpdate(book, chapterList.get(position));
+				Intent intent = new Intent(context, ComicReaderActivity.class);
+				intent.putExtra("bookname", book.getName());
+				ChapterAdapter.this.chapterList.get(position).saveToIntent(intent);
+				context.startActivity(intent);					
+			}
+		});
+
+		return button;
+	}
+
+}

android/src/me/yangblog/manmanpa/adapter/DownloadAdapter.java

+package me.yangblog.manmanpa.adapter;
+
+import java.util.LinkedList;
+
+import me.yangblog.manmanpa.R;
+import me.yangblog.manmanpa.R.drawable;
+import me.yangblog.manmanpa.R.id;
+import me.yangblog.manmanpa.R.layout;
+import me.yangblog.manmanpa.model.Book;
+import me.yangblog.manmanpa.model.Chapter;
+import me.yangblog.manmanpa.reader.ComicReaderActivity;
+import me.yangblog.manmanpa.sql.DownloadSource;
+import me.yangblog.manmanpa.sql.HistorySource;
+import me.yangblog.manmanpa.util.GlobalVariable;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.Message;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.BaseExpandableListAdapter;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.graphics.LightingColorFilter;
+import android.graphics.PorterDuff;
+public class DownloadAdapter extends BaseExpandableListAdapter {
+
+	private Context context;
+	private LinkedList<Book> bookList;
+	public DownloadAdapter(Context context, LinkedList<Book> bookList) {
+		this.context = context;
+		this.bookList = bookList;
+	}
+
+	@Override
+	public Object getChild(int groupPosition, int childPosition) {
+		// TODO Auto-generated method stub
+		return bookList.get(groupPosition).getChapterList().get(childPosition);
+	}
+
+	@Override
+	public long getChildId(int groupPosition, int childPosition) {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public View getChildView(final int groupPosition, final int childPosition,
+			boolean isLastChild, View convertView, final ViewGroup parent) {
+		LayoutInflater inflater = (LayoutInflater) context
+				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+		convertView = inflater.inflate(R.layout.download_shower, parent, false);
+		Chapter ch = bookList.get(groupPosition).getChapterList()
+				.get(childPosition);
+		TextView tvName = (TextView) convertView.findViewById(R.id.chapterName);
+		tvName.setText(ch.getName());
+		final TextView tvNumberShower = (TextView) convertView
+				.findViewById(R.id.downloadNumberShower);
+		tvNumberShower.setText(ch.getDownloadedNumber() + "/" + ch.getLength());
+		final ProgressBar pb = (ProgressBar) convertView
+				.findViewById(R.id.downloadProgressBar);
+		pb.setMax(ch.getLength());
+		pb.setProgress(ch.getDownloadedNumber());
+		if (ch.equals(GlobalVariable.downloader.getCurrentDownloadingChapter())) {
+			final Chapter downloaCh = GlobalVariable.downloader.getCurrentDownloadingChapter();
+			final Handler handler = new Handler();
+			new Thread(new Runnable() {
+				public void run() {
+					while (!downloaCh.isDownloaded()) {
+						try {
+							Thread.sleep(400);
+						} catch (InterruptedException e) {
+							e.printStackTrace();
+						}
+						handler.post(new Runnable() {
+							@Override
+							public void run() {
+								tvNumberShower.setText(downloaCh.getDownloadedNumber()
+										+ "/" + downloaCh.getLength());
+								pb.setProgress(downloaCh.getDownloadedNumber());
+							}
+						});
+						
+
+					}
+					handler.post(new Runnable() {
+						@Override
+						public void run() {
+							TextView stateText = (TextView) parent
+									.findViewById(R.id.downloadState);
+							Button stopOrResumeButton = (Button) parent
+									.findViewById(R.id.stopOrResume);
+							stateText.setText("�����");
+							stopOrResumeButton.setText("���");
+							stopOrResumeButton.setEnabled(false);
+							DownloadAdapter.this.notifyDataSetChanged();
+						}
+					});
+
+				}
+			}).start();
+
+		}
+		
+		Button readButton = (Button) convertView.findViewById(R.id.read);
+		readButton.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
+		readButton.setOnClickListener(new OnClickListener() {
+			
+			@Override
+			public void onClick(View v) {
+//				context.getHs().saveHistoryorUpdate(book, chapterList.get(position));
+				DownloadAdapter.this.notifyDataSetChanged();
+				Intent intent = new Intent(context, ComicReaderActivity.class);
+				Book book = bookList.get(groupPosition);
+				Chapter ch = book.getChapterList().get(childPosition);
+				intent.putExtra("bookname", book.getName());
+				new HistorySource(context).saveHistoryorUpdate(book, ch);
+				ch.saveToIntent(intent);
+				context.startActivity(intent);					
+				
+			}
+		});
+		return convertView;
+	}
+
+	@Override
+	public int getChildrenCount(int groupPosition) {
+		// TODO Auto-generated method stub
+		return bookList.get(groupPosition).getChapterList().size();
+	}
+
+	@Override
+	public Object getGroup(int groupPosition) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public int getGroupCount() {
+		// TODO Auto-generated method stub
+		return bookList.size();
+	}
+
+	@Override
+	public long getGroupId(int groupPosition) {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public View getGroupView(int groupPosition, boolean isExpanded, View row,
+			ViewGroup parent) {
+
+		LayoutInflater inflater = (LayoutInflater) context
+				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+		row = inflater.inflate(R.layout.download_book_list, parent, false);
+
+		ImageView image = (ImageView) row.findViewById(R.id.imgIcon);
+		TextView titleText = (TextView) row.findViewById(R.id.txtTitle);
+		TextView stateText = (TextView) row.findViewById(R.id.downloadState);
+		
+		Button stopOrResumeButton = (Button) row
+				.findViewById(R.id.stopOrResume);
+		Button deleteButton = (Button) row
+		.findViewById(R.id.delete);
+		deleteButton.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
+		stopOrResumeButton.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
+		Book book = bookList.get(groupPosition);
+		titleText.setText(book.getName());
+		if (book.isDownloading() && GlobalVariable.downloader.isRunning()) {
+			setDownloadingState(stopOrResumeButton, stateText, groupPosition);
+		} else if (GlobalVariable.downloader.isBookWaitForDownload(book)) {
+			setWaitState(stopOrResumeButton, stateText, groupPosition);
+		} else if (book.isDownloadFinish()) {
+			stateText.setText("�����");
+			stopOrResumeButton.setText("���");
+			stopOrResumeButton.setEnabled(false);
+		} else {
+			setResumeState(stopOrResumeButton, stateText, groupPosition);
+		}
+
+		if (book.getCoverImage() == null) {
+			image.setImageResource(R.drawable.ic_launcher);
+		} else {
+			image.setImageBitmap(book.getCoverImage());
+		}
+		// row.setTag(holder);
+		return row;
+	}
+
+	private void setDownloadingState(final Button button, final TextView tv,
+			final int groupPosition) {
+		tv.setText("��������");
+		button.setText("��ͣ");
+		final Book book = bookList.get(groupPosition);
+		button.setOnClickListener(new OnClickListener() {
+
+			@Override
+			public void onClick(View v) {
+				GlobalVariable.downloader.stopDownloadBook(book);
+				setResumeState(button, tv, groupPosition);
+			}
+		});
+	}
+
+	private void setResumeState(final Button button, final TextView tv,
+			final int groupPosition) {
+		button.setText("�ָ�");
+		tv.setText("��ͣ");
+		final Book book = bookList.get(groupPosition);
+		button.setOnClickListener(new OnClickListener() {
+
+			@Override
+			public void onClick(View v) {
+				GlobalVariable.downloader.setDs(new DownloadSource(context));
+				GlobalVariable.downloader.resume(book);
+
+				if (!GlobalVariable.downloader.isRunning()) {
+					new Thread(GlobalVariable.downloader).start();
+					setDownloadingState(button, tv, groupPosition);
+					DownloadAdapter.this.notifyDataSetChanged();
+					return;
+				}
+				setWaitState(button, tv, groupPosition);
+			}
+		});
+	}
+
+	private void setWaitState(final Button button, final TextView tv,
+			final int groupPosition) {
+		tv.setText("�ȴ�����");
+		button.setText("ȡ��");
+		final Book book = bookList.get(groupPosition);
+		button.setOnClickListener(new OnClickListener() {
+
+			@Override
+			public void onClick(View v) {
+				GlobalVariable.downloader.stopDownloadBook(book);
+				setResumeState(button, tv, groupPosition);
+			}
+		});
+	}
+
+	@Override
+	public boolean hasStableIds() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean isChildSelectable(int groupPosition, int childPosition) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

android/src/me/yangblog/manmanpa/adapter/DownloadChapterAdapter.java

+package me.yangblog.manmanpa.adapter;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+
+import me.yangblog.manmanpa.ChapterListActivity;
+import me.yangblog.manmanpa.model.Book;
+import me.yangblog.manmanpa.model.Chapter;
+import me.yangblog.manmanpa.util.GlobalVariable;
+import android.content.Context;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ToggleButton;
+
+public class DownloadChapterAdapter extends ChapterAdapter {
+	private Set<Chapter> downloadChapters = new HashSet<Chapter>();
+	private Context context;
+	private boolean selectAll = false;
+
+	public DownloadChapterAdapter(ChapterListActivity context, Book book) {
+		super(context, book);
+		this.context = context;
+	}
+
+	@Override
+	public View getView(final int position, View convertView, ViewGroup parent) {
+
+		ToggleButton button = new ToggleButton(context);
+		button.getBackground().setColorFilter(GlobalVariable.BUTTON_COLOR);
+		button.setMinLines(2);
+		final Chapter currentCh = this.chapterList.get(position);
+		button.setText(currentCh.getName());
+		button.setTextOff(currentCh.getName());
+		button.setTextOn(currentCh.getName());
+		if (selectAll) {
+			button.setChecked(true);
+		}
+
+		button.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+			@Override
+			public void onCheckedChanged(CompoundButton buttonView,
+					boolean isChecked) {
+				if (isChecked) {
+					downloadChapters.add(currentCh);
+				} else if (downloadChapters.contains(currentCh)) {
+					downloadChapters.remove(currentCh);
+				}
+			}
+		});
+
+		button.setOnClickListener(new OnClickListener() {
+
+			@Override
+			public void onClick(View v) {
+
+			}
+		});
+
+		return button;
+	}
+
+	public void selectALl() {
+		selectAll = true;
+		notifyDataSetChanged();
+	}
+
+	public void unSelectAll() {
+		selectAll = false;
+		notifyDataSetChanged();
+	}
+
+	public LinkedList<Chapter> getSelectChapter() {
+		LinkedList<Chapter> tempList = new LinkedList<Chapter>();
+		tempList.addAll(downloadChapters);
+		return tempList;
+	}
+
+}

android/src/me/yangblog/manmanpa/adapter/MyBookArrayAdapter.java

+package me.yangblog.manmanpa.adapter;
+
+import java.util.LinkedList;
+
+import me.yangblog.manmanpa.R;
+import me.yangblog.manmanpa.R.drawable;
+import me.yangblog.manmanpa.R.id;
+import me.yangblog.manmanpa.R.layout;
+import me.yangblog.manmanpa.model.Book;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class MyBookArrayAdapter extends BookArrayAdapter {
+
+	public MyBookArrayAdapter(Activity context, LinkedList bookList) {
+		super(context, bookList);
+	}
+	
+	@Override
+	public int getCount (){
+		return bookList.size();
+	}
+
+	@Override
+	public View getView(int position, View convertView, ViewGroup parent) {
+		 LayoutInflater inflater = (LayoutInflater) context
+	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+	    View row = inflater.inflate(R.layout.mybook_list, parent, false);
+
+
+	    ImageView image = (ImageView) row.findViewById(R.id.imgIcon);
+		TextView titleText = (TextView) row.findViewById(R.id.txtTitle);
+		TextView lastCh = (TextView) row.findViewById(R.id.lastchapter);
+		Book book = (Book) bookList.get(position);
+        titleText.setText(book.getName());
+        lastCh.setText("�Ķ���"+book.getLastReadChapter().getName()+"��"+book.getLastReadNumber()+"ҳ");
+        if(book.getCoverImage() == null){
+        	image.setImageResource(R.drawable.ic_launcher);
+        }else{
+        	image.setImageBitmap(book.getCoverImage());
+        }
+		//row.setTag(holder);
+
+		return row;
+	}
+	
+}

android/src/me/yangblog/manmanpa/download/ChapterDownloader.java

-package me.yangblog.manmanpa.download;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.LinkedList;
-import java.util.List;
-
-import me.yangblog.manmanpa.GlobalVariable;
-import me.yangblog.manmanpa.Helper;
-import me.yangblog.manmanpa.NotifyAble;
-import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.model.Chapter;
-import me.yangblog.manmanpa.model.Page;
-import me.yangblog.manmanpa.network.JSONParser;
-import me.yangblog.manmanpa.sql.DownloadSource;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-
-public class ChapterDownloader {
-	private Chapter chapter;
-	private String bookname;
-	private List<Page> pageList = new LinkedList<Page>();
-	private JSONParser jsonPaser;
-	private static String imageUrl = "http://t5.mangafiles.com/";
-	private DownloadSource ds;
-	private boolean stop = false;
-
-	public ChapterDownloader(Chapter ch, String bookname) {
-		this.chapter = ch;
-		this.bookname = bookname;
-
-	}
-	
-	public void init_pageList(){
-		if (Helper.isChapterJsonFileCached(chapter.getId() + ".ch")) {
-			initPageList();
-		} else {
-			downLoad_init();
-		}
-		chapter.setPageList(pageList);
-	}
-
-	
-	private void downLoad_init(){
-		JSONObject jObj  = getJsonObject(GlobalVariable.PAGE_URL + chapter.getId());
-		try {
-			_parseJSON(jObj);
-		} catch (JSONException e) {
-			e.printStackTrace();
-		}
-	}
-
-	private void initPageList() {
-		File f = Helper.getCachedChapterJsonFile(chapter.getId() + ".ch");
-		String text = Helper.readContentFromFile(f);
-		try {
-			JSONObject jObj = new JSONObject(text.toString());
-			_parseJSON(jObj);
-		} catch (JSONException e) {
-			// TODO Autogenerated catch block
-			e.printStackTrace();
-		}
-	}
-
-	private void _parseJSON(JSONObject jObj) throws JSONException {
-		chapter.setLength(jObj.getInt("length"));
-		JSONArray pageJson = jObj.getJSONArray("content");
-		for (int i = 0; i < pageJson.length(); i++) {
-			JSONObject c = pageJson.getJSONObject(i);
-			Page page = Page.createPageByJSONObject(c);
-			page.setReferLink(chapter.getReLink());
-			this.pageList.add(page);
-		}
-	}
-
-	public boolean isInitial() {
-		if(pageList ==null || pageList.isEmpty()){
-			return false;
-		}
-		return true;
-	}
-
-	public void stop() {
-		this.stop = true;
-	}
-
-	public void saveInfor() {
-		ds.saveDownloadInfo(chapter, bookname);
-	}
-
-	public void startDownload(NotifyAble notifyable) {
-		ds.saveDownloadInfo(chapter, bookname);
-		int i = 0;
-		for (Page page : pageList) {
-			if (stop) {
-				return;
-			}
-
-			if (Helper.isPageCached(page)) {
-				i++;
-				chapter.setDownloadedNumber(i);
-				ds.updateDownloadInfo(chapter, i);
-				continue;
-			}
-
-			page.setImage(LoadImage(page));
-			page.cached();
-			page.setImage(null);
-			page = null;
-			i++;
-			chapter.setDownloadedNumber(i);
-//			if(notifyable != null){notifyable.notifyDataChange();}
-			ds.updateDownloadInfo(chapter, i);
-		}
-		pageList = null;
-		jsonPaser = null;
-	}
-
-	public Chapter getChapter() {
-		return chapter;
-	}
-
-	public Bitmap LoadImage(Page page) {
-		Bitmap bitmap = null;
-		InputStream in = null;
-		try {
-			in = OpenHttpConnection(imageUrl + page.getLink(),
-					page.getReferLink());
-			BitmapFactory.Options options = new BitmapFactory.Options();
-			bitmap = BitmapFactory.decodeStream(in, null, options);
-			in.close();
-		} catch (IOException e1) {
-		}
-
-		return bitmap;
-	}
-
-	private InputStream OpenHttpConnection(String strURL, String referLink)
-			throws IOException {
-		InputStream inputStream = null;
-		URL url = new URL(strURL);
-		URLConnection conn = url.openConnection();
-
-		try {
-			HttpURLConnection httpConn = (HttpURLConnection) conn;
-			httpConn.setRequestMethod("GET");
-			if (referLink != null) {
-
-				httpConn.setRequestProperty("Referer", referLink);
-			}
-			httpConn.connect();
-
-			if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
-				inputStream = httpConn.getInputStream();
-			}
-		} catch (Exception ex) {
-		}
-
-		return inputStream;
-	}
-	
-	public JSONObject getJsonObject(String url) {
-		InputStream is = null;
-		JSONObject jObj = null;
-		String json = "";
-		// Making HTTP request
-		try {
-			// defaultHttpClient
-			DefaultHttpClient httpClient = new DefaultHttpClient();
-			HttpGet httpGet = new HttpGet(url);
-
-			HttpResponse httpResponse = httpClient.execute(httpGet);
-			HttpEntity httpEntity = httpResponse.getEntity();
-			is = httpEntity.getContent();
-
-		} catch (UnsupportedEncodingException e) {
-			e.printStackTrace();
-		} catch (ClientProtocolException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-
-		try {
-			BufferedReader reader = new BufferedReader(new InputStreamReader(
-					is, "iso-8859-1"), 8);
-			StringBuilder sb = new StringBuilder();
-			String line = null;
-			while ((line = reader.readLine()) != null) {
-				sb.append(line + "\n");
-			}
-			is.close();
-			json = sb.toString();
-		} catch (Exception e) {
-			//Toast.makeText(fa, "�������Ӵ���", Toast.LENGTH_LONG).show();
-			Log.e("Buffer Error", "Error converting result " + e.toString());
-			return null;
-		}
-
-		// try parse the string to a JSON object
-		try {
-			jObj = new JSONObject(json);
-		} catch (JSONException e) {
-			Log.e("JSON Parser", "Error parsing data " + e.toString());
-		}
-		return jObj;
-	}
-
-	
-	
-
-	public void setDs(DownloadSource ds) {
-		this.ds = ds;
-	}
-
-	public void restart() {
-		this.stop = false;
-	}
-
-}

android/src/me/yangblog/manmanpa/download/Downloader.java

-package me.yangblog.manmanpa.download;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-
-import me.yangblog.manmanpa.GlobalVariable;
-import me.yangblog.manmanpa.NotifyAble;
-import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.model.Chapter;
-import me.yangblog.manmanpa.sql.DownloadSource;
-
-public class Downloader implements Runnable {
-	private HashMap<Integer, LinkedList<ChapterDownloader>> taskQueueMap = new HashMap<Integer, LinkedList<ChapterDownloader>>();
-	private static boolean running = false;
-	private ChapterDownloader currentChd;
-	private DownloadSource ds;
-	private NotifyAble notifyAble;
-
-	public Downloader() {
-
-	}
-
-	public void addTask(ChapterDownloader chd) {
-		chd.saveInfor();
-		int bookid = chd.getChapter().getBookid();
-		if (taskQueueMap.containsKey(bookid)) {
-			taskQueueMap.get(bookid).add(chd);
-			return;
-		}
-		LinkedList<ChapterDownloader> tempList = new LinkedList<ChapterDownloader>();
-		tempList.add(chd);
-		taskQueueMap.put(bookid, tempList);
-
-	}
-
-	public void addTasks(List<ChapterDownloader> chdList) {
-		for (ChapterDownloader chd : chdList) {
-			addTask(chd);
-		}
-	}
-
-	
-	public void addChapterList(List<Chapter> chList, String bookname) {
-		for (Chapter ch : chList) {
-			ChapterDownloader temp = new ChapterDownloader(ch, bookname);
-			temp.setDs(ds);
-			this.addTask(temp);
-		}
-	}
-	
-	public Chapter getCurrentDownloadingChapter() {
-		if (currentChd == null) {
-			return null;
-		}
-		return currentChd.getChapter();
-
-	}
-
-	public void stopDownloadBook(Book book) {
-		if (currentChd == null) {
-			return;
-		}
-		if (currentChd.getChapter().getBookid() == book.getId()) {
-			currentChd.stop();
-		}
-		for (ChapterDownloader chd : taskQueueMap.get(book.getId())) {
-			if (chd.getChapter().getBookid() == book.getId()) {
-				chd.stop();
-			}
-		}
-	}
-
-	public void stop() {
-		if(currentChd!=null){
-			currentChd.stop();
-		}
-		for (List<ChapterDownloader> taskQueue : taskQueueMap.values()) {
-			for (ChapterDownloader chd : taskQueue) {
-				chd.stop();
-			}
-		}
-		running = false;
-		currentChd = null;
-	}
-
-	@Override
-	public void run() {
-		running = true;
-		while (true) {
-			for (Integer key:taskQueueMap.keySet()) {
-				LinkedList<ChapterDownloader> taskQueue = taskQueueMap.get(key);
-				while (!taskQueue.isEmpty()) {
-					currentChd = taskQueue.removeFirst();
-					if(!currentChd.isInitial()){
-						currentChd.init_pageList();
-					}
-					
-					currentChd.startDownload(notifyAble);
-				}
-				currentChd = null;
-				taskQueueMap.remove(key);
-			}
-
-			try {
-				Thread.sleep(100);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	public boolean isBookWaitForDownload(Book book) {
-		if (!taskQueueMap.containsKey(book.getId())) {
-			return false;
-		}
-		for (ChapterDownloader chd : taskQueueMap.get(book.getId())) {
-			if (!chd.getChapter().isDownloaded()) {
-				return true;
-			}
-		}
-
-		return false;
-	}
-
-	public boolean isBookListDownloadFinish(List<Book> bookList) {
-		for (Book book : bookList) {
-			if (!book.isDownloadFinish()) {
-				return false;
-			}
-		}
-		return true;
-	}
-
-	public static boolean isRunning() {
-		return running;
-	}
-
-	public ChapterDownloader getChapterDownloaderIfExsit(Chapter ch) {
-		if (!taskQueueMap.containsKey(ch.getBookid())) {
-			return null;
-		}
-
-		for (ChapterDownloader chd : taskQueueMap.get(ch.getBookid())) {
-			if (chd.getChapter().getId() == ch.getId()) {
-				return chd;
-			}
-		}
-
-		return null;
-	}
-
-	public void resumeTask(Chapter ch, String bookname) {
-		ChapterDownloader chd = getChapterDownloaderIfExsit(ch);
-		if (chd == null) {
-			chd = new ChapterDownloader(ch, bookname);
-			chd.setDs(ds);
-			addTask(chd);
-			return;
-		}
-		chd.restart();
-	}
-
-	public void resume(Book book) {
-		for (Chapter ch : book.getChapterList()) {
-			resumeTask(ch, book.getName());
-		}
-	}
-
-	public DownloadSource getDs() {
-		return ds;
-	}
-
-	public void setDs(DownloadSource ds) {
-		this.ds = ds;
-	}
-
-	public void setNotifyAble(NotifyAble notifyAble) {
-		this.notifyAble = notifyAble;
-	}
-
-}

android/src/me/yangblog/manmanpa/fragment/CategoryFragment.java

 import org.json.JSONException;
 import org.json.JSONObject;
 
-import me.yangblog.manmanpa.BookArrayAdapter;
-import me.yangblog.manmanpa.GlobalVariable;
-import me.yangblog.manmanpa.JSONNeedParser;
 import me.yangblog.manmanpa.MainActivity;
 import me.yangblog.manmanpa.R;
+import me.yangblog.manmanpa.adapter.BookArrayAdapter;
 import me.yangblog.manmanpa.model.Book;
-import me.yangblog.manmanpa.network.JSONParser;
+import me.yangblog.manmanpa.util.GlobalVariable;
+import me.yangblog.manmanpa.util.JSONNeedParser;
+import me.yangblog.manmanpa.util.JSONParser;
 import android.graphics.Color;
 import android.graphics.drawable.ColorDrawable;
 import android.os.Bundle;

android/src/me/yangblog/manmanpa/fragment/DownloadFragment.java

 
 import java.util.LinkedList;
 
-import me.yangblog.manmanpa.DownloadAdapter;
-import me.yangblog.manmanpa.GlobalVariable;
-import me.yangblog.manmanpa.Helper;
 import me.yangblog.manmanpa.MainActivity;
-import me.yangblog.manmanpa.NotifyAble;
 import me.yangblog.manmanpa.R;
+import me.yangblog.manmanpa.adapter.DownloadAdapter;
 import me.yangblog.manmanpa.model.Book;
 import me.yangblog.manmanpa.sql.DownloadSource;
 import me.yangblog.manmanpa.sql.HistorySource;
+import me.yangblog.manmanpa.util.GlobalVariable;
+import me.yangblog.manmanpa.util.Helper;
+import me.yangblog.manmanpa.util.NotifyAble;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;

android/src/me/yangblog/manmanpa/fragment/MyComicFragment.java

 
 import java.util.LinkedList;
 
-import me.yangblog.manmanpa.ChapterAdapter;
 import me.yangblog.manmanpa.ChapterListActivity;
-import me.yangblog.manmanpa.GlobalVariable;
-import me.yangblog.manmanpa.Helper;
 import me.yangblog.manmanpa.MainActivity;
-import me.yangblog.manmanpa.MyBookArrayAdapter;
+import me.yangblog.manmanpa.adapter.ChapterAdapter;
+import me.yangblog.manmanpa.adapter.MyBookArrayAdapter;
 import me.yangblog.manmanpa.model.Book;
 import me.yangblog.manmanpa.reader.ComicReaderActivity;
 import me.yangblog.manmanpa.sql.HistorySource;
<