├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── runConfigurations.xml
├── modules.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── domain
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── micky
│ │ │ └── commonproj
│ │ │ └── domain
│ │ │ ├── service
│ │ │ ├── response
│ │ │ │ ├── BaseResponse.java
│ │ │ │ ├── GetIpInfoResponse.java
│ │ │ │ └── WeatherResponse.java
│ │ │ ├── WeatherService.java
│ │ │ └── ServiceManager.java
│ │ │ ├── model
│ │ │ ├── WeatherExtra.java
│ │ │ ├── WeatherResult.java
│ │ │ ├── WeatherData.java
│ │ │ ├── IpInfo.java
│ │ │ └── Place.java
│ │ │ ├── db
│ │ │ ├── manager
│ │ │ │ ├── PlaceDaoManager.java
│ │ │ │ └── BaseDaoManager.java
│ │ │ ├── DaoManagerFactory.java
│ │ │ ├── DBCore.java
│ │ │ ├── dao
│ │ │ │ ├── DaoSession.java
│ │ │ │ ├── DaoMaster.java
│ │ │ │ ├── PlaceDao.java
│ │ │ │ └── IpInfoDao.java
│ │ │ ├── generator
│ │ │ │ └── GreenDaoGenerator.java
│ │ │ └── MigrationHelper.java
│ │ │ ├── DomainInit.java
│ │ │ └── repository
│ │ │ └── PlaceRepository.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── micky
│ │ │ └── domain
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── micky
│ │ └── domain
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── domain.iml
├── commonlib
├── .gitignore
├── libs
│ ├── log4j-1.2.16.jar
│ └── android-logging-log4j-1.0.3.jar
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── micky
│ │ │ └── commonlib
│ │ │ └── utils
│ │ │ ├── ViewUtils.java
│ │ │ ├── RxUtils.java
│ │ │ ├── Constants.java
│ │ │ ├── DateUtils.java
│ │ │ ├── CrashHandler.java
│ │ │ ├── RxBus.java
│ │ │ └── FileUtils.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── micky
│ │ │ └── commonlib
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── micky
│ │ └── commonlib
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── commonlib.iml
├── presentation
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── back.png
│ │ │ │ ├── menu.png
│ │ │ │ ├── test.png
│ │ │ │ ├── header.jpg
│ │ │ │ ├── refresh.png
│ │ │ │ ├── test1.png
│ │ │ │ ├── weather.png
│ │ │ │ ├── cols_head.png
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ ├── left_menu_place_item_bg.xml
│ │ │ │ ├── left_menu_weather_item_bg.xml
│ │ │ │ └── list_divider.xml
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ └── layout
│ │ │ │ ├── content_right.xml
│ │ │ │ ├── item_place.xml
│ │ │ │ ├── content_left.xml
│ │ │ │ ├── view_toolbar.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── item_weather_extra.xml
│ │ │ │ ├── item_weather_data.xml
│ │ │ │ └── content_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── micky
│ │ │ │ └── commonproj
│ │ │ │ ├── presenter
│ │ │ │ ├── BasePresenter.java
│ │ │ │ ├── MainPresenter.java
│ │ │ │ └── impl
│ │ │ │ │ ├── BasePresenterImpl.java
│ │ │ │ │ └── MainPresenterImpl.java
│ │ │ │ ├── ui
│ │ │ │ ├── view
│ │ │ │ │ ├── MainView.java
│ │ │ │ │ └── ItemDecoration.java
│ │ │ │ ├── adapter
│ │ │ │ │ ├── BaseListAdapter.java
│ │ │ │ │ ├── WeatherExtraAdapter.java
│ │ │ │ │ ├── WeatherDataAdapter.java
│ │ │ │ │ └── PlaceAdapter.java
│ │ │ │ └── activity
│ │ │ │ │ ├── BaseActivity.java
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── BaseApplication.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── micky
│ │ │ └── retrofitrxandroiddragger2
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── micky
│ │ └── retrofitrxandroiddragger2
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── presentation.iml
├── settings.gradle
├── screenshots
├── a.png
├── b.png
└── c.png
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── local.properties
├── gradle.properties
├── CommonProj.iml
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | CommonProj
--------------------------------------------------------------------------------
/domain/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/commonlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/presentation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':domain', ':presentation', ':commonlib'
--------------------------------------------------------------------------------
/screenshots/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/screenshots/a.png
--------------------------------------------------------------------------------
/screenshots/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/screenshots/b.png
--------------------------------------------------------------------------------
/screenshots/c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/screenshots/c.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /.idea/workspace.xml
3 | /.idea/libraries
4 | .DS_Store
5 | /build
6 | /captures
7 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/commonlib/libs/log4j-1.2.16.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/commonlib/libs/log4j-1.2.16.jar
--------------------------------------------------------------------------------
/domain/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | domain
3 |
4 |
--------------------------------------------------------------------------------
/commonlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | commonLib
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/commonlib/libs/android-logging-log4j-1.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/commonlib/libs/android-logging-log4j-1.0.3.jar
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/back.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/menu.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/test.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/header.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/header.jpg
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/refresh.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/test1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/test1.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/weather.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/weather.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/cols_head.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/cols_head.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mickyliu945/CommonProj/HEAD/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 15 16:49:02 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/presentation/src/main/res/drawable/left_menu_place_item_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/presentation/src/main/res/drawable/left_menu_weather_item_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 使用RxAndroid、Retrofit、MVP模式实现的简易天气APP
2 | ====
3 | 
4 |
5 |
6 | 
7 |
8 |
9 | 
--------------------------------------------------------------------------------
/presentation/src/main/res/drawable/list_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/commonlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/domain/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/presentation/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 50dp
7 |
8 |
9 |
--------------------------------------------------------------------------------
/presentation/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/presentation/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/domain/src/test/java/com/micky/domain/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.micky.domain;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/commonlib/src/test/java/com/micky/commonlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/service/response/BaseResponse.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.service.response;
2 |
3 | /**
4 | * @Project CommonProject
5 | * @Packate com.micky.commonproject.data.api.response
6 | * @Description
7 | * @Author Micky Liu
8 | * @Email mickyliu@126.com
9 | * @Date 2015-12-21 16:39
10 | * @Version 1.0
11 | */
12 | public class BaseResponse {
13 | public int code;
14 | }
15 |
--------------------------------------------------------------------------------
/presentation/src/test/java/com/micky/retrofitrxandroiddragger2/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/domain/src/androidTest/java/com/micky/domain/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.micky.domain;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/commonlib/src/androidTest/java/com/micky/commonlib/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/presenter/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.presenter;
2 |
3 | /**
4 | * @Project CommonProject
5 | * @Packate com.micky.presentation
6 | * @Description
7 | * @Author Micky Liu
8 | * @Email mickyliu@126.com
9 | * @Date 2015-12-22 13:46
10 | * @Version 1.0
11 | */
12 | public interface BasePresenter {
13 | void onCreate();
14 | void onResume();
15 | void onPause();
16 | void onDestroy();
17 | }
18 |
--------------------------------------------------------------------------------
/presentation/src/androidTest/java/com/micky/retrofitrxandroiddragger2/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/model/WeatherExtra.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.model;
2 |
3 | /**
4 | * @Project CommonProj
5 | * @Packate com.micky.commonproj.domain.model
6 | * @Description
7 | * @Author Micky Liu
8 | * @Email mickyliu@126.com
9 | * @Date 2016-01-04 18:13
10 | * @Version 1.0
11 | */
12 | public class WeatherExtra {
13 | public String title;
14 | public String zs;
15 | public String tipt;
16 | public String des;
17 | }
18 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Tue Apr 12 09:50:14 CST 2016
11 | sdk.dir=D\:\\Android\\sdk
12 |
--------------------------------------------------------------------------------
/presentation/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CommonProj
3 | Settings
4 | Please input ip address
5 | network error
6 | 空气质量:%s
7 | 城市:%s
8 | %1$s : %2$s
9 | 暂无天气推荐数据,请查看左侧栏最近天气信息
10 |
11 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/service/response/GetIpInfoResponse.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.service.response;
2 |
3 |
4 | import com.micky.commonproj.domain.model.IpInfo;
5 |
6 | /**
7 | * @Project CommonProject
8 | * @Packate com.micky.commonproject.data.api.response
9 | * @Description
10 | * @Author Micky Liu
11 | * @Email mickyliu@126.com
12 | * @Date 2015-12-21 16:39
13 | * @Version 1.0
14 | */
15 | public class GetIpInfoResponse extends BaseResponse {
16 | public IpInfo data;
17 | }
18 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/model/WeatherResult.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @Project CommonProj
7 | * @Packate com.micky.commonproj.domain.model
8 | * @Description
9 | * @Author Micky Liu
10 | * @Email mickyliu@126.com
11 | * @Date 2016-01-04 18:13
12 | * @Version 1.0
13 | */
14 | public class WeatherResult {
15 | public String currentCity;
16 | public String pm25;
17 | public List index;
18 | public List weather_data;
19 | }
20 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/presenter/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.presenter;
2 |
3 | /**
4 | * @Project CommonProject
5 | * @Packate com.micky.presentation
6 | * @Description
7 | * @Author Micky Liu
8 | * @Email mickyliu@126.com
9 | * @Date 2015-12-22 13:46
10 | * @Version 1.0
11 | */
12 | public interface MainPresenter extends BasePresenter {
13 |
14 | void getWeatherData(String place);
15 |
16 | void getPlaceData();
17 |
18 | void getPlaceAndWeatherData(String place);
19 |
20 | void onRefresh();
21 | }
22 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/model/WeatherData.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.model;
2 |
3 | /**
4 | * @Project CommonProj
5 | * @Packate com.micky.commonproj.domain.model
6 | * @Description
7 | * @Author Micky Liu
8 | * @Email mickyliu@126.com
9 | * @Date 2016-01-04 18:12
10 | * @Version 1.0
11 | */
12 | public class WeatherData {
13 | public String date;
14 | public String dayPictureUrl;
15 | public String nightPictureUrl;
16 | public String weather;
17 | public String wind;
18 | public String temperature;
19 | }
20 |
--------------------------------------------------------------------------------
/presentation/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/manager/PlaceDaoManager.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db.manager;
2 |
3 | import com.micky.commonproj.domain.model.Place;
4 |
5 | import de.greenrobot.dao.AbstractDao;
6 |
7 | /**
8 | * @Project CommonProj
9 | * @Packate com.micky.commonproj.domain.db.manager
10 | * @Description
11 | * @Author Micky Liu
12 | * @Email mickyliu@126.com
13 | * @Date 2016-01-29 13:43
14 | * @Version 1.0
15 | */
16 | public class PlaceDaoManager extends BaseDaoManager {
17 |
18 | public PlaceDaoManager(AbstractDao dao) {
19 | super(dao);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/service/response/WeatherResponse.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.service.response;
2 |
3 | import com.micky.commonproj.domain.model.WeatherResult;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @Project CommonProj
9 | * @Packate com.micky.commonproj.domain.service.response
10 | * @Description
11 | * @Author Micky Liu
12 | * @Email mickyliu@126.com
13 | * @Date 2016-01-04 18:14
14 | * @Version 1.0
15 | */
16 | public class WeatherResponse extends BaseResponse {
17 | public int error;
18 | public String status;
19 | public String date;
20 | public List results;
21 | }
22 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/view/MainView.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.view;
2 |
3 | import com.micky.commonproj.domain.model.Place;
4 | import com.micky.commonproj.domain.service.response.WeatherResponse;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @Project CommonProject
10 | * @Packate com.micky.presentation
11 | * @Description
12 | * @Author Micky Liu
13 | * @Email mickyliu@126.com
14 | * @Date 2015-12-22 13:55
15 | * @Version 1.0
16 | */
17 | public interface MainView {
18 | void showProgress();
19 | void hideProgress();
20 | void setupPlaceData(List placeList);
21 | void setupWeatherData(WeatherResponse response);
22 | }
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/content_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/ViewUtils.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 | /**
4 | * @Project CommonProj
5 | * @Packate com.micky.commonlib.utils
6 | * @Description
7 | * @Author Micky Liu
8 | * @Email mickyliu@126.com
9 | * @Date 2016-01-08 14:51
10 | * @Version 1.0
11 | */
12 | public class ViewUtils {
13 | /**防止连续点击*/
14 | private static long lastClickTime;
15 | public static boolean isFastClick() {
16 | long time = System.currentTimeMillis();
17 | long timeD = time - lastClickTime;
18 | if ( timeD > 0 && timeD < 500) {
19 | return true;
20 | }
21 | lastClickTime = time;
22 | return false;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/commonlib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\software\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/domain/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\software\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/presentation/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\software\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/DomainInit.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain;
2 |
3 | import android.content.Context;
4 |
5 | import com.micky.commonproj.domain.db.DBCore;
6 |
7 | /**
8 | * @Project CommonProj
9 | * @Packate com.micky.commonproj.domain
10 | *
11 | * @Description Domain 相关初始化
12 | *
13 | * @Author Micky Liu
14 | * @Email mickyliu@126.com
15 | * @Date 2016-01-29 14:34
16 | * @Version 1.0
17 | */
18 | public class DomainInit {
19 |
20 | public static void init(Context context) {
21 | initDatabase(context);
22 | }
23 |
24 | /**
25 | * 初始化数据库
26 | * @param context
27 | */
28 | public static void initDatabase(Context context) {
29 | DBCore.init(context);
30 | DBCore.enableQueryBuilderLog();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/domain/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 10
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.1.1'
25 | compile 'de.greenrobot:greendao:2.0.0'
26 | compile 'de.greenrobot:greendao-generator:2.0.0'
27 |
28 | compile project(':commonlib')
29 | }
30 |
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/item_place.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
20 |
21 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/DaoManagerFactory.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db;
2 |
3 | import com.micky.commonproj.domain.db.dao.PlaceDao;
4 | import com.micky.commonproj.domain.db.manager.PlaceDaoManager;
5 |
6 | /**
7 | * @Project CommonProj
8 | * @Packate com.micky.commonproj.domain.db
9 | *
10 | * @Description
11 | *
12 | * @Author Micky Liu
13 | * @Email mickyliu@126.com
14 | * @Date 2016-01-29 14:29
15 | * @Version 1.0
16 | */
17 | public class DaoManagerFactory {
18 |
19 | private static PlaceDaoManager sPlaceDaoManager;
20 |
21 | public static PlaceDaoManager getPlaceDaoManager() {
22 | if (sPlaceDaoManager == null) {
23 | PlaceDao userDao = DBCore.getDaoSession().getPlaceDao();
24 | sPlaceDaoManager = new PlaceDaoManager(userDao);
25 | }
26 | return sPlaceDaoManager;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/content_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
22 |
23 |
--------------------------------------------------------------------------------
/presentation/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1a9bd0
4 | #1a9bd0
5 | #ff009688
6 | #EFEFF4
7 | #FFFFFF
8 | #000000
9 | #ddd
10 |
11 | #05c7a5
12 | #0ca3d0
13 | #01b8d7
14 | #d76d93
15 | #7e4b84
16 | #ea8010
17 | #27ae60
18 | #61c883
19 | #01b8d7
20 | #05c7a5
21 |
22 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/RxUtils.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 | import rx.Subscription;
4 | import rx.subscriptions.CompositeSubscription;
5 |
6 | /**
7 | * @Project CommonProj
8 | * @Packate com.micky.commonlib.utils
9 | * @Description
10 | * @Author Micky Liu
11 | * @Email mickyliu@126.com
12 | * @Date 2016-01-11 14:22
13 | * @Version 1.0
14 | */
15 | public class RxUtils {
16 |
17 | public static void unsubscribeIfNotNull(Subscription subscription) {
18 | if (subscription != null) {
19 | subscription.unsubscribe();
20 | }
21 | }
22 |
23 | public static CompositeSubscription getNewCompositeSubIfUnsubscribed(CompositeSubscription subscription) {
24 | if (subscription == null || subscription.isUnsubscribed()) {
25 | return new CompositeSubscription();
26 | }
27 |
28 | return subscription;
29 | }
30 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/view_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
23 |
--------------------------------------------------------------------------------
/CommonProj.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/Constants.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * @Project CommonProject
7 | * @Packate com.micky.commonlib.utils
8 | * @Description
9 | * @Author Micky Liu
10 | * @Email mickyliu@126.com
11 | * @Date 2015-12-30 17:43
12 | * @Version 1.0
13 | */
14 | public class Constants {
15 |
16 | //网络相关
17 | public static final int HTTP_RESPONSE_DISK_CACHE_MAX_SIZE = 10 * 1024 * 1024;
18 |
19 | public static final String ENDPOINT_IP = "http://ip.taobao.com";
20 | public static final String ENDPOINT_WEATHER = " http://api.map.baidu.com";
21 | public static final String BAIDU_AK = "MPDgj92wUYvRmyaUdQs1XwCf";
22 |
23 |
24 |
25 | public static final boolean DEBUG = true;
26 |
27 | //日志相关
28 | public static final String BASE_FILE_PATH = "CommonProj";
29 | public static final String LOG_PATH = BASE_FILE_PATH + File.separator + "log";
30 | public static final String LOG_FILE = BASE_FILE_PATH + ".log";
31 | }
32 |
--------------------------------------------------------------------------------
/commonlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 10
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | final RETROFIT_VERSION = '2.0.2'
23 |
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | testCompile 'junit:junit:4.12'
26 |
27 | compile 'io.reactivex:rxandroid:1.1.0'
28 | compile 'io.reactivex:rxjava:1.1.3'
29 | compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
30 | compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
31 | compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
32 | compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
33 | }
34 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/presentation/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/DateUtils.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 | import java.text.DateFormat;
4 | import java.text.SimpleDateFormat;
5 | import java.util.Date;
6 |
7 | /**
8 | * @Project CommonProj
9 | * @Packate com.micky.commonlib.utils
10 | * @Description
11 | * @Author Micky Liu
12 | * @Email mickyliu@126.com
13 | * @Date 2016-01-08 10:30
14 | * @Version 1.0
15 | */
16 | public class DateUtils {
17 | private static final String DATE_SHORT_FORMAT = "yyyy-MM-dd";
18 | private static final String DATE_WEEK_FORMAT = "yyyy-MM-dd EEEE";
19 |
20 | public static String getWeekDay(String dateStr) {
21 | String result = "";
22 | try {
23 | Date date = new SimpleDateFormat(DATE_SHORT_FORMAT).parse(dateStr);
24 | result = getWeekDate(date);
25 | } catch (Exception e) {
26 | e.printStackTrace();
27 | }
28 | return result;
29 | }
30 |
31 | public static String getWeekDate(Date date) {
32 | SimpleDateFormat dateFm = new SimpleDateFormat(DATE_WEEK_FORMAT);
33 | return dateFm.format(date);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/service/WeatherService.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.service;
2 |
3 |
4 | import com.micky.commonproj.domain.service.response.WeatherResponse;
5 |
6 | import org.w3c.dom.UserDataHandler;
7 |
8 | import java.util.List;
9 |
10 | import retrofit2.http.POST;
11 | import retrofit2.http.Query;
12 | import rx.Observable;
13 |
14 | /**
15 | * @Project CommonProject
16 | * @Packate com.micky.commonproj.data.api
17 | * @Description
18 | * @Author Micky Liu
19 | * @Email mickyliu@126.com
20 | * @Date 2015-12-21 17:22
21 | * @Version 1.0
22 | */
23 | public interface WeatherService {
24 |
25 | /*@GET("service/getIpInfo.php")
26 | Call getIpInfo(@Query("ip") String ip);*/
27 |
28 | // @GET("service/getIpInfo.php")
29 | // Observable getIpInfo(@Query("ip") String ip);
30 |
31 |
32 | //http://api.map.baidu.com/telematics/v3/weather?location=%E6%88%90%E9%83%BD&output=json&ak=MPDgj92wUYvRmyaUdQs1XwCf
33 | @POST("/telematics/v3/weather?output=json")
34 | Observable getWeatherInfo(@Query("location") String location, @Query("ak") String ak);
35 | }
36 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/CrashHandler.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 |
4 | import android.content.Context;
5 | import android.util.Log;
6 |
7 | /**
8 | * @Description 全局Crash捕获处理
9 | * @Author Micky Liu
10 | * @Email sglazelhw@126.com
11 | * @Date 2015-04-03 下午 1:43
12 | */
13 | public class CrashHandler implements Thread.UncaughtExceptionHandler {
14 |
15 | // public final Logger mLogger = Logger.getLogger(getClass());
16 |
17 | private static CrashHandler INSTANCE = new CrashHandler();
18 | private Thread.UncaughtExceptionHandler mDefaultUEH;
19 | private Context mContext;
20 |
21 | private CrashHandler() {
22 | mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
23 | }
24 |
25 | public static CrashHandler getInstance() {
26 | return INSTANCE;
27 | }
28 |
29 | public void init(Context ctx) {
30 | Thread.setDefaultUncaughtExceptionHandler(this);
31 | mContext = ctx;
32 | }
33 |
34 | @Override
35 | public void uncaughtException(Thread thread, Throwable ex) {
36 | Log.e("CrashHandler", ex.getMessage(), ex);
37 | mDefaultUEH.uncaughtException(thread, ex);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/RxBus.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 | import rx.Observable;
4 | import rx.subjects.PublishSubject;
5 | import rx.subjects.SerializedSubject;
6 | import rx.subjects.Subject;
7 |
8 | /**
9 | * @Project CommonProj
10 | * @Packate com.micky.commonlib.utils
11 | * @Description
12 | * @Author Micky Liu
13 | * @Email mickyliu@126.com
14 | * @Date 2016-01-11 15:03
15 | * @Version 1.0
16 | */
17 | public class RxBus {
18 |
19 | private final PublishSubject publishSubject = PublishSubject.create();
20 | private final Subject mBus = new SerializedSubject(publishSubject);
21 |
22 | private static class RxBusHolder {
23 | private static final RxBus INSTANCE = new RxBus();
24 | }
25 |
26 | private RxBus() {}
27 |
28 | public static final RxBus getInstance() {
29 | return RxBusHolder.INSTANCE;
30 | }
31 |
32 | public void send(BusEvent event) {
33 | mBus.onNext(event);
34 | }
35 |
36 | public Observable toObserverable() {
37 | return mBus;
38 | }
39 |
40 | public boolean hasObservers() {
41 | return mBus.hasObservers();
42 | }
43 |
44 | public static class BusEvent {}
45 | }
--------------------------------------------------------------------------------
/presentation/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.micky.commonproj"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile project(':commonlib')
26 | compile project(':domain')
27 |
28 | compile 'com.android.support:appcompat-v7:23.1.1'
29 | compile 'com.android.support:design:23.1.1'
30 | compile 'com.android.support:cardview-v7:23.1.1'
31 | compile 'com.jakewharton:butterknife:7.0.1'
32 | compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
33 | compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.3.0'
34 | compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:0.3.0'
35 | compile 'com.jakewharton.rxbinding:rxbinding-design:0.3.0'
36 | compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7:0.3.0'
37 | compile 'com.facebook.fresco:fresco:0.8.0+'
38 |
39 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
40 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
41 | }
42 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/view/ItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.View;
8 |
9 | import com.micky.commonproj.R;
10 |
11 | /**
12 | * @Package com.micky.commonlib.view
13 | * @Project CommonProj
14 | * @Description
15 | * @Author Micky Liu
16 | * @Email mickyliu@126.com
17 | * @Team KTEAM
18 | * @Date 2016-01-04 23:13
19 | */
20 | public class ItemDecoration extends RecyclerView.ItemDecoration {
21 | private Drawable mDivider;
22 |
23 | public ItemDecoration(Context context) {
24 | mDivider = context.getResources().getDrawable(R.drawable.list_divider);
25 | }
26 |
27 | @Override
28 | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
29 | int left = parent.getPaddingLeft();
30 | int right = parent.getWidth() - parent.getPaddingRight();
31 |
32 | int childCount = parent.getChildCount();
33 | for (int i = 0; i < childCount; i++) {
34 | View child = parent.getChildAt(i);
35 |
36 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
37 |
38 | int top = child.getBottom() + params.bottomMargin;
39 | int bottom = top + mDivider.getIntrinsicHeight();
40 |
41 | mDivider.setBounds(left, top, right, bottom);
42 | mDivider.draw(c);
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/presenter/impl/BasePresenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.presenter.impl;
2 |
3 | import com.micky.commonlib.utils.RxUtils;
4 | import com.micky.commonproj.presenter.BasePresenter;
5 |
6 | import rx.Observable;
7 | import rx.android.schedulers.AndroidSchedulers;
8 | import rx.schedulers.Schedulers;
9 | import rx.subscriptions.CompositeSubscription;
10 |
11 | /**
12 | * @Project CommonProject
13 | * @Packate com.micky.commonproj.presenter
14 | * @Description
15 | * @Author Micky Liu
16 | * @Email mickyliu@126.com
17 | * @Date 2015-12-22 14:34
18 | * @Version 0.1
19 | */
20 | public class BasePresenterImpl implements BasePresenter {
21 | protected CompositeSubscription mSubscriptions = new CompositeSubscription();
22 |
23 | @Override
24 | public void onCreate() {
25 | mSubscriptions = RxUtils.getNewCompositeSubIfUnsubscribed(mSubscriptions);
26 | }
27 |
28 | @Override
29 | public void onResume() {
30 |
31 | }
32 |
33 | @Override
34 | public void onPause() {
35 |
36 | }
37 |
38 | @Override
39 | public void onDestroy() {
40 | mSubscriptions.unsubscribe();
41 | }
42 |
43 | protected Observable.Transformer applyScheduler() {
44 | return new Observable.Transformer() {
45 | @Override
46 | public Observable call(Observable observable) {
47 | return observable.subscribeOn(Schedulers.io())
48 | .observeOn(AndroidSchedulers.mainThread());
49 | }
50 | };
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/adapter/BaseListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.ViewGroup;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * @Package org.kteam.palm.adapter
11 | * @Project CommonProj
12 | * @Description
13 | * @Author Micky Liu
14 | * @Email mickyliu@126.com
15 | * @Team KTEAM
16 | * @Date 2015-12-05 15:45
17 | */
18 | public class BaseListAdapter extends RecyclerView.Adapter {
19 | protected List mDataList;
20 |
21 | public BaseListAdapter() {
22 | mDataList = new ArrayList();
23 | }
24 |
25 | public void clearData() {
26 | mDataList.clear();
27 | }
28 |
29 | public void setData(List list) {
30 | mDataList.clear();
31 | mDataList.addAll(list);
32 | }
33 |
34 | public void appendDataList(List list) {
35 | mDataList.addAll(list);
36 | }
37 |
38 | public void appendData(T t) {
39 | mDataList.add(t);
40 | }
41 |
42 | @Override
43 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
44 | return null;
45 | }
46 |
47 | @Override
48 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
49 |
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return mDataList.size();
55 | }
56 |
57 | public T getItem(int position) {
58 | return mDataList.get(position);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
30 |
31 |
32 |
41 |
--------------------------------------------------------------------------------
/presentation/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
19 |
20 |
24 |
28 |
29 |
33 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/item_weather_extra.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
17 |
24 |
30 |
37 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/adapter/WeatherExtraAdapter.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.micky.commonproj.R;
10 | import com.micky.commonproj.domain.model.WeatherExtra;
11 |
12 | import butterknife.Bind;
13 | import butterknife.ButterKnife;
14 |
15 | /**
16 | * @Package com.micky.commonproj.ui.adapter
17 | * @Project CommonProj
18 | * @Description
19 | * @Author Micky Liu
20 | * @Email mickyliu@126.com
21 | * @Team KTEAM
22 | * @Date 2016-01-04 22:52
23 | */
24 | public class WeatherExtraAdapter extends BaseListAdapter {
25 |
26 | @Override
27 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
28 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_weather_extra, parent, false);
29 | return new ItemViewHolder(view);
30 | }
31 |
32 | @Override
33 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
34 | super.onBindViewHolder(holder, position);
35 | ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
36 | WeatherExtra weatherExtra = getItem(position);
37 | itemViewHolder.tvTitle.setText(weatherExtra.title);
38 | itemViewHolder.tvZs.setText(weatherExtra.zs);
39 | itemViewHolder.tvTipt.setText(holder.itemView.getContext().getString(R.string.weather_content, weatherExtra.tipt, weatherExtra.des));
40 | }
41 |
42 | public class ItemViewHolder extends RecyclerView.ViewHolder{
43 | @Bind(R.id.tv_title) TextView tvTitle;
44 | @Bind(R.id.tv_zs) TextView tvZs;
45 | @Bind(R.id.tv_tipt) TextView tvTipt;
46 |
47 | public ItemViewHolder(View itemView) {
48 | super(itemView);
49 | ButterKnife.bind(this, itemView);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/DBCore.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db;
2 |
3 | import android.content.Context;
4 |
5 | import com.micky.commonproj.domain.db.dao.DaoMaster;
6 | import com.micky.commonproj.domain.db.dao.DaoSession;
7 |
8 | import de.greenrobot.dao.query.QueryBuilder;
9 |
10 | /**
11 | * @Project CommonProj
12 | * @Packate com.micky.commonproj.domain.db
13 | * @Description
14 | * @Author Micky Liu
15 | * @Email mickyliu@126.com
16 | * @Date 2016-01-29 14:27
17 | * @Version 1.0
18 | */
19 | public class DBCore {
20 | private static final String DEFAULT_DB_NAME = "green_dao_test.db";
21 | private static DaoMaster sDaoMaster;
22 | private static DaoSession sDaoSession;
23 |
24 | private static Context sContext;
25 | private static String sDbName;
26 |
27 | public static void init(Context context) {
28 | init(context, DEFAULT_DB_NAME);
29 | }
30 |
31 | public static void init(Context context, String dbName) {
32 | if (context == null) {
33 | throw new IllegalArgumentException("Init DBCore failed, context can't be null.");
34 | }
35 | sContext = context.getApplicationContext();
36 | sDbName = dbName;
37 | }
38 |
39 | public static DaoMaster getDaoMaster() {
40 | if (sDaoMaster == null) {
41 | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(sContext, sDbName, null);
42 | sDaoMaster = new DaoMaster(helper.getWritableDatabase());
43 | }
44 | return sDaoMaster;
45 | }
46 |
47 | public static DaoSession getDaoSession() {
48 | if (sDaoSession == null) {
49 | if (sDaoMaster == null) {
50 | sDaoMaster = getDaoMaster();
51 | }
52 | sDaoSession = sDaoMaster.newSession();
53 | }
54 | return sDaoSession;
55 | }
56 |
57 | public static void enableQueryBuilderLog() {
58 | QueryBuilder.LOG_SQL = true;
59 | QueryBuilder.LOG_VALUES = true;
60 | }
61 | }
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/dao/DaoSession.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db.dao;
2 |
3 | import android.database.sqlite.SQLiteDatabase;
4 |
5 | import java.util.Map;
6 |
7 | import de.greenrobot.dao.AbstractDao;
8 | import de.greenrobot.dao.AbstractDaoSession;
9 | import de.greenrobot.dao.identityscope.IdentityScopeType;
10 | import de.greenrobot.dao.internal.DaoConfig;
11 |
12 | import com.micky.commonproj.domain.model.IpInfo;
13 | import com.micky.commonproj.domain.model.Place;
14 |
15 | import com.micky.commonproj.domain.db.dao.IpInfoDao;
16 | import com.micky.commonproj.domain.db.dao.PlaceDao;
17 |
18 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
19 |
20 | /**
21 | * {@inheritDoc}
22 | *
23 | * @see de.greenrobot.dao.AbstractDaoSession
24 | */
25 | public class DaoSession extends AbstractDaoSession {
26 |
27 | private final DaoConfig ipInfoDaoConfig;
28 | private final DaoConfig placeDaoConfig;
29 |
30 | private final IpInfoDao ipInfoDao;
31 | private final PlaceDao placeDao;
32 |
33 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig>
34 | daoConfigMap) {
35 | super(db);
36 |
37 | ipInfoDaoConfig = daoConfigMap.get(IpInfoDao.class).clone();
38 | ipInfoDaoConfig.initIdentityScope(type);
39 |
40 | placeDaoConfig = daoConfigMap.get(PlaceDao.class).clone();
41 | placeDaoConfig.initIdentityScope(type);
42 |
43 | ipInfoDao = new IpInfoDao(ipInfoDaoConfig, this);
44 | placeDao = new PlaceDao(placeDaoConfig, this);
45 |
46 | registerDao(IpInfo.class, ipInfoDao);
47 | registerDao(Place.class, placeDao);
48 | }
49 |
50 | public void clear() {
51 | ipInfoDaoConfig.getIdentityScope().clear();
52 | placeDaoConfig.getIdentityScope().clear();
53 | }
54 |
55 | public IpInfoDao getIpInfoDao() {
56 | return ipInfoDao;
57 | }
58 |
59 | public PlaceDao getPlaceDao() {
60 | return placeDao;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/generator/GreenDaoGenerator.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db.generator;
2 |
3 | import de.greenrobot.daogenerator.DaoGenerator;
4 | import de.greenrobot.daogenerator.Entity;
5 | import de.greenrobot.daogenerator.Schema;
6 |
7 | /**
8 | * @Project CommonProj
9 | * @Packate com.micky.commonproj.domain.db.manager
10 | * @Description
11 | * @Author Micky Liu
12 | * @Email mickyliu@126.com
13 | * @Date 2016-01-29 13:33
14 | * @Version 1.0
15 | */
16 | public class GreenDaoGenerator {
17 |
18 | /**需要生成model的时候,请设置成true, 用于防止手贱点错了 */
19 | public static final boolean GENERATE_MODEL = false;
20 |
21 | /**
22 | * 数据库版本
23 | * 如果数据库需要升级,请在DaoMaster中的onUpgrade方法中加入:
24 | * MigrationHelper.getInstance().migrate(db, IpInfoDao.class, PlaceDao.class,...);
25 | */
26 | public static final int DB_VERSION = 2;
27 |
28 | public static void main(String[] args) throws Exception {
29 | if (GENERATE_MODEL) {
30 | Schema schema = new Schema(DB_VERSION, "com.micky.commonproj.domain.model");
31 | schema.setDefaultJavaPackageDao("com.micky.commonproj.domain.db.dao");
32 | schema.enableKeepSectionsByDefault();
33 | addUser(schema);
34 | addPlace(schema);
35 | new DaoGenerator().generateAll(schema, "./domain/src/main/java");
36 | }
37 | }
38 |
39 | private static void addUser(Schema schema) {
40 | Entity user = schema.addEntity("IpInfo");
41 | user.addIdProperty().primaryKey();
42 | user.addStringProperty("country");
43 | user.addDoubleProperty("country_id");
44 | user.addDoubleProperty("area");
45 | user.addDoubleProperty("area_id");
46 | user.addDoubleProperty("ip");
47 | }
48 |
49 | private static void addPlace(Schema schema) {
50 | Entity card = schema.addEntity("Place");
51 | card.addIdProperty().primaryKey();
52 | card.addStringProperty("label");
53 | card.addStringProperty("name");
54 | card.addStringProperty("pinyin");
55 | card.addStringProperty("province");
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/commonlib/src/main/java/com/micky/commonlib/utils/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonlib.utils;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageInfo;
5 | import android.content.pm.PackageManager;
6 | import android.os.Environment;
7 |
8 | import java.io.File;
9 |
10 | /**
11 | * @Description
12 | * @Author Micky Liu
13 | * @Email mickyliu@126.com
14 | * @Date 2015-06-16 11:11
15 | */
16 | public class FileUtils {
17 |
18 | /**
19 | * 获取日志文件目录
20 | * @return
21 | */
22 | public static String getLogFilePath() {
23 | String sdPath = getSDPath();
24 | if (!"".equals(sdPath)) {
25 | return sdPath + File.separator + Constants.LOG_PATH;
26 | }
27 | return "";
28 | }
29 |
30 | /**
31 | * 获取SDCard目录
32 | * @return
33 | */
34 | public static final String getSDPath() {
35 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
36 | return Environment.getExternalStorageDirectory().toString();
37 | }
38 | return "";
39 | }
40 |
41 | /**
42 | * 获取版本名
43 | * @param context
44 | * @return
45 | */
46 | public static String getAppVersion(Context context)
47 | {
48 | try {
49 | PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
50 | return pi.versionName;
51 | } catch (PackageManager.NameNotFoundException e) {
52 | // TODO Auto-generated catch block
53 | e.printStackTrace();
54 | }
55 |
56 | return "";
57 | }
58 |
59 | /**
60 | * 获取版本号
61 | * @param context
62 | * @return
63 | */
64 | public static int getVersionCode(Context context)//获取版本号(内部识别号)
65 | {
66 | try {
67 | PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
68 | return pi.versionCode;
69 | } catch (PackageManager.NameNotFoundException e) {
70 | // TODO Auto-generated catch block
71 | e.printStackTrace();
72 | }
73 | return 0;
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/model/IpInfo.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.model;
2 |
3 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS
4 |
5 | // KEEP INCLUDES - put your custom includes here
6 | // KEEP INCLUDES END
7 | /**
8 | * Entity mapped to table "IP_INFO".
9 | */
10 | public class IpInfo {
11 |
12 | private Long id;
13 | private String country;
14 | private Double country_id;
15 | private Double area;
16 | private Double area_id;
17 | private Double ip;
18 |
19 | // KEEP FIELDS - put your custom fields here
20 | // KEEP FIELDS END
21 |
22 | public IpInfo() {
23 | }
24 |
25 | public IpInfo(Long id) {
26 | this.id = id;
27 | }
28 |
29 | public IpInfo(Long id, String country, Double country_id, Double area, Double area_id, Double ip) {
30 | this.id = id;
31 | this.country = country;
32 | this.country_id = country_id;
33 | this.area = area;
34 | this.area_id = area_id;
35 | this.ip = ip;
36 | }
37 |
38 | public Long getId() {
39 | return id;
40 | }
41 |
42 | public void setId(Long id) {
43 | this.id = id;
44 | }
45 |
46 | public String getCountry() {
47 | return country;
48 | }
49 |
50 | public void setCountry(String country) {
51 | this.country = country;
52 | }
53 |
54 | public Double getCountry_id() {
55 | return country_id;
56 | }
57 |
58 | public void setCountry_id(Double country_id) {
59 | this.country_id = country_id;
60 | }
61 |
62 | public Double getArea() {
63 | return area;
64 | }
65 |
66 | public void setArea(Double area) {
67 | this.area = area;
68 | }
69 |
70 | public Double getArea_id() {
71 | return area_id;
72 | }
73 |
74 | public void setArea_id(Double area_id) {
75 | this.area_id = area_id;
76 | }
77 |
78 | public Double getIp() {
79 | return ip;
80 | }
81 |
82 | public void setIp(Double ip) {
83 | this.ip = ip;
84 | }
85 |
86 | // KEEP METHODS - put your custom methods here
87 | // KEEP METHODS END
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/repository/PlaceRepository.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.repository;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 |
6 | import com.google.gson.Gson;
7 | import com.google.gson.GsonBuilder;
8 | import com.google.gson.reflect.TypeToken;
9 | import com.micky.commonproj.domain.db.DaoManagerFactory;
10 | import com.micky.commonproj.domain.model.Place;
11 |
12 | import java.io.ByteArrayOutputStream;
13 | import java.io.InputStream;
14 | import java.util.List;
15 |
16 | import rx.Observable;
17 | import rx.Subscriber;
18 |
19 | /**
20 | * @Project CommonProj
21 | * @Packate com.micky.commonproj.domain.repository
22 | * @Description
23 | * @Author Micky Liu
24 | * @Email mickyliu@126.com
25 | * @Date 2016-01-08 13:36
26 | * @Version 1.0
27 | */
28 | public class PlaceRepository {
29 |
30 | public Observable> getPlaceList(final Context context) {
31 | return Observable.create(new Observable.OnSubscribe>() {
32 | @Override
33 | public void call(Subscriber super List> subscriber) {
34 | try {
35 | AssetManager assertManager = context.getAssets();
36 | InputStream inputStream = assertManager.open("place");
37 | ByteArrayOutputStream outStream = new ByteArrayOutputStream();
38 | byte[] data = new byte[1024];
39 | int count = -1;
40 | while((count = inputStream.read(data,0, 1024)) != -1) {
41 | outStream.write(data, 0, count);
42 | }
43 | String json = new String(outStream.toByteArray(),"UTF-8");
44 | Gson gson = new GsonBuilder().create();
45 | List placeList = gson.fromJson(json, new TypeToken>() {
46 | }.getType());
47 | subscriber.onNext(placeList);
48 | } catch (Exception e) {
49 | subscriber.onError(e);
50 | }
51 | subscriber.onCompleted();
52 | }
53 | });
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/item_weather_data.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
22 |
28 |
32 |
38 |
44 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/model/Place.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.model;
2 |
3 | // THIS CODE IS GENERATED BY greenDAO, EDIT ONLY INSIDE THE "KEEP"-SECTIONS
4 |
5 | // KEEP INCLUDES - put your custom includes here
6 | // KEEP INCLUDES END
7 | /**
8 | * Entity mapped to table "PLACE".
9 | */
10 | public class Place implements Comparable {
11 |
12 | private Long id;
13 | private String label;
14 | private String name;
15 | private String pinyin;
16 | private String province;
17 |
18 | // KEEP FIELDS - put your custom fields here
19 | // KEEP FIELDS END
20 |
21 | public Place() {
22 | }
23 |
24 | public Place(Long id) {
25 | this.id = id;
26 | }
27 |
28 | public Place(Long id, String label, String name, String pinyin, String province) {
29 | this.id = id;
30 | this.label = label;
31 | this.name = name;
32 | this.pinyin = pinyin;
33 | this.province = province;
34 | }
35 |
36 | public Long getId() {
37 | return id;
38 | }
39 |
40 | public void setId(Long id) {
41 | this.id = id;
42 | }
43 |
44 | public String getLabel() {
45 | return label;
46 | }
47 |
48 | public void setLabel(String label) {
49 | this.label = label;
50 | }
51 |
52 | public String getName() {
53 | return name;
54 | }
55 |
56 | public void setName(String name) {
57 | this.name = name;
58 | }
59 |
60 | public String getPinyin() {
61 | return pinyin;
62 | }
63 |
64 | public void setPinyin(String pinyin) {
65 | this.pinyin = pinyin;
66 | }
67 |
68 | public String getProvince() {
69 | return province;
70 | }
71 |
72 | public void setProvince(String province) {
73 | this.province = province;
74 | }
75 |
76 | // KEEP METHODS - put your custom methods here
77 | @Override
78 | public int hashCode() {
79 | return pinyin.hashCode();
80 | }
81 |
82 | @Override
83 | public boolean equals(Object o) {
84 | if (o instanceof Place) {
85 | return pinyin.equals(((Place)o).pinyin);
86 | }
87 | return false;
88 | }
89 |
90 | @Override
91 | public int compareTo(Place another) {
92 | return pinyin.compareTo(another.pinyin);
93 | }
94 | // KEEP METHODS END
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/adapter/WeatherDataAdapter.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.adapter;
2 |
3 | import android.net.Uri;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.facebook.drawee.view.SimpleDraweeView;
11 | import com.jakewharton.rxbinding.view.RxView;
12 | import com.micky.commonproj.R;
13 | import com.micky.commonproj.domain.model.WeatherData;
14 | import com.micky.commonproj.domain.model.WeatherExtra;
15 |
16 | import java.util.concurrent.TimeUnit;
17 |
18 | import butterknife.Bind;
19 | import butterknife.ButterKnife;
20 | import rx.functions.Action1;
21 |
22 | /**
23 | * @Package com.micky.commonproj.ui.adapter
24 | * @Project CommonProj
25 | * @Description
26 | * @Author Micky Liu
27 | * @Email mickyliu@126.com
28 | * @Team KTEAM
29 | * @Date 2016-01-04 22:52
30 | */
31 | public class WeatherDataAdapter extends BaseListAdapter {
32 |
33 | @Override
34 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
35 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_weather_data, parent, false);
36 | return new ItemViewHolder(view);
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
41 | super.onBindViewHolder(holder, position);
42 | ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
43 | WeatherData weatherData = getItem(position);
44 | itemViewHolder.tvDate.setText(weatherData.date);
45 | itemViewHolder.sdvWeather.setImageURI(Uri.parse(weatherData.dayPictureUrl));
46 | itemViewHolder.tvWeather.setText(weatherData.weather);
47 | itemViewHolder.tvTemperature.setText(weatherData.temperature);
48 | }
49 |
50 | public class ItemViewHolder extends RecyclerView.ViewHolder{
51 | @Bind(R.id.tv_date) TextView tvDate;
52 | @Bind(R.id.sdv_weather) SimpleDraweeView sdvWeather;
53 | @Bind(R.id.tv_weather) TextView tvWeather;
54 | @Bind(R.id.tv_temperature) TextView tvTemperature;
55 |
56 | public ItemViewHolder(final View itemView) {
57 | super(itemView);
58 | ButterKnife.bind(this, itemView);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/adapter/PlaceAdapter.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.jakewharton.rxbinding.view.RxView;
10 | import com.micky.commonproj.R;
11 | import com.micky.commonproj.domain.model.Place;
12 |
13 | import java.util.concurrent.TimeUnit;
14 |
15 | import butterknife.Bind;
16 | import butterknife.ButterKnife;
17 | import rx.functions.Action1;
18 |
19 | /**
20 | * @Project CommonProj
21 | * @Packate com.micky.commonproj.ui.adapter
22 | * @Description
23 | * @Author Micky Liu
24 | * @Email mickyliu@126.com
25 | * @Date 2016-01-08 14:13
26 | * @Version 1.0
27 | */
28 | public class PlaceAdapter extends BaseListAdapter {
29 | private OnPlaceClickListener mOnPlaceClickListener;
30 |
31 | public void setOnPlaceClickListener(OnPlaceClickListener listener) {
32 | mOnPlaceClickListener = listener;
33 | }
34 |
35 | @Override
36 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
37 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_place, parent, false);
38 | return new ItemViewHolder(view);
39 | }
40 |
41 | @Override
42 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
43 | super.onBindViewHolder(holder, position);
44 | ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
45 | Place place = getItem(position);
46 | itemViewHolder.place = place;
47 | itemViewHolder.tvPlace.setText(place.getName());
48 | }
49 |
50 | public class ItemViewHolder extends RecyclerView.ViewHolder{
51 | @Bind(R.id.tv_place) TextView tvPlace;
52 |
53 | public Place place;
54 |
55 | public ItemViewHolder(final View itemView) {
56 | super(itemView);
57 | ButterKnife.bind(this, itemView);
58 | RxView.clicks(itemView).throttleFirst(1000, TimeUnit.MILLISECONDS).subscribe(new Action1() {
59 | @Override
60 | public void call(Void aVoid) {
61 | mOnPlaceClickListener.onClick(itemView, place);
62 | }
63 | });
64 | }
65 | }
66 |
67 | public interface OnPlaceClickListener {
68 | void onClick(View view, Place place);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
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 |
43 |
44 |
45 |
46 |
47 | C:\Users\Administrator\AppData\Roaming\Subversion
48 |
49 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import com.facebook.drawee.backends.pipeline.Fresco;
7 | import com.micky.commonlib.utils.Constants;
8 | import com.micky.commonlib.utils.CrashHandler;
9 | import com.micky.commonlib.utils.FileUtils;
10 | import com.micky.commonproj.domain.DomainInit;
11 | import com.squareup.leakcanary.LeakCanary;
12 | import com.squareup.leakcanary.RefWatcher;
13 |
14 | import org.apache.log4j.Level;
15 |
16 | import java.io.File;
17 |
18 | import de.mindpipe.android.logging.log4j.LogConfigurator;
19 |
20 | /**
21 | * @Project CommonProject
22 | * @Packate com.micky.commonproj
23 | * @Description
24 | * @Author Micky Liu
25 | * @Email mickyliu@126.com
26 | * @Date 2015-12-21 17:47
27 | * @Version 1.0
28 | */
29 | public class BaseApplication extends Application {
30 | private static BaseApplication instance;
31 |
32 | private RefWatcher mRefWatcher;
33 |
34 | @Override
35 | public void onCreate() {
36 | super.onCreate();
37 | instance = this;
38 | CrashHandler.getInstance().init(this);
39 | DomainInit.init(this);
40 | mRefWatcher = Constants.DEBUG ? LeakCanary.install(this) : RefWatcher.DISABLED;
41 | Fresco.initialize(this);
42 | initLog4j();
43 | }
44 |
45 | public static BaseApplication getInstance() {
46 | return instance;
47 | }
48 |
49 | public static RefWatcher getRefWatcher() {
50 | return getInstance().mRefWatcher;
51 | }
52 |
53 | private void initLog4j() {
54 | final LogConfigurator logConfigurator = new LogConfigurator();
55 |
56 | String logPath = FileUtils.getLogFilePath();
57 | try {
58 | if (!"".equals(logPath)) {
59 | File file = new File(logPath);
60 | if (!file.exists()) {
61 | file.mkdirs();
62 | }
63 | logPath += File.separator + Constants.LOG_FILE;
64 | file = new File(logPath);
65 | if (!file.exists()) {
66 | file.createNewFile();
67 | }
68 | logConfigurator.setFileName(logPath);
69 | }
70 | Level level = Constants.DEBUG ? Level.ALL : Level.ERROR;
71 | logConfigurator.setRootLevel(level);
72 | logConfigurator.setLevel("org.apache", Level.ALL);
73 | logConfigurator.configure();
74 | } catch (Exception e) {
75 | android.util.Log.e("Application", e.getMessage(), e);
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/ui/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.ui.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.Toolbar;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import com.micky.commonproj.BaseApplication;
10 | import com.micky.commonproj.R;
11 |
12 | import butterknife.Bind;
13 | import butterknife.ButterKnife;
14 |
15 | /**
16 | * @Package com.micky.commonproj.ui.activity
17 | * @Project CommonProj
18 | * @Description
19 | * @Author Micky Liu
20 | * @Email mickyliu@126.com
21 | * @Team KTEAM
22 | * @Date 2016-01-04 21:27
23 | */
24 | public class BaseActivity extends AppCompatActivity {
25 | @Bind(R.id.toolbar) Toolbar mToolBar;
26 | @Bind(R.id.tv_title) TextView mTvTitle;
27 | private boolean mAutoBindView;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | }
33 |
34 | @Override
35 | public void setContentView(int layoutResID) {
36 | setContentView(layoutResID, false);
37 | }
38 |
39 | public void setContentView(int layoutResID, boolean hideBackButton) {
40 | super.setContentView(layoutResID);
41 | ButterKnife.bind(this);
42 | initToolBar(hideBackButton);
43 | mAutoBindView = true;
44 | }
45 |
46 | @Override
47 | protected void onDestroy() {
48 | super.onDestroy();
49 | if (mAutoBindView) {
50 | ButterKnife.unbind(this);
51 | }
52 | BaseApplication.getRefWatcher().watch(this);
53 | }
54 |
55 | private void initToolBar(boolean hideBackButton) {
56 | if (mToolBar == null) {
57 | return;
58 | }
59 | setTitle("");
60 |
61 | setSupportActionBar(mToolBar);
62 | getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(false);
63 | getSupportActionBar().setHomeButtonEnabled(false);
64 |
65 | if (!hideBackButton) {
66 | mToolBar.setNavigationIcon(R.mipmap.back);
67 | mToolBar.setNavigationOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View v) {
70 | finish();
71 | }
72 | });
73 | }
74 | }
75 |
76 | protected void setTitleText(String title) {
77 | mTvTitle.setVisibility(View.VISIBLE);
78 | mTvTitle.setText(title);
79 | }
80 |
81 | protected void setTitleRes(int resId) {
82 | mTvTitle.setVisibility(View.VISIBLE);
83 | mTvTitle.setText(resId);
84 | }
85 |
86 | protected void hideTitle() {
87 | mTvTitle.setVisibility(View.GONE);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/presentation/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
17 |
25 |
33 |
34 |
38 |
44 |
54 |
55 |
56 |
57 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/dao/DaoMaster.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db.dao;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteDatabase.CursorFactory;
6 | import android.database.sqlite.SQLiteOpenHelper;
7 | import android.util.Log;
8 | import de.greenrobot.dao.AbstractDaoMaster;
9 | import de.greenrobot.dao.identityscope.IdentityScopeType;
10 |
11 | import com.micky.commonproj.domain.db.MigrationHelper;
12 | import com.micky.commonproj.domain.db.dao.IpInfoDao;
13 | import com.micky.commonproj.domain.db.dao.PlaceDao;
14 |
15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16 | /**
17 | * Master of DAO (schema version 2): knows all DAOs.
18 | */
19 | public class DaoMaster extends AbstractDaoMaster {
20 | public static final int SCHEMA_VERSION = 2;
21 |
22 | /** Creates underlying database table using DAOs. */
23 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
24 | IpInfoDao.createTable(db, ifNotExists);
25 | PlaceDao.createTable(db, ifNotExists);
26 | }
27 |
28 | /** Drops underlying database table using DAOs. */
29 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
30 | IpInfoDao.dropTable(db, ifExists);
31 | PlaceDao.dropTable(db, ifExists);
32 | }
33 |
34 | public static abstract class OpenHelper extends SQLiteOpenHelper {
35 |
36 | public OpenHelper(Context context, String name, CursorFactory factory) {
37 | super(context, name, factory, SCHEMA_VERSION);
38 | }
39 |
40 | @Override
41 | public void onCreate(SQLiteDatabase db) {
42 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
43 | createAllTables(db, false);
44 | }
45 | }
46 |
47 | /** WARNING: Drops all table on Upgrade! Use only during development. */
48 | public static class DevOpenHelper extends OpenHelper {
49 | public DevOpenHelper(Context context, String name, CursorFactory factory) {
50 | super(context, name, factory);
51 | }
52 |
53 | @Override
54 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
55 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
56 | // dropAllTables(db, true);
57 | // onCreate(db);
58 | MigrationHelper.getInstance().migrate(db, IpInfoDao.class, PlaceDao.class);
59 | }
60 | }
61 |
62 | public DaoMaster(SQLiteDatabase db) {
63 | super(db, SCHEMA_VERSION);
64 | registerDaoClass(IpInfoDao.class);
65 | registerDaoClass(PlaceDao.class);
66 | }
67 |
68 | public DaoSession newSession() {
69 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
70 | }
71 |
72 | public DaoSession newSession(IdentityScopeType type) {
73 | return new DaoSession(db, type, daoConfigMap);
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/service/ServiceManager.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.service;
2 |
3 | import android.content.Context;
4 |
5 | import com.micky.commonlib.utils.Constants;
6 |
7 | import org.apache.log4j.Logger;
8 |
9 | import java.io.File;
10 | import java.io.IOException;
11 | import java.util.HashMap;
12 |
13 | import okhttp3.Cache;
14 | import okhttp3.Interceptor;
15 | import okhttp3.OkHttpClient;
16 | import okhttp3.Request;
17 | import okhttp3.Response;
18 | import okhttp3.logging.HttpLoggingInterceptor;
19 | import retrofit2.Retrofit;
20 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
21 | import retrofit2.converter.gson.GsonConverterFactory;
22 |
23 | /**
24 | * @Project CommonProject
25 | * @Packate com.micky.commonproj.domain.service
26 | *
27 | * @Description Retrofit 服务管理
28 | *
29 | * @Author Micky Liu
30 | * @Email mickyliu@126.com
31 | * @Date 2015-12-22 14:43
32 | * @Version 1.0
33 | */
34 | public class ServiceManager {
35 |
36 | private static HashMap mServiceMap = new HashMap();
37 |
38 | /**
39 | * 创建Retrofit Service
40 | * @param t Service类型
41 | * @param
42 | * @return
43 | */
44 | public static T createService(Context context, Class t) {
45 | T service = (T) mServiceMap.get(t.getName());
46 |
47 | if (service == null) {
48 | OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
49 |
50 | if (Constants.DEBUG) {
51 | //日志处理
52 | HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
53 | @Override
54 | public void log(String s) {
55 | Logger.getLogger(getClass()).debug(s);
56 | }
57 | });
58 | loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
59 | clientBuilder.addInterceptor(loggingInterceptor);
60 | }
61 |
62 |
63 | //缓存处理
64 | final File baseDir = context.getCacheDir();
65 | if (baseDir != null) {
66 | final File cacheDir = new File(baseDir, "HttpResponseCache");
67 | clientBuilder.cache(new Cache(cacheDir, Constants.HTTP_RESPONSE_DISK_CACHE_MAX_SIZE));
68 | }
69 | clientBuilder.interceptors().add(new ServiceInterceptor());
70 |
71 | Retrofit retrofit = new Retrofit.Builder()
72 | .baseUrl(getEndPoint(t))
73 | .addConverterFactory(GsonConverterFactory.create())
74 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
75 | .client(clientBuilder.build())
76 | .build();
77 | service = retrofit.create(t);
78 | mServiceMap.put(t.getName(), service);
79 | }
80 | return service;
81 | }
82 |
83 | /**
84 | * 获取EndPoint URL
85 | * @param t Service类型
86 | * @param
87 | * @return
88 | */
89 | public static String getEndPoint(Class t) {
90 | String endPoint = "";
91 | if (t.getName().equals(WeatherService.class.getName())) {
92 | endPoint = Constants.ENDPOINT_WEATHER;
93 | }
94 | if ("".equals(endPoint)) {
95 | throw new IllegalArgumentException("Error: Can't get end point url. Please configure at the method " + ServiceManager.class.getSimpleName() + ".getEndPoint(T t)");
96 | }
97 | return endPoint;
98 | }
99 |
100 | /**
101 | * OkHttpClient的拦截器
102 | */
103 | static class ServiceInterceptor implements Interceptor {
104 | @Override
105 | public Response intercept(Chain chain) throws IOException {
106 | Request request = chain.request();
107 | Response response = chain.proceed(request);
108 | return response;
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/dao/PlaceDao.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db.dao;
2 |
3 | import android.database.Cursor;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteStatement;
6 |
7 | import de.greenrobot.dao.AbstractDao;
8 | import de.greenrobot.dao.Property;
9 | import de.greenrobot.dao.internal.DaoConfig;
10 |
11 | import com.micky.commonproj.domain.model.Place;
12 |
13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
14 | /**
15 | * DAO for table "PLACE".
16 | */
17 | public class PlaceDao extends AbstractDao {
18 |
19 | public static final String TABLENAME = "PLACE";
20 |
21 | /**
22 | * Properties of entity Place.
23 | * Can be used for QueryBuilder and for referencing column names.
24 | */
25 | public static class Properties {
26 | public final static Property Id = new Property(0, Long.class, "id", true, "_id");
27 | public final static Property Label = new Property(1, String.class, "label", false, "LABEL");
28 | public final static Property Name = new Property(2, String.class, "name", false, "NAME");
29 | public final static Property Pinyin = new Property(3, String.class, "pinyin", false, "PINYIN");
30 | public final static Property Province = new Property(4, String.class, "province", false, "PROVINCE");
31 | };
32 |
33 |
34 | public PlaceDao(DaoConfig config) {
35 | super(config);
36 | }
37 |
38 | public PlaceDao(DaoConfig config, DaoSession daoSession) {
39 | super(config, daoSession);
40 | }
41 |
42 | /** Creates the underlying database table. */
43 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
44 | String constraint = ifNotExists? "IF NOT EXISTS ": "";
45 | db.execSQL("CREATE TABLE " + constraint + "\"PLACE\" (" + //
46 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
47 | "\"LABEL\" TEXT," + // 1: label
48 | "\"NAME\" TEXT," + // 2: name
49 | "\"PINYIN\" TEXT," + // 3: pinyin
50 | "\"PROVINCE\" TEXT);"); // 4: province
51 | }
52 |
53 | /** Drops the underlying database table. */
54 | public static void dropTable(SQLiteDatabase db, boolean ifExists) {
55 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PLACE\"";
56 | db.execSQL(sql);
57 | }
58 |
59 | /** @inheritdoc */
60 | @Override
61 | protected void bindValues(SQLiteStatement stmt, Place entity) {
62 | stmt.clearBindings();
63 |
64 | Long id = entity.getId();
65 | if (id != null) {
66 | stmt.bindLong(1, id);
67 | }
68 |
69 | String label = entity.getLabel();
70 | if (label != null) {
71 | stmt.bindString(2, label);
72 | }
73 |
74 | String name = entity.getName();
75 | if (name != null) {
76 | stmt.bindString(3, name);
77 | }
78 |
79 | String pinyin = entity.getPinyin();
80 | if (pinyin != null) {
81 | stmt.bindString(4, pinyin);
82 | }
83 |
84 | String province = entity.getProvince();
85 | if (province != null) {
86 | stmt.bindString(5, province);
87 | }
88 | }
89 |
90 | /** @inheritdoc */
91 | @Override
92 | public Long readKey(Cursor cursor, int offset) {
93 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
94 | }
95 |
96 | /** @inheritdoc */
97 | @Override
98 | public Place readEntity(Cursor cursor, int offset) {
99 | Place entity = new Place( //
100 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
101 | cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // label
102 | cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // name
103 | cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pinyin
104 | cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // province
105 | );
106 | return entity;
107 | }
108 |
109 | /** @inheritdoc */
110 | @Override
111 | public void readEntity(Cursor cursor, Place entity, int offset) {
112 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
113 | entity.setLabel(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
114 | entity.setName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
115 | entity.setPinyin(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
116 | entity.setProvince(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
117 | }
118 |
119 | /** @inheritdoc */
120 | @Override
121 | protected Long updateKeyAfterInsert(Place entity, long rowId) {
122 | entity.setId(rowId);
123 | return rowId;
124 | }
125 |
126 | /** @inheritdoc */
127 | @Override
128 | public Long getKey(Place entity) {
129 | if(entity != null) {
130 | return entity.getId();
131 | } else {
132 | return null;
133 | }
134 | }
135 |
136 | /** @inheritdoc */
137 | @Override
138 | protected boolean isEntityUpdateable() {
139 | return true;
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/micky/commonproj/domain/db/dao/IpInfoDao.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.domain.db.dao;
2 |
3 | import android.database.Cursor;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteStatement;
6 |
7 | import de.greenrobot.dao.AbstractDao;
8 | import de.greenrobot.dao.Property;
9 | import de.greenrobot.dao.internal.DaoConfig;
10 |
11 | import com.micky.commonproj.domain.model.IpInfo;
12 |
13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
14 | /**
15 | * DAO for table "IP_INFO".
16 | */
17 | public class IpInfoDao extends AbstractDao {
18 |
19 | public static final String TABLENAME = "IP_INFO";
20 |
21 | /**
22 | * Properties of entity IpInfo.
23 | * Can be used for QueryBuilder and for referencing column names.
24 | */
25 | public static class Properties {
26 | public final static Property Id = new Property(0, Long.class, "id", true, "_id");
27 | public final static Property Country = new Property(1, String.class, "country", false, "COUNTRY");
28 | public final static Property Country_id = new Property(2, Double.class, "country_id", false, "COUNTRY_ID");
29 | public final static Property Area = new Property(3, Double.class, "area", false, "AREA");
30 | public final static Property Area_id = new Property(4, Double.class, "area_id", false, "AREA_ID");
31 | public final static Property Ip = new Property(5, Double.class, "ip", false, "IP");
32 | };
33 |
34 |
35 | public IpInfoDao(DaoConfig config) {
36 | super(config);
37 | }
38 |
39 | public IpInfoDao(DaoConfig config, DaoSession daoSession) {
40 | super(config, daoSession);
41 | }
42 |
43 | /** Creates the underlying database table. */
44 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
45 | String constraint = ifNotExists? "IF NOT EXISTS ": "";
46 | db.execSQL("CREATE TABLE " + constraint + "\"IP_INFO\" (" + //
47 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
48 | "\"COUNTRY\" TEXT," + // 1: country
49 | "\"COUNTRY_ID\" REAL," + // 2: country_id
50 | "\"AREA\" REAL," + // 3: area
51 | "\"AREA_ID\" REAL," + // 4: area_id
52 | "\"IP\" REAL);"); // 5: ip
53 | }
54 |
55 | /** Drops the underlying database table. */
56 | public static void dropTable(SQLiteDatabase db, boolean ifExists) {
57 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"IP_INFO\"";
58 | db.execSQL(sql);
59 | }
60 |
61 | /** @inheritdoc */
62 | @Override
63 | protected void bindValues(SQLiteStatement stmt, IpInfo entity) {
64 | stmt.clearBindings();
65 |
66 | Long id = entity.getId();
67 | if (id != null) {
68 | stmt.bindLong(1, id);
69 | }
70 |
71 | String country = entity.getCountry();
72 | if (country != null) {
73 | stmt.bindString(2, country);
74 | }
75 |
76 | Double country_id = entity.getCountry_id();
77 | if (country_id != null) {
78 | stmt.bindDouble(3, country_id);
79 | }
80 |
81 | Double area = entity.getArea();
82 | if (area != null) {
83 | stmt.bindDouble(4, area);
84 | }
85 |
86 | Double area_id = entity.getArea_id();
87 | if (area_id != null) {
88 | stmt.bindDouble(5, area_id);
89 | }
90 |
91 | Double ip = entity.getIp();
92 | if (ip != null) {
93 | stmt.bindDouble(6, ip);
94 | }
95 | }
96 |
97 | /** @inheritdoc */
98 | @Override
99 | public Long readKey(Cursor cursor, int offset) {
100 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
101 | }
102 |
103 | /** @inheritdoc */
104 | @Override
105 | public IpInfo readEntity(Cursor cursor, int offset) {
106 | IpInfo entity = new IpInfo( //
107 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
108 | cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // country
109 | cursor.isNull(offset + 2) ? null : cursor.getDouble(offset + 2), // country_id
110 | cursor.isNull(offset + 3) ? null : cursor.getDouble(offset + 3), // area
111 | cursor.isNull(offset + 4) ? null : cursor.getDouble(offset + 4), // area_id
112 | cursor.isNull(offset + 5) ? null : cursor.getDouble(offset + 5) // ip
113 | );
114 | return entity;
115 | }
116 |
117 | /** @inheritdoc */
118 | @Override
119 | public void readEntity(Cursor cursor, IpInfo entity, int offset) {
120 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
121 | entity.setCountry(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
122 | entity.setCountry_id(cursor.isNull(offset + 2) ? null : cursor.getDouble(offset + 2));
123 | entity.setArea(cursor.isNull(offset + 3) ? null : cursor.getDouble(offset + 3));
124 | entity.setArea_id(cursor.isNull(offset + 4) ? null : cursor.getDouble(offset + 4));
125 | entity.setIp(cursor.isNull(offset + 5) ? null : cursor.getDouble(offset + 5));
126 | }
127 |
128 | /** @inheritdoc */
129 | @Override
130 | protected Long updateKeyAfterInsert(IpInfo entity, long rowId) {
131 | entity.setId(rowId);
132 | return rowId;
133 | }
134 |
135 | /** @inheritdoc */
136 | @Override
137 | public Long getKey(IpInfo entity) {
138 | if(entity != null) {
139 | return entity.getId();
140 | } else {
141 | return null;
142 | }
143 | }
144 |
145 | /** @inheritdoc */
146 | @Override
147 | protected boolean isEntityUpdateable() {
148 | return true;
149 | }
150 |
151 | }
152 |
--------------------------------------------------------------------------------
/presentation/src/main/java/com/micky/commonproj/presenter/impl/MainPresenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.micky.commonproj.presenter.impl;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 |
6 | import com.micky.commonlib.utils.Constants;
7 | import com.micky.commonlib.utils.RxBus;
8 | import com.micky.commonproj.BaseApplication;
9 | import com.micky.commonproj.domain.model.Place;
10 | import com.micky.commonproj.domain.repository.PlaceRepository;
11 | import com.micky.commonproj.domain.service.WeatherService;
12 | import com.micky.commonproj.domain.service.response.WeatherResponse;
13 | import com.micky.commonproj.presenter.MainPresenter;
14 | import com.micky.commonproj.ui.view.MainView;
15 | import com.micky.commonproj.domain.service.ServiceManager;
16 |
17 | import org.apache.log4j.Logger;
18 |
19 | import java.util.List;
20 |
21 | import rx.Observable;
22 | import rx.Subscriber;
23 | import rx.android.schedulers.AndroidSchedulers;
24 | import rx.functions.Action1;
25 | import rx.schedulers.Schedulers;
26 |
27 | /**
28 | * @Project CommonProject
29 | * @Packate com.micky.commonproj.presenter
30 | * @Description
31 | * @Author Micky Liu
32 | * @Email mickyliu@126.com
33 | * @Date 2015-12-22 14:33
34 | * @Version 1.0
35 | */
36 | public class MainPresenterImpl extends BasePresenterImpl implements MainPresenter {
37 | private final Logger mLogger = Logger.getLogger(getClass());
38 |
39 | private MainView mMainView;
40 |
41 | public MainPresenterImpl(MainView mainView) {
42 | mMainView = mainView;
43 | }
44 |
45 | @Override
46 | public void onCreate() {
47 | super.onCreate();
48 | mSubscriptions.add(RxBus.getInstance().toObserverable().subscribe(new Action1() {
49 | @Override
50 | public void call(RxBus.BusEvent rxBusEvent) {
51 | if (rxBusEvent instanceof RefreshEvent) {
52 | getPlaceAndWeatherData("成都");
53 | }
54 | }
55 | }));
56 | }
57 |
58 | @Override
59 | public void getWeatherData(String place) {
60 | if (TextUtils.isEmpty(place)) {
61 | return;
62 | }
63 | mMainView.showProgress();
64 | mSubscriptions.add(ServiceManager.createService(BaseApplication.getInstance(), WeatherService.class).getWeatherInfo(place, Constants.BAIDU_AK)
65 | .subscribeOn(Schedulers.io())
66 | .observeOn(AndroidSchedulers.mainThread())
67 | .subscribe(new Subscriber() {
68 | @Override
69 | public void onCompleted() {
70 | mMainView.hideProgress();
71 | }
72 |
73 | @Override
74 | public void onError(Throwable e) {
75 | mLogger.error(e.getMessage(), e);
76 | mMainView.hideProgress();
77 | }
78 |
79 | @Override
80 | public void onNext(WeatherResponse weatherResponse) {
81 | mMainView.setupWeatherData(weatherResponse);
82 | }
83 | }));
84 | }
85 |
86 | @Override
87 | public void getPlaceData() {
88 | PlaceRepository repository = new PlaceRepository();
89 | mSubscriptions.add(repository.getPlaceList(BaseApplication.getInstance())
90 | .subscribeOn(Schedulers.io())
91 | .observeOn(AndroidSchedulers.mainThread())
92 | .subscribe(new Subscriber>() {
93 | @Override
94 | public void onNext(List places) {
95 | mMainView.setupPlaceData(places);
96 | }
97 |
98 | @Override
99 | public void onCompleted() {
100 |
101 | }
102 |
103 | @Override
104 | public void onError(Throwable e) {
105 | mLogger.error(e.getMessage(), e);
106 | }
107 | }));
108 | }
109 |
110 | @Override
111 | public void getPlaceAndWeatherData(String place) {
112 | mMainView.showProgress();
113 | PlaceRepository repository = new PlaceRepository();
114 | Context context = BaseApplication.getInstance();
115 | Observable placeObservable = repository.getPlaceList(context);
116 | Observable weatherObservable = ServiceManager.createService(BaseApplication.getInstance(), WeatherService.class).getWeatherInfo(place, Constants.BAIDU_AK);
117 |
118 | mSubscriptions.add(Observable.merge(placeObservable, weatherObservable)
119 | .subscribeOn(Schedulers.io())
120 | .observeOn(AndroidSchedulers.mainThread())
121 | .subscribe(new Subscriber