<file_sep>package com.yunjian.activity;

import java.util.List;

import com.umeng.analytics.MobclickAgent;
import com.yunjian.connection.HttpUtils.EHttpError;
import com.yunjian.fragment.SearchResultFragment;
import com.yunjian.service.BookService;
import com.yunjian.service.OnQueryCompleteListener;
import com.yunjian.service.QueryId;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;

public class SearchActivity extends Activity implements OnClickListener,OnQueryCompleteListener{
	private AutoCompleteTextView autoCompleteTextView;
	private Button searchButton;
	private ListView listView;
	
	private List<String>booksList;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search);
		initView();
	}
	
	public void initView(){
		autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.search_et);
		listView = (ListView) findViewById(R.id.search_list);
		searchButton = (Button) findViewById(R.id.search_btn);
		
		autoCompleteTextView.addTextChangedListener(textWatcher);
		searchButton.setOnClickListener(this);
		
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				listView.setVisibility(View.GONE);
				FragmentManager fManager = getFragmentManager();
				Fragment searchresultFragment =  new SearchResultFragment();
				((SearchResultFragment) searchresultFragment).setCountent(booksList.get(arg2));
				fManager.beginTransaction().replace(R.id.search_result_ll,searchresultFragment).commit();
			}
		});
		
		new BookService().getSimilarBook("Κι", SearchActivity.this);
	}
	
	private TextWatcher textWatcher = new TextWatcher() {
		
		@Override
		public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
			// TODO Auto-generated method stub
			String content = autoCompleteTextView.getText().toString();
			try {
				new BookService().getSimilarBook(content, SearchActivity.this);
				
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		
		@Override
		public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
				int arg3) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void afterTextChanged(Editable arg0) {
			// TODO Auto-generated method stub
			
		}
	};

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()) {
		case R.id.search_btn:
			listView.setVisibility(View.GONE);
			FragmentManager fManager = getFragmentManager();
			Fragment searchresultFragment =  new SearchResultFragment();
			((SearchResultFragment) searchresultFragment).setCountent(autoCompleteTextView.getText().toString());
			fManager.beginTransaction().replace(R.id.search_result_ll,searchresultFragment).commit();
			break;

		default:
			break;
		}
	}

	@Override
	public void onQueryComplete(QueryId queryId, Object result, EHttpError error) {
		// TODO Auto-generated method stub
		if(queryId.equals(BookService.AUTOCOMPLETE)){
			if(result != null){
				booksList = (List<String>) result;
				ArrayAdapter<String> adapter = new ArrayAdapter<String>(SearchActivity.this, android.R.layout.simple_list_item_1, booksList); 
				listView.setAdapter(adapter);
				listView.setVisibility(View.VISIBLE);
			}
		}
	}
	
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		MobclickAgent.onPause(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		MobclickAgent.onResume(this);
	}

}
<file_sep>package com.yunjian.activity;

import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;

public class LoadingActivity extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_loading);
		new Thread(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				try {
					Thread.sleep(2000);
					Intent intent = new Intent(LoadingActivity.this,MainActivity.class);
					startActivity(intent);
					finish();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}).start();
	}
	
	public static boolean isNetworkAvailable(Activity activity)
    {
        Context context = activity.getApplicationContext();
        // 获取手机所有连接管理对象（包括对wi-fi,net等连接的管理）
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        
        if (connectivityManager == null)
        {
            return false;
        }
        else
        {
            // 获取NetworkInfo对象
            NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();
            
            if (networkInfo != null && networkInfo.length > 0)
            {
                for (int i = 0; i < networkInfo.length; i++)
                {
                    // 判断当前网络状态是否为连接状态
                    if (networkInfo[i].getState() == NetworkInfo.State.CONNECTED)
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		MobclickAgent.onPause(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		MobclickAgent.onResume(this);
	}
	

}
<file_sep>package com.yunjian.adapter;

import java.util.List;
import java.util.Map;

import com.yunjian.activity.R;
import com.yunjian.image.ImageLoader;
import com.yunjian.util.Utils;
import com.yunjian.view.CircleImageView;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MessageCenterAdapter extends BaseAdapter{
	private Context context;
	private LayoutInflater layoutInflater;
	private List<Map<String, Object>>list;
	private ImageLoader mImageLoader;
	
	public MessageCenterAdapter(Context context,List<Map<String, Object>>list){
		this.context = context;
		this.layoutInflater = LayoutInflater.from(context);
		this.list = list;
		mImageLoader = ImageLoader.getInstance(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@SuppressWarnings("unused")
	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		Item item = null;
		if(item == null){
			item = new Item();
			arg1 = layoutInflater.inflate(R.layout.message_item, null);
			item.imageView = (CircleImageView)arg1.findViewById(R.id.message_icon);
			item.messageType = (TextView)arg1.findViewById(R.id.message_type);
			item.messageContent = (TextView)arg1.findViewById(R.id.message_content);
			item.messageTime = (TextView)arg1.findViewById(R.id.message_time);
			item.messageAfterType = (TextView)arg1.findViewById(R.id.message_aftertype);
			String type = list.get(arg0).get("type").toString();
			if(type.equals("0.0")){
				item.messageType.setText("系统消息");
				item.imageView.setBackgroundResource(R.drawable.message_system_icon);
				item.messageContent.setText(list.get(arg0).get("content").toString());
			}
			else if(type.equals("1.0")){
				item.messageAfterType.setText("评论了你卖的书籍");
				item.messageType.setText(list.get(arg0).get("username").toString());
				item.messageContent.setText(list.get(arg0).get("content").toString());
				item.messageTime.setText(list.get(arg0).get("time").toString());
				//图片加载
				try {
					mImageLoader.addTask(Utils.URL+list.get(arg0).get("user_id"), item.imageView);
				} catch (Exception e) {
					// TODO: handle exception
					e.printStackTrace();
				}
			}
			else if(type.equals("2.0")){
				try {
					item.messageAfterType.setText("评论了你的心愿书单");
					item.messageType.setText(list.get(arg0).get("username").toString());
					item.messageContent.setText(list.get(arg0).get("content").toString());
					item.messageTime.setText(list.get(arg0).get("time").toString());
				} catch (Exception e) {
					// TODO: handle exception
				}
				//图片加载
				try {
					mImageLoader.addTask(Utils.URL+list.get(arg0).get("user_id"), item.imageView);
				} catch (Exception e) {
					// TODO: handle exception
					e.printStackTrace();
				}
			}
			else if(type.equals("3.0")){
				item.messageType.setText("心愿单通知");
				item.imageView.setBackgroundResource(R.drawable.message_wish_icon);
				item.messageContent.setText("你的心愿单被"+list.get(arg0).get("username").toString()+"接下啦");
				item.messageTime.setText(list.get(arg0).get("time").toString());
			}
			
			arg1.setTag(item);
		}
		else{
			item=(Item)arg1.getTag();
		}
		return arg1;
	}
	
	private class Item{
		private CircleImageView imageView;
		private TextView messageType;
		private TextView messageContent;
		private TextView messageTime;
		private TextView messageAfterType;
	}

}
<file_sep>package com.yunjian.service;

import java.io.FileOutputStream;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.IBinder;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yunjian.connection.HttpUtils;
import com.yunjian.connection.HttpUtils.EHttpError;
import com.yunjian.util.Utils;

public class BookService extends Service{
	private final String ADDBOOKACTION = "book/setBookInfo";
	
	private final String GETBOOKSBYTYPEACTION = "book/getBooksByType";
	
	private final String GETBOOKBYNAMEACTION = "book/getBooksByName";
	
	private final String SEARCHBOOKACTION = "book/searchBook";
	
	private final String GETSIMILARBOOKNAME = "book/getSimilarBookname";
	
	private final String CLICKBOOKACTION = "book/bookClicked";
	
	public final static QueryId GETBOOKBYNAME = new QueryId();
	public static final QueryId GETBOOKBYTAPE = new QueryId();	
	public final static QueryId CLICKWISH = new QueryId();
	public static final QueryId AUTOCOMPLETE = new QueryId();
	/*
	 * @function   发布二手书
	 * @param      
	 * @return     
	 */
	
	public void addBook(Map<String, Object>map,OnQueryCompleteListener onQueryCompleteListener){
		List<BasicNameValuePair>parms = new ArrayList<BasicNameValuePair>();
		parms.add(new BasicNameValuePair("user_id", map.get("user_id").toString()));
		parms.add(new BasicNameValuePair("bookname", map.get("bookname").toString()));
		parms.add(new BasicNameValuePair("book_id", map.get("book_id").toString()));
		parms.add(new BasicNameValuePair("username", map.get("username").toString()));
		parms.add(new BasicNameValuePair("price", map.get("bookprice").toString()));
		parms.add(new BasicNameValuePair("type", map.get("type").toString()));
		parms.add(new BasicNameValuePair("newness", map.get("newness").toString()));
		parms.add(new BasicNameValuePair("audience", map.get("audience").toString()));
		parms.add(new BasicNameValuePair("description", map.get("description").toString()));
		parms.add(new BasicNameValuePair("mobile", map.get("mobile").toString()));
		parms.add(new BasicNameValuePair("qq", map.get("qq").toString()));
		parms.add(new BasicNameValuePair("weixin", map.get("wexin").toString()));
		parms.add(new BasicNameValuePair("img1", map.get("img1").toString()));
		parms.add(new BasicNameValuePair("img2", map.get("img2").toString()));
		parms.add(new BasicNameValuePair("img3", map.get("img3").toString()));
		System.out.println("addbook");
		HttpUtils.makeAsyncPost(ADDBOOKACTION, parms,
				new QueryCompleteHandler(onQueryCompleteListener, new QueryId()) {
					
					@Override
					public void handleResponse(String jsonResult, EHttpError error) {
						// TODO Auto-generated method stub
						if(jsonResult!=null&&error == EHttpError.KErrorNone){
							System.out.println("发布书单"+jsonResult);
							this.completeListener.onQueryComplete(new QueryId(), jsonResult, error);
						}
						else {
							this.completeListener.onQueryComplete(new QueryId(), null, error);
						}
					}
				});
 	}
	
	/*
	 * @function   得到二手书
	 * @param      
	 * @return     
	 */
	
	public void getBooksByType(String type,String order_by,String page,OnQueryCompleteListener onQueryCompleteListener,final Context context){
		List<BasicNameValuePair>parms = new ArrayList<BasicNameValuePair>();
		parms.add(new BasicNameValuePair("type", type));
		parms.add(new BasicNameValuePair("order_by", order_by));
		parms.add(new BasicNameValuePair("page", page));
		parms.add(new BasicNameValuePair("pagesize","18"));
		parms.add(new BasicNameValuePair("user_id",Utils.user_id));
		HttpUtils.makeAsyncPost(GETBOOKSBYTYPEACTION, parms,
				new QueryCompleteHandler(onQueryCompleteListener, GETBOOKBYTAPE) {
					Map<String, Object>books;
					@Override
					public void handleResponse(String jsonResult, EHttpError error) {
						// TODO Auto-generated method stub
						if(jsonResult!=null&&error == EHttpError.KErrorNone){
							Gson gson = new Gson();
							Type type = new TypeToken<Map<String, Object>>() {
							}.getType();
							books = gson.fromJson(jsonResult, type);
							List<Map<String, Object>>list = (List<Map<String, Object>>) books.get("books");
                            saveCache(context, jsonResult);
							System.out.println("旧书"+list);
							this.completeListener.onQueryComplete(GETBOOKBYTAPE, books, error);
						}
						else {
							this.completeListener.onQueryComplete(GETBOOKBYTAPE, null, error);
						}
					}
				});
	}
	
	public void saveCache(Context context,String filecontent){
		FileOutputStream out = null;  
        try {  
            out = context.openFileOutput("booklist", Context.MODE_PRIVATE);  
            out.write(filecontent.getBytes("UTF-8")); 
            System.out.println("写入成功");
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        finally{  
            try {  
                out.close();  
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
        }  
	}
	
	/*
	 * @function   得到书籍详情
	 * @param      
	 * @return     
	 */
	public void getBooksByName(String bookname,OnQueryCompleteListener onQueryCompleteListener){
		List<BasicNameValuePair>parms = new ArrayList<BasicNameValuePair>();
		parms.add(new BasicNameValuePair("bookname", bookname));
		HttpUtils.makeAsyncPost(GETBOOKBYNAMEACTION, parms,
				new QueryCompleteHandler(onQueryCompleteListener, GETBOOKBYNAME) {
					Map<String, Object>books;
					@Override
					public void handleResponse(String jsonResult, EHttpError error) {
						// TODO Auto-generated method stub
						if(jsonResult!=null&&error == EHttpError.KErrorNone){
							Gson gson = new Gson();
							Type type = new TypeToken<Map<String, Object>>() {
							}.getType();
							books = gson.fromJson(jsonResult, type);
							List<Map<String, Object>>list = (List<Map<String, Object>>) books.get("books");
							System.out.println("书籍详情"+list);
							this.completeListener.onQueryComplete(GETBOOKBYNAME, list, error);
						}
						else {
							this.completeListener.onQueryComplete(GETBOOKBYNAME, null, error);
						}
					}
				});
	}
	
	/*
	 * @Function  搜索二手书
	 */
	public void searchBook(String bookname,String type,String page,OnQueryCompleteListener onQueryCompleteListener){
		List<BasicNameValuePair>parms = new ArrayList<BasicNameValuePair>();
		parms.add(new BasicNameValuePair("keyword", bookname));
		parms.add(new BasicNameValuePair("page", page));
		parms.add(new BasicNameValuePair("pagesize", "6"));
		parms.add(new BasicNameValuePair("type", type));
		HttpUtils.makeAsyncPost(SEARCHBOOKACTION, parms,
				new QueryCompleteHandler(onQueryCompleteListener, new QueryId()) {
					Map<String, Object>books;
					@Override
					public void handleResponse(String jsonResult, EHttpError error) {
						// TODO Auto-generated method stub
						if(jsonResult!=null&&error == EHttpError.KErrorNone){
							Gson gson = new Gson();
							Type type = new TypeToken<Map<String, Object>>() {
							}.getType();
							books = gson.fromJson(jsonResult, type);
							List<Map<String, Object>>list = (List<Map<String, Object>>) books.get("books");
							System.out.println("搜索到的书"+list);
							this.completeListener.onQueryComplete(new QueryId(), list, error);
						}
						else {
							this.completeListener.onQueryComplete(new QueryId(), null, error);
						}
					}
				});
	}
	
	/*
	 * 近似书名
	 */
	public void getSimilarBook(String bookname,OnQueryCompleteListener onQueryCompleteListener){
		List<BasicNameValuePair>parms = new ArrayList<BasicNameValuePair>();
		parms.add(new BasicNameValuePair("bookname", bookname));
		parms.add(new BasicNameValuePair("limit", 10+""));
		HttpUtils.makeAsyncPost(GETSIMILARBOOKNAME, parms, 
				new QueryCompleteHandler(onQueryCompleteListener, AUTOCOMPLETE) {
					
					@Override
					public void handleResponse(String jsonResult, EHttpError error) {
						// TODO Auto-generated method stub
						Map<String, Object>books;
						if(jsonResult!=null&&error == EHttpError.KErrorNone){
							Gson gson = new Gson();
							Type type = new TypeToken<Map<String, Object>>() {
							}.getType();
							books = gson.fromJson(jsonResult, type);
							List<String>list = (List<String>) books.get("booknames");
							System.out.println("搜索到的书"+list);
							this.completeListener.onQueryComplete(AUTOCOMPLETE, list, error);
						}
						else {
							this.completeListener.onQueryComplete(AUTOCOMPLETE, null, error);
						}
					}
				});
	}
	
	
	/*
	 * 最新
	 */
	public void clickListener(String bookid,OnQueryCompleteListener onQueryCompleteListener){
		List<BasicNameValuePair>parms = new ArrayList<BasicNameValuePair>();
		parms.add(new BasicNameValuePair("book_id", bookid));
		HttpUtils.makeAsyncPost(CLICKBOOKACTION, parms, 
				new QueryCompleteHandler(onQueryCompleteListener, CLICKWISH) {
					
					@Override
					public void handleResponse(String jsonResult, EHttpError error) {
						// TODO Auto-generated method stub
						if(jsonResult!=null&&error == EHttpError.KErrorNone){
							this.completeListener.onQueryComplete(CLICKWISH, jsonResult, error);
						}
						else {
							this.completeListener.onQueryComplete(CLICKWISH, jsonResult, error);
						}
					}
				});
	}

	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}

}
<file_sep># OldBookMarket
This is the project of 校园淘书
<file_sep>package com.yunjian.fragment;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.umeng.analytics.MobclickAgent;
import com.yunjian.activity.AddWishActivity;
import com.yunjian.activity.LoadingActivity;
import com.yunjian.activity.LoginActivity;
import com.yunjian.activity.R;
import com.yunjian.activity.WishDetailActivity;
import com.yunjian.adapter.BookAdapter;
import com.yunjian.adapter.WishAdapter;
import com.yunjian.connection.HttpUtils.EHttpError;
import com.yunjian.service.OnQueryCompleteListener;
import com.yunjian.service.QueryId;
import com.yunjian.service.WishService;
import com.yunjian.util.Utils;
import com.yunjian.view.LoadingDialog;
import com.yunjian.view.PullToRefreshView;
import com.yunjian.view.PullToRefreshView.OnFooterRefreshListener;
import com.yunjian.view.PullToRefreshView.OnHeaderRefreshListener;

import android.app.Fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class WishFragment extends Fragment implements OnHeaderRefreshListener,
			OnFooterRefreshListener, OnClickListener{
	private PullToRefreshView mPullToRefreshView;
	private ListView listView;
	private LinearLayout productButton;
	private Button allbook,coursebook,english,japanese,technology,master,entertain;

	private WishAdapter adapter;
	private List<Map<String, Object>> list;
	private int page = 1;
	private String order_by = "clicks";
	private int type = 0;

	private WishService service;
	private OnQueryCompleteListener onQueryCompleteListener;
	private LoadingDialog loadingDialog;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.wish_book, null);
		initView(view);
		return view;
	}
	
	
	
	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		initService();
	}
 	@Override
 	public void onPause() {
 	    super.onPause();
 	}



	public void initService(){
		service = new WishService();
		onQueryCompleteListener = new OnQueryCompleteListener() {

			@Override
			public void onQueryComplete(QueryId queryId, Object result,
					EHttpError error) {
				// TODO Auto-generated method stub
				loadingDialog.dismiss();
				if(WishService.LISTWISH.equals(queryId)){
					if (result != null) {
						if (page == 1) {
							list = (List<Map<String, Object>>) result;
							try {
								adapter = new WishAdapter(getActivity(), list);
							} catch (Exception e) {
								// TODO: handle exception
							}
							listView.setAdapter(adapter);
						} else {
							List<Map<String, Object>> temp = (List<Map<String, Object>>) result;
							for (int i = 0; i < temp.size(); i++) {
								list.add(temp.get(i));
							}
							adapter.notifyDataSetChanged();
						}

					} else {
						Toast.makeText(getActivity(), "网络连接超时", 2000).show();
						loadingDialog.dismiss();
					}
				}
				else if(queryId.equals(WishService.CLICKWISH)){
					System.out.println("click"+result);
				}
				
			}
		};
	    getCache();
		// 启动后台服务
	    if(LoadingActivity.isNetworkAvailable(getActivity())){
			resetService();
		}
 		else {
			Toast.makeText(getActivity(), "请检查你的网络", Toast.LENGTH_SHORT).show();
		}

	
	}

	public void resetService() {
		service.getWishes(type,String.valueOf(page), order_by,
				onQueryCompleteListener,getActivity());
		loadingDialog.show();
	}
	
	public void getCache(){
        String filename = "wishlist"; //获得读取的文件的名称  
        FileInputStream in = null;  
        ByteArrayOutputStream bout = null;  
        byte[]buf = new byte[1024];  
        bout = new ByteArrayOutputStream();  
        int length = 0;  
        try {  
            in = getActivity().openFileInput(filename); //获得输入流  
            while((length=in.read(buf))!=-1){  
                bout.write(buf,0,length);  
            }  
            byte[] content = bout.toByteArray();  
            Gson gson = new Gson();
			Type type = new TypeToken<Map<String, Object>>() {
			}.getType();
			Map<String, Object>wishes = gson.fromJson(new String(content,"UTF-8"), type);
			list = (List<Map<String, Object>>) wishes.get("wishes");
			adapter = new WishAdapter(getActivity(), list);
			listView.setAdapter(adapter);
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        try{  
            in.close();  
            bout.close();  
        }  
        catch(Exception e){}  
    } 
	
	public void resetButtonColor(){
		allbook.setTextColor(Color.BLACK);
		coursebook.setTextColor(Color.BLACK);
		english.setTextColor(Color.BLACK);
		japanese.setTextColor(Color.BLACK);
		technology.setTextColor(Color.BLACK);
		master.setTextColor(Color.BLACK);
		entertain.setTextColor(Color.BLACK);
		coursebook.setBackgroundResource(R.drawable.white);
		allbook.setBackgroundResource(R.drawable.white);
		english.setBackgroundResource(R.drawable.white);
		japanese.setBackgroundResource(R.drawable.white);
		technology.setBackgroundResource(R.drawable.white);
		master.setBackgroundResource(R.drawable.white);
		entertain.setBackgroundResource(R.drawable.white);
	}
	
	public void initView(View view)
	{
		mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.main_pull_refresh_view);
		listView = (ListView) view.findViewById(R.id.wish_book_list);
		productButton = (LinearLayout) view.findViewById(R.id.wish_product_btn);
		allbook = (Button)view.findViewById(R.id.all);
		coursebook = (Button)view.findViewById(R.id.coursebook);
		english = (Button)view.findViewById(R.id.english);
		japanese = (Button)view.findViewById(R.id.japanese);
		technology = (Button)view.findViewById(R.id.technology);
		master = (Button)view.findViewById(R.id.master);
		entertain = (Button)view.findViewById(R.id.entertain);
		productButton.setClickable(true);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),
						WishDetailActivity.class);
				intent.putExtra("wish_id", list.get(arg2).get("wish_id")
						.toString());
				startActivity(intent);
				
				service.clickListener(list.get(arg2).get("wish_id").toString(), onQueryCompleteListener);
			}
		});


		mPullToRefreshView.setOnHeaderRefreshListener(this);
		mPullToRefreshView.setOnFooterRefreshListener(this);
		productButton.setOnClickListener(this);
		
		allbook.setOnClickListener(this);
		coursebook.setOnClickListener(this);
		english.setOnClickListener(this);
		japanese.setOnClickListener(this);
		technology.setOnClickListener(this);
		master.setOnClickListener(this);
		entertain.setOnClickListener(this);
		loadingDialog = new LoadingDialog(getActivity());

	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()) {
		case R.id.wish_product_btn:
			if(Utils.user_id.equals("")){
				Intent intent3 = new Intent(getActivity(),LoginActivity.class);
				startActivity(intent3);
			}
			else {
				Intent intent = new Intent(getActivity(), AddWishActivity.class);
				startActivity(intent);
			}
			break;
		case R.id.all:
			type = 0;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			allbook.setTextColor(this.getResources().getColor(R.color.seagreen));
			allbook.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		case R.id.coursebook:
			type = 1;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			coursebook.setTextColor(this.getResources().getColor(R.color.seagreen));
			coursebook.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		case R.id.english:
			type = 2;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			english.setTextColor(this.getResources().getColor(R.color.seagreen));
			english.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		case R.id.japanese:
			type = 3;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			japanese.setTextColor(this.getResources().getColor(R.color.seagreen));
			japanese.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		case R.id.technology:
			type = 4;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			technology.setTextColor(this.getResources().getColor(R.color.seagreen));
			technology.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		case R.id.master:
			type = 5;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			master.setTextColor(this.getResources().getColor(R.color.seagreen));
			master.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		case R.id.entertain:
			type = 6;
			page = 1;
			resetService();
			resetButtonColor();
			loadingDialog.show();
			entertain.setTextColor(this.getResources().getColor(R.color.seagreen));
			entertain.setBackgroundResource(R.drawable.wish_type_bg);
			break;
		default:
			break;
		}
	}

	@Override
	public void onFooterRefresh(PullToRefreshView view) {
		// TODO Auto-generated method stub
		mPullToRefreshView.postDelayed(new Runnable() {

			@Override
			public void run() {
				page++;
				System.out.println("页数" + page);
				service.getWishes(type,String.valueOf(page), order_by,
						onQueryCompleteListener,getActivity());
				mPullToRefreshView.onFooterRefreshComplete();
			}
		}, 1000);
	}

	@Override
	public void onHeaderRefresh(PullToRefreshView view) {
		// TODO Auto-generated method stub
		mPullToRefreshView.postDelayed(new Runnable() {

			@Override
			public void run() {
				// 设置更新时间
				// mPullToRefreshView.onHeaderRefreshComplete("最近更新:01-23 12:01");
				list.clear();
				page = 1;
				service.getWishes(type,String.valueOf(page), order_by,
						onQueryCompleteListener,getActivity());
				mPullToRefreshView.onHeaderRefreshComplete();
			}
		}, 1000);
	}

}
<file_sep>package com.yunjian.adapter;

import java.util.List;
import java.util.Map;

import com.yunjian.activity.AddWishActivity;
import com.yunjian.activity.R;
import com.yunjian.connection.HttpUtils.EHttpError;
import com.yunjian.fragment.MyWishesFragment;
import com.yunjian.image.ImageLoader;
import com.yunjian.service.OnQueryCompleteListener;
import com.yunjian.service.QueryId;
import com.yunjian.service.UserCenterService;
import com.yunjian.util.Utils;
import com.yunjian.util.SerializableMap;

import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MyWishesAdapter extends BaseAdapter{
	private Context context;
	private LayoutInflater layoutInflater;
	private List<Map<String, Object>>list;
	private ImageLoader imageLoader;
	private UserCenterService service;
	private OnQueryCompleteListener onQueryCompleteListener;
	private Fragment mywishesfraFragment;
	
	public MyWishesAdapter(Context context,List<Map<String, Object>>list,Fragment mywishes){
		this.context = context;
		layoutInflater = LayoutInflater.from(context);
		this.list = list;
		this.mywishesfraFragment = mywishes;
		imageLoader = ImageLoader.getInstance(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		Item item = null;
		if(item == null){
			item = new Item();
			arg1 = layoutInflater.inflate(R.layout.wisheslist_item,null);
			item.imageView = (ImageView)arg1.findViewById(R.id.wishphoto);
			item.wishname = (TextView)arg1.findViewById(R.id.wishname);
			item.wishstatus = (TextView)arg1.findViewById(R.id.wishstaus);
			item.editButton = (Button)arg1.findViewById(R.id.edit_btn);
			item.achieveButton = (Button)arg1.findViewById(R.id.achieve_btn);
			
			item.wishname.setText(list.get(arg0).get("bookname").toString());
			String status = list.get(arg0).get("status").toString();
			if(status.equals("2.0")){
				item.wishstatus.setText("心愿单有人接下啦");
				item.editButton.setVisibility(View.GONE);
			}
			else if(status.equals("1.0")){
				item.wishstatus.setText("已实现");
				item.achieveButton.setVisibility(View.GONE);
				item.editButton.setVisibility(View.GONE);
			}
			else {
				item.wishstatus.setText("心愿单正常显示着呢");
			}
			arg1.setTag(item);
		}
		else {
			item = (Item)arg1.getTag();
		}
		//加载图片
		try {
			int length = list.get(arg0).get("imgs").toString().length();
			if(length>10){
				imageLoader.addTask(Utils.IMGURL+list.get(arg0).get("imgs").toString().substring(1,37), item.imageView);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		onQueryCompleteListener = new OnQueryCompleteListener() {
			
			@Override
			public void onQueryComplete(QueryId queryId, Object result, EHttpError error) {
				// TODO Auto-generated method stub
				if(result.equals("success")){
					Toast.makeText(context, "心愿已实现", 2000).show();
					((MyWishesFragment) mywishesfraFragment).resetService();
				}
				else {
					Toast.makeText(context, "实现失败", 2000).show();
				}
			}
		};
		ItemClickListener itemClickListener = new ItemClickListener(arg0);
		//编辑监听
		item.editButton.setOnClickListener(itemClickListener);
		//实现监听
		item.achieveButton.setOnClickListener(itemClickListener);
		
		return arg1;
	}
	public class ItemClickListener implements OnClickListener{
		private int position;
		public ItemClickListener(int position){
			this.position = position;
		}

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			if(arg0.getId()==R.id.edit_btn){
				Intent intent = new Intent(context,AddWishActivity.class);
				Bundle bundle = new Bundle();
				Map<String,Object> data=list.get(position);  
	            SerializableMap tmpmap=new SerializableMap();  
	            tmpmap.setMap(data);  
	            bundle.putSerializable("wishinfo", tmpmap);  
	            intent.putExtras(bundle);
	            Utils.IFEDITWISH  = 1;
				context.startActivity(intent);
			}
			else if (arg0.getId()==R.id.achieve_btn) {
				new AlertDialog.Builder(context)   
				.setTitle("确认售出")  
				.setMessage("书籍出售后将不再显示，其他人也看不到此商品，是否确认售出")  
				.setPositiveButton("是", 
						new DialogInterface.OnClickListener() {
							
							@Override
							public void onClick(DialogInterface arg0, int arg1) {
								// TODO Auto-generated method stub
								service = new UserCenterService();
								service.setWishStatus(Utils.user_id, Utils.username,list.get(position).get("wish_id").toString(), 1, onQueryCompleteListener);
							}
						})  
				.setNegativeButton("否", null)  
				.show();  
			}
		}
		
	}
	
	private class Item{
		private ImageView imageView;
		private TextView wishname;
		private TextView wishstatus;
		private Button editButton;
		private Button achieveButton;
	}

}
<file_sep>package com.yunjian.adapter;

import java.util.List;
import java.util.Map;

import com.yunjian.activity.LoginActivity;
import com.yunjian.activity.R;
import com.yunjian.connection.HttpUtils.EHttpError;
import com.yunjian.image.ImageLoader;
import com.yunjian.service.OnQueryCompleteListener;
import com.yunjian.service.QueryId;
import com.yunjian.service.UserCenterService;
import com.yunjian.util.Utils;
import com.yunjian.view.CircleImageView;
import com.yunjian.view.HelpAchievePop;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class WishAdapter extends BaseAdapter implements OnQueryCompleteListener{
	private LayoutInflater layoutInflater;
	private Context context;
	private List<Map<String, Object>>list;
	private ImageLoader mImageLoader;
	
	public WishAdapter(Context context,List<Map<String, Object>>list){
		this.context = context;
		this.list = list;
		this.layoutInflater = LayoutInflater.from(context);
		mImageLoader = ImageLoader.getInstance(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@SuppressWarnings("unused")
	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		Item item = null;
		if (item == null) {
			item = new Item();
			arg1 = layoutInflater.inflate(R.layout.list_item, null);
			item.userImage = (CircleImageView)arg1.findViewById(R.id.user_image);
			item.userName = (TextView)arg1.findViewById(R.id.user_name);
			item.userSex = (ImageView)arg1.findViewById(R.id.user_sex);
			item.achieve = (Button)arg1.findViewById(R.id.achieve);
			item.bookName = (TextView)arg1.findViewById(R.id.book_name);
			item.wishContent = (TextView)arg1.findViewById(R.id.wish_content);
			//图片加载
			try {
				mImageLoader.addTask(Utils.URL+list.get(arg0).get("user_id"), item.userImage);
			} catch (Exception e) {
			// TODO: handle exception
				e.printStackTrace();
			}
			item.userName.setText(list.get(arg0).get("username").toString());
			item.bookName.setText(list.get(arg0).get("bookname").toString());
			item.wishContent.setText(list.get(arg0).get("description").toString());
			if(list.get(arg0).get("gender").toString().equals("0.0")){
				item.userSex.setImageResource(R.drawable.user_sex_woman);
			}
			else if(list.get(arg0).get("gender").toString().equals("2.0")){
				item.userSex.setImageResource(R.drawable.user_sex_secret);
			}
			arg1.setTag(item);
		}
		else {
			item = (Item)arg1.getTag();
		}
		//图片加载
		try {
			//mImageLoader.addTask(Utils.IMGURL+list.get(arg0).get("img"), item.imageView);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		ItemClickListener itemClickListener = new ItemClickListener(arg0);
		item.achieve.setOnClickListener(itemClickListener);
		return arg1;
	}
	
	public class ItemClickListener implements OnClickListener{
    	private int pos;
    	
    	public ItemClickListener(int position){
    		this.pos = position;
    	}

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			if(arg0.getId() == R.id.achieve){
				if(list.get(pos).get("user_id").toString().equals(Utils.user_id)){
					Toast.makeText(context, "这是你自己的心愿单喔", 2000).show();
				}
				else if(Utils.user_id.equals("")){
					Intent intent3 = new Intent(context,LoginActivity.class);
					context.startActivity(intent3);
				}
				else {
					HelpAchievePop helpAchievePop = new HelpAchievePop(context,list.get(pos));
					helpAchievePop.showAtLocation(((Activity) context)
							.findViewById(R.id.wishmain), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
				}
			}
		}
	}
	
	private class Item{
		private CircleImageView userImage;
		private TextView userName;
		private ImageView userSex;
		private Button achieve;
		private TextView bookName;
		private TextView wishContent;
	}

	@Override
	public void onQueryComplete(QueryId queryId, Object result, EHttpError error) {
		// TODO Auto-generated method stub
		if(result.equals("success")){
			Toast.makeText(context, "已经接下心愿单", 2000).show();
		}
	}

}
<file_sep>remoteHost = http://172.16.31.10:5000/<file_sep>package com.yunjian.activity;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.umeng.analytics.MobclickAgent;
import com.yunjian.adapter.BookDetailCommentAdapter;
import com.yunjian.connection.HttpUtils.EHttpError;
import com.yunjian.image.AsyncImageLoader;
import com.yunjian.image.ImageLoader;
import com.yunjian.service.BookService;
import com.yunjian.service.OnQueryCompleteListener;
import com.yunjian.service.QueryId;
import com.yunjian.service.UserManageService;
import com.yunjian.service.WishService;
import com.yunjian.util.ScreenShot;
import com.yunjian.util.Utils;
import com.yunjian.view.CircleImageView;
import com.yunjian.view.ConnectSellerPopwindow;
import com.yunjian.view.GestureListener;
import com.yunjian.view.InputPopwindow;
import com.yunjian.view.MyScrollView;
import com.yunjian.view.NoScrollListView;
import com.yunjian.view.ScrollListener;



public class BookDetailActivity extends Activity implements OnClickListener {

	private TextView title, readTime,publishDays,price,
	userName,userTel,userQQ,userWinxin,basicCondition,suitCrowd,
	myEvaluation,showAll,emptytTextView;
	private CircleImageView userImage;
	private LinearLayout llUserQQ,llUserWeChat;
	private RelativeLayout header,nextLayout;
	private ImageButton back;
	private ImageView bookDetailImage1,bookDetailImage2,bookDetailImage3;
	private Button nextSeller,frontSeller;
	private NoScrollListView comment;
	private ImageView bottomComment,bottomConnect,bottomShare,usersex;
	private Boolean showAllFlag=true;
	private List<Map<String, Object>> list;
	private List<Map<String, Object>> commentlist;
	private Map<String, Object>map;
	private int curPage=0,maxPage=0;
	private LinearLayout bottomLayout;
	private OnQueryCompleteListener onQueryCompleteListener;
	private ImageLoader imageLoader;
	private BookDetailCommentAdapter bookDetailCommentAdapter; 
	private BookService service;
	private String bookname,bookid;
	private int image_number = 0;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.book_detail);

		imageLoader = ImageLoader.getInstance(this);
				
				
		initView();
		onQueryCompleteListener = new OnQueryCompleteListener() {
			
			@Override
			public void onQueryComplete(QueryId queryId, Object result, EHttpError error) {
				// TODO Auto-generated method stub
				if(result!=null){
					if(queryId.equals(BookService.GETBOOKBYNAME)){
						list = (List<Map<String, Object>>) result;
						getInfomation();
					}
					else if(queryId.equals(WishService.GETCOMMENT)){
						commentlist = (List<Map<String, Object>>) result;
                        if(commentlist.size() == 0){
                        	emptytTextView.setVisibility(View.VISIBLE);
                        	bookDetailCommentAdapter = new BookDetailCommentAdapter(BookDetailActivity.this,commentlist);
    						comment.setAdapter(bookDetailCommentAdapter);
                        }
                        else {
                        	emptytTextView.setVisibility(View.GONE);
                        	bookDetailCommentAdapter = new BookDetailCommentAdapter(BookDetailActivity.this,commentlist);
    						comment.setAdapter(bookDetailCommentAdapter);
						}
					}
					else if(queryId.equals(WishService.MAKECOMMENT)){
						if(result.equals("success")){
							Toast.makeText(BookDetailActivity.this, "评论成功", 2000).show();
						}
						else {
							Toast.makeText(BookDetailActivity.this, "评论失败", 2000).show();
						}
					}
					else if(queryId.equals(BookService.CLICKWISH)){
						if(result.equals("success")){
						}
						else {
						}
					}
				}
			}
		};
		
		service = new BookService();
		Intent intent = getIntent();
		bookname = intent.getStringExtra("bookname");
		service.getBooksByName(bookname, onQueryCompleteListener);
		
		

	}

	private void getInfomation()  {
		// TODO Auto-generated method stub
		if(list.size() == 1){
			nextLayout.setVisibility(View.GONE);
		}
		maxPage = list.size()-1;
		if(list.get(curPage).get("status").toString().equals("1.0")){
			bottomLayout.setVisibility(View.GONE);
		}
		title.setText((list.get(curPage).get("bookname")).toString());
		getDays();
		publishDays.setText(getDays()+"天前发布");
		price.setText(list.get(curPage).get("price").toString());
		userTel.setText(list.get(curPage).get("mobile").toString());
		String readtime = list.get(curPage).get("clicks").toString().substring(0, list.get(curPage).get("clicks").toString().length()-2);
		readTime.setText(readtime+"次浏览");
		
		map = list.get(curPage);
		bookid = list.get(curPage).get("book_id").toString();
		service.clickListener(bookid, onQueryCompleteListener);
		resetService();
		
		if(list.get(curPage).get("qq").toString().equals("")){
			llUserQQ.setVisibility(View.GONE);
		}else{
			llUserQQ.setVisibility(View.VISIBLE);
			userQQ.setText(list.get(curPage).get("qq").toString());
		}
		if(list.get(curPage).get("weixin").toString().equals("") ||list.get(curPage).get("weixin").toString().equals(null) ){
			llUserWeChat.setVisibility(View.GONE);
		}else{
			llUserWeChat.setVisibility(View.VISIBLE);
			userWinxin.setText(list.get(curPage).get("weixin").toString());
		}
		
		userName.setText(list.get(curPage).get("username").toString());
		System.out.println(list.get(curPage).get("gender").toString()+"  "+list.get(curPage).get("user_id").toString());
		if(list.get(curPage).get("gender").toString().equals("0.0")){
		    	usersex.setImageResource(R.drawable.user_sex_woman);
		}
		else if(list.get(curPage).get("gender").toString().equals("2.0")){
			usersex.setImageResource(R.drawable.user_sex_secret);
		}
		else if(list.get(curPage).get("gender").toString().equals("1.0")){
			usersex.setImageResource(R.drawable.user_sex_man);
		}
		
		basicCondition.setText(list.get(curPage).get("newness").toString());
		suitCrowd.setText(list.get(curPage).get("audience").toString());
		myEvaluation.setText(list.get(curPage).get("description").toString());
		imageLoader.addTask(Utils.URL+list.get(curPage).get("user_id").toString(), userImage);
		int length = list.get(curPage).get("imgs").toString().length();
		if(length<10){
			image_number = 0;
			bookDetailImage1.setVisibility(View.GONE);
			bookDetailImage2.setVisibility(View.GONE);
			bookDetailImage3.setVisibility(View.VISIBLE);
		}
		else if(length<40){
			image_number = 1;
			bookDetailImage1.setVisibility(View.GONE);
			bookDetailImage2.setVisibility(View.GONE);
			bookDetailImage3.setVisibility(View.VISIBLE);
			imageLoader.addTask(Utils.IMGURL+list.get(curPage).get("imgs").toString().substring(1,37), bookDetailImage3);
		}
		else if(length<80){
			image_number = 2;
			bookDetailImage1.setVisibility(View.GONE);
			bookDetailImage2.setVisibility(View.VISIBLE);
			bookDetailImage3.setVisibility(View.VISIBLE);
			imageLoader.addTask(Utils.IMGURL+list.get(curPage).get("imgs").toString().substring(1,37), bookDetailImage3);
			imageLoader.addTask(Utils.IMGURL+list.get(curPage).get("imgs").toString().substring(39,75), bookDetailImage2);
		}
		else{
			image_number = 3;
			bookDetailImage1.setVisibility(View.VISIBLE);
			bookDetailImage2.setVisibility(View.VISIBLE);
			bookDetailImage3.setVisibility(View.VISIBLE);
			imageLoader.addTask(Utils.IMGURL+list.get(curPage).get("imgs").toString().substring(1,37), bookDetailImage1);
			imageLoader.addTask(Utils.IMGURL+list.get(curPage).get("imgs").toString().substring(39,75), bookDetailImage2);
			imageLoader.addTask(Utils.IMGURL+list.get(curPage).get("imgs").toString().substring(77,113), bookDetailImage3);	
		}
		
	}
	public void resetService(){
		new WishService().getWishComment(bookid,  onQueryCompleteListener);
	}
	private int getDays() {
		// TODO Auto-generated method stub
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		Date adddate = null;
		try {
			adddate = sdf.parse(list.get(curPage).get("added_time").toString());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Date curDate = new Date(System.currentTimeMillis());//閼惧嘲褰囪ぐ鎾冲閺冨爼妫�

		Calendar cal0 = Calendar.getInstance();    
		cal0.setTime(adddate);
		Calendar cal1 = Calendar.getInstance();    
		cal1.setTime(curDate);    
		long time0 = cal0.getTimeInMillis(); 
		long time1 = cal1.getTimeInMillis(); 
		int days = (int) ((time1-time0)/(1000*3600*24));
		return days;
	}

	private void initView() {
		// TODO Auto-generated method stub
		title = (TextView)findViewById(R.id.book_detail_title);
		readTime = (TextView)findViewById(R.id.book_detail_read_time);
		publishDays = (TextView)findViewById(R.id.book_detail_publish_days);
		price = (TextView)findViewById(R.id.book_detail_price);
		userImage = (CircleImageView)findViewById(R.id.book_detail_user_image);
		userName = (TextView)findViewById(R.id.book_detail_user_name);
		userTel = (TextView)findViewById(R.id.book_detail_user_tel);
		userQQ = (TextView)findViewById(R.id.book_detail_user_QQ);
		userWinxin = (TextView)findViewById(R.id.book_detail_user_weixin);
		basicCondition = (TextView)findViewById(R.id.book_detail_basic_condition);
		suitCrowd = (TextView)findViewById(R.id.book_detail_suit_crowd);
		myEvaluation = (TextView)findViewById(R.id.book_detail_my_evaluation);
		showAll = (TextView)findViewById(R.id.book_detail_show_all);
		emptytTextView = (TextView)findViewById(R.id.empty_txv);
		usersex = (ImageView)findViewById(R.id.user_sex);
		
		llUserQQ = (LinearLayout)findViewById(R.id.ll_book_user_qq);
		llUserWeChat = (LinearLayout)findViewById(R.id.ll_book_user_wechat);
		
		bottomLayout = (LinearLayout)findViewById(R.id.bookdetail_bottomlayout);
		header = (RelativeLayout)findViewById(R.id.header);
		nextLayout = (RelativeLayout)findViewById(R.id.next_front_layout);
		
		back = (ImageButton)findViewById(R.id.bt_detail_back);
		
		bookDetailImage1 = (ImageView)findViewById(R.id.book_detail_image_1);
		bookDetailImage2 = (ImageView)findViewById(R.id.book_detail_image_2);
		bookDetailImage3 = (ImageView)findViewById(R.id.book_detail_image_3);
		
		nextSeller = (Button)findViewById(R.id.next_seller);
		frontSeller = (Button)findViewById(R.id.front_seller);
		
		comment = (NoScrollListView)findViewById(R.id.book_detail_comment);
		
		bottomComment = (ImageView)findViewById(R.id.book_detail_bottom_comment);
		bottomConnect = (ImageView)findViewById(R.id.book_detail_bottom_connect);
		bottomShare = (ImageView)findViewById(R.id.book_detail_bottom_share);
		back.setOnClickListener(this);
		showAll.setClickable(true);
		showAll.setOnClickListener(this);
		bottomComment.setClickable(true);
		bottomConnect.setClickable(true);
		bottomShare.setClickable(true);
		header.setLongClickable(true);
		header.setOnTouchListener(new MyGestureListener(this));
		nextSeller.setOnClickListener(this);
		frontSeller.setOnClickListener(this);
		bottomComment.setOnClickListener(this);
		bottomConnect.setOnClickListener(this);
		bottomShare.setOnClickListener(this);

	}

	public class MyGestureListener extends GestureListener {

		public MyGestureListener(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
		}

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			// TODO Auto-generated method stub
			return super.onTouch(v, event);
		}

		@Override
		public boolean left() {
			if(image_number == 2){
				Bitmap bitmap = ((BitmapDrawable) bookDetailImage2.getDrawable())
						.getBitmap();
				bookDetailImage2.setImageBitmap(((BitmapDrawable) bookDetailImage3
						.getDrawable()).getBitmap());
				bookDetailImage3.setImageBitmap(bitmap);
					
			}else if(image_number == 3){
			Bitmap bitmap = ((BitmapDrawable) bookDetailImage1.getDrawable())
					.getBitmap();
			bookDetailImage1.setImageBitmap(((BitmapDrawable) bookDetailImage3
					.getDrawable()).getBitmap());
			bookDetailImage3.setImageBitmap(((BitmapDrawable) bookDetailImage2
					.getDrawable()).getBitmap());
			bookDetailImage2.setImageBitmap(bitmap);
			}
			return super.left();
		}

		@Override
		public boolean right() {
			if(image_number == 2){
				Bitmap bitmap = ((BitmapDrawable) bookDetailImage2.getDrawable())
						.getBitmap();
				bookDetailImage2.setImageBitmap(((BitmapDrawable) bookDetailImage3
						.getDrawable()).getBitmap());
				bookDetailImage3.setImageBitmap(bitmap);
			}else if(image_number == 3){
			Bitmap bitmap = ((BitmapDrawable) bookDetailImage1.getDrawable())
					.getBitmap();
			bookDetailImage1.setImageBitmap(((BitmapDrawable) bookDetailImage2
					.getDrawable()).getBitmap());
			bookDetailImage2.setImageBitmap(((BitmapDrawable) bookDetailImage3
					.getDrawable()).getBitmap());
			bookDetailImage3.setImageBitmap(bitmap);
			}
			return super.right();
		}

	}


	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()) {
		case R.id.bt_detail_back:
			this.finish();
			break;
		case R.id.book_detail_show_all:
			if(showAllFlag){
				showAll.setText("向上收起");
				basicCondition.setSingleLine(false);
				suitCrowd.setSingleLine(false);
				myEvaluation.setSingleLine(false);
				showAllFlag=false;
			}else{
				basicCondition.setSingleLine(true);
				suitCrowd.setSingleLine(true);
				myEvaluation.setSingleLine(true);
				showAllFlag=true;
				showAll.setText("展开全部");
			}
			
			break;
			
		case R.id.front_seller:
			if(curPage>0){
				curPage--;
				getInfomation();
			}else{
				Toast.makeText(BookDetailActivity.this, "没有前一家", 2000).show();
			}
			break;
		case R.id.next_seller:
			if(curPage != maxPage){
				curPage++;
				getInfomation();
			}else{
				Toast.makeText(BookDetailActivity.this, "没有后一家", 2000).show();
			}
			break;
		case R.id.book_detail_bottom_comment:
			if(Utils.user_id.equals("")){
				Intent intent3 = new Intent(BookDetailActivity.this,LoginActivity.class);
				startActivity(intent3);
			}
			else {
				InputPopwindow inputPopwindow = new InputPopwindow(this,list.get(curPage).get("book_id").toString(),0);
	        	inputPopwindow.showAtLocation(this.findViewById(R.id.main_bottom), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
			}
			break;
		case R.id.book_detail_bottom_connect:
			if(Utils.user_id.equals("")){
				Intent intent3 = new Intent(BookDetailActivity.this,LoginActivity.class);
				startActivity(intent3);
			}
			else {
				ConnectSellerPopwindow connectSellerPopwindow = new ConnectSellerPopwindow(BookDetailActivity.this, map);
				connectSellerPopwindow.showAtLocation(this.findViewById(R.id.main_bottom), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
			}
			break;
		case R.id.book_detail_bottom_share:
			if(Utils.user_id.equals("")){
				Intent intent3 = new Intent(BookDetailActivity.this,LoginActivity.class);
				startActivity(intent3);
			}
			else {
				ScreenShot.shoot(this);
				shareMsg("/sdcard/share.png");
			}
			break;
		default:
			break;
		}
	}
	
	public void shareMsg(String imgPath) {  
	     Intent intent = new Intent(Intent.ACTION_SEND);  
	     if (imgPath == null || imgPath.equals("")) {  
	      intent.setType("text/plain"); // 纯文本  
	     } else {  
	      File f = new File(imgPath);  
	      if (f != null && f.exists() && f.isFile()) {  
	       intent.setType("image/png");
	        Uri u = Uri.fromFile(f);  
	       intent.putExtra(Intent.EXTRA_STREAM, u);  
	      }  
	     }  
	     intent.putExtra(Intent.EXTRA_SUBJECT, "分享");  
	     intent.putExtra(Intent.EXTRA_TEXT, "我在校园淘书上看到了这本书蛮有意思, 最便捷的二手书交易App, 人生之路, 淘书起步! http://172.16.17.32:5000/download/OldBookMarket.apk");  
	     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
	     startActivity(Intent.createChooser(intent, "请选择"));
	    }
	
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		MobclickAgent.onPause(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		MobclickAgent.onResume(this);
	}

}

