├── bin
├── .gitignore
├── Busleep.apk
├── classes.dex
├── resources.ap_
├── res
│ └── crunch
│ │ ├── drawable-hdpi
│ │ ├── pre_.png
│ │ ├── next_.png
│ │ ├── popup.png
│ │ ├── msg_tips.png
│ │ ├── top_bar.9.png
│ │ ├── ic_launcher.png
│ │ ├── right_arrow.png
│ │ ├── base_dialog_bg.9.png
│ │ ├── ic_refresh_redrection.png
│ │ └── base_horizontal_line.9.png
│ │ ├── drawable-xhdpi
│ │ ├── off.png
│ │ ├── on.png
│ │ ├── arrow.png
│ │ ├── ic_launcher.png
│ │ ├── ic_navi_about.png
│ │ ├── ic_navi_home.png
│ │ ├── ic_action_edit.png
│ │ ├── icon_msg_search.png
│ │ ├── icon_set_normal.png
│ │ ├── icon_set_press.png
│ │ ├── item_botton_bar.png
│ │ ├── base_edit_input.9.png
│ │ ├── default_ptr_rotate.png
│ │ ├── ic_navi_feedback.png
│ │ ├── icon_contact_press.png
│ │ ├── icon_message_press.png
│ │ ├── icon_contact_normal.png
│ │ ├── icon_message_normal.png
│ │ ├── search_clear_normal.png
│ │ ├── search_clear_pressed.png
│ │ ├── ic_refresh_redrection.png
│ │ ├── base_action_bar_back_bg_n.png
│ │ ├── base_action_bar_back_bg_p.png
│ │ ├── base_action_bar_navi_bg_p.png
│ │ ├── base_action_bar_baidu_bg_n.png
│ │ └── base_action_bar_baidu_bg_p.png
│ │ ├── drawable-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_refresh_redrection.png
│ │ └── drawable-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_refresh_redrection.png
├── dexedLibs
│ ├── locSDK_3.1-9ec55c8b58a9c141e15993ac65f3abc0.jar
│ ├── appcompat_v7_2-c8c0b8becc51966c8a044fd331781dd9.jar
│ ├── android-support-v4-c3f6e773c74b6afafab8d884e58877cc.jar
│ ├── baidumapapi_v3_1_0-75f0276cdb29f7a19b7b46c70af0d9a2.jar
│ └── android-support-v7-appcompat-276c9181f6cc5d187029a07b6079d519.jar
├── jarlist.cache
└── AndroidManifest.xml
├── ic_launcher-web.png
├── libs
├── locSDK_3.1.jar
├── android-support-v4.jar
├── armeabi
│ ├── liblocSDK3.so
│ └── libBaiduMapSDK_v3_1_0.so
└── baidumapapi_v3_1_0.jar
├── res
├── raw
│ └── notify.mp3
├── drawable-hdpi
│ ├── next_.png
│ ├── popup.png
│ ├── pre_.png
│ ├── msg_tips.png
│ ├── top_bar.9.png
│ ├── ic_launcher.png
│ ├── right_arrow.png
│ ├── base_dialog_bg.9.png
│ ├── base_horizontal_line.9.png
│ └── ic_refresh_redrection.png
├── drawable-xhdpi
│ ├── off.png
│ ├── on.png
│ ├── arrow.png
│ ├── ic_launcher.png
│ ├── ic_action_edit.png
│ ├── ic_navi_about.png
│ ├── ic_navi_home.png
│ ├── icon_set_press.png
│ ├── ic_navi_feedback.png
│ ├── icon_msg_search.png
│ ├── icon_set_normal.png
│ ├── item_botton_bar.png
│ ├── base_edit_input.9.png
│ ├── default_ptr_rotate.png
│ ├── icon_contact_normal.png
│ ├── icon_contact_press.png
│ ├── icon_message_normal.png
│ ├── icon_message_press.png
│ ├── search_clear_normal.png
│ ├── ic_refresh_redrection.png
│ ├── search_clear_pressed.png
│ ├── base_action_bar_back_bg_n.png
│ ├── base_action_bar_back_bg_p.png
│ ├── base_action_bar_baidu_bg_n.png
│ ├── base_action_bar_baidu_bg_p.png
│ └── base_action_bar_navi_bg_p.png
├── drawable-mdpi
│ ├── ic_launcher.png
│ └── ic_refresh_redrection.png
├── drawable-xxhdpi
│ ├── ic_launcher.png
│ └── ic_refresh_redrection.png
├── values
│ ├── ids_sliding.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ ├── attrs_sliding.xml
│ └── styles.xml
├── layout
│ ├── fragment_station.xml
│ ├── frame_navi.xml
│ ├── slidingmenumain.xml
│ ├── include_action_bar.xml
│ ├── fragment_sleep_plan.xml
│ ├── activity_main.xml
│ ├── fragment_bus_near.xml
│ ├── activity_sleep_plan.xml
│ ├── common_header_leftbutton.xml
│ ├── common_header_rightbutton.xml
│ ├── item_bus_stations.xml
│ ├── xlistview_footer.xml
│ ├── activity_splash.xml
│ ├── fragment_route.xml
│ ├── common_header.xml
│ ├── activity_busline_baidu_map.xml
│ ├── xlistview_header.xml
│ ├── fragment_bus_query.xml
│ ├── item_bus_near.xml
│ ├── item_sleep_alarm.xml
│ ├── behind_slidingmenu.xml
│ ├── activity_busline_detail.xml
│ └── v2_dialog_base.xml
├── drawable
│ ├── slidingmenu_shadow.xml
│ ├── item_bus_near_bg_selector.xml
│ ├── search_clear.xml
│ ├── tab_sleep_plan_btn.xml
│ ├── tab_collect_btn.xml
│ ├── tab_reverse_busline_btn.xml
│ ├── dialog_shape_pressed.xml
│ ├── tab_textcolor.xml
│ ├── dialog_shape_normal.xml
│ ├── item_sleep_plan_bg_selector.xml
│ ├── dialog_btn_selector.xml
│ ├── base_action_bar_back_bg_selector.xml
│ ├── base_action_bar_baidu_bg_selector.xml
│ └── base_action_bar_navi_bg_selector.xml
├── values-v11
│ └── styles.xml
├── menu
│ └── sleep_plan.xml
├── values-w820dp
│ └── dimens.xml
└── values-v14
│ └── styles.xml
├── ic_refresh_redrection-web.png
├── .settings
└── org.eclipse.core.resources.prefs
├── src
└── com
│ └── busleep
│ ├── ui
│ ├── fragment
│ │ ├── StationFragment.java
│ │ ├── MoreFragment.java
│ │ ├── TransferFragment.java
│ │ ├── ShareFragment.java
│ │ ├── MainFragment.java
│ │ ├── RouteFragment.java
│ │ ├── BusQueryFragment.java
│ │ └── BusNearFragment.java
│ ├── SplashActivity.java
│ ├── SleepPlanActivity.java
│ ├── base
│ │ ├── BaseFragment.java
│ │ ├── BaseActivity.java
│ │ ├── BaseFragmentActivity.java
│ │ └── BaseSlidingFragmentActivity.java
│ ├── MainActivity.java
│ └── BuslineBaiduMapActivity.java
│ ├── utils
│ ├── ToastFactory.java
│ ├── NetWorksUtils.java
│ ├── LogUtils.java
│ ├── StringUtil.java
│ ├── CommonUtil.java
│ └── PixelUtil.java
│ ├── config
│ └── Constant.java
│ ├── bean
│ ├── MrBusLine.java
│ ├── MrNearbyBus.java
│ └── MrAlarm.java
│ ├── db
│ ├── AlarmColumn.java
│ ├── DatabaseColumn.java
│ ├── DBHelper.java
│ └── DBProvider.java
│ ├── adapter
│ ├── BusLineStationsAdapter.java
│ ├── BusNearAdapter.java
│ └── AlarmAdapter.java
│ ├── view
│ └── dialog
│ │ └── DialogTips.java
│ ├── baidu
│ ├── LocationHelper.java
│ └── BusLineHelper.java
│ ├── slidingmenu
│ └── SlidingActivityBase.java
│ ├── app
│ ├── CustomApplication.java
│ └── SleepPlanService.java
│ └── widget
│ ├── XListViewFooter.java
│ ├── ClearEditText.java
│ └── XListViewHeader.java
├── project.properties
├── .classpath
├── proguard-project.txt
├── .project
└── AndroidManifest.xml
/bin/.gitignore:
--------------------------------------------------------------------------------
1 | /classes/
2 |
--------------------------------------------------------------------------------
/bin/Busleep.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/Busleep.apk
--------------------------------------------------------------------------------
/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/classes.dex
--------------------------------------------------------------------------------
/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/resources.ap_
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/ic_launcher-web.png
--------------------------------------------------------------------------------
/libs/locSDK_3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/libs/locSDK_3.1.jar
--------------------------------------------------------------------------------
/res/raw/notify.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/raw/notify.mp3
--------------------------------------------------------------------------------
/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/libs/armeabi/liblocSDK3.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/libs/armeabi/liblocSDK3.so
--------------------------------------------------------------------------------
/libs/baidumapapi_v3_1_0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/libs/baidumapapi_v3_1_0.jar
--------------------------------------------------------------------------------
/res/drawable-hdpi/next_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/next_.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/popup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/popup.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/pre_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/pre_.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/off.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/on.png
--------------------------------------------------------------------------------
/ic_refresh_redrection-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/ic_refresh_redrection-web.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/arrow.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/msg_tips.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/msg_tips.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/top_bar.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/top_bar.9.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/right_arrow.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/pre_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/pre_.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/off.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/on.png
--------------------------------------------------------------------------------
/libs/armeabi/libBaiduMapSDK_v3_1_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/libs/armeabi/libBaiduMapSDK_v3_1_0.so
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/ic_action_edit.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_navi_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/ic_navi_about.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_navi_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/ic_navi_home.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_set_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_set_press.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/next_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/next_.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/popup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/popup.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/arrow.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/base_dialog_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/base_dialog_bg.9.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_navi_feedback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/ic_navi_feedback.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_msg_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_msg_search.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_set_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_set_normal.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/item_botton_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/item_botton_bar.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/msg_tips.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/msg_tips.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/top_bar.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/top_bar.9.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/base_edit_input.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/base_edit_input.9.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/default_ptr_rotate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/default_ptr_rotate.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_contact_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_contact_normal.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_contact_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_contact_press.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_message_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_message_normal.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/icon_message_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/icon_message_press.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/search_clear_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/search_clear_normal.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/right_arrow.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/base_horizontal_line.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/base_horizontal_line.9.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-hdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-mdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/search_clear_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/search_clear_pressed.png
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/com/busleep/widget/XListViewHeader.java=UTF-8
3 |
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/ic_navi_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/ic_navi_about.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/ic_navi_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/ic_navi_home.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xxhdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/base_dialog_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/base_dialog_bg.9.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/ic_action_edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/ic_action_edit.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_msg_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_msg_search.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_set_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_set_normal.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_set_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_set_press.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/item_botton_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/item_botton_bar.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/base_action_bar_back_bg_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/base_action_bar_back_bg_n.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/base_action_bar_back_bg_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/base_action_bar_back_bg_p.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/base_action_bar_baidu_bg_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/base_action_bar_baidu_bg_n.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/base_action_bar_baidu_bg_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/base_action_bar_baidu_bg_p.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/base_action_bar_navi_bg_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/res/drawable-xhdpi/base_action_bar_navi_bg_p.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/base_edit_input.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/base_edit_input.9.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/default_ptr_rotate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/default_ptr_rotate.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/ic_navi_feedback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/ic_navi_feedback.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_contact_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_contact_press.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_message_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_message_press.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-mdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-mdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_contact_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_contact_normal.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/icon_message_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/icon_message_normal.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/search_clear_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/search_clear_normal.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/search_clear_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/search_clear_pressed.png
--------------------------------------------------------------------------------
/res/values/ids_sliding.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-hdpi/base_horizontal_line.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-hdpi/base_horizontal_line.9.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xxhdpi/ic_refresh_redrection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xxhdpi/ic_refresh_redrection.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/base_action_bar_back_bg_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/base_action_bar_back_bg_n.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/base_action_bar_back_bg_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/base_action_bar_back_bg_p.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/base_action_bar_navi_bg_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/base_action_bar_navi_bg_p.png
--------------------------------------------------------------------------------
/bin/dexedLibs/locSDK_3.1-9ec55c8b58a9c141e15993ac65f3abc0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/dexedLibs/locSDK_3.1-9ec55c8b58a9c141e15993ac65f3abc0.jar
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/base_action_bar_baidu_bg_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/base_action_bar_baidu_bg_n.png
--------------------------------------------------------------------------------
/bin/res/crunch/drawable-xhdpi/base_action_bar_baidu_bg_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/res/crunch/drawable-xhdpi/base_action_bar_baidu_bg_p.png
--------------------------------------------------------------------------------
/bin/dexedLibs/appcompat_v7_2-c8c0b8becc51966c8a044fd331781dd9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/dexedLibs/appcompat_v7_2-c8c0b8becc51966c8a044fd331781dd9.jar
--------------------------------------------------------------------------------
/bin/dexedLibs/android-support-v4-c3f6e773c74b6afafab8d884e58877cc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/dexedLibs/android-support-v4-c3f6e773c74b6afafab8d884e58877cc.jar
--------------------------------------------------------------------------------
/bin/dexedLibs/baidumapapi_v3_1_0-75f0276cdb29f7a19b7b46c70af0d9a2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/dexedLibs/baidumapapi_v3_1_0-75f0276cdb29f7a19b7b46c70af0d9a2.jar
--------------------------------------------------------------------------------
/bin/dexedLibs/android-support-v7-appcompat-276c9181f6cc5d187029a07b6079d519.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RaoGY/Busleep/HEAD/bin/dexedLibs/android-support-v7-appcompat-276c9181f6cc5d187029a07b6079d519.jar
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/StationFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import com.busleep.ui.base.BaseFragment;
4 |
5 | /**
6 | * 公交查询站点的片段;
7 | */
8 | public class StationFragment extends BaseFragment {
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/MoreFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import com.busleep.ui.base.BaseFragment;
4 |
5 | /**
6 | * 更多...片段;
7 | * @author Render
8 | */
9 | public class MoreFragment extends BaseFragment{
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/TransferFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import com.busleep.ui.base.BaseFragment;
4 |
5 | /**
6 | * 换乘片段;
7 | * @author Render;
8 | */
9 | public class TransferFragment extends BaseFragment{
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/res/layout/fragment_station.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/layout/frame_navi.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/ShareFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import com.busleep.ui.base.BaseFragment;
4 |
5 | /**
6 | * 分享片段;
7 | * @author Render;
8 | *
9 | */
10 | public class ShareFragment extends BaseFragment {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/res/layout/slidingmenumain.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/MainFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import com.busleep.ui.base.BaseFragment;
4 |
5 | /**
6 | * 主页的片段对象;
7 | * @author Render;
8 | *
9 | */
10 | public class MainFragment extends BaseFragment{
11 |
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/res/drawable/slidingmenu_shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/res/drawable/item_bus_near_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/res/drawable/search_clear.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/res/drawable/tab_sleep_plan_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/res/layout/include_action_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/res/drawable/tab_collect_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/res/drawable/tab_reverse_busline_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/res/drawable/dialog_shape_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/drawable/tab_textcolor.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/res/drawable/dialog_shape_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/bin/jarlist.cache:
--------------------------------------------------------------------------------
1 | # cache for current jar dependency. DO NOT EDIT.
2 | # format is
3 | # Encoding is UTF-8
4 | 1408782680734 627582 cb6883d96005bc85b3e868f204507ea5b4fa9bbf F:\Workspace\AndroidDevelop\MySelf\Busleep\libs\android-support-v4.jar
5 | 1389936690000 627582 cb6883d96005bc85b3e868f204507ea5b4fa9bbf F:\Workspace\AndroidDevelop\MySelf\appcompat_v7_2\libs\android-support-v4.jar
6 |
--------------------------------------------------------------------------------
/res/drawable/item_sleep_plan_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/res/drawable/dialog_btn_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/res/menu/sleep_plan.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/res/drawable/base_action_bar_back_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/drawable/base_action_bar_baidu_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/res/drawable/base_action_bar_navi_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/layout/fragment_sleep_plan.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library.reference.1=../appcompat_v7_2
16 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/res/layout/fragment_bus_near.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/res/layout/activity_sleep_plan.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/res/layout/common_header_leftbutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
21 |
22 |
--------------------------------------------------------------------------------
/src/com/busleep/utils/ToastFactory.java:
--------------------------------------------------------------------------------
1 | package com.busleep.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * 解决Toast重复出现多次,保持全局只有一个Toast实例
8 | *
9 | * @author Render
10 | *
11 | */
12 | public class ToastFactory {
13 | private static Context context = null;
14 | private static Toast toast = null;
15 |
16 | public static Toast getToast(Context context, String text) {
17 | if (ToastFactory.context == context) {
18 | // toast.cancel();
19 | toast.setText(text);
20 | toast.setDuration(Toast.LENGTH_SHORT);
21 |
22 | } else {
23 |
24 | ToastFactory.context = context;
25 | toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
26 | }
27 | return toast;
28 | }
29 |
30 | public static void cancelToast() {
31 | if (toast != null) {
32 | toast.cancel();
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui;
2 |
3 | import com.mr.busleep.R;
4 | import com.busleep.ui.base.BaseActivity;
5 |
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 |
9 | public class SplashActivity extends BaseActivity {
10 |
11 | private static final long DELAY_TIME = 2000L;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_splash);
17 |
18 | //定位到主页面;
19 | redirectByTime();
20 | }
21 |
22 | private void redirectByTime() {
23 | new Handler().postDelayed(new Runnable() {
24 |
25 | @Override
26 | public void run() {
27 | // TODO Auto-generated method stub
28 | redictToActivity(SplashActivity.this, MainActivity.class, null);
29 | finish();
30 | }
31 | }, DELAY_TIME);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/res/layout/common_header_rightbutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
23 |
24 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Busleep
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/SleepPlanActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui;
2 |
3 | import android.os.Bundle;
4 | import com.mr.busleep.R;
5 | import com.busleep.ui.base.BaseFragmentActivity;
6 | import com.busleep.ui.fragment.SleepPlanFragment;
7 |
8 | /**
9 | * 启动睡眠计划的Activity,该Activity是由公交线路详细信息Activity启动的,里面直接采用睡眠计划片段;
10 | * @author Render;
11 | */
12 |
13 | public class SleepPlanActivity extends BaseFragmentActivity {
14 |
15 | /**
16 | * 加载睡眠计划的片段;
17 | */
18 | private SleepPlanFragment sleepPlanFragment=null;
19 |
20 | @Override
21 | protected void onCreate(Bundle arg0) {
22 | super.onCreate(arg0);
23 | setContentView(R.layout.activity_sleep_plan);
24 | init();
25 | }
26 |
27 | //初始化;
28 | private void init(){
29 |
30 | initTopBarForLeft("睡眠计划");
31 |
32 | sleepPlanFragment=new SleepPlanFragment();
33 | getSupportFragmentManager().beginTransaction().
34 | replace(R.id.rl_sleep_plan, sleepPlanFragment).commit();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/res/layout/item_bus_stations.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #D95555
4 | #4889DB
5 |
6 | #000000
7 | #FFFFFF
8 | #515151
9 | #276CBA
10 | #A42D21
11 | #DC143C
12 | #00000000
13 |
14 | #2000
15 |
16 | #f4f6f6
17 | #489cfa
18 | #9da0a4
19 | #4f9ef6
20 |
21 | #3e3e39
22 | #9fa0a0
23 | #ffffff
24 | #f82c22
25 |
26 |
--------------------------------------------------------------------------------
/src/com/busleep/config/Constant.java:
--------------------------------------------------------------------------------
1 | package com.busleep.config;
2 |
3 | public final class Constant {
4 |
5 | public static final String NETWORK_TYPE_WIFI = "wifi";
6 | public static final String NETWORK_TYPE_MOBILE = "mobile";
7 | public static final String NETWORK_TYPE_ERROR = "error";
8 |
9 | public static final String PRE_NAME = "my_pre";
10 | public static final int nearbyRadius=1000; //百度地图搜索周边环境的范围;
11 |
12 | public static String city="";
13 | public static String address="";
14 |
15 | public static final int alarmDistanceThreshold=500; //闹铃响起的距离阈值;
16 |
17 | /**
18 | * 闹铃服务发送的广播有关的值;
19 | */
20 | public static final int LOCATION_COMPLETED=1; //定位完成;
21 | public static final int ALARM_RING=2; //闹铃响起;
22 | public static final String BROADCAST_VALUE_TYPE="broadcast_value_type"; //广播值类型;
23 | public static final String BROADCAST_ACTION="com.busleep.app.BroadcastReceiver";
24 | public static final String IDS="ids"; //传递正在响的闹铃;
25 |
26 | public static final String ROUTE="线路";
27 | public static final String STATION="站点";
28 | public static final String TRANSFER="换乘";
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/com/busleep/bean/MrBusLine.java:
--------------------------------------------------------------------------------
1 | package com.busleep.bean;
2 |
3 | import java.io.Serializable;
4 | import com.baidu.mapapi.search.busline.BusLineResult;
5 |
6 | /**
7 | * 公交车信息;
8 | * @author Render
9 | *
10 | */
11 | public class MrBusLine implements Serializable {
12 |
13 | private static final long serialVersionUID = 1L;
14 |
15 | public MrBusLine(){
16 |
17 | }
18 |
19 | private String busName=null;
20 |
21 | /**
22 | * 百度地图中公交搜索的结果;
23 | */
24 | private BusLineResult busLineResult=null;
25 |
26 | /**
27 | * 该公交线路的uid,该字段和BusLineResult中的uid相同;
28 | */
29 | private String uid=null;
30 |
31 | public String getBusName() {
32 | return busName;
33 | }
34 |
35 | public void setBusName(String busName) {
36 | this.busName = busName;
37 | }
38 |
39 | public String getUid() {
40 |
41 | return uid;
42 | }
43 |
44 | public void setUid(String uid) {
45 |
46 | this.uid=uid;
47 | }
48 |
49 | public BusLineResult getBusLineResult() {
50 | return busLineResult;
51 | }
52 |
53 | public void setBusLineResult(BusLineResult busLineResult) {
54 | this.busLineResult = busLineResult;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/res/layout/xlistview_footer.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
19 |
20 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 | 0dp
7 | 48.0dip
8 | 22.0sp
9 |
10 |
11 | 48dp
12 | 40dp
13 | 8dp
14 | 12sp
15 |
16 |
17 | 110dp
18 | 45dp
19 | 160dp
20 | 50dp
21 | 20sp
22 |
23 | 150dp
24 | 15dp
25 |
26 |
27 | 1dip
28 | 2dip
29 | 0.5dip
30 |
31 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.base;
2 |
3 | import com.busleep.config.Constant;
4 | import com.busleep.utils.Sputil;
5 |
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.support.v4.app.Fragment;
10 |
11 | public class BaseFragment extends Fragment {
12 |
13 | protected Context mContext;
14 | protected Sputil sputil;
15 |
16 | @Override
17 | public void onCreate(Bundle savedInstanceState) {
18 | // TODO Auto-generated method stub
19 | super.onCreate(savedInstanceState);
20 | mContext = getActivity();
21 | if(null == sputil){
22 | sputil = new Sputil(mContext, Constant.PRE_NAME);
23 | }
24 | }
25 |
26 | @Override
27 | public void onResume() {
28 | // TODO Auto-generated method stub
29 | super.onResume();
30 | }
31 |
32 | @Override
33 | public void onPause() {
34 | // TODO Auto-generated method stub
35 | super.onPause();
36 | }
37 |
38 | /**
39 | * Activity跳转
40 | * @param context
41 | * @param targetActivity
42 | * @param bundle
43 | */
44 | public void redictToActivity(Context context,Class> targetActivity,Bundle bundle){
45 | Intent intent = new Intent(context, targetActivity);
46 | if(null != bundle){
47 | intent.putExtras(bundle);
48 | }
49 | startActivity(intent);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
11 |
22 |
33 |
34 |
--------------------------------------------------------------------------------
/src/com/busleep/db/AlarmColumn.java:
--------------------------------------------------------------------------------
1 | package com.busleep.db;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import android.net.Uri;
7 |
8 | public class AlarmColumn extends DatabaseColumn{
9 |
10 | public static final String TABLE_NAME="alarm";
11 | public static final Uri CONTENT_URI=Uri.parse("content://"+AUTHORITY+"/"+TABLE_NAME);
12 |
13 | //数据库字段常量;
14 | public static final String STATIONNAME="station_name";
15 | public static final String LONGTITUDE="longtitude";
16 | public static final String LATITUDE="latitude";
17 | public static final String ISON="ison";
18 |
19 | //定义表字段与数据库操作字段的映射表;
20 | private static final Map mColumnMap=new HashMap();
21 |
22 | static{
23 | mColumnMap.put(_ID, "integer primary key autoincrement");
24 | mColumnMap.put(STATIONNAME, "text not null");
25 | mColumnMap.put(LONGTITUDE, "float not null");
26 | mColumnMap.put(LATITUDE, "float not null");
27 | mColumnMap.put(ISON, "bit");
28 | }
29 |
30 |
31 | @Override
32 | public String getTableName() {
33 | // TODO Auto-generated method stub
34 | return TABLE_NAME;
35 | }
36 |
37 | @Override
38 | public Uri getTableContent() {
39 | // TODO Auto-generated method stub
40 | return CONTENT_URI;
41 | }
42 |
43 | @Override
44 | protected Map getTableMap() {
45 | // TODO Auto-generated method stub
46 | return mColumnMap;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/busleep/utils/NetWorksUtils.java:
--------------------------------------------------------------------------------
1 | package com.busleep.utils;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | public class NetWorksUtils {
8 |
9 | /**检查网络是否可用 */
10 | public static boolean isNetworkAvailable(Context context) {
11 | NetworkInfo info = getNetworkInfo(context);
12 | if (info != null) {
13 | return info.isAvailable();
14 | }
15 | return false;
16 | }
17 |
18 | /** 判断是否是WIFI */
19 | public static boolean isWifi(Context context) {
20 | NetworkInfo info = getNetworkInfo(context);
21 | if (info != null) {
22 | if (info.getType() == ConnectivityManager.TYPE_WIFI)
23 | return true;
24 | }
25 | return false;
26 | }
27 |
28 | /** 判断是否是手机网络 */
29 | public static boolean isMobile(Context context) {
30 | NetworkInfo info = getNetworkInfo(context);
31 | if (info != null) {
32 | if (info.getType() == ConnectivityManager.TYPE_MOBILE)
33 | return true;
34 | }
35 | return false;
36 | }
37 |
38 | /** 获得网络信息 */
39 | private static NetworkInfo getNetworkInfo(Context context) {
40 |
41 | ConnectivityManager cm = (ConnectivityManager) context
42 | .getSystemService(Context.CONNECTIVITY_SERVICE);
43 | return cm.getActiveNetworkInfo();
44 | }
45 |
46 | /** 检测是否有SD卡 */
47 | public static boolean checkSdCard() {
48 | if (android.os.Environment.getExternalStorageState().equals(
49 | android.os.Environment.MEDIA_MOUNTED))
50 | return true;
51 | else
52 | return false;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/busleep/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.busleep.utils;
2 |
3 | /**
4 | * @date 2014-8-26
5 | * TODO Log工具类,设置开关,防止发布版本时log信息泄露
6 | */
7 |
8 | public class LogUtils {
9 |
10 | public static boolean isDebug = true;
11 |
12 | public static void v(String tag, String msg) {
13 | if (isDebug)
14 | android.util.Log.v(tag, msg);
15 | }
16 |
17 | public static void v(String tag, String msg, Throwable t) {
18 | if (isDebug)
19 | android.util.Log.v(tag, msg, t);
20 | }
21 |
22 | public static void d(String tag, String msg) {
23 | if (isDebug)
24 | android.util.Log.d(tag, msg);
25 | }
26 |
27 | public static void d(String tag, String msg, Throwable t) {
28 | if (isDebug)
29 | android.util.Log.d(tag, msg, t);
30 | }
31 |
32 | public static void i(String tag, String msg) {
33 | if (isDebug)
34 | android.util.Log.i(tag, msg);
35 | }
36 |
37 | public static void i(String tag, String msg, Throwable t) {
38 | if (isDebug)
39 | android.util.Log.i(tag, msg, t);
40 | }
41 |
42 | public static void w(String tag, String msg) {
43 | if (isDebug)
44 | android.util.Log.w(tag, msg);
45 | }
46 |
47 | public static void w(String tag, String msg, Throwable t) {
48 | if (isDebug)
49 | android.util.Log.w(tag, msg, t);
50 | }
51 |
52 | public static void e(String tag, String msg) {
53 | if (isDebug)
54 | android.util.Log.e(tag, msg);
55 | }
56 |
57 | public static void e(String tag, String msg, Throwable t) {
58 | if (isDebug)
59 | android.util.Log.e(tag, msg, t);
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/res/layout/fragment_route.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/res/layout/common_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
25 |
26 |
31 |
32 |
33 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/com/busleep/adapter/BusLineStationsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.busleep.adapter;
2 |
3 | import java.util.List;
4 |
5 | import com.baidu.mapapi.search.busline.BusLineResult.BusStation;
6 | import com.busleep.adapter.base.AdapterBase;
7 | import com.mr.busleep.R;
8 |
9 | import android.content.Context;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.TextView;
14 |
15 | public class BusLineStationsAdapter extends AdapterBase{
16 |
17 | private Context ct;
18 |
19 | public BusLineStationsAdapter(Context ct, List datas) {
20 | this.ct = ct;
21 | super.appendToList(datas);
22 | }
23 |
24 | public void updateListView(List list) {
25 | super.clear();
26 | appendToList(list);
27 | notifyDataSetChanged();
28 | }
29 |
30 | static class ViewHolder {
31 | TextView busStation;
32 | }
33 |
34 | @Override
35 | protected View getExView(int position, View convertView, ViewGroup parent) {
36 |
37 | ViewHolder viewHolder = null;
38 |
39 | if (convertView == null) {
40 | convertView = LayoutInflater.from(ct).inflate(R.layout.item_bus_stations, null);
41 | viewHolder = new ViewHolder();
42 |
43 | viewHolder.busStation = (TextView) convertView.findViewById(R.id.tv_bus_station);
44 | convertView.setTag(viewHolder);
45 |
46 | } else{
47 | viewHolder = (ViewHolder) convertView.getTag();
48 | }
49 |
50 | BusStation busStation=getList().get(position);
51 |
52 | viewHolder.busStation.setText(busStation.getTitle());
53 |
54 | return convertView;
55 | }
56 |
57 | @Override
58 | protected void onReachBottom() {
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/com/busleep/bean/MrNearbyBus.java:
--------------------------------------------------------------------------------
1 | package com.busleep.bean;
2 |
3 | import com.baidu.mapapi.model.LatLng;
4 |
5 | /**
6 | * 周边的公交车信息;
7 | * @author Render;
8 | */
9 | public class MrNearbyBus {
10 |
11 | /**
12 | * 公交车名称;
13 | */
14 | private String busName=null;
15 |
16 | /**
17 | * 该公交线路的uid;
18 | */
19 | private String uid=null;
20 |
21 | /**
22 | * 反向公交的Uid;
23 | */
24 | private String reverseUid=null;
25 |
26 | /**
27 | * 查到周围的站点名称,根据该名称查到的公交线路;
28 | */
29 | private String stationName=null;
30 |
31 | /**
32 | * 站点位置;
33 | */
34 | private LatLng stationLaction=null;
35 |
36 | /**
37 | * 开往的方向;
38 | */
39 | private String busDrection=null;
40 |
41 | /**
42 | * 构造函数;
43 | */
44 | public MrNearbyBus(){
45 |
46 | }
47 |
48 | public String getBusName() {
49 | return busName;
50 | }
51 |
52 | public String getUid() {
53 | return uid;
54 | }
55 |
56 | public void setUid(String uid) {
57 | this.uid = uid;
58 | }
59 |
60 | public String getReverseUid() {
61 | return reverseUid;
62 | }
63 |
64 | public void setReverseUid(String reverseUid) {
65 | this.reverseUid = reverseUid;
66 | }
67 |
68 | public void setBusName(String busName) {
69 | this.busName = busName;
70 | }
71 |
72 | public String getStationName() {
73 | return stationName;
74 | }
75 |
76 | public void setStationName(String stationName) {
77 | this.stationName = stationName;
78 | }
79 |
80 | public LatLng getStationLaction() {
81 | return stationLaction;
82 | }
83 |
84 | public void setStationLaction(LatLng stationLaction) {
85 | this.stationLaction = stationLaction;
86 | }
87 |
88 | public String getBusDrection() {
89 | return busDrection;
90 | }
91 |
92 | public void setBusDrection(String busDrection) {
93 | this.busDrection = busDrection;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 500公交
5 | Busleep
6 | Hello world!
7 | Settings
8 | SplashActivity
9 | MainActivity
10 | 请允许我来照顾你,小伙伴们!
11 | 个人中心
12 | 睡眠计划
13 | 周边公交
14 | 公交查询
15 | 分享
16 | 更多
17 | 线路
18 | 换乘
19 | 站点
20 | 请输入线路名,如521,591
21 | 下拉刷新
22 | 松开刷新数据
23 | 正在加载…
24 | 上次更新时间:
25 | 查看更多
26 | 松开载入更多
27 | BusLineDetailActivity
28 | 返程
29 | 收藏
30 | 睡眠计划
31 | BuslineBaiduMapActivity
32 | TestBaiduActivity
33 | SleepPlanActivity
34 | 提示
35 | 添加闹铃
36 |
37 |
38 |
--------------------------------------------------------------------------------
/res/values/attrs_sliding.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/com/busleep/utils/StringUtil.java:
--------------------------------------------------------------------------------
1 | package com.busleep.utils;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.util.regex.Pattern;
9 |
10 | public class StringUtil {
11 |
12 | public static final String URL_REG_EXPRESSION = "^(https?://)?([a-zA-Z0-9_-]+\\.[a-zA-Z0-9_-]+)+(/*[A-Za-z0-9/\\-_&:?\\+=//.%]*)*";
13 | public static final String EMAIL_REG_EXPRESSION = "\\w+(\\.\\w+)*@\\w+(\\.\\w+)+";
14 |
15 | public static boolean isUrl(String s) {
16 | if (s == null) {
17 | return false;
18 | }
19 | return Pattern.matches(URL_REG_EXPRESSION, s);
20 | }
21 |
22 | public static boolean isEmail(String s) {
23 | if (s == null) {
24 | return true;
25 | }
26 | return Pattern.matches(EMAIL_REG_EXPRESSION, s);
27 | }
28 |
29 | public static boolean isBlank(String s) {
30 | if (s == null) {
31 | return true;
32 | }
33 | return Pattern.matches("\\s*", s);
34 | }
35 |
36 | public static String join(String spliter, Object[] arr) {
37 | if (arr == null || arr.length == 0) {
38 | return "";
39 | }
40 | if (spliter == null) {
41 | spliter = "";
42 | }
43 | StringBuilder builder = new StringBuilder();
44 | for (int i = 0; i < arr.length; i++) {
45 | if (i == arr.length - 1) {
46 | break;
47 | }
48 | if (arr[i] == null) {
49 | continue;
50 | }
51 | builder.append(arr[i].toString());
52 | builder.append(spliter);
53 | }
54 | return builder.toString();
55 | }
56 |
57 | public static String fromFile(File f) throws IOException {
58 | InputStream is = new FileInputStream(f);
59 | byte[] bs = new byte[is.available()];
60 | is.read(bs);
61 | is.close();
62 | return new String(bs);
63 | }
64 |
65 | public static void toFile(File f, String s) throws IOException {
66 | // 只有手机rom有足够的空间才写入本地缓存
67 | if (CommonUtil.enoughSpaceOnPhone(s.getBytes().length)) {
68 | FileOutputStream fos = new FileOutputStream(f);
69 | fos.write(s.getBytes());
70 | fos.close();
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/com/busleep/bean/MrAlarm.java:
--------------------------------------------------------------------------------
1 | package com.busleep.bean;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 闹铃对象;
7 | * @author Render;
8 | *
9 | */
10 | public class MrAlarm implements Serializable{
11 |
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = 1L;
16 |
17 | private String id;
18 |
19 | /**
20 | * 当前闹铃设置的站点名称;
21 | */
22 | private String busStationName;
23 |
24 | /**
25 | * 站点对应的经度;
26 | */
27 | private double longtitude;
28 |
29 | /**
30 | * 站点对应的纬度;
31 | */
32 | private double latitude;
33 |
34 |
35 | /**
36 | * 当前位置距离目的地的距离;
37 | */
38 | private int currentDistance;
39 |
40 | /**
41 | * 当前设置的闹钟是否打开;
42 | */
43 | private boolean isOn=true;
44 |
45 | /**
46 | * 该闹铃是否正在响起;
47 | */
48 | private boolean isRing=false;
49 |
50 | public String getId() {
51 | return id;
52 | }
53 |
54 | public void setId(String id) {
55 | this.id = id;
56 | }
57 |
58 | public int getCurrentDistance() {
59 | return currentDistance;
60 | }
61 |
62 | public void setCurrentDistance(int currentDistance) {
63 | this.currentDistance = currentDistance;
64 | }
65 |
66 | public boolean isOn() {
67 | return isOn;
68 | }
69 |
70 | public void setOn(boolean isOn) {
71 | this.isOn = isOn;
72 | }
73 |
74 | public String getBusStationName() {
75 | return busStationName;
76 | }
77 |
78 | public void setBusStationName(String busStationName) {
79 | this.busStationName = busStationName;
80 | }
81 |
82 | public double getLongtitude() {
83 | return longtitude;
84 | }
85 |
86 | public void setLongtitude(double longtitude) {
87 | this.longtitude = longtitude;
88 | }
89 |
90 | public double getLatitude() {
91 | return latitude;
92 | }
93 |
94 | public void setLatitude(double latitude) {
95 | this.latitude = latitude;
96 | }
97 |
98 | public boolean isRing() {
99 | return isRing;
100 | }
101 |
102 | public void setRing(boolean isRing) {
103 | this.isRing = isRing;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/res/layout/activity_busline_baidu_map.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
15 |
16 |
22 |
23 |
32 |
33 |
42 |
43 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/src/com/busleep/view/dialog/DialogTips.java:
--------------------------------------------------------------------------------
1 | package com.busleep.view.dialog;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * 提示对话框,有一个确认、一个返回按钮
7 | */
8 | public class DialogTips extends DialogBase {
9 | boolean hasNegative;
10 | boolean hasTitle;
11 | /**
12 | * 构造函数
13 | * @param context
14 | */
15 | public DialogTips(Context context, String title,String message,String buttonText,boolean hasNegative,boolean hasTitle) {
16 | super(context);
17 | super.setMessage(message);
18 | super.setNamePositiveButton(buttonText);
19 | this.hasNegative = hasNegative;
20 | this.hasTitle = hasTitle;
21 | super.setTitle(title);
22 | }
23 |
24 | /**下线通知的对话框样式
25 | * @param context
26 | * @param title
27 | * @param message
28 | * @param buttonText
29 | */
30 | public DialogTips(Context context,String message,String buttonText) {
31 | super(context);
32 | super.setMessage(message);
33 | super.setNamePositiveButton(buttonText);
34 | this.hasNegative = false;
35 | this.hasTitle = true;
36 | super.setTitle("提示");
37 | super.setCancel(false);
38 | }
39 |
40 | public DialogTips(Context context, String message,String buttonText,String negetiveText,String title,boolean isCancel) {
41 | super(context);
42 | super.setMessage(message);
43 | super.setNamePositiveButton(buttonText);
44 | this.hasNegative=false;
45 | super.setNameNegativeButton(negetiveText);
46 | this.hasTitle = true;
47 | super.setTitle(title);
48 | super.setCancel(isCancel);
49 | }
50 |
51 | /**
52 | * 创建对话框
53 | */
54 | @Override
55 | protected void onBuilding() {
56 | super.setWidth(dip2px(mainContext, 300));
57 | if(hasNegative){
58 | super.setNameNegativeButton("取消");
59 | }
60 | if(!hasTitle){
61 | super.setHasTitle(false);
62 | }
63 | }
64 |
65 | public int dip2px(Context context,float dipValue){
66 | float scale=context.getResources().getDisplayMetrics().density;
67 | return (int) (scale*dipValue+0.5f);
68 | }
69 |
70 | @Override
71 | protected void onDismiss() { }
72 |
73 | @Override
74 | protected void OnClickNegativeButton() {
75 | if(onCancelListener != null){
76 | onCancelListener.onClick(this, 0);
77 | }
78 | }
79 |
80 | /**
81 | * 确认按钮,触发onSuccessListener的onClick
82 | */
83 | @Override
84 | protected boolean OnClickPositiveButton() {
85 | if(onSuccessListener != null){
86 | onSuccessListener.onClick(this, 1);
87 | }
88 | return true;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/com/busleep/baidu/LocationHelper.java:
--------------------------------------------------------------------------------
1 | package com.busleep.baidu;
2 |
3 | import android.content.Context;
4 |
5 | import com.baidu.location.BDLocation;
6 | import com.baidu.location.BDLocationListener;
7 | import com.baidu.location.LocationClient;
8 | import com.baidu.location.LocationClientOption;
9 |
10 | public class LocationHelper {
11 |
12 | private LocationClient mLocationClient=null;
13 |
14 | /**
15 | * 接受百度地图定位的回调类;
16 | */
17 | private MyBDLocationListener mMyBDLocationListener=null;
18 |
19 | /**
20 | * 自定义的定位回调接口,主要是对百度地图定位的封装;
21 | */
22 | private OnLocationListener mLocationListener=null;
23 |
24 | private Context ct;
25 |
26 | public LocationHelper(Context ct){
27 |
28 | this.ct=ct;
29 | }
30 |
31 | /**
32 | * 设置自定义的监听器;
33 | * @param locationListener
34 | */
35 | public void setOnLocationListener(OnLocationListener locationListener){
36 |
37 | this.mLocationListener=locationListener;
38 | }
39 |
40 | /**
41 | * 停止定位;
42 | */
43 | public void stop(){
44 |
45 | if(mLocationClient!=null){
46 |
47 | mLocationClient.stop();
48 | }
49 | }
50 |
51 | /**
52 | * 启动定位;
53 | */
54 | public void start(){
55 |
56 | mLocationClient=new LocationClient(ct);
57 | mMyBDLocationListener=new MyBDLocationListener();
58 | mLocationClient.registerLocationListener(mMyBDLocationListener);
59 |
60 |
61 | LocationClientOption option = new LocationClientOption();
62 | option.setOpenGps(true); // 打开gps;
63 | option.setCoorType("bd09ll"); // 设置坐标类型;
64 | option.setScanSpan(10000); // 每隔10s定位一次;
65 | option.setAddrType("all");
66 |
67 | mLocationClient.setLocOption(option);
68 | mLocationClient.start();
69 | }
70 |
71 | /**
72 | * 实现百度地图的接口;
73 | * @author Render;
74 | *
75 | */
76 | public class MyBDLocationListener implements BDLocationListener{
77 |
78 | @Override
79 | public void onReceiveLocation(BDLocation location) {
80 |
81 | if(mLocationListener!=null){
82 |
83 | mLocationListener.onReceiveLocation(location);
84 | }
85 | }
86 |
87 | @Override
88 | public void onReceivePoi(BDLocation arg0) {
89 | // TODO Auto-generated method stub
90 |
91 | }
92 | }
93 |
94 | public interface OnLocationListener {
95 |
96 | public void onReceiveLocation(BDLocation location);
97 |
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/com/busleep/slidingmenu/SlidingActivityBase.java:
--------------------------------------------------------------------------------
1 | package com.busleep.slidingmenu;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup.LayoutParams;
5 |
6 |
7 | public interface SlidingActivityBase {
8 |
9 | /**
10 | * Set the behind view content to an explicit view. This view is placed directly into the behind view 's view hierarchy.
11 | * It can itself be a complex view hierarchy.
12 | *
13 | * @param view The desired content to display.
14 | * @param layoutParams Layout parameters for the view.
15 | */
16 | public void setBehindContentView(View view, LayoutParams layoutParams);
17 |
18 | /**
19 | * Set the behind view content to an explicit view. This view is placed directly into the behind view 's view hierarchy.
20 | * It can itself be a complex view hierarchy. When calling this method, the layout parameters of the specified
21 | * view are ignored. Both the width and the height of the view are set by default to MATCH_PARENT. To use your
22 | * own layout parameters, invoke setContentView(android.view.View, android.view.ViewGroup.LayoutParams) instead.
23 | *
24 | * @param view The desired content to display.
25 | */
26 | public void setBehindContentView(View view);
27 |
28 | /**
29 | * Set the behind view content from a layout resource. The resource will be inflated, adding all top-level views
30 | * to the behind view.
31 | *
32 | * @param layoutResID Resource ID to be inflated.
33 | */
34 | public void setBehindContentView(int layoutResID);
35 |
36 | /**
37 | * Gets the SlidingMenu associated with this activity.
38 | *
39 | * @return the SlidingMenu associated with this activity.
40 | */
41 | public SlidingMenu getSlidingMenu();
42 |
43 | /**
44 | * Toggle the SlidingMenu. If it is open, it will be closed, and vice versa.
45 | */
46 | public void toggle();
47 |
48 | /**
49 | * Close the SlidingMenu and show the content view.
50 | */
51 | public void showContent();
52 |
53 | /**
54 | * Open the SlidingMenu and show the menu view.
55 | */
56 | public void showMenu();
57 |
58 | /**
59 | * Open the SlidingMenu and show the secondary (right) menu view. Will default to the regular menu
60 | * if there is only one.
61 | */
62 | public void showSecondaryMenu();
63 |
64 | /**
65 | * Controls whether the ActionBar slides along with the above view when the menu is opened,
66 | * or if it stays in place.
67 | *
68 | * @param slidingActionBarEnabled True if you want the ActionBar to slide along with the SlidingMenu,
69 | * false if you want the ActionBar to stay in place
70 | */
71 | public void setSlidingActionBarEnabled(boolean slidingActionBarEnabled);
72 |
73 | }
--------------------------------------------------------------------------------
/src/com/busleep/db/DatabaseColumn.java:
--------------------------------------------------------------------------------
1 | package com.busleep.db;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Map;
5 |
6 | import android.net.Uri;
7 | import android.provider.BaseColumns;
8 |
9 | public abstract class DatabaseColumn implements BaseColumns {
10 |
11 | /**
12 | * The identifier to indicate a specific ContentProvider
13 | */
14 | public static final String AUTHORITY="com.busleep.provider";
15 |
16 | /**
17 | * The database's name
18 | */
19 | public static final String DATABASE_NAME="busleep.db";
20 |
21 | /**
22 | * The version of current database
23 | */
24 | public static final int DATABASE_VERSION = 1;
25 |
26 | /**
27 | * Classes's name extends from this class
28 | */
29 | public static final String[] SUBCLASSES=new String[]{
30 | "com.busleep.db.AlarmColumn"};
31 |
32 | public String getTableCreateor(){
33 | return getTableCreator(getTableName(), getTableMap());
34 | }
35 | /**
36 | * Get sub-classes of this class.
37 | *
38 | * @return Array of sub-classes.
39 | */
40 |
41 | @SuppressWarnings("unchecked")
42 | public static final Class[] getSubClasses(){
43 | ArrayList> classes=new ArrayList>();
44 | Class subClass=null;
45 | for(int i=0;i) Class.forName(SUBCLASSES[i]);
48 | classes.add(subClass);
49 | } catch (ClassNotFoundException e) {
50 | e.printStackTrace();
51 | continue;
52 | }
53 | }
54 | return classes.toArray(new Class[0]);
55 | }
56 |
57 | /**
58 | * Create a sentence to create a table by using a hash-map.
59 | *
60 | * @param tableName
61 | * The table's name to create.
62 | * @param map
63 | * A map to store table columns info.
64 | * @return
65 | */
66 | private static final String getTableCreator(String tableName,
67 | Map map){
68 | String[] keys=map.keySet().toArray(new String[0]);
69 | String value=null;
70 | StringBuilder creator=new StringBuilder();
71 | creator.append("CREATE TABLE ").append(tableName).append("( ");
72 | int length=keys.length;
73 | for(int i=0;i getTableMap();
91 | }
92 |
--------------------------------------------------------------------------------
/res/layout/xlistview_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
19 |
20 |
25 |
26 |
30 |
31 |
38 |
39 |
44 |
45 |
46 |
47 |
55 |
56 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/res/layout/fragment_bus_query.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
25 |
26 |
38 |
39 |
50 |
51 |
52 |
53 |
54 |
60 |
61 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/res/layout/item_bus_near.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
19 |
20 |
29 |
30 |
40 |
41 |
52 |
53 |
54 |
62 |
63 |
64 |
65 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/res/layout/item_sleep_alarm.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
14 |
15 |
22 |
23 |
30 |
31 |
39 |
40 |
41 |
42 |
51 |
52 |
61 |
62 |
66 |
67 |
68 |
69 |
70 |
77 |
78 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui;
2 |
3 | import com.mr.busleep.R;
4 | import com.busleep.db.DBHelper;
5 | import com.busleep.slidingmenu.SlidingMenu;
6 | import com.busleep.ui.base.BaseSlidingFragmentActivity;
7 | import com.busleep.ui.fragment.NaviFragment;
8 | import com.busleep.utils.ToastFactory;
9 | import com.busleep.widget.HeaderLayout;
10 | import com.busleep.widget.HeaderLayout.HeaderStyle;
11 | import com.busleep.widget.HeaderLayout.onLeftImageButtonClickListener;
12 |
13 | import android.os.Bundle;
14 |
15 | public class MainActivity extends BaseSlidingFragmentActivity {
16 |
17 | public static final String TAG="MainAcivity";
18 |
19 | private NaviFragment naviFragment;
20 | private SlidingMenu mSlidingMenu;
21 |
22 | @Override
23 | public void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_main);
26 | initSlidingMenu();
27 | initView("周边公交");
28 | initFragment();
29 | }
30 |
31 | public void initView(String title){
32 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
33 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
34 | mHeaderLayout.setTitleAndLeftImageButton(title,
35 | R.drawable.base_action_bar_navi_bg_selector,new OnNaviButtonClickListener());
36 | }
37 |
38 | private void initSlidingMenu() {
39 | setBehindContentView(R.layout.frame_navi);
40 | // customize the SlidingMenu
41 | mSlidingMenu = getSlidingMenu();
42 | mSlidingMenu.setShadowWidthRes(R.dimen.shadow_width);
43 | mSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
44 |
45 | mSlidingMenu.setMode(SlidingMenu.LEFT);
46 | mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
47 | mSlidingMenu.setShadowDrawable(R.drawable.slidingmenu_shadow);
48 |
49 | mSlidingMenu.setBehindScrollScale(0);
50 | }
51 |
52 | /**
53 | * 初始化片段;
54 | */
55 | private void initFragment(){
56 |
57 | naviFragment=new NaviFragment();
58 | getSupportFragmentManager().beginTransaction().
59 | replace(R.id.frame_navi, naviFragment).commit();
60 | }
61 |
62 | /**
63 | * 定义左键
64 | */
65 | public class OnNaviButtonClickListener implements onLeftImageButtonClickListener{
66 |
67 | @Override
68 | public void onClick() {
69 |
70 | toggle();
71 | }
72 | }
73 |
74 |
75 | private static long firstTime;
76 | /**
77 | * 连续按两次返回键就退出
78 | */
79 | @Override
80 | public void onBackPressed() {
81 |
82 | if (firstTime + 2000 > System.currentTimeMillis()) {
83 | super.onBackPressed();
84 | } else {
85 | ToastFactory.getToast(this, "再按一次退出程序").show();
86 |
87 | }
88 | firstTime = System.currentTimeMillis();
89 | }
90 |
91 | @Override
92 | protected void onDestroy() {
93 | super.onDestroy();
94 | try {
95 | DBHelper db = DBHelper.getInstance(this);
96 | db.closeDb();
97 | } catch (Exception e) {
98 | e.printStackTrace();
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/com/busleep/adapter/BusNearAdapter.java:
--------------------------------------------------------------------------------
1 | package com.busleep.adapter;
2 |
3 | import java.util.List;
4 |
5 | import com.baidu.mapapi.model.LatLng;
6 | import com.baidu.mapapi.utils.DistanceUtil;
7 | import com.mr.busleep.R;
8 | import com.busleep.adapter.base.AdapterBase;
9 | import com.busleep.app.CustomApplication;
10 | import com.busleep.bean.MrNearbyBus;
11 |
12 | import android.content.Context;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.TextView;
17 |
18 | public class BusNearAdapter extends AdapterBase{
19 |
20 | Context ct;
21 |
22 | public BusNearAdapter(Context ct, List lists) {
23 | this.ct = ct;
24 |
25 | super.appendToList(lists);
26 | }
27 |
28 | /**
29 | * 根据位置不同设置背景颜色;
30 |
31 | private void setViewBackgroundColor(int position, View convertView){
32 |
33 | if(position%5==0)
34 | {
35 | //蓝色;
36 | convertView.setBackgroundColor(Color.parseColor("#2468B6"));
37 | }
38 | if(position%5==1)
39 | {
40 | //紫色;
41 | convertView.setBackgroundColor(Color.parseColor("#753BD5"));
42 | }
43 | if(position%5==2)
44 | {
45 | //绿色;
46 | convertView.setBackgroundColor(Color.parseColor("#0F952B"));
47 | }
48 | if(position%5==3)
49 | {
50 | //暗红色;
51 | convertView.setBackgroundColor(Color.parseColor("#9F291E"));
52 | }
53 | if(position%5==4)
54 | {
55 | //黄色;
56 | convertView.setBackgroundColor(Color.parseColor("#D1971B"));
57 | }
58 | } */
59 |
60 | static class ViewHolder {
61 | TextView busName;
62 | TextView busDrection;
63 | TextView busDistance;
64 | }
65 |
66 | @Override
67 | protected View getExView(int position, View convertView, ViewGroup parent) {
68 |
69 | ViewHolder viewHolder = null;
70 |
71 | if (convertView == null) {
72 | convertView = LayoutInflater.from(ct).inflate(R.layout.item_bus_near, null);
73 | viewHolder = new ViewHolder();
74 |
75 | viewHolder.busName = (TextView) convertView.findViewById(R.id.tv_bus_name);
76 | viewHolder.busDrection = (TextView) convertView.findViewById(R.id.tv_bus_drection);
77 | viewHolder.busDistance = (TextView) convertView.findViewById(R.id.tv_bus_distance);
78 | convertView.setTag(viewHolder);
79 |
80 | } else{
81 | viewHolder = (ViewHolder) convertView.getTag();
82 | }
83 |
84 | MrNearbyBus nearbyBus= getList().get(position);
85 |
86 | String busName = nearbyBus.getBusName();
87 | String busDrection = nearbyBus.getBusDrection();
88 |
89 | LatLng nowLatLng=CustomApplication.getInstance().getCurrentLatLng();
90 | LatLng stationLatLng=nearbyBus.getStationLaction();
91 |
92 | int distance=(int)DistanceUtil.getDistance(nowLatLng, stationLatLng);
93 |
94 | String busStation=nearbyBus.getStationName();
95 | busStation="距离 "+busStation+" 约"+String.valueOf(distance)+"米";
96 |
97 | viewHolder.busName.setText(busName);
98 | viewHolder.busDrection.setText(busDrection);
99 | viewHolder.busDistance.setText(busStation);
100 |
101 | return convertView;
102 | }
103 |
104 | @Override
105 | protected void onReachBottom() {
106 |
107 |
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.base;
2 |
3 | import com.busleep.widget.HeaderLayout;
4 | import com.busleep.widget.HeaderLayout.HeaderStyle;
5 | import com.busleep.widget.HeaderLayout.onLeftImageButtonClickListener;
6 | import com.busleep.widget.HeaderLayout.onRightImageButtonClickListener;
7 | import com.mr.busleep.R;
8 |
9 | import android.app.Activity;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.os.Bundle;
13 |
14 | public class BaseActivity extends Activity{
15 |
16 | /**
17 | * 公有的头部对象;
18 | */
19 | protected HeaderLayout mHeaderLayout;
20 |
21 | @Override
22 | protected void onCreate(Bundle arg0) {
23 | // TODO Auto-generated method stub
24 | super.onCreate(arg0);
25 | }
26 |
27 | /**
28 | * 初始化头部布局,只有名称;
29 | * @param titleName
30 | */
31 | public void initTopBarForOnlyTitle(String titleName){
32 | mHeaderLayout=(HeaderLayout)findViewById(R.id.common_actionbar);
33 | mHeaderLayout.init(HeaderStyle.DEFAULT_TITLE);
34 | mHeaderLayout.setDefaultTitle(titleName);
35 | }
36 |
37 | /**
38 | * 初始化布局,左右按钮都存在;
39 | */
40 | public void initTopBarForBoth(String titleName, int rightDrawableId,String text,
41 | onRightImageButtonClickListener listener) {
42 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
43 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
44 | mHeaderLayout.setTitleAndLeftImageButton(titleName,
45 | R.drawable.base_action_bar_back_bg_selector,
46 | new OnLeftButtonClickListener());
47 | mHeaderLayout.setTitleAndRightButton(titleName, rightDrawableId,text,
48 | listener);
49 | }
50 |
51 | public void initTopBarForBoth(String titleName, int rightDrawableId,
52 | onRightImageButtonClickListener listener) {
53 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
54 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
55 | mHeaderLayout.setTitleAndLeftImageButton(titleName,
56 | R.drawable.base_action_bar_back_bg_selector,
57 | new OnLeftButtonClickListener());
58 | mHeaderLayout.setTitleAndRightImageButton(titleName, rightDrawableId,
59 | listener);
60 | }
61 |
62 | /**
63 | * 初始化头部布局只有Title和左侧后退响应;
64 | * @param titleName
65 | */
66 | public void initTopBarForLeft(String titleName ) {
67 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
68 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
69 | mHeaderLayout.setTitleAndLeftImageButton(titleName,
70 | R.drawable.base_action_bar_back_bg_selector,
71 | new OnLeftButtonClickListener());
72 | }
73 |
74 |
75 | /**
76 | * 该类实现左键响应接口,退出当前Activity;
77 | */
78 | public class OnLeftButtonClickListener implements
79 | onLeftImageButtonClickListener {
80 |
81 | @Override
82 | public void onClick() {
83 |
84 | finish();
85 | }
86 | }
87 |
88 | /**
89 | * Activity跳转
90 | * @param context
91 | * @param targetActivity
92 | * @param bundle
93 | */
94 | public void redictToActivity(Context context,Class> targetActivity,Bundle bundle){
95 | Intent intent = new Intent(context, targetActivity);
96 | if(null != bundle){
97 | intent.putExtras(bundle);
98 | }
99 | startActivity(intent);
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/com/busleep/app/CustomApplication.java:
--------------------------------------------------------------------------------
1 | package com.busleep.app;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.baidu.location.BDLocation;
7 | import com.baidu.mapapi.SDKInitializer;
8 | import com.baidu.mapapi.model.LatLng;
9 | import com.busleep.bean.MrAlarm;
10 | import com.busleep.db.AlarmColumn;
11 | import com.busleep.db.DBHelper;
12 | import com.busleep.utils.LogUtils;
13 |
14 | import android.app.Application;
15 | import android.database.Cursor;
16 |
17 | /**
18 | * 自定义的Android的应用类,进行一些接口的初始化操作,如百度地图;
19 | * @author Render
20 | *
21 | */
22 | public class CustomApplication extends Application {
23 |
24 | private static final String TAG="CustomApplication";
25 |
26 | private static CustomApplication mCustomApplication=null;
27 |
28 | /**
29 | * 记录当前用户的位置;
30 | */
31 | public static BDLocation mLocation=null;
32 |
33 | /**
34 | * 静态的Object对象,Intent中对象传递转化为该对象;
35 | */
36 | public static Object mObject=null;
37 |
38 | public static CustomApplication getInstance() {
39 |
40 | return mCustomApplication;
41 | }
42 |
43 | public double getLongtitude(){
44 |
45 | if(mLocation!=null)
46 | {
47 | return mLocation.getLongitude();
48 | }
49 |
50 | return 0.0;
51 | }
52 |
53 | public double getLatitude() {
54 |
55 | if(mLocation!=null)
56 | {
57 | return mLocation.getLatitude();
58 | }
59 |
60 | return 0.0;
61 | }
62 |
63 | /**
64 | * 获取当前的位置;
65 | * @return
66 | */
67 | public LatLng getCurrentLatLng(){
68 |
69 | return new LatLng(getLatitude(), getLongtitude());
70 | }
71 |
72 | @Override
73 | public void onCreate() {
74 |
75 | super.onCreate();
76 |
77 | mCustomApplication=this;
78 |
79 | //初始化百度地图;
80 | SDKInitializer.initialize(this);
81 |
82 | LogUtils.i(TAG, "Baidu Map Init Completed!");
83 | }
84 |
85 | /**
86 | * 获取所有的闹铃;
87 | * @return
88 | */
89 | public List getAllAlarms(){
90 |
91 | List alarms=new ArrayList();
92 |
93 | DBHelper dbHelper=DBHelper.getInstance(getApplicationContext());
94 |
95 | Cursor cursor=dbHelper.query(AlarmColumn.TABLE_NAME, null, null, null);
96 |
97 | int nIndex=0;
98 | while(cursor.moveToNext())
99 | {
100 | MrAlarm alarm=new MrAlarm();
101 | nIndex=cursor.getColumnIndex(AlarmColumn._ID);
102 | String id=cursor.getString(nIndex);
103 | alarm.setId(id);
104 |
105 | nIndex=cursor.getColumnIndex(AlarmColumn.STATIONNAME);
106 | String stationName=cursor.getString(nIndex);
107 | alarm.setBusStationName(stationName);
108 |
109 | nIndex=cursor.getColumnIndex(AlarmColumn.LONGTITUDE);
110 | double longtitude=cursor.getDouble(nIndex);
111 | alarm.setLongtitude(longtitude);
112 |
113 | nIndex=cursor.getColumnIndex(AlarmColumn.LATITUDE);
114 | double latitude=cursor.getDouble(nIndex);
115 | alarm.setLatitude(latitude);
116 |
117 | nIndex=cursor.getColumnIndex(AlarmColumn.ISON);
118 | int ison=cursor.getInt(nIndex);
119 | if(ison!=0){
120 | alarm.setOn(true);
121 | }else {
122 | alarm.setOn(false);
123 | }
124 | alarms.add(alarm);
125 | }
126 | return alarms;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/base/BaseFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.base;
2 |
3 | import com.mr.busleep.R;
4 | import com.busleep.widget.HeaderLayout;
5 | import com.busleep.widget.HeaderLayout.HeaderStyle;
6 | import com.busleep.widget.HeaderLayout.onLeftImageButtonClickListener;
7 | import com.busleep.widget.HeaderLayout.onRightImageButtonClickListener;
8 |
9 | import android.content.Context;
10 | import android.content.Intent;
11 | import android.os.Bundle;
12 | import android.support.v4.app.FragmentActivity;
13 |
14 | public class BaseFragmentActivity extends FragmentActivity {
15 |
16 | /**
17 | * 公有的头部对象;
18 | */
19 | protected HeaderLayout mHeaderLayout;
20 |
21 | @Override
22 | protected void onCreate(Bundle arg0) {
23 | // TODO Auto-generated method stub
24 | super.onCreate(arg0);
25 | }
26 |
27 | /**
28 | * 初始化头部布局,只有名称;
29 | * @param titleName
30 | */
31 | public void initTopBarForOnlyTitle(String titleName){
32 | mHeaderLayout=(HeaderLayout)findViewById(R.id.common_actionbar);
33 | mHeaderLayout.init(HeaderStyle.DEFAULT_TITLE);
34 | mHeaderLayout.setDefaultTitle(titleName);
35 | }
36 |
37 | /**
38 | * 初始化布局,左右按钮都存在;
39 | */
40 | public void initTopBarForBoth(String titleName, int rightDrawableId,String text,
41 | onRightImageButtonClickListener listener) {
42 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
43 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
44 | mHeaderLayout.setTitleAndLeftImageButton(titleName,
45 | R.drawable.base_action_bar_back_bg_selector,
46 | new OnLeftButtonClickListener());
47 | mHeaderLayout.setTitleAndRightButton(titleName, rightDrawableId,text,
48 | listener);
49 | }
50 |
51 | public void initTopBarForBoth(String titleName, int rightDrawableId,
52 | onRightImageButtonClickListener listener) {
53 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
54 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
55 | mHeaderLayout.setTitleAndLeftImageButton(titleName,
56 | R.drawable.base_action_bar_back_bg_selector,
57 | new OnLeftButtonClickListener());
58 | mHeaderLayout.setTitleAndRightImageButton(titleName, rightDrawableId,
59 | listener);
60 | }
61 |
62 | /**
63 | * 初始化头部布局只有Title和左侧后退响应;
64 | * @param titleName
65 | */
66 | public void initTopBarForLeft(String titleName ) {
67 | mHeaderLayout = (HeaderLayout)findViewById(R.id.common_actionbar);
68 | mHeaderLayout.init(HeaderStyle.TITLE_DOUBLE_IMAGEBUTTON);
69 | mHeaderLayout.setTitleAndLeftImageButton(titleName,
70 | R.drawable.base_action_bar_back_bg_selector,
71 | new OnLeftButtonClickListener());
72 | }
73 |
74 |
75 | /**
76 | * 该类实现左键响应接口,退出当前Activity;
77 | */
78 | public class OnLeftButtonClickListener implements
79 | onLeftImageButtonClickListener {
80 |
81 | @Override
82 | public void onClick() {
83 |
84 | finish();
85 | }
86 | }
87 |
88 | /**
89 | * Activity跳转
90 | * @param context
91 | * @param targetActivity
92 | * @param bundle
93 | */
94 | public void redictToActivity(Context context,Class> targetActivity,Bundle bundle){
95 | Intent intent = new Intent(context, targetActivity);
96 | if(null != bundle){
97 | intent.putExtras(bundle);
98 | }
99 | startActivity(intent);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/com/busleep/widget/XListViewFooter.java:
--------------------------------------------------------------------------------
1 | package com.busleep.widget;
2 |
3 | import com.mr.busleep.R;
4 |
5 | import android.content.Context;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 |
12 |
13 | public class XListViewFooter extends LinearLayout{
14 | public final static int STATE_NORMAL = 0;
15 | public final static int STATE_READY = 1;
16 | public final static int STATE_LOADING = 2;
17 |
18 | private Context mContext;
19 |
20 | private View mContentView;
21 | private View mProgressBar;
22 | private TextView mHintView;
23 |
24 | public XListViewFooter(Context context) {
25 | super(context);
26 | initView(context);
27 | }
28 |
29 | public XListViewFooter(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | initView(context);
32 | }
33 |
34 |
35 | public void setState(int state) {
36 | mHintView.setVisibility(View.INVISIBLE);
37 | mProgressBar.setVisibility(View.INVISIBLE);
38 | mHintView.setVisibility(View.INVISIBLE);
39 | if (state == STATE_READY) {
40 | mHintView.setVisibility(View.VISIBLE);
41 | mHintView.setText(R.string.xlistview_footer_hint_ready);
42 | } else if (state == STATE_LOADING) {
43 | mProgressBar.setVisibility(View.VISIBLE);
44 | } else {
45 | mHintView.setVisibility(View.VISIBLE);
46 | mHintView.setText(R.string.xlistview_footer_hint_normal);
47 | }
48 | }
49 |
50 | public void setBottomMargin(int height) {
51 | if (height < 0) return ;
52 | LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mContentView.getLayoutParams();
53 | lp.bottomMargin = height;
54 | mContentView.setLayoutParams(lp);
55 | }
56 |
57 | public int getBottomMargin() {
58 | LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mContentView.getLayoutParams();
59 | return lp.bottomMargin;
60 | }
61 |
62 |
63 | /**
64 | * normal status
65 | */
66 | public void normal() {
67 | mHintView.setVisibility(View.VISIBLE);
68 | mProgressBar.setVisibility(View.GONE);
69 | }
70 |
71 |
72 | /**
73 | * loading status
74 | */
75 | public void loading() {
76 | mHintView.setVisibility(View.GONE);
77 | mProgressBar.setVisibility(View.VISIBLE);
78 | }
79 |
80 | /**
81 | * hide footer when disable pull load more
82 | */
83 | public void hide() {
84 | LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mContentView.getLayoutParams();
85 | lp.height = 0;
86 | mContentView.setLayoutParams(lp);
87 | }
88 |
89 | /**
90 | * show footer
91 | */
92 | public void show() {
93 | LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mContentView.getLayoutParams();
94 | lp.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
95 | mContentView.setLayoutParams(lp);
96 | }
97 |
98 | private void initView(Context context) {
99 | mContext = context;
100 | LinearLayout moreView = (LinearLayout)LayoutInflater.from(mContext).inflate(R.layout.xlistview_footer, null);
101 | addView(moreView);
102 | moreView.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
103 |
104 | mContentView = moreView.findViewById(R.id.xlistview_footer_content);
105 | mProgressBar = moreView.findViewById(R.id.xlistview_footer_progressbar);
106 | mHintView = (TextView)moreView.findViewById(R.id.xlistview_footer_hint_textview);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/com/busleep/utils/CommonUtil.java:
--------------------------------------------------------------------------------
1 | package com.busleep.utils;
2 |
3 | import java.io.File;
4 |
5 | import android.app.Activity;
6 | import android.app.Service;
7 | import android.content.Context;
8 | import android.os.Environment;
9 | import android.os.StatFs;
10 | import android.os.Vibrator;
11 |
12 | public class CommonUtil {
13 |
14 | /**
15 | * 检测sdcard是否可用
16 | *
17 | * @return true为可用,否则为不可用
18 | */
19 | public static boolean sdCardIsAvailable() {
20 | String status = Environment.getExternalStorageState();
21 | if (!status.equals(Environment.MEDIA_MOUNTED))
22 | return false;
23 | return true;
24 | }
25 |
26 | /**
27 | * Checks if there is enough Space on SDCard
28 | *
29 | * @param updateSize
30 | * Size to Check
31 | * @return True if the Update will fit on SDCard, false if not enough space on SDCard Will also return false, if the SDCard is
32 | * not mounted as read/write
33 | */
34 | public static boolean enoughSpaceOnSdCard(long updateSize) {
35 | String status = Environment.getExternalStorageState();
36 | if (!status.equals(Environment.MEDIA_MOUNTED))
37 | return false;
38 | return (updateSize < getRealSizeOnSdcard());
39 | }
40 |
41 | /**
42 | * get the space is left over on sdcard
43 | */
44 | public static long getRealSizeOnSdcard() {
45 | File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
46 | StatFs stat = new StatFs(path.getPath());
47 | long blockSize = stat.getBlockSize();
48 | long availableBlocks = stat.getAvailableBlocks();
49 | return availableBlocks * blockSize;
50 | }
51 |
52 | /**
53 | * Checks if there is enough Space on phone self
54 | *
55 | */
56 | public static boolean enoughSpaceOnPhone(long updateSize) {
57 | return getRealSizeOnPhone() > updateSize;
58 | }
59 |
60 | /**
61 | * get the space is left over on phone self
62 | */
63 | public static long getRealSizeOnPhone() {
64 | File path = Environment.getDataDirectory();
65 | StatFs stat = new StatFs(path.getPath());
66 | long blockSize = stat.getBlockSize();
67 | long availableBlocks = stat.getAvailableBlocks();
68 | long realSize = blockSize * availableBlocks;
69 | return realSize;
70 | }
71 |
72 | /**
73 | * 根据手机分辨率从dp转成px
74 | * @param context
75 | * @param dpValue
76 | * @return
77 | */
78 | public static int dip2px(Context context, float dpValue) {
79 | final float scale = context.getResources().getDisplayMetrics().density;
80 | return (int) (dpValue * scale + 0.5f);
81 | }
82 |
83 | /**
84 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
85 | */
86 | public static int px2dip(Context context, float pxValue) {
87 | final float scale = context.getResources().getDisplayMetrics().density;
88 | return (int) (pxValue / scale + 0.5f)-15;
89 | }
90 |
91 | /**
92 | * 震动实现;
93 | * @param activity
94 | * @param pattern
95 | * @param isRepeat
96 | */
97 | public static void Vibrate(final Activity activity, long[] pattern,boolean isRepeat) {
98 | Vibrator vib = (Vibrator) activity.getSystemService(Service.VIBRATOR_SERVICE);
99 | vib.vibrate(pattern, isRepeat ? 1 : -1);
100 | }
101 |
102 | public static void Vibrate(final Service service, long[] pattern,boolean isRepeat) {
103 | Vibrator vib = (Vibrator) service.getSystemService(Service.VIBRATOR_SERVICE);
104 | vib.vibrate(pattern, isRepeat ? 1 : -1);
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/com/busleep/utils/PixelUtil.java:
--------------------------------------------------------------------------------
1 | package com.busleep.utils;
2 |
3 | import com.busleep.app.CustomApplication;
4 |
5 | import android.content.Context;
6 | import android.content.res.Resources;
7 |
8 | /** Android中像素等尺寸之间的转换工具;
9 | * @author MarkMjw
10 | */
11 | public class PixelUtil {
12 |
13 | /**
14 | * The context.
15 | */
16 | private static Context mContext = CustomApplication.getInstance();
17 |
18 | /**
19 | * dpת px.
20 | *
21 | * @param value the value
22 | * @return the int
23 | */
24 | public static int dp2px(float value) {
25 | final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
26 | return (int) (value * (scale / 160) + 0.5f);
27 | }
28 |
29 | /**
30 | * dpת px.
31 | *
32 | * @param value the value
33 | * @param context the context
34 | * @return the int
35 | */
36 | public static int dp2px(float value, Context context) {
37 | final float scale = context.getResources().getDisplayMetrics().densityDpi;
38 | return (int) (value * (scale / 160) + 0.5f);
39 | }
40 |
41 | /**
42 | * pxתdp.
43 | *
44 | * @param value the value
45 | * @return the int
46 | */
47 | public static int px2dp(float value) {
48 | final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
49 | return (int) ((value * 160) / scale + 0.5f);
50 | }
51 |
52 | /**
53 | * pxתdp.
54 | *
55 | * @param value the value
56 | * @param context the context
57 | * @return the int
58 | */
59 | public static int px2dp(float value, Context context) {
60 | final float scale = context.getResources().getDisplayMetrics().densityDpi;
61 | return (int) ((value * 160) / scale + 0.5f);
62 | }
63 |
64 | /**
65 | * spתpx.
66 | *
67 | * @param value the value
68 | * @return the int
69 | */
70 | public static int sp2px(float value) {
71 | Resources r;
72 | if (mContext == null) {
73 | r = Resources.getSystem();
74 | } else {
75 | r = mContext.getResources();
76 | }
77 | float spvalue = value * r.getDisplayMetrics().scaledDensity;
78 | return (int) (spvalue + 0.5f);
79 | }
80 |
81 | /**
82 | * spתpx.
83 | *
84 | * @param value the value
85 | * @param context the context
86 | * @return the int
87 | */
88 | public static int sp2px(float value, Context context) {
89 | Resources r;
90 | if (context == null) {
91 | r = Resources.getSystem();
92 | } else {
93 | r = context.getResources();
94 | }
95 | float spvalue = value * r.getDisplayMetrics().scaledDensity;
96 | return (int) (spvalue + 0.5f);
97 | }
98 |
99 | /**
100 | * pxתsp.
101 | *
102 | * @param value the value
103 | * @return the int
104 | */
105 | public static int px2sp(float value) {
106 | final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
107 | return (int) (value / scale + 0.5f);
108 | }
109 |
110 | /**
111 | * pxתsp.
112 | *
113 | * @param value the value
114 | * @param context the context
115 | * @return the int
116 | */
117 | public static int px2sp(float value, Context context) {
118 | final float scale = context.getResources().getDisplayMetrics().scaledDensity;
119 | return (int) (value / scale + 0.5f);
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/src/com/busleep/widget/ClearEditText.java:
--------------------------------------------------------------------------------
1 | package com.busleep.widget;
2 |
3 | import com.mr.busleep.R;
4 |
5 | import android.content.Context;
6 | import android.graphics.drawable.Drawable;
7 | import android.text.Editable;
8 | import android.text.TextWatcher;
9 | import android.util.AttributeSet;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.view.View.OnFocusChangeListener;
13 | import android.view.animation.Animation;
14 | import android.view.animation.CycleInterpolator;
15 | import android.view.animation.TranslateAnimation;
16 | import android.widget.EditText;
17 |
18 | /**
19 | * @ClassName: ClearEditText
20 | * @Description: TODO
21 | * @author Render
22 | * @date 2014-5-4 ����4:18:45
23 | */
24 | public class ClearEditText extends EditText implements
25 | OnFocusChangeListener, TextWatcher {
26 |
27 | private Drawable mClearDrawable;
28 |
29 | public ClearEditText(Context context) {
30 | this(context, null);
31 | }
32 |
33 | public ClearEditText(Context context, AttributeSet attrs) {
34 | this(context, attrs, android.R.attr.editTextStyle);
35 | }
36 |
37 | public ClearEditText(Context context, AttributeSet attrs, int defStyle) {
38 | super(context, attrs, defStyle);
39 | init();
40 | }
41 |
42 |
43 | private void init() {
44 | mClearDrawable = getCompoundDrawables()[2];
45 | if (mClearDrawable == null) {
46 | mClearDrawable = getResources().getDrawable(R.drawable.search_clear);
47 | }
48 | mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight());
49 | setClearIconVisible(false);
50 | setOnFocusChangeListener(this);
51 | addTextChangedListener(this);
52 | }
53 |
54 | @Override
55 | public boolean onTouchEvent(MotionEvent event) {
56 | if (getCompoundDrawables()[2] != null) {
57 | if (event.getAction() == MotionEvent.ACTION_UP) {
58 | boolean touchable = event.getX() > (getWidth()
59 | - getPaddingRight() - mClearDrawable.getIntrinsicWidth())
60 | && (event.getX() < ((getWidth() - getPaddingRight())));
61 | if (touchable) {
62 | this.setText("");
63 | }
64 | }
65 | }
66 |
67 | return super.onTouchEvent(event);
68 | }
69 |
70 | @Override
71 | public void onFocusChange(View v, boolean hasFocus) {
72 | if (hasFocus) {
73 | setClearIconVisible(getText().length() > 0);
74 | } else {
75 | setClearIconVisible(false);
76 | }
77 | }
78 |
79 |
80 | /**
81 | * @param visible
82 | */
83 | protected void setClearIconVisible(boolean visible) {
84 | Drawable right = visible ? mClearDrawable : null;
85 | setCompoundDrawables(getCompoundDrawables()[0],
86 | getCompoundDrawables()[1], right, getCompoundDrawables()[3]);
87 | }
88 |
89 | @Override
90 | public void onTextChanged(CharSequence s, int start, int count,
91 | int after) {
92 | setClearIconVisible(s.length() > 0);
93 | }
94 |
95 | @Override
96 | public void beforeTextChanged(CharSequence s, int start, int count,
97 | int after) {
98 |
99 | }
100 |
101 | @Override
102 | public void afterTextChanged(Editable s) {
103 |
104 | }
105 |
106 |
107 | /**
108 | * ���ûζ�����
109 | */
110 | public void setShakeAnimation(){
111 | this.setAnimation(shakeAnimation(5));
112 | }
113 |
114 |
115 | /**
116 | * @param
117 | * @return
118 | */
119 | public static Animation shakeAnimation(int counts){
120 | Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
121 | translateAnimation.setInterpolator(new CycleInterpolator(counts));
122 | translateAnimation.setDuration(1000);
123 | return translateAnimation;
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/com/busleep/db/DBHelper.java:
--------------------------------------------------------------------------------
1 | package com.busleep.db;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.database.Cursor;
6 | import android.database.sqlite.SQLiteDatabase;
7 | import android.database.sqlite.SQLiteDatabase.CursorFactory;
8 | import android.database.sqlite.SQLiteOpenHelper;
9 | import android.provider.BaseColumns;
10 |
11 | /**
12 | * 数据库帮助类;
13 | * @author Render;
14 | *
15 | */
16 | public class DBHelper extends SQLiteOpenHelper{
17 |
18 | private static final String DB_NAME="busleep";
19 | private static final int DB_VERSION=2;
20 |
21 | private SQLiteDatabase db;
22 |
23 | private static DBHelper mdbHelper;
24 |
25 | public static DBHelper getInstance(Context context){
26 |
27 | if(mdbHelper==null){
28 | mdbHelper=new DBHelper(context);
29 | }
30 | return mdbHelper;
31 | }
32 |
33 | private DBHelper(Context context){
34 | super(context,DB_NAME,null,DB_VERSION);
35 | }
36 |
37 | private DBHelper(Context context, String name, CursorFactory factory,
38 | int version) {
39 | super(context, name, factory, version);
40 | }
41 |
42 | @Override
43 | public void onCreate(SQLiteDatabase db) {
44 | this.db=db;
45 | operateTable(db, "");
46 | }
47 |
48 | @Override
49 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
50 |
51 | if(newVersion==oldVersion){
52 | return;
53 | }
54 | operateTable(db, "DROP TABLE IF EXISTS ");
55 | onCreate(db);
56 | }
57 |
58 | public void operateTable(SQLiteDatabase db,String actionString){
59 |
60 | Class[] columnsClasses=DatabaseColumn.getSubClasses();
61 | DatabaseColumn columns=null;
62 | for(int i=0;i
2 |
8 |
9 |
10 |
11 |
21 |
22 |
23 |
29 |
30 |
31 |
105 |
106 |
--------------------------------------------------------------------------------
/src/com/busleep/baidu/BusLineHelper.java:
--------------------------------------------------------------------------------
1 | package com.busleep.baidu;
2 |
3 | import com.baidu.mapapi.search.busline.BusLineResult;
4 | import com.baidu.mapapi.search.busline.BusLineSearch;
5 | import com.baidu.mapapi.search.busline.BusLineSearchOption;
6 | import com.baidu.mapapi.search.busline.OnGetBusLineSearchResultListener;
7 | import com.baidu.mapapi.search.core.PoiInfo;
8 | import com.baidu.mapapi.search.core.SearchResult;
9 | import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener;
10 | import com.baidu.mapapi.search.poi.PoiCitySearchOption;
11 | import com.baidu.mapapi.search.poi.PoiDetailResult;
12 | import com.baidu.mapapi.search.poi.PoiResult;
13 | import com.baidu.mapapi.search.poi.PoiSearch;
14 | import com.busleep.bean.MrBusLine;
15 | import com.busleep.config.Constant;
16 | import com.busleep.utils.LogUtils;
17 |
18 | /**
19 | * 公交路线搜索帮助类;
20 | * @author Render;
21 | */
22 | public class BusLineHelper implements OnGetPoiSearchResultListener,OnGetBusLineSearchResultListener{
23 |
24 | public static final String TAG = "BusLineHelper";
25 |
26 | private PoiSearch mPoiSearch = null; //搜索模块;
27 | private BusLineSearch mBusLineSearch = null; //公交路线搜索模块;
28 | private MrBusLine mBusLine=null; //搜索到的公交线路;
29 | private String mUid=null; //正向的Uid;
30 | private OnBusLineSearchListener mrBusLineSearchListener; //自定义的搜索监听器;
31 |
32 |
33 | public void init(){
34 | if(mPoiSearch==null||mBusLineSearch==null){
35 |
36 | mPoiSearch = PoiSearch.newInstance();
37 | mPoiSearch.setOnGetPoiSearchResultListener(this);
38 | mBusLineSearch = BusLineSearch.newInstance();
39 | mBusLineSearch.setOnGetBusLineSearchResultListener(this);
40 | }
41 | }
42 |
43 | /**
44 | * 添加自定义公交线路搜索监听器;
45 | * @param mrBusLineSearchListener
46 | */
47 | public void setMrBusLineSearchListener(OnBusLineSearchListener mrBusLineSearchListener) {
48 |
49 | this.mrBusLineSearchListener = mrBusLineSearchListener;
50 | }
51 |
52 | /**
53 | * 根据Uid查询公交线路;
54 | * @param uid
55 | */
56 | public void searchBusLineByUid(String uid){
57 |
58 | mBusLine=new MrBusLine();
59 | mBusLine.setUid(uid);
60 | mBusLineSearch.searchBusLine(new BusLineSearchOption().city(Constant.city).uid(uid));
61 | }
62 |
63 | /**
64 | * 根据名称查询该公交线路;
65 | * @param busName
66 | */
67 | public void searchBusLineByName(String busName,String uid){
68 |
69 | mBusLine=new MrBusLine();
70 | mUid=uid;
71 | //根据名字查公交的话先要用PoiSearch;
72 | mPoiSearch.searchInCity(new PoiCitySearchOption().city(Constant.city).keyword(busName));
73 | }
74 |
75 |
76 | @Override
77 | public void onGetBusLineResult(BusLineResult result) {
78 |
79 | if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
80 |
81 | LogUtils.i(TAG, "没找到该公交路线");
82 | return;
83 | }
84 |
85 | mBusLine.setBusLineResult(result);
86 |
87 | /**
88 | * 回调实现该接口的对象;
89 | */
90 | if(mrBusLineSearchListener!=null){
91 | mrBusLineSearchListener.onGetBusLineResult(mBusLine);
92 | }
93 | }
94 |
95 | @Override
96 | public void onGetPoiDetailResult(PoiDetailResult result) {
97 |
98 |
99 | }
100 | @Override
101 | public void onGetPoiResult(PoiResult result) {
102 |
103 | if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
104 |
105 | LogUtils.i(TAG, "Poi公交路线搜索失败");
106 | return;
107 | }
108 |
109 | for(PoiInfo poi:result.getAllPoi()){
110 |
111 | if (poi.type == PoiInfo.POITYPE.BUS_LINE){
112 |
113 | //如果正向Uid为空,则查询到的一个uid直接赋值;
114 | if(mUid==null){
115 | mBusLine.setUid(poi.uid);
116 | break;
117 | }else {
118 | //如果正向uid等于查询到的uid,则继续查找,查找的下一个uid即为需要反向uid,否则直接为反向uid;
119 | if(mUid.equals(poi.uid)){
120 | continue;
121 | }else {
122 | mBusLine.setUid(poi.uid);
123 | break;
124 | }
125 | }
126 | }
127 | }
128 | //poi搜索完成后,根据搜索到的uid继续搜索;
129 | mBusLineSearch.searchBusLine(new BusLineSearchOption().city(Constant.city).uid(mBusLine.getUid()));
130 | }
131 |
132 | public interface OnBusLineSearchListener {
133 |
134 | public void onGetBusLineResult(MrBusLine mBusLine);
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
26 |
27 |
36 |
37 |
44 |
45 |
49 |
50 |
53 |
54 |
57 |
58 |
61 |
62 |
65 |
66 |
69 |
70 |
71 |
79 |
80 |
83 |
84 |
89 |
90 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/src/com/busleep/app/SleepPlanService.java:
--------------------------------------------------------------------------------
1 | package com.busleep.app;
2 |
3 | import java.util.List;
4 |
5 | import com.baidu.location.BDLocation;
6 | import com.baidu.mapapi.model.LatLng;
7 | import com.baidu.mapapi.utils.DistanceUtil;
8 | import com.busleep.baidu.LocationHelper;
9 | import com.busleep.baidu.LocationHelper.OnLocationListener;
10 | import com.busleep.bean.MrAlarm;
11 | import com.busleep.config.Constant;
12 | import com.busleep.utils.LogUtils;
13 | import com.mr.busleep.R;
14 |
15 | import android.app.Service;
16 | import android.content.Intent;
17 | import android.media.MediaPlayer;
18 | import android.os.IBinder;
19 | import android.os.Vibrator;
20 |
21 | public class SleepPlanService extends Service implements OnLocationListener{
22 |
23 | private static final String TAG = "SleepPlanService";
24 |
25 | private LocationHelper mLocationHelper=null;
26 | private List mAlarms=null;
27 | private MediaPlayer mediaPlayer=null;
28 |
29 | @Override
30 | public IBinder onBind(Intent intent) {
31 | return null;
32 | }
33 |
34 | @Override
35 | public void onCreate() {
36 | super.onCreate();
37 |
38 | mLocationHelper=new LocationHelper(this);
39 | mLocationHelper.setOnLocationListener(this);
40 | mLocationHelper.start();
41 |
42 | mediaPlayer = MediaPlayer.create(this, R.raw.notify);
43 | mediaPlayer.setLooping(true);
44 | }
45 |
46 | @Override
47 | public void onDestroy() {
48 | super.onDestroy();
49 |
50 | LogUtils.v(TAG, "onDestroy");
51 | if (mediaPlayer != null) {
52 | mediaPlayer.stop();
53 | mediaPlayer.release();
54 | }
55 |
56 | mLocationHelper.stop();
57 | }
58 |
59 | @SuppressWarnings("unchecked")
60 | @Override
61 | public void onStart(Intent intent, int startId) {
62 | super.onStart(intent, startId);
63 |
64 | mAlarms=(List)(intent.getExtras().getSerializable("alarms"));
65 |
66 | JudgeAlarm();
67 | }
68 |
69 | @Override
70 | public void onReceiveLocation(BDLocation location) {
71 |
72 | CustomApplication.mLocation=location;
73 |
74 | Intent intent=new Intent();
75 | intent.setAction(Constant.BROADCAST_ACTION);
76 | intent.putExtra(Constant.BROADCAST_VALUE_TYPE, Constant.LOCATION_COMPLETED);
77 |
78 | sendBroadcast(intent);
79 |
80 | JudgeAlarm();
81 | }
82 |
83 | /**
84 | * 判断闹铃是否响起;
85 | */
86 | private void JudgeAlarm(){
87 |
88 | double longtitude=0.0;
89 | double latitude=0.0;
90 | boolean isCloseAlarm=true;
91 |
92 | int size=mAlarms.size();
93 | int [] ids=new int[size];
94 | int index=0;
95 |
96 | for(MrAlarm alarm:mAlarms){
97 |
98 | if(alarm.isOn())
99 | {
100 | longtitude=alarm.getLongtitude();
101 | latitude=alarm.getLatitude();
102 | LatLng currentLatLng=CustomApplication.getInstance().getCurrentLatLng();
103 | LatLng alarmLatLng=new LatLng(latitude, longtitude);
104 |
105 | double distance=DistanceUtil.getDistance(currentLatLng, alarmLatLng);
106 |
107 | if(distance<=Constant.alarmDistanceThreshold){
108 | isCloseAlarm=false;
109 | start();
110 | ids[index++]=Integer.parseInt(alarm.getId());
111 | }
112 | }
113 | }
114 |
115 | if(isCloseAlarm){
116 | stop();
117 | }
118 | else { //发送广播提醒;
119 |
120 | Intent intent=new Intent();
121 | intent.setAction(Constant.BROADCAST_ACTION);
122 | intent.putExtra(Constant.BROADCAST_VALUE_TYPE, Constant.ALARM_RING);
123 | intent.putExtra(Constant.IDS, ids);
124 |
125 | sendBroadcast(intent);
126 | }
127 |
128 | }
129 |
130 | /**
131 | * 启动MediaPlayer;
132 | */
133 | private void start(){
134 |
135 | if (!mediaPlayer.isPlaying()) {
136 | mediaPlayer.start();
137 |
138 | long pattern[]={0,1000,500};
139 | Vibrator vib = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
140 | vib.vibrate(pattern, 0);
141 | }
142 | }
143 |
144 | /**
145 | * 停止mediaPlayer;
146 | */
147 | private void stop(){
148 |
149 | if(mediaPlayer.isPlaying()){
150 | mediaPlayer.pause();
151 | mediaPlayer.seekTo(0);
152 | Vibrator vib = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
153 | vib.cancel();
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
48 |
49 |
55 |
56 |
57 |
60 |
61 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
74 |
75 |
76 |
79 |
80 |
81 |
84 |
85 |
88 |
89 |
94 |
95 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
48 |
49 |
55 |
56 |
57 |
60 |
61 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
74 |
75 |
76 |
79 |
80 |
81 |
84 |
85 |
88 |
89 |
94 |
95 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/BuslineBaiduMapActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 | import android.widget.TextView;
7 | import android.widget.Toast;
8 |
9 | import com.baidu.mapapi.map.BaiduMap;
10 | import com.baidu.mapapi.map.InfoWindow;
11 | import com.baidu.mapapi.map.MapPoi;
12 | import com.baidu.mapapi.map.MapStatusUpdateFactory;
13 | import com.baidu.mapapi.map.SupportMapFragment;
14 | import com.baidu.mapapi.model.LatLng;
15 | import com.baidu.mapapi.overlayutil.BusLineOverlay;
16 | import com.baidu.mapapi.search.busline.BusLineResult;
17 | import com.mr.busleep.R;
18 | import com.busleep.app.CustomApplication;
19 | import com.busleep.bean.MrBusLine;
20 | import com.busleep.ui.base.BaseFragmentActivity;
21 | import com.busleep.utils.LogUtils;
22 |
23 | /**
24 | * 用百度地图来显示公交路线;
25 | * @author Render;
26 | *
27 | */
28 | public class BuslineBaiduMapActivity extends BaseFragmentActivity implements BaiduMap.OnMapClickListener{
29 |
30 | private static final String TAG = "BusLineBaiduMapActivity";
31 |
32 | /**
33 | * 当前显示的为该公交车的路线信息;
34 | */
35 | private BusLineResult mBusLineResult=null;
36 |
37 | private BaiduMap mBaiduMap = null;
38 |
39 | private int nodeIndex=-1;
40 |
41 | private Button mBtnPre=null;
42 |
43 | private Button mBtnNext=null;
44 |
45 | @Override
46 | protected void onCreate(Bundle arg0) {
47 |
48 | super.onCreate(arg0);
49 |
50 | try {
51 | setContentView(R.layout.activity_busline_baidu_map);
52 | } catch (Exception e) {
53 | LogUtils.i(TAG, e.getMessage());
54 | }
55 |
56 | init();
57 | }
58 |
59 | /**
60 | * 初始化界面;
61 | */
62 | private void init(){
63 |
64 | MrBusLine busLine=(MrBusLine) CustomApplication.mObject;
65 |
66 | if(busLine==null){
67 | return;
68 | }
69 |
70 | mBusLineResult=busLine.getBusLineResult();
71 | initTopBarForLeft(busLine.getBusName());
72 |
73 | mBaiduMap = ((SupportMapFragment) getSupportFragmentManager()
74 | .findFragmentById(R.id.fragment_baidu_map)).getBaiduMap();
75 | mBaiduMap.setOnMapClickListener(this);
76 |
77 | mBtnPre = (Button) findViewById(R.id.pre);
78 | mBtnNext = (Button) findViewById(R.id.next);
79 | mBtnPre.setVisibility(View.INVISIBLE);
80 | mBtnNext.setVisibility(View.INVISIBLE);
81 |
82 | showBuslineOnBaiduMap();
83 | }
84 |
85 | /**
86 | * 在百度地图上显示公交信息;
87 | */
88 | private void showBuslineOnBaiduMap(){
89 |
90 | mBaiduMap.clear();
91 | nodeIndex = -1;
92 | BusLineOverlay overlay = new BusLineOverlay(mBaiduMap);
93 | mBaiduMap.setOnMarkerClickListener(overlay);
94 | overlay.setData(mBusLineResult);
95 | overlay.addToMap();
96 | overlay.zoomToSpan();
97 | mBtnPre.setVisibility(View.VISIBLE);
98 | mBtnNext.setVisibility(View.VISIBLE);
99 | Toast.makeText(BuslineBaiduMapActivity.this,
100 | mBusLineResult.getBusLineName(),Toast.LENGTH_SHORT).show();
101 |
102 | }
103 |
104 | /**
105 | * 节点浏览示例
106 | * @param v
107 | */
108 | public void nodeClick(View v) {
109 |
110 | if (nodeIndex < -1 || mBusLineResult == null
111 | || nodeIndex >= mBusLineResult.getStations().size())
112 | return;
113 |
114 | TextView popupText = new TextView(this);
115 | popupText.setBackgroundResource(R.drawable.popup);
116 | popupText.setTextColor(0xff000000);
117 | // 上一个节点
118 | if (mBtnPre.equals(v) && nodeIndex > 0) {
119 | // 索引减
120 | nodeIndex--;
121 | }
122 | // 下一个节点
123 | if (mBtnNext.equals(v) && nodeIndex < (mBusLineResult.getStations().size() - 1)) {
124 | // 索引加
125 | nodeIndex++;
126 | }
127 | // 移动到指定索引的坐标
128 | mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(mBusLineResult
129 | .getStations().get(nodeIndex).getLocation()));
130 | // 弹出泡泡
131 | popupText.setText(mBusLineResult.getStations().get(nodeIndex).getTitle());
132 | mBaiduMap.showInfoWindow(new InfoWindow(popupText, mBusLineResult.getStations()
133 | .get(nodeIndex).getLocation(), null));
134 | }
135 |
136 |
137 | @Override
138 | public void onMapClick(LatLng arg0) {
139 | // TODO Auto-generated method stub
140 | mBaiduMap.hideInfoWindow();
141 | }
142 |
143 | @Override
144 | public boolean onMapPoiClick(MapPoi arg0) {
145 | // TODO Auto-generated method stub
146 | return false;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/res/layout/activity_busline_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
17 |
18 |
28 |
29 |
41 |
42 |
43 |
44 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
63 |
67 |
68 |
81 |
82 |
83 |
87 |
88 |
101 |
102 |
103 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/RouteFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.text.Editable;
6 | import android.text.TextWatcher;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ListView;
11 | import android.widget.SimpleAdapter;
12 |
13 | import com.mr.busleep.R;
14 | import com.baidu.mapapi.search.busline.BusLineResult;
15 | import com.baidu.mapapi.search.busline.BusLineSearch;
16 | import com.baidu.mapapi.search.busline.OnGetBusLineSearchResultListener;
17 | import com.baidu.mapapi.search.core.SearchResult;
18 | import com.baidu.mapapi.search.sug.OnGetSuggestionResultListener;
19 | import com.baidu.mapapi.search.sug.SuggestionResult;
20 | import com.baidu.mapapi.search.sug.SuggestionResult.SuggestionInfo;
21 | import com.baidu.mapapi.search.sug.SuggestionSearch;
22 | import com.baidu.mapapi.search.sug.SuggestionSearchOption;
23 | import com.busleep.config.Constant;
24 | import com.busleep.ui.base.BaseFragment;
25 | import com.busleep.utils.LogUtils;
26 | import com.busleep.widget.ClearEditText;
27 |
28 | /**
29 | * 公交查询中线路的片段;
30 | * @author Administrator
31 | *
32 | */
33 | public class RouteFragment extends BaseFragment implements OnGetSuggestionResultListener,
34 |
35 | OnGetBusLineSearchResultListener{
36 |
37 | Thread thread;
38 |
39 | private static final String TAG = "RouteFragment";
40 |
41 | private View rootView;
42 | private ClearEditText mClearEditText;
43 | private SuggestionSearch mSuggestSearch=null;
44 | private BusLineSearch mBusLineSearch=null;
45 | private ListView mListView;
46 | private SimpleAdapter mAdapter;
47 |
48 | @Override
49 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
50 | Bundle savedInstanceState) {
51 |
52 | if(rootView==null){
53 | rootView=inflater.inflate(R.layout.fragment_route,container,false);
54 | }
55 |
56 | return rootView;
57 | }
58 |
59 | @Override
60 | public void onAttach(Activity activity) {
61 |
62 | super.onAttach(activity);
63 | }
64 |
65 | @Override
66 | public void onViewCreated(View view, Bundle savedInstanceState) {
67 | super.onViewCreated(view, savedInstanceState);
68 |
69 | mListView=(ListView) rootView.findViewById(R.id.list_bus_line);
70 |
71 | initSearch();
72 | initEditText();
73 | }
74 |
75 | private void initSearch(){
76 |
77 | mBusLineSearch=BusLineSearch.newInstance();
78 | mBusLineSearch.setOnGetBusLineSearchResultListener(this);
79 |
80 | mSuggestSearch=SuggestionSearch.newInstance();
81 | mSuggestSearch.setOnGetSuggestionResultListener(this);
82 | }
83 |
84 | private void initEditText(){
85 |
86 | mClearEditText = (ClearEditText)rootView.findViewById(R.id.et_bus_line_search);
87 |
88 | mClearEditText.addTextChangedListener(new TextWatcher() {
89 |
90 | @Override
91 | public void onTextChanged(CharSequence s, int start, int before,
92 | int count) {
93 |
94 | searchSuggestBus(s.toString());
95 | }
96 |
97 | @Override
98 | public void beforeTextChanged(CharSequence s, int start, int count,
99 | int after) {
100 |
101 | }
102 |
103 | @Override
104 | public void afterTextChanged(Editable s) {
105 | }
106 | });
107 | }
108 |
109 | //利用百度地图进行建议搜索;
110 | private void searchSuggestBus(String strName){
111 |
112 | mSuggestSearch.requestSuggestion(new SuggestionSearchOption().city(Constant.city)
113 | .keyword(strName+"路公交"));
114 | }
115 |
116 | @Override
117 | public void onGetSuggestionResult(SuggestionResult res) {
118 |
119 | if (res == null||res.getAllSuggestions()==null
120 | || res.error != SearchResult.ERRORNO.NO_ERROR) {
121 |
122 | LogUtils.i(TAG, "建议搜索为空");
123 | return;
124 | }
125 |
126 | for(SuggestionInfo sInfo:res.getAllSuggestions()){
127 |
128 | String strCity=sInfo.city;
129 | String strDistrict=sInfo.district;
130 | String strKey=sInfo.key;
131 |
132 | LogUtils.i(TAG, strCity+" "+strDistrict+" "+strKey);
133 | }
134 | }
135 |
136 | @Override
137 | public void onDestroy() {
138 | super.onDestroy();
139 | mSuggestSearch.destroy();
140 | }
141 |
142 | @Override
143 | public void onGetBusLineResult(BusLineResult result) {
144 |
145 | if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
146 |
147 | LogUtils.i(TAG, "没找到该公交路线");
148 | return;
149 | }
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/src/com/busleep/widget/XListViewHeader.java:
--------------------------------------------------------------------------------
1 | package com.busleep.widget;
2 |
3 | import com.mr.busleep.R;
4 |
5 | import android.content.Context;
6 | import android.text.format.Time;
7 | import android.util.AttributeSet;
8 | import android.view.Gravity;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.animation.Animation;
12 | import android.view.animation.RotateAnimation;
13 | import android.widget.ImageView;
14 | import android.widget.LinearLayout;
15 | import android.widget.ProgressBar;
16 | import android.widget.TextView;
17 |
18 | /**
19 | * 下拉刷新的ListView的头部;
20 | * @author Render
21 | *
22 | */
23 | public class XListViewHeader extends LinearLayout{
24 | private LinearLayout mContainer;
25 | private ImageView mArrowImageView;
26 | private ProgressBar mProgressBar;
27 | private TextView mHintTextView;
28 | private TextView mHeaderTimeView;
29 | private TextView mHeaderTimeLabel;
30 | private int mState = STATE_NORMAL;
31 |
32 | private Animation mRotateUpAnim;
33 | private Animation mRotateDownAnim;
34 |
35 | private final int ROTATE_ANIM_DURATION = 180;
36 |
37 | public final static int STATE_NORMAL = 0;
38 | public final static int STATE_READY = 1;
39 | public final static int STATE_REFRESHING = 2;
40 |
41 | public XListViewHeader(Context context) {
42 | super(context);
43 | initView(context);
44 | }
45 |
46 | /**
47 | * @param context
48 | * @param attrs
49 | */
50 | public XListViewHeader(Context context, AttributeSet attrs) {
51 | super(context, attrs);
52 | initView(context);
53 | }
54 |
55 | private void initView(Context context) {
56 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
57 | android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0);
58 | mContainer = (LinearLayout) LayoutInflater.from(context).inflate(
59 | R.layout.xlistview_header, null);
60 | addView(mContainer, lp);
61 | setGravity(Gravity.BOTTOM);
62 |
63 | mArrowImageView = (ImageView)findViewById(R.id.xlistview_header_arrow);
64 | mHintTextView = (TextView)findViewById(R.id.xlistview_header_hint_textview);
65 | mProgressBar = (ProgressBar)findViewById(R.id.xlistview_header_progressbar);
66 | mHeaderTimeView = (TextView)findViewById(R.id.xlistview_header_time);
67 | mHeaderTimeLabel = (TextView)findViewById(R.id.xlistview_header_time_label);
68 |
69 | mRotateUpAnim = new RotateAnimation(0.0f, -180.0f,
70 | Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
71 | 0.5f);
72 |
73 | mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
74 | mRotateUpAnim.setFillAfter(true);
75 | mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f,
76 | Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
77 | 0.5f);
78 |
79 | mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
80 | mRotateDownAnim.setFillAfter(true);
81 | }
82 |
83 | public void setState(int state) {
84 | if (state == mState) return ;
85 |
86 | if (state == STATE_REFRESHING) {
87 | mArrowImageView.clearAnimation();
88 | mArrowImageView.setVisibility(View.INVISIBLE);
89 | mProgressBar.setVisibility(View.VISIBLE);
90 | } else {
91 | mArrowImageView.setVisibility(View.VISIBLE);
92 | mProgressBar.setVisibility(View.INVISIBLE);
93 | }
94 |
95 | switch(state){
96 | case STATE_NORMAL:
97 | if (mState == STATE_READY) {
98 | mArrowImageView.startAnimation(mRotateDownAnim);
99 | }
100 | if (mState == STATE_REFRESHING) {
101 | mArrowImageView.clearAnimation();
102 | }
103 | mHintTextView.setText(R.string.xlistview_header_hint_normal);
104 | break;
105 | case STATE_READY:
106 | if (mState != STATE_READY) {
107 | mArrowImageView.clearAnimation();
108 | mArrowImageView.startAnimation(mRotateUpAnim);
109 | mHintTextView.setText(R.string.xlistview_header_hint_ready);
110 | }
111 | break;
112 | case STATE_REFRESHING:
113 | mHintTextView.setText(R.string.xlistview_header_hint_loading);
114 | Time time = new Time();
115 | time.setToNow();
116 | setRefreshTime(time.format("%Y-%m-%d %T"));
117 | break;
118 | default:
119 | }
120 | mState = state;
121 | }
122 |
123 | public void setVisiableHeight(int height) {
124 | if (height < 0)
125 | height = 0;
126 | LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mContainer.getLayoutParams();
127 | lp.height = height;
128 | mContainer.setLayoutParams(lp);
129 | }
130 |
131 | public int getVisiableHeight() {
132 | return mContainer.getHeight();
133 | }
134 |
135 | public void setRefreshTime(String time) {
136 | mHeaderTimeLabel.setVisibility(View.VISIBLE);
137 | mHeaderTimeView.setText(time);
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/base/BaseSlidingFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.base;
2 |
3 | import com.busleep.slidingmenu.SlidingActivityBase;
4 | import com.busleep.slidingmenu.SlidingActivityHelper;
5 | import com.busleep.slidingmenu.SlidingMenu;
6 |
7 | import android.os.Bundle;
8 | import android.view.KeyEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup.LayoutParams;
11 |
12 | public class BaseSlidingFragmentActivity extends BaseFragmentActivity implements SlidingActivityBase {
13 |
14 | private SlidingActivityHelper mHelper;
15 |
16 | /* (non-Javadoc)
17 | * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
18 | */
19 | @Override
20 | public void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | mHelper = new SlidingActivityHelper(this);
23 | mHelper.onCreate(savedInstanceState);
24 | }
25 |
26 | /* (non-Javadoc)
27 | * @see android.app.Activity#onPostCreate(android.os.Bundle)
28 | */
29 | @Override
30 | public void onPostCreate(Bundle savedInstanceState) {
31 | super.onPostCreate(savedInstanceState);
32 | mHelper.onPostCreate(savedInstanceState);
33 | }
34 |
35 | /* (non-Javadoc)
36 | * @see android.app.Activity#findViewById(int)
37 | */
38 | @Override
39 | public View findViewById(int id) {
40 | View v = super.findViewById(id);
41 | if (v != null)
42 | return v;
43 | return mHelper.findViewById(id);
44 | }
45 |
46 | /* (non-Javadoc)
47 | * @see android.support.v4.app.FragmentActivity#onSaveInstanceState(android.os.Bundle)
48 | */
49 | @Override
50 | protected void onSaveInstanceState(Bundle outState) {
51 | super.onSaveInstanceState(outState);
52 | mHelper.onSaveInstanceState(outState);
53 | }
54 |
55 | /* (non-Javadoc)
56 | * @see android.app.Activity#setContentView(int)
57 | */
58 | @Override
59 | public void setContentView(int id) {
60 | setContentView(getLayoutInflater().inflate(id, null));
61 | }
62 |
63 | /* (non-Javadoc)
64 | * @see android.app.Activity#setContentView(android.view.View)
65 | */
66 | @Override
67 | public void setContentView(View v) {
68 | setContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
69 | }
70 |
71 | /* (non-Javadoc)
72 | * @see android.app.Activity#setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
73 | */
74 | @Override
75 | public void setContentView(View v, LayoutParams params) {
76 | super.setContentView(v, params);
77 | mHelper.registerAboveContentView(v, params);
78 | }
79 |
80 | /* (non-Javadoc)
81 | * @see com.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(int)
82 | */
83 | public void setBehindContentView(int id) {
84 | setBehindContentView(getLayoutInflater().inflate(id, null));
85 | }
86 |
87 | /* (non-Javadoc)
88 | * @see com.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(android.view.View)
89 | */
90 | public void setBehindContentView(View v) {
91 | setBehindContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
92 | }
93 |
94 | /* (non-Javadoc)
95 | * @see com.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(android.view.View, android.view.ViewGroup.LayoutParams)
96 | */
97 | public void setBehindContentView(View v, LayoutParams params) {
98 | mHelper.setBehindContentView(v, params);
99 | }
100 |
101 | /* (non-Javadoc)
102 | * @see com.slidingmenu.lib.app.SlidingActivityBase#getSlidingMenu()
103 | */
104 | public SlidingMenu getSlidingMenu() {
105 | return mHelper.getSlidingMenu();
106 | }
107 |
108 | /* (non-Javadoc)
109 | * @see com.slidingmenu.lib.app.SlidingActivityBase#toggle()
110 | */
111 | public void toggle() {
112 | mHelper.toggle();
113 | }
114 |
115 | /* (non-Javadoc)
116 | * @see com.slidingmenu.lib.app.SlidingActivityBase#showAbove()
117 | */
118 | public void showContent() {
119 | mHelper.showContent();
120 | }
121 |
122 | /* (non-Javadoc)
123 | * @see com.slidingmenu.lib.app.SlidingActivityBase#showBehind()
124 | */
125 | public void showMenu() {
126 | mHelper.showMenu();
127 | }
128 |
129 | /* (non-Javadoc)
130 | * @see com.slidingmenu.lib.app.SlidingActivityBase#showSecondaryMenu()
131 | */
132 | public void showSecondaryMenu() {
133 | mHelper.showSecondaryMenu();
134 | }
135 |
136 | /* (non-Javadoc)
137 | * @see com.slidingmenu.lib.app.SlidingActivityBase#setSlidingActionBarEnabled(boolean)
138 | */
139 | public void setSlidingActionBarEnabled(boolean b) {
140 | mHelper.setSlidingActionBarEnabled(b);
141 | }
142 |
143 | /* (non-Javadoc)
144 | * @see android.app.Activity#onKeyUp(int, android.view.KeyEvent)
145 | */
146 | @Override
147 | public boolean onKeyUp(int keyCode, KeyEvent event) {
148 | boolean b = mHelper.onKeyUp(keyCode, event);
149 | if (b) return b;
150 | return super.onKeyUp(keyCode, event);
151 | }
152 |
153 | }
--------------------------------------------------------------------------------
/src/com/busleep/db/DBProvider.java:
--------------------------------------------------------------------------------
1 | package com.busleep.db;
2 |
3 | import java.util.List;
4 |
5 | import android.content.ContentProvider;
6 | import android.content.ContentResolver;
7 | import android.content.ContentValues;
8 | import android.content.UriMatcher;
9 | import android.database.Cursor;
10 | import android.database.sqlite.SQLiteDatabase;
11 | import android.net.Uri;
12 |
13 | /**
14 | * 查询数据库;
15 | * @author Render
16 | *
17 | */
18 | public class DBProvider extends ContentProvider{
19 |
20 | private static final int ALARM=1;
21 |
22 | private DBHelper mDBHelper=null;
23 |
24 | private static final UriMatcher URIMATCHER;
25 | static{
26 | URIMATCHER=new UriMatcher(UriMatcher.NO_MATCH);
27 | URIMATCHER.addURI(DatabaseColumn.AUTHORITY, AlarmColumn.TABLE_NAME, 1);
28 |
29 | }
30 |
31 | /**
32 | * Init DB
33 | */
34 | @Override
35 | public boolean onCreate() {
36 |
37 | mDBHelper=DBHelper.getInstance(getContext());
38 | SQLiteDatabase db=mDBHelper.getReadableDatabase();
39 | return db==null ? false : true;
40 | }
41 |
42 | @Override
43 | public Cursor query(Uri uri, String[] projection, String selection,
44 | String[] selectionArgs, String sortOrder) {
45 |
46 | Cursor cursor=null;
47 | switch(URIMATCHER.match(uri)){
48 | case ALARM:
49 | cursor = query(AlarmColumn.TABLE_NAME, projection,selection, selectionArgs, "", "", sortOrder);
50 | break;
51 | }
52 |
53 | return cursor;
54 | }
55 |
56 | @Override
57 | public String getType(Uri uri) {
58 | int witch=URIMATCHER.match(uri);
59 |
60 | return String.valueOf(witch);
61 |
62 | }
63 |
64 | @Override
65 | public Uri insert(Uri uri, ContentValues values) {
66 |
67 | long rowId=0;
68 | int witch=URIMATCHER.match(uri);
69 | switch(witch){
70 | case ALARM:
71 | rowId=insert(AlarmColumn.TABLE_NAME,null,values);
72 | break;
73 | }
74 |
75 | return null;
76 | }
77 |
78 | @Override
79 | public int delete(Uri uri, String selection, String[] selectionArgs) {
80 |
81 | int count=0;
82 | int witch=URIMATCHER.match(uri);
83 | switch(witch){
84 | case ALARM:
85 | count=delete(AlarmColumn.TABLE_NAME, selection, selectionArgs);
86 | notifyChange(uri);
87 | break;
88 | }
89 |
90 | return count;
91 | }
92 |
93 | @Override
94 | public int update(Uri uri, ContentValues values, String selection,
95 | String[] selectionArgs) {
96 |
97 | int count = 0;
98 | switch(URIMATCHER.match(uri)){
99 | case ALARM:
100 | count = update(AlarmColumn.TABLE_NAME,values,selection,selectionArgs);
101 | notifyChange(uri);
102 | break;
103 | }
104 |
105 | return count;
106 | }
107 |
108 | /*********Define Insert Delete Update Query ***********/
109 |
110 | private Cursor query(String table,String[] columns,String selection,
111 | String[] selectionArgs,String groupBy,String having,
112 | String orderBy){
113 | synchronized (mDBHelper) {
114 | SQLiteDatabase db=mDBHelper.getReadableDatabase();
115 | if(db==null||!db.isOpen()){
116 | return null;
117 | }
118 | try {
119 | return db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
120 | } catch (Exception e) {
121 | return null;
122 | }
123 | }
124 | }
125 |
126 | private int delete(String table,String where,String[] whereArgs){
127 | synchronized (mDBHelper) {
128 | SQLiteDatabase db=mDBHelper.getReadableDatabase();
129 | if(db==null||!db.isOpen()){
130 | return 0;
131 | }
132 | try {
133 | return db.delete(table, where, whereArgs);
134 | } catch (Exception e) {
135 | return 0;
136 | }
137 | }
138 |
139 | }
140 |
141 | private int update(String table, ContentValues values, String whereClause,
142 | String[] whereArgs) {
143 | synchronized (mDBHelper) {
144 | SQLiteDatabase db = mDBHelper.getReadableDatabase();
145 | if (db == null || !db.isOpen()) {
146 | return 0;
147 | }
148 | try {
149 | return db.update(table, values, whereClause, whereArgs);
150 | } catch (Exception e) {
151 | return 0;
152 | }
153 | }
154 | }
155 |
156 | private long insert(String table, String nullColumnHack,
157 | ContentValues values) {
158 | synchronized (mDBHelper) {
159 | SQLiteDatabase db = mDBHelper.getReadableDatabase();
160 | if (db == null || !db.isOpen()) {
161 | return 0;
162 | }
163 | return db.insert(table, nullColumnHack, values);
164 | }
165 | }
166 |
167 | private void notifyChange(List uri) {
168 | ContentResolver cr = getContext().getContentResolver();
169 | for (int i = 0; i < uri.size(); i++) {
170 | cr.notifyChange(uri.get(i), null);
171 | }
172 |
173 | }
174 |
175 | private void notifyChange(Uri uri) {
176 | ContentResolver cr = getContext().getContentResolver();
177 | cr.notifyChange(uri, null);
178 |
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/res/layout/v2_dialog_base.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
31 |
32 |
33 |
38 |
39 |
49 |
50 |
56 |
57 |
58 |
63 |
64 |
68 |
69 |
70 |
74 |
75 |
80 |
81 |
88 |
89 |
101 |
102 |
106 |
107 |
120 |
121 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/src/com/busleep/adapter/AlarmAdapter.java:
--------------------------------------------------------------------------------
1 | package com.busleep.adapter;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.List;
5 |
6 | import com.baidu.mapapi.model.LatLng;
7 | import com.baidu.mapapi.utils.DistanceUtil;
8 | import com.busleep.adapter.base.AdapterBase;
9 | import com.busleep.app.CustomApplication;
10 | import com.busleep.bean.MrAlarm;
11 | import com.mr.busleep.R;
12 |
13 | import android.content.Context;
14 | import android.graphics.Color;
15 | import android.view.LayoutInflater;
16 | import android.view.View;
17 | import android.view.View.OnClickListener;
18 | import android.view.ViewGroup;
19 | import android.widget.ImageView;
20 | import android.widget.TextView;
21 |
22 | public class AlarmAdapter extends AdapterBase{
23 |
24 | private Context ct;
25 | private ViewHolder viewHolder=null;
26 | private OnAlarmStateChangeListener mLister;
27 |
28 | public AlarmAdapter(List datas,Context ct){
29 | this.ct=ct;
30 | appendToList(datas);
31 | }
32 |
33 | public void updateListView(List datas){
34 |
35 | clear();
36 | appendToList(datas);
37 | notifyDataSetChanged();
38 | }
39 |
40 | public void setOnAlarmStateChangeLister(OnAlarmStateChangeListener lister) {
41 | this.mLister = lister;
42 | }
43 |
44 | private class ImageViewListener implements OnClickListener{
45 |
46 | private int position;
47 |
48 | public ImageViewListener(int position){
49 | this.position=position;
50 | }
51 |
52 | @Override
53 | public void onClick(View v) {
54 |
55 | if(viewHolder==null){
56 | return;
57 | }
58 | int vid=v.getId();
59 | if(vid==viewHolder.ivOpenAlarm.getId()){
60 |
61 | MrAlarm alarm=getList().get(position);
62 | mLister.onAlarmStateChange(false, alarm);
63 |
64 | }else if(vid==viewHolder.ivCloseAlarm.getId()) {
65 |
66 | MrAlarm alarm=getList().get(position);
67 | mLister.onAlarmStateChange(true, alarm);
68 |
69 | }
70 | }
71 | }
72 |
73 | static class ViewHolder {
74 |
75 | TextView tvStationName;
76 | TextView tvCurrentDistance;
77 | TextView tvAlarmState;
78 | ImageView ivOpenAlarm;
79 | ImageView ivCloseAlarm;
80 | }
81 |
82 | private void initViewData(int position,ViewHolder viewHolder, View convertView){
83 |
84 | MrAlarm alarm=getList().get(position);
85 |
86 | if(alarm.isRing()){
87 | convertView.setBackgroundColor(Color.parseColor("#9F291E"));
88 | }
89 | else {
90 | convertView.setBackgroundColor(Color.parseColor("#F0FFFF"));
91 | }
92 |
93 | viewHolder.tvStationName.setText("目的地:"+alarm.getBusStationName());
94 |
95 | //计算当前位置距离目标位置的距离;
96 | double longtitude=alarm.getLongtitude();
97 | double latitude=alarm.getLatitude();
98 | LatLng destinationLng=new LatLng(latitude, longtitude);
99 | LatLng currentLng=CustomApplication.getInstance().getCurrentLatLng();
100 |
101 | double distance=DistanceUtil.getDistance(destinationLng, currentLng);
102 |
103 | BigDecimal bg = new BigDecimal(distance/1000.0);
104 | double distance1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
105 | viewHolder.tvCurrentDistance.setText("当前距离:"+distance1+"km");
106 |
107 | boolean isOn=alarm.isOn();
108 | if(isOn){
109 | viewHolder.ivOpenAlarm.setVisibility(View.VISIBLE);
110 | viewHolder.ivCloseAlarm.setVisibility(View.GONE);
111 | viewHolder.tvAlarmState.setVisibility(View.GONE);
112 | }else {
113 | viewHolder.ivOpenAlarm.setVisibility(View.GONE);
114 | viewHolder.ivCloseAlarm.setVisibility(View.VISIBLE);
115 | viewHolder.tvAlarmState.setVisibility(View.VISIBLE);
116 | viewHolder.tvAlarmState.setText(" | 未开启");
117 | }
118 | }
119 |
120 | /**
121 | * 闹钟状态改变的监听器接口;
122 | * @author Render
123 | */
124 | public interface OnAlarmStateChangeListener{
125 |
126 | public void onAlarmStateChange(boolean b,MrAlarm alarm);
127 | }
128 |
129 | @Override
130 | protected View getExView(int position, View convertView, ViewGroup parent) {
131 |
132 | if (convertView == null) {
133 |
134 | convertView = LayoutInflater.from(ct).inflate(R.layout.item_sleep_alarm, null);
135 | viewHolder = new ViewHolder();
136 |
137 | viewHolder.tvStationName = (TextView) convertView.findViewById(R.id.tv_bus_station);
138 | viewHolder.tvCurrentDistance=(TextView)convertView.findViewById(R.id.tv_current_distance);
139 | viewHolder.tvAlarmState=(TextView)convertView.findViewById(R.id.tv_alarm_state);
140 | viewHolder.ivOpenAlarm=(ImageView)convertView.findViewById(R.id.iv_open_alarm);
141 | viewHolder.ivCloseAlarm=(ImageView)convertView.findViewById(R.id.iv_close_alarm);
142 | convertView.setTag(viewHolder);
143 |
144 | } else{
145 | viewHolder = (ViewHolder) convertView.getTag();
146 | }
147 |
148 | viewHolder.ivOpenAlarm.setOnClickListener(new ImageViewListener(position));
149 | viewHolder.ivCloseAlarm.setOnClickListener(new ImageViewListener(position));
150 |
151 | initViewData(position, viewHolder,convertView);
152 |
153 | return convertView;
154 | }
155 |
156 | @Override
157 | protected void onReachBottom() {
158 |
159 |
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/BusQueryFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import android.app.Activity;
7 | import android.graphics.BitmapFactory;
8 | import android.graphics.Matrix;
9 | import android.os.Bundle;
10 | import android.support.v4.view.ViewPager;
11 | import android.support.v4.view.ViewPager.OnPageChangeListener;
12 | import android.util.DisplayMetrics;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.view.View.OnClickListener;
17 | import android.view.animation.Animation;
18 | import android.view.animation.TranslateAnimation;
19 | import android.widget.ImageView;
20 | import android.widget.TextView;
21 |
22 | import com.mr.busleep.R;
23 | import com.busleep.adapter.BasePageAdapter;
24 | import com.busleep.config.Constant;
25 | import com.busleep.ui.base.BaseFragment;
26 |
27 | /**
28 | * 公交查询片段;
29 | * @author Render;
30 | */
31 | public class BusQueryFragment extends BaseFragment{
32 |
33 | private View rootView;
34 | private TextView mTvRoute;
35 | private TextView mTvStation;
36 | private TextView mTvTransfer;
37 |
38 | private ViewPager mPager;
39 | private ImageView mIvCursor;
40 | private BasePageAdapter mAdapter;
41 |
42 | private int mOffset=0; //动画偏移量;
43 | private int mCurrentItem=0; //当前的编号;
44 | private int mBmpWidth; //图片宽度;
45 |
46 |
47 | @Override
48 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
49 | Bundle savedInstanceState) {
50 |
51 | if(rootView==null){
52 | rootView=inflater.inflate(R.layout.fragment_bus_query, null);
53 | }
54 |
55 | initTextView();
56 | initViewPager();
57 | initImageView();
58 |
59 | return rootView;
60 | }
61 |
62 | @Override
63 | public void onAttach(Activity activity) {
64 | super.onAttach(activity);
65 | }
66 |
67 | /**
68 | * 初始化点击事件;
69 | */
70 | private void initTextView(){
71 |
72 | mTvRoute=(TextView)rootView.findViewById(R.id.tv_bus_route);
73 | mTvStation=(TextView)rootView.findViewById(R.id.tv_bus_station);
74 | mTvTransfer=(TextView)rootView.findViewById(R.id.tv_bus_transfer);
75 | mIvCursor=(ImageView)rootView.findViewById(R.id.iv_cursor);
76 |
77 | mTvRoute.setOnClickListener(new MyOnClickListener(0));
78 | mTvStation.setOnClickListener(new MyOnClickListener(1));
79 | mTvTransfer.setOnClickListener(new MyOnClickListener(2));
80 |
81 | mTvRoute.setSelected(true);
82 | mTvStation.setSelected(false);
83 | mTvTransfer.setSelected(false);
84 |
85 | }
86 |
87 | private void initViewPager(){
88 | mPager=(ViewPager) rootView.findViewById(R.id.vPager);
89 |
90 | mAdapter=new BasePageAdapter(getActivity());
91 | List strNames=new ArrayList();
92 | strNames.add(Constant.ROUTE);
93 | strNames.add(Constant.STATION);
94 | strNames.add(Constant.TRANSFER);
95 | mAdapter.addFragment(strNames);
96 |
97 | mPager.setAdapter(mAdapter);
98 | mPager.setCurrentItem(0);
99 | mPager.setOnPageChangeListener(new MyOnPageChangeListener());
100 | }
101 |
102 |
103 | private void initImageView(){
104 | mIvCursor = (ImageView) rootView.findViewById(R.id.iv_cursor);
105 | mBmpWidth = BitmapFactory.decodeResource(getResources(), R.drawable.cursor).getWidth();// 获取图片宽度
106 | DisplayMetrics dm = new DisplayMetrics();
107 | getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
108 | int screenW = dm.widthPixels;// 获取分辨率宽度;
109 | mOffset = (screenW / 3 - mBmpWidth) / 2;// 计算偏移量;
110 | Matrix matrix = new Matrix();
111 | matrix.postTranslate(mOffset, 0);
112 | mIvCursor.setImageMatrix(matrix);// 设置动画初始位置
113 |
114 | }
115 |
116 |
117 | public class MyOnClickListener implements OnClickListener{
118 |
119 | private int index=0;
120 |
121 | public MyOnClickListener(int i){
122 | index=i;
123 | }
124 |
125 | @Override
126 | public void onClick(View v) {
127 | mPager.setCurrentItem(index);
128 |
129 | }
130 | }
131 |
132 | public class MyOnPageChangeListener implements OnPageChangeListener{
133 |
134 | @Override
135 | public void onPageScrollStateChanged(int arg0) {
136 |
137 |
138 | }
139 |
140 | @Override
141 | public void onPageScrolled(int arg0, float arg1, int arg2) {
142 |
143 |
144 | }
145 |
146 | @Override
147 | public void onPageSelected(int arg0) {
148 |
149 | int one=mOffset*2+mBmpWidth; // 页卡1 -> 页卡2 偏移量
150 | int two=one*2; // 页卡1 -> 页卡3 偏移量
151 |
152 | Animation animation = null;
153 |
154 | switch (arg0) {
155 | case 0:
156 | if (mCurrentItem == 1) {
157 | animation = new TranslateAnimation(one, 0, 0, 0);
158 | } else if (mCurrentItem == 2) {
159 | animation = new TranslateAnimation(two, 0, 0, 0);
160 | }
161 | mTvRoute.setSelected(true);
162 | mTvStation.setSelected(false);
163 | mTvTransfer.setSelected(false);
164 | break;
165 | case 1:
166 | if (mCurrentItem == 0) {
167 | animation = new TranslateAnimation(mOffset, one, 0, 0);
168 | } else if (mCurrentItem == 2) {
169 | animation = new TranslateAnimation(two, one, 0, 0);
170 | }
171 | mTvRoute.setSelected(false);
172 | mTvStation.setSelected(true);
173 | mTvTransfer.setSelected(false);
174 | break;
175 | case 2:
176 | if (mCurrentItem == 0) {
177 | animation = new TranslateAnimation(mOffset, two, 0, 0);
178 | } else if (mCurrentItem == 1) {
179 | animation = new TranslateAnimation(one, two, 0, 0);
180 | }
181 | mTvRoute.setSelected(false);
182 | mTvStation.setSelected(false);
183 | mTvTransfer.setSelected(true);
184 | break;
185 | }
186 | mCurrentItem = arg0;
187 | animation.setFillAfter(true);// True:图片停在动画结束位置
188 | animation.setDuration(300);
189 | mIvCursor.startAnimation(animation);
190 |
191 | }
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/src/com/busleep/ui/fragment/BusNearFragment.java:
--------------------------------------------------------------------------------
1 | package com.busleep.ui.fragment;
2 |
3 | import java.util.List;
4 |
5 | import android.app.Activity;
6 | import android.app.ProgressDialog;
7 | import android.os.Bundle;
8 | import android.os.Handler;
9 | import android.os.Message;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.AdapterView;
14 | import android.widget.AdapterView.OnItemClickListener;
15 |
16 | import com.baidu.location.BDLocation;
17 | import com.mr.busleep.R;
18 | import com.busleep.adapter.BusNearAdapter;
19 | import com.busleep.app.CustomApplication;
20 | import com.busleep.baidu.LocationHelper;
21 | import com.busleep.baidu.LocationHelper.OnLocationListener;
22 | import com.busleep.baidu.NearbySearchHelper;
23 | import com.busleep.baidu.NearbySearchHelper.OnNearbySearchListener;
24 | import com.busleep.bean.MrNearbyBus;
25 | import com.busleep.config.Constant;
26 | import com.busleep.ui.BuslineDetailActivity;
27 | import com.busleep.ui.base.BaseFragment;
28 | import com.busleep.utils.LogUtils;
29 | import com.busleep.widget.XListView;
30 | import com.busleep.widget.XListView.IXListViewListener;
31 |
32 | /**
33 | * 公交查询中的周边片段;
34 | * @author Render;
35 | */
36 | public class BusNearFragment extends BaseFragment implements OnNearbySearchListener,IXListViewListener
37 | ,OnItemClickListener,OnLocationListener{
38 |
39 | public final String TAG="BusNearFragment";
40 |
41 | private boolean isFirstUpdate=true;
42 |
43 | /**
44 | * 周边搜索帮助类;
45 | */
46 | public NearbySearchHelper nearbySearchHelper=null;
47 | private View rootView;
48 | private XListView mBusNearListView;
49 | private ProgressDialog progress=null ;
50 | private MyHandler mHandler; //处理消息的Handle对象;
51 |
52 | /**
53 | * 定位帮助类;
54 | */
55 | private LocationHelper locationHelper=null;
56 |
57 | /**
58 | * 适配器;
59 | */
60 | private BusNearAdapter busNearAdapter=null;
61 |
62 | @Override
63 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
64 | Bundle savedInstanceState) {
65 |
66 | if(rootView==null){
67 |
68 | rootView=inflater.inflate(R.layout.fragment_bus_near,container,false);
69 | }
70 | return rootView;
71 | }
72 |
73 | @Override
74 | public void onActivityCreated(Bundle savedInstanceState) {
75 | super.onActivityCreated(savedInstanceState);
76 |
77 | initXListView();
78 |
79 | initData();
80 | }
81 |
82 | /**
83 | * 初始化数据;
84 | */
85 | private void initData(){
86 |
87 | /**
88 | * 创建定位帮助类;
89 | */
90 | locationHelper=new LocationHelper(getActivity());
91 | locationHelper.setOnLocationListener(this);
92 |
93 | /**
94 | * 创建周边搜索帮助类;
95 | */
96 | nearbySearchHelper=new NearbySearchHelper();
97 | nearbySearchHelper.init();
98 | nearbySearchHelper.setNearBySearchListener(this);
99 |
100 | mHandler=new MyHandler();
101 | mHandler.sendEmptyMessage(0);
102 | }
103 |
104 | private void initXListView(){
105 |
106 | mBusNearListView=(XListView)rootView.findViewById(R.id.list_near_bus_info);
107 | mBusNearListView.setPullLoadEnable(false);
108 | mBusNearListView.setPullRefreshEnable(true);
109 | mBusNearListView.setXListViewListener(this);
110 | mBusNearListView.setOnItemClickListener(this);
111 | mBusNearListView.pullRefreshing();
112 | }
113 |
114 | @Override
115 | public void onAttach(Activity activity) {
116 | super.onAttach(activity);
117 | }
118 |
119 | @Override
120 | public void onDestroy() {
121 |
122 | /**
123 | * 销毁周边搜索帮助类;
124 | */
125 | nearbySearchHelper.Destory();
126 | super.onDestroy();
127 | }
128 |
129 | /**
130 | * 搜索周边公交,步骤:先定位,再搜索;
131 | */
132 | private void excuteSearch(){
133 |
134 | if(isFirstUpdate){
135 | progress = new ProgressDialog(getActivity());
136 | progress.setMessage("正在定位...");
137 | progress.setCanceledOnTouchOutside(true);
138 | progress.show();
139 | }
140 |
141 | if(locationHelper!=null){
142 | locationHelper.start();
143 | }
144 | }
145 |
146 | //接受定位的信息;
147 | @Override
148 | public void onReceiveLocation(BDLocation location) {
149 |
150 | CustomApplication.mLocation=location;
151 | Constant.city=location.getCity();
152 | Constant.address=location.getAddrStr();
153 |
154 | locationHelper.stop();
155 |
156 | if(isFirstUpdate){
157 | progress.setMessage("正在搜索周边信息...");
158 | progress.setCanceledOnTouchOutside(true);
159 | }
160 |
161 | //开始搜索周边信息;
162 | nearbySearchHelper.searchNearby();
163 | }
164 |
165 | @Override
166 | public void onRefresh() {
167 |
168 | if(null==mHandler){
169 | return;
170 | }
171 | mHandler.sendEmptyMessage(0);
172 | }
173 |
174 | @Override
175 | public void onLoadMore() {
176 |
177 | }
178 |
179 | /**
180 | * 点击Item节点,进行跳转;
181 | */
182 | @Override
183 | public void onItemClick(AdapterView> parent, View view, int position,
184 | long id) {
185 |
186 | MrNearbyBus nearbyBus = (MrNearbyBus) busNearAdapter.getItem(position-1);
187 |
188 | if(nearbyBus==null){
189 | return;
190 | }
191 |
192 | Bundle bundle=new Bundle();
193 | bundle.putString("buslineUid", nearbyBus.getUid());
194 | bundle.putString("busName", nearbyBus.getBusName());
195 | bundle.putString("reverseBuslineUid",nearbyBus.getReverseUid());
196 |
197 | redictToActivity(getActivity(), BuslineDetailActivity.class, bundle);
198 | }
199 |
200 | private void refreshPull(){
201 | if (mBusNearListView.getPullRefreshing()) {
202 | mBusNearListView.stopRefresh();
203 | }
204 | }
205 |
206 | @Override
207 | public void onRefreshBusNearby(List list) {
208 |
209 | if(isFirstUpdate){
210 | progress.dismiss();
211 | isFirstUpdate=false;
212 | }
213 |
214 | for(int i=0;i