├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── raw │ │ │ │ └── city.db │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_menu_search.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── weather_bg_1.jpg │ │ │ │ ├── weather_bg_2.jpg │ │ │ │ └── ic_menu_search.png │ │ │ ├── xml │ │ │ │ └── network_security_config.xml │ │ │ ├── values-v19 │ │ │ │ └── styles.xml │ │ │ ├── drawable │ │ │ │ ├── side_nav_bar.xml │ │ │ │ ├── bg_launch_window.xml │ │ │ │ ├── shape_card_bg.xml │ │ │ │ ├── ic_index_sun_cure.xml │ │ │ │ ├── ic_index_clod.xml │ │ │ │ ├── ic_vector_weather2.xml │ │ │ │ ├── ic_index_dress.xml │ │ │ │ ├── ic_vector_weather.xml │ │ │ │ ├── ic_index_shopping.xml │ │ │ │ ├── ic_index_sport.xml │ │ │ │ ├── ic_index_car_wash.xml │ │ │ │ └── ic_index_sunscreen.xml │ │ │ ├── drawable-v21 │ │ │ │ ├── ic_menu_send.xml │ │ │ │ ├── ic_menu_slideshow.xml │ │ │ │ ├── ic_menu_gallery.xml │ │ │ │ ├── ic_menu_manage.xml │ │ │ │ ├── ic_menu_camera.xml │ │ │ │ └── ic_menu_share.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── values-v23 │ │ │ │ └── styles.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── drawables.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ ├── menu │ │ │ │ ├── search_city.xml │ │ │ │ ├── main.xml │ │ │ │ └── activity_main_drawer.xml │ │ │ ├── layout │ │ │ │ ├── fragment_select_city.xml │ │ │ │ ├── activity_city_manager.xml │ │ │ │ ├── item_city.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── layout_app_bar.xml │ │ │ │ ├── fragment_drawer_menu.xml │ │ │ │ ├── activity_select_city.xml │ │ │ │ ├── activity_welcome.xml │ │ │ │ ├── item_detail.xml │ │ │ │ ├── item_life_index.xml │ │ │ │ ├── layout_drawer_menu_head.xml │ │ │ │ ├── item_city_manager.xml │ │ │ │ └── item_forecast.xml │ │ │ └── layout-v21 │ │ │ │ └── item_city_manager.xml │ │ ├── ic_launcher-web.png │ │ ├── java │ │ │ └── com │ │ │ │ └── baronzhang │ │ │ │ └── android │ │ │ │ └── weather │ │ │ │ ├── AppConstants.java │ │ │ │ ├── base │ │ │ │ ├── BaseView.java │ │ │ │ ├── BasePresenter.java │ │ │ │ ├── BaseRecyclerViewAdapter.java │ │ │ │ ├── BaseFragment.java │ │ │ │ └── BaseActivity.java │ │ │ │ ├── util │ │ │ │ ├── StethoHelper.java │ │ │ │ └── stetho │ │ │ │ │ └── ReleaseStethoHelper.java │ │ │ │ ├── di │ │ │ │ ├── scope │ │ │ │ │ └── ActivityScoped.java │ │ │ │ ├── component │ │ │ │ │ ├── ApplicationComponent.java │ │ │ │ │ └── PresenterComponent.java │ │ │ │ └── module │ │ │ │ │ └── ApplicationModule.java │ │ │ │ ├── data │ │ │ │ ├── http │ │ │ │ │ ├── interceptor │ │ │ │ │ │ └── HttpRequestInterceptor.java │ │ │ │ │ ├── ApiConstants.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── WeatherService.java │ │ │ │ │ │ └── EnvironmentCloudWeatherService.java │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── mi │ │ │ │ │ │ │ ├── MiIndex.java │ │ │ │ │ │ │ ├── MiWeather.java │ │ │ │ │ │ │ ├── MiRealTime.java │ │ │ │ │ │ │ └── MiAQI.java │ │ │ │ │ │ └── envicloud │ │ │ │ │ │ │ ├── EnvironmentCloudCityAirLive.java │ │ │ │ │ │ │ └── EnvironmentCloudWeatherLive.java │ │ │ │ │ ├── configuration │ │ │ │ │ │ └── ApiConfiguration.java │ │ │ │ │ └── ApiClient.java │ │ │ │ ├── preference │ │ │ │ │ ├── ConfigurationListener.java │ │ │ │ │ └── WeatherSettings.java │ │ │ │ ├── WeatherDetail.java │ │ │ │ ├── db │ │ │ │ │ ├── entities │ │ │ │ │ │ ├── HotCity.java │ │ │ │ │ │ ├── adapter │ │ │ │ │ │ │ └── WeatherAdapter.java │ │ │ │ │ │ ├── minimalist │ │ │ │ │ │ │ ├── LifeIndex.java │ │ │ │ │ │ │ └── Weather.java │ │ │ │ │ │ └── City.java │ │ │ │ │ ├── dao │ │ │ │ │ │ └── CityDao.java │ │ │ │ │ ├── CityDatabaseHelper.java │ │ │ │ │ └── WeatherDatabaseHelper.java │ │ │ │ └── repository │ │ │ │ │ └── WeatherDataRepository.java │ │ │ │ ├── feature │ │ │ │ ├── home │ │ │ │ │ ├── HomePageComponent.java │ │ │ │ │ ├── HomePageContract.java │ │ │ │ │ ├── drawer │ │ │ │ │ │ ├── DrawerMenuModule.java │ │ │ │ │ │ ├── DrawerContract.java │ │ │ │ │ │ ├── CityManagerAdapter.java │ │ │ │ │ │ └── DrawerMenuPresenter.java │ │ │ │ │ ├── HomePageModule.java │ │ │ │ │ ├── DetailAdapter.java │ │ │ │ │ ├── HomePagePresenter.java │ │ │ │ │ ├── ForecastAdapter.java │ │ │ │ │ └── LifeIndexAdapter.java │ │ │ │ └── selectcity │ │ │ │ │ ├── SelectCityComponent.java │ │ │ │ │ ├── SelectCityContract.java │ │ │ │ │ ├── SelectCityModule.java │ │ │ │ │ ├── SelectCityPresenter.java │ │ │ │ │ ├── SelectCityActivity.java │ │ │ │ │ └── SelectCityFragment.java │ │ │ │ ├── WelcomeActivity.java │ │ │ │ └── WeatherApplication.java │ │ └── AndroidManifest.xml │ └── debug │ │ └── java │ │ └── com │ │ └── baronzhang │ │ └── android │ │ └── weather │ │ └── DebugStethoHelper.java ├── fabric.properties ├── proguard-rules.pro └── build.gradle ├── widget ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── attrs.xml │ │ │ │ └── arrays.xml │ │ │ ├── drawable-xxxhdpi │ │ │ │ └── housekeeper_hotdegree_mark.png │ │ │ ├── drawable │ │ │ │ ├── ic_vector_indicator_down.xml │ │ │ │ └── ic_vector_indicator_location.xml │ │ │ └── layout │ │ │ │ └── layout_title_view.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── baronzhang │ │ │ └── android │ │ │ └── widget │ │ │ ├── IndicatorValueChangeListener.java │ │ │ └── TitleView.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── baronzhang │ │ │ └── android │ │ │ └── widget │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── baronzhang │ │ └── android │ │ └── widget │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ ├── java │ │ └── com │ │ │ └── baronzhang │ │ │ └── android │ │ │ └── library │ │ │ ├── view │ │ │ ├── OnRecyclerViewItemClickListener.java │ │ │ └── DividerItemDecoration.java │ │ │ └── util │ │ │ ├── system │ │ │ ├── SystemHelper.java │ │ │ ├── AndroidMHelper.java │ │ │ ├── MIUIHelper.java │ │ │ ├── FlymeHelper.java │ │ │ └── StatusBarHelper.java │ │ │ ├── lifecycle │ │ │ ├── ActivityLifecycleEvent.java │ │ │ └── FragmentLifecycleEvent.java │ │ │ ├── ActivityUtils.java │ │ │ ├── RxSchedulerUtils.java │ │ │ ├── NetworkUtils.java │ │ │ └── DateConvertUtils.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── 扫码关注.png ├── .gitignore ├── framework_minimalist_weather.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew.bat ├── README.md └── dependencies.gradle /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /widget/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library', ':widget' 2 | -------------------------------------------------------------------------------- /扫码关注.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/扫码关注.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /app/src/main/res/raw/city.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/raw/city.db -------------------------------------------------------------------------------- /widget/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | widget 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /framework_minimalist_weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/framework_minimalist_weather.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/drawable-xhdpi/ic_menu_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/weather_bg_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/drawable-xxhdpi/weather_bg_1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/weather_bg_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/drawable-xxhdpi/weather_bg_2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/app/src/main/res/drawable-xxhdpi/ic_menu_search.png -------------------------------------------------------------------------------- /widget/src/main/res/drawable-xxxhdpi/housekeeper_hotdegree_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/MinimalistWeather/HEAD/widget/src/main/res/drawable-xxxhdpi/housekeeper_hotdegree_mark.png -------------------------------------------------------------------------------- /app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/fabric.properties: -------------------------------------------------------------------------------- 1 | #Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. 2 | #Fri Jul 22 11:51:10 CST 2016 3 | apiSecret=e86a9bd81d553715a7b0b66668a872664323d6b52a6a1cd519437557c494909e 4 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/AppConstants.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | * 16/3/13 6 | */ 7 | public class AppConstants { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroidLibrary 3 | 4 | 5 | Hello blank fragment 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 28 02:17:57 CST 2020 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-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /widget/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/base/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.base; 2 | 3 | /** 4 | * view interface,所有View(此项目中的View主要是Fragment和自定义的ViewGroup)必须实现此接口 5 | * 6 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 7 | */ 8 | public interface BaseView { 9 | 10 | void setPresenter(T presenter); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.base; 2 | 3 | /** 4 | * presenter interface,所有Presenter必须实现此接口 5 | * 6 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 7 | */ 8 | public interface BasePresenter { 9 | 10 | void subscribe(); 11 | 12 | void unSubscribe(); 13 | } 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/view/OnRecyclerViewItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.view; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | * 16/3/21 6 | */ 7 | public interface OnRecyclerViewItemClickListener { 8 | 9 | void onRecyclerViewItemClick(int position); 10 | } 11 | -------------------------------------------------------------------------------- /widget/src/main/java/com/baronzhang/android/widget/IndicatorValueChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.widget; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | */ 6 | public interface IndicatorValueChangeListener { 7 | 8 | void onChange(int currentIndicatorValue, String stateDescription, int indicatorTextColor); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_launch_window.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /widget/src/main/res/drawable/ic_vector_indicator_down.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/system/SystemHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util.system; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 7 | * 2017/6/2 8 | */ 9 | interface SystemHelper { 10 | 11 | boolean setStatusBarLightMode(Activity activity, boolean isFontColorDark); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/values-v23/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/lifecycle/ActivityLifecycleEvent.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util.lifecycle; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | * 2017/2/17 6 | */ 7 | public enum ActivityLifecycleEvent { 8 | 9 | CREATE, 10 | START, 11 | RESUME, 12 | PAUSE, 13 | STOP, 14 | DESTROY, 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/util/StethoHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.util; 2 | 3 | import android.content.Context; 4 | 5 | import okhttp3.OkHttpClient; 6 | 7 | /** 8 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 9 | * 2017/7/25 10 | */ 11 | public interface StethoHelper { 12 | 13 | void init(Context context); 14 | 15 | OkHttpClient.Builder addNetworkInterceptor(OkHttpClient.Builder builder); 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00AD7C 4 | @color/colorPrimary 5 | #FA4659 6 | 7 | @color/colorPrimary 8 | 9 | #E6E6E6 10 | 11 | @android:color/darker_gray 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/lifecycle/FragmentLifecycleEvent.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util.lifecycle; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | * 2017/2/17 6 | */ 7 | public enum FragmentLifecycleEvent { 8 | 9 | ATTACH, 10 | CREATE, 11 | CREATE_VIEW, 12 | START, 13 | RESUME, 14 | PAUSE, 15 | STOP, 16 | DESTROY_VIEW, 17 | DESTROY, 18 | DETACH, 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/di/scope/ActivityScoped.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.di.scope; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | import javax.inject.Scope; 8 | 9 | /** 10 | * @author 张磊 (baronzhang[at]anjuke[dot]com) 11 | * 2016/12/1 12 | */ 13 | @Scope 14 | @Documented 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface ActivityScoped { 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /widget/src/main/res/drawable/ic_vector_indicator_location.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /widget/src/test/java/com/baronzhang/android/widget/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.widget; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/http/interceptor/HttpRequestInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.http.interceptor; 2 | 3 | import java.io.IOException; 4 | 5 | import okhttp3.Interceptor; 6 | import okhttp3.Response; 7 | 8 | /** 9 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 10 | * 16/2/25 11 | */ 12 | public class HttpRequestInterceptor implements Interceptor { 13 | 14 | @Override 15 | public Response intercept(Chain chain) throws IOException { 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/menu/search_city.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_select_city.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/home/HomePageComponent.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.home; 2 | 3 | import com.baronzhang.android.weather.di.component.ApplicationComponent; 4 | import com.baronzhang.android.weather.di.scope.ActivityScoped; 5 | 6 | import dagger.Component; 7 | 8 | /** 9 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 10 | * 2016/11/29 11 | */ 12 | @ActivityScoped 13 | @Component(modules = HomePageModule.class, dependencies = ApplicationComponent.class) 14 | public interface HomePageComponent { 15 | 16 | void inject(MainActivity mainActivity); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | @android:drawable/ic_menu_camera 3 | @android:drawable/ic_menu_gallery 4 | @android:drawable/ic_menu_slideshow 5 | @android:drawable/ic_menu_manage 6 | @android:drawable/ic_menu_share 7 | @android:drawable/ic_menu_send 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/selectcity/SelectCityComponent.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.selectcity; 2 | 3 | import com.baronzhang.android.weather.di.component.ApplicationComponent; 4 | import com.baronzhang.android.weather.di.scope.ActivityScoped; 5 | 6 | import dagger.Component; 7 | 8 | /** 9 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 10 | * 2016/11/30 11 | */ 12 | @ActivityScoped 13 | @Component(modules = SelectCityModule.class, dependencies = ApplicationComponent.class) 14 | public interface SelectCityComponent { 15 | 16 | void inject(SelectCityActivity selectCityActivity); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/util/stetho/ReleaseStethoHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.util.stetho; 2 | 3 | import android.content.Context; 4 | 5 | import com.baronzhang.android.weather.util.StethoHelper; 6 | 7 | import okhttp3.OkHttpClient; 8 | 9 | /** 10 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 11 | * 2017/7/25 12 | */ 13 | public class ReleaseStethoHelper implements StethoHelper { 14 | 15 | @Override 16 | public void init(Context context) { 17 | 18 | } 19 | 20 | @Override 21 | public OkHttpClient.Builder addNetworkInterceptor(OkHttpClient.Builder builder) { 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/di/component/ApplicationComponent.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.di.component; 2 | 3 | import android.content.Context; 4 | 5 | import com.baronzhang.android.weather.WeatherApplication; 6 | import com.baronzhang.android.weather.di.module.ApplicationModule; 7 | 8 | import javax.inject.Singleton; 9 | 10 | import dagger.Component; 11 | 12 | /** 13 | * @author 张磊 (baron[dot]zhanglei[at]gmail[dot]com) 14 | * 2016/11/30 15 | */ 16 | @Singleton 17 | @Component(modules = {ApplicationModule.class}) 18 | public interface ApplicationComponent { 19 | 20 | WeatherApplication getApplication(); 21 | 22 | Context getContext(); 23 | } 24 | -------------------------------------------------------------------------------- /widget/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #FFFFFF 5 | 6 | #60C2CB 7 | #6FB452 8 | #F2AC00 9 | #DF3000 10 | #CA004A 11 | #7D0000 12 | 13 | #B2FFFFFF 14 | #333333 15 | #E6E6E6 16 | 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/ActivityUtils.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util; 2 | 3 | 4 | import androidx.fragment.app.Fragment; 5 | import androidx.fragment.app.FragmentManager; 6 | import androidx.fragment.app.FragmentTransaction; 7 | 8 | /** 9 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 10 | * 16/4/13 11 | */ 12 | public final class ActivityUtils { 13 | 14 | public static void addFragmentToActivity(FragmentManager fragmentManager, Fragment fragment, int frameId) { 15 | FragmentTransaction transaction = fragmentManager.beginTransaction(); 16 | transaction.add(frameId, fragment); 17 | transaction.commit(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/selectcity/SelectCityContract.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.selectcity; 2 | 3 | import java.util.List; 4 | 5 | import com.baronzhang.android.weather.data.db.entities.City; 6 | import com.baronzhang.android.weather.base.BasePresenter; 7 | import com.baronzhang.android.weather.base.BaseView; 8 | 9 | /** 10 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 11 | */ 12 | public interface SelectCityContract { 13 | 14 | interface View extends BaseView { 15 | 16 | void displayCities(List cities); 17 | } 18 | 19 | interface Presenter extends BasePresenter { 20 | 21 | void loadCities(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/home/HomePageContract.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.home; 2 | 3 | import com.baronzhang.android.weather.data.db.entities.minimalist.Weather; 4 | import com.baronzhang.android.weather.base.BasePresenter; 5 | import com.baronzhang.android.weather.base.BaseView; 6 | 7 | /** 8 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 9 | */ 10 | public interface HomePageContract { 11 | 12 | interface View extends BaseView { 13 | 14 | void displayWeatherInformation(Weather weather); 15 | } 16 | 17 | interface Presenter extends BasePresenter { 18 | 19 | void loadWeather(String cityId, boolean refreshNow); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /widget/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 /Users/baron/develop/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 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/selectcity/SelectCityModule.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.selectcity; 2 | 3 | import dagger.Module; 4 | import dagger.Provides; 5 | 6 | import com.baronzhang.android.weather.di.scope.ActivityScoped; 7 | 8 | /** 9 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 10 | * 2016/11/30 11 | */ 12 | @Module 13 | public class SelectCityModule { 14 | 15 | private SelectCityContract.View view; 16 | 17 | public SelectCityModule(SelectCityContract.View view) { 18 | this.view = view; 19 | } 20 | 21 | @Provides 22 | @ActivityScoped 23 | SelectCityContract.View provideSelectCityContractView() { 24 | return view; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/http/ApiConstants.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.http; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | * 16/3/8 6 | */ 7 | public final class ApiConstants { 8 | 9 | static final String MI_WEATHER_API_HOST = "http://weatherapi.market.xiaomi.com/wtr-v2/"; 10 | static final String KNOW_WEATHER_API_HOST = "http://knowweather.duapp.com/"; 11 | static final String ENVIRONMENT_CLOUD_WEATHER_API_HOST = "http://service.envicloud.cn:8082/"; 12 | 13 | public static final int WEATHER_DATA_SOURCE_TYPE_KNOW = 1; 14 | public static final int WEATHER_DATA_SOURCE_TYPE_MI = 2; 15 | public static final int WEATHER_DATA_SOURCE_TYPE_ENVIRONMENT_CLOUD = 3; 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_city_manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_city.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 14 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/home/drawer/DrawerMenuModule.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.home.drawer; 2 | 3 | import com.baronzhang.android.weather.di.scope.ActivityScoped; 4 | import com.baronzhang.android.weather.feature.home.drawer.DrawerContract; 5 | 6 | import dagger.Module; 7 | import dagger.Provides; 8 | 9 | /** 10 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 11 | * 2016/11/30 12 | */ 13 | @Module 14 | public class DrawerMenuModule { 15 | 16 | private DrawerContract.View view; 17 | 18 | public DrawerMenuModule(DrawerContract.View view) { 19 | this.view = view; 20 | } 21 | 22 | @Provides 23 | @ActivityScoped 24 | DrawerContract.View provideCityManagerContactView() { 25 | return view; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_card_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_app_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/RxSchedulerUtils.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util; 2 | 3 | 4 | import rx.Observable; 5 | import rx.android.schedulers.AndroidSchedulers; 6 | import rx.schedulers.Schedulers; 7 | 8 | 9 | /** 10 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 11 | * 2017/2/17 12 | */ 13 | public final class RxSchedulerUtils { 14 | 15 | /** 16 | * 在RxJava的使用过程中我们会频繁的调用subscribeOn()和observeOn(),通过Transformer结合 17 | * Observable.compose()我们可以复用这些代码 18 | * 19 | * @return Transformer 20 | */ 21 | public static Observable.Transformer normalSchedulersTransformer() { 22 | 23 | return observable -> observable.subscribeOn(Schedulers.io()) 24 | .observeOn(AndroidSchedulers.mainThread()); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/debug/java/com/baronzhang/android/weather/DebugStethoHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather; 2 | 3 | import android.content.Context; 4 | 5 | import com.baronzhang.android.weather.util.StethoHelper; 6 | import com.facebook.stetho.Stetho; 7 | import com.facebook.stetho.okhttp3.StethoInterceptor; 8 | 9 | import okhttp3.OkHttpClient; 10 | 11 | /** 12 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 13 | * 2017/7/25 14 | */ 15 | public class DebugStethoHelper implements StethoHelper { 16 | 17 | @Override 18 | public void init(Context context) { 19 | Stetho.initializeWithDefaults(context); 20 | } 21 | 22 | @Override 23 | public OkHttpClient.Builder addNetworkInterceptor(OkHttpClient.Builder builder) { 24 | return builder.addNetworkInterceptor(new StethoInterceptor()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /widget/src/main/res/layout/layout_title_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | 21 | 22 | -------------------------------------------------------------------------------- /app/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 /Users/baron/develop/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 | 19 | -keep public class * extends com.baronzhang.android.weather.util.StethoHelper 20 | 21 | # Retrofit 22 | -dontwarn okio.** 23 | -dontwarn javax.annotation.* -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/di/component/PresenterComponent.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.di.component; 2 | 3 | import com.baronzhang.android.weather.di.module.ApplicationModule; 4 | import com.baronzhang.android.weather.feature.home.drawer.DrawerMenuPresenter; 5 | import com.baronzhang.android.weather.feature.selectcity.SelectCityPresenter; 6 | 7 | import javax.inject.Singleton; 8 | 9 | import dagger.Component; 10 | import com.baronzhang.android.weather.feature.home.HomePagePresenter; 11 | 12 | /** 13 | * @author 张磊 (baron[dot]zhanglei[at]gmail[dot]com) 14 | * 2016/12/2 15 | */ 16 | @Singleton 17 | @Component(modules = {ApplicationModule.class}) 18 | public interface PresenterComponent { 19 | 20 | void inject(HomePagePresenter presenter); 21 | 22 | void inject(SelectCityPresenter presenter); 23 | 24 | void inject(DrawerMenuPresenter presenter); 25 | } 26 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/NetworkUtils.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | /** 8 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 9 | */ 10 | public final class NetworkUtils { 11 | 12 | /** 13 | * 判断网络连接是否可用 14 | */ 15 | public static Boolean isNetworkConnected(Context context) { 16 | ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 17 | if (manager != null) { 18 | NetworkInfo networkinfo = manager.getActiveNetworkInfo(); 19 | if (networkinfo != null && networkinfo.isConnected() && networkinfo.isAvailable()) { 20 | return true; 21 | } 22 | } 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /widget/src/androidTest/java/com/baronzhang/android/widget/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.widget; 2 | 3 | import android.content.Context; 4 | import androidx.test.InstrumentationRegistry; 5 | import androidx.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.baronzhang.android.widget.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## For more details on how to configure your build environment visit 2 | # http://www.gradle.org/docs/current/userguide/build_environment.html 3 | # 4 | # Specifies the JVM arguments used for the daemon process. 5 | # The setting is particularly useful for tweaking memory settings. 6 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 7 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 8 | # 9 | # When configured, Gradle will run in incubating parallel mode. 10 | # This option should only be used with decoupled projects. More details, visit 11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 12 | # org.gradle.parallel=true 13 | #Wed Apr 29 01:18:35 CST 2020 14 | android.enableJetifier=true 15 | org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M" 16 | android.useAndroidX=true 17 | android.enableBuildCache=true 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/preference/ConfigurationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 BaronZhang(BaronZ88) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.baronzhang.android.weather.data.preference; 17 | 18 | public interface ConfigurationListener { 19 | 20 | void onConfigurationChanged(WeatherSettings pref, Object newValue); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/di/module/ApplicationModule.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.di.module; 2 | 3 | import android.content.Context; 4 | 5 | import com.baronzhang.android.weather.WeatherApplication; 6 | 7 | import javax.inject.Singleton; 8 | 9 | import dagger.Module; 10 | import dagger.Provides; 11 | 12 | /** 13 | * @author 张磊 (baronzhang[at]anjuke[dot]com) 14 | * 2016/11/30 15 | */ 16 | @Module 17 | public class ApplicationModule { 18 | 19 | private Context context; 20 | 21 | public ApplicationModule(Context context) { 22 | 23 | this.context = context; 24 | } 25 | 26 | @Provides 27 | @Singleton 28 | WeatherApplication provideApplication() { 29 | 30 | return (WeatherApplication) context.getApplicationContext(); 31 | } 32 | 33 | @Provides 34 | @Singleton 35 | Context provideContext() { 36 | 37 | return context; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/home/drawer/DrawerContract.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.home.drawer; 2 | 3 | import com.baronzhang.android.weather.base.BasePresenter; 4 | import com.baronzhang.android.weather.base.BaseView; 5 | import com.baronzhang.android.weather.data.db.entities.minimalist.Weather; 6 | 7 | import java.io.InvalidClassException; 8 | import java.util.List; 9 | 10 | /** 11 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 12 | * 16/4/16 13 | */ 14 | public interface DrawerContract { 15 | 16 | interface View extends BaseView { 17 | 18 | void displaySavedCities(List weatherList); 19 | } 20 | 21 | interface Presenter extends BasePresenter { 22 | 23 | void loadSavedCities(); 24 | 25 | void deleteCity(String cityId); 26 | 27 | void saveCurrentCityToPreference(String cityId) throws InvalidClassException; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_drawer_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 16dp 7 | 160dp 8 | 16dp 9 | 16dp 10 | 11 | 24sp 12 | 22sp 13 | 20sp 14 | 18sp 15 | 16sp 16 | 14sp 17 | 12sp 18 | 10sp 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_select_city.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 20 | -------------------------------------------------------------------------------- /widget/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/home/HomePageModule.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.home; 2 | 3 | import com.baronzhang.android.weather.di.scope.ActivityScoped; 4 | import com.baronzhang.android.weather.feature.home.HomePagePresenter; 5 | 6 | import dagger.Module; 7 | import dagger.Provides; 8 | 9 | import com.baronzhang.android.weather.feature.home.HomePageContract; 10 | 11 | /** 12 | * This is a Dagger module. We use this to pass in the View dependency to the 13 | * {@link HomePagePresenter} 14 | * 15 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 16 | * 2016/11/30 17 | */ 18 | @Module 19 | public class HomePageModule { 20 | 21 | private HomePageContract.View view; 22 | 23 | public HomePageModule(HomePageContract.View view) { 24 | 25 | this.view = view; 26 | } 27 | 28 | @Provides 29 | @ActivityScoped 30 | HomePageContract.View provideHomePageContractView() { 31 | return view; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /widget/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 轻度污染 8 | 中度污染 9 | 重度污染 10 | 严重污染 11 | 12 | 13 | 14 | @color/indicator_color_1 15 | @color/indicator_color_2 16 | @color/indicator_color_3 17 | @color/indicator_color_4 18 | @color/indicator_color_5 19 | @color/indicator_color_6 20 | 21 | 22 | -------------------------------------------------------------------------------- /library/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 /Users/baron/develop/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 | 19 | #ButterKnife混淆配置 20 | -keep class butterknife.** { *; } 21 | -dontwarn butterknife.internal.** 22 | -keep class **$$ViewBinder { *; } 23 | 24 | -keepclasseswithmembernames class * { 25 | @butterknife.* ; 26 | } 27 | 28 | -keepclasseswithmembernames class * { 29 | @butterknife.* ; 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_welcome.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/WeatherDetail.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | * 2017/7/6 6 | */ 7 | public class WeatherDetail { 8 | 9 | private int iconResourceId; 10 | private String key; 11 | private String value; 12 | 13 | public WeatherDetail(int iconResourceId, String key, String value) { 14 | this.iconResourceId = iconResourceId; 15 | this.key = key; 16 | this.value = value; 17 | } 18 | 19 | public int getIconResourceId() { 20 | return iconResourceId; 21 | } 22 | 23 | public void setIconResourceId(int iconResourceId) { 24 | this.iconResourceId = iconResourceId; 25 | } 26 | 27 | public String getKey() { 28 | return key; 29 | } 30 | 31 | public void setKey(String key) { 32 | this.key = key; 33 | } 34 | 35 | public String getValue() { 36 | return value; 37 | } 38 | 39 | public void setValue(String value) { 40 | this.value = value; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/preference/WeatherSettings.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.preference; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | */ 6 | public enum WeatherSettings { 7 | 8 | /*默认配置项*/ 9 | SETTINGS_FIRST_USE("first_use", Boolean.TRUE), 10 | 11 | SETTINGS_CURRENT_CITY_ID("current_city_id", ""); 12 | 13 | private final String mId; 14 | private final Object mDefaultValue; 15 | 16 | WeatherSettings(String id, Object defaultValue) { 17 | this.mId = id; 18 | this.mDefaultValue = defaultValue; 19 | } 20 | 21 | public String getId() { 22 | return this.mId; 23 | } 24 | 25 | public Object getDefaultValue() { 26 | return this.mDefaultValue; 27 | } 28 | 29 | public static WeatherSettings fromId(String id) { 30 | WeatherSettings[] values = values(); 31 | for (WeatherSettings value : values) { 32 | if (value.mId.equals(id)) { 33 | return value; 34 | } 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/http/service/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.http.service; 2 | 3 | import com.baronzhang.android.weather.data.http.entity.know.KnowWeather; 4 | import com.baronzhang.android.weather.data.http.entity.mi.MiWeather; 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Path; 7 | import retrofit2.http.Query; 8 | import rx.Observable; 9 | 10 | /** 11 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 12 | * 16/2/25 13 | */ 14 | public interface WeatherService { 15 | 16 | /** 17 | * http://weatherapi.market.xiaomi.com/wtr-v2/weather?cityId=101010100 18 | * 19 | * @param cityId 城市ID 20 | * @return 天气数据 21 | */ 22 | @GET("weather") 23 | Observable getMiWeather(@Query("cityId") String cityId); 24 | 25 | 26 | /** 27 | * http://knowweather.duapp.com/v1.0/weather/101010100 28 | * 29 | * @param cityId 城市ID 30 | * @return 天气数据 31 | */ 32 | @GET("v1.0/weather/{cityId}") 33 | Observable getKnowWeather(@Path("cityId") String cityId); 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/base/BaseRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.base; 2 | 3 | import androidx.recyclerview.widget.RecyclerView; 4 | import android.widget.AdapterView; 5 | 6 | /** 7 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 8 | * 16/4/15 9 | */ 10 | public abstract class BaseRecyclerViewAdapter extends RecyclerView.Adapter{ 11 | 12 | protected AdapterView.OnItemClickListener onItemClickListener; 13 | 14 | public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) { 15 | 16 | this.onItemClickListener = onItemClickListener; 17 | } 18 | 19 | protected void onItemHolderClick(RecyclerView.ViewHolder itemHolder) { 20 | if (onItemClickListener != null) { 21 | onItemClickListener.onItemClick(null, itemHolder.itemView, 22 | itemHolder.getAdapterPosition(), itemHolder.getItemId()); 23 | } else { 24 | throw new IllegalStateException("Please call setOnItemClickListener method set the click event listeners"); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /widget/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | 5 | compileSdkVersion rootProject.ext.android.compileSdkVersion 6 | defaultConfig { 7 | minSdkVersion rootProject.ext.android.minSdkVersion 8 | targetSdkVersion rootProject.ext.android.targetSdkVersion 9 | versionCode 1 10 | versionName "1.0" 11 | 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | vectorDrawables.useSupportLibrary = true 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(dir: 'libs', include: ['*.jar']) 25 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', { 26 | exclude group: 'com.android.support', module: 'support-annotations' 27 | }) 28 | implementation rootProject.ext.dependencies["support-v4"] 29 | implementation rootProject.ext.dependencies["appcompat-v7"] 30 | testImplementation 'junit:junit:4.12' 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_index_sun_cure.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/system/AndroidMHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util.system; 2 | 3 | import android.app.Activity; 4 | import android.os.Build; 5 | import android.view.View; 6 | 7 | /** 8 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 9 | * 2017/6/2 10 | */ 11 | class AndroidMHelper implements SystemHelper { 12 | 13 | @Override 14 | public boolean setStatusBarLightMode(Activity activity, boolean isFontColorDark) { 15 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 16 | if (isFontColorDark) { 17 | // 沉浸式 18 | // activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 19 | //非沉浸式 20 | activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 21 | } else { 22 | //非沉浸式 23 | activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); 24 | } 25 | return true; 26 | } 27 | return false; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/db/entities/HotCity.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.db.entities; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | 6 | /** 7 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 8 | * 16/6/21 9 | */ 10 | @DatabaseTable(tableName = "HotCity") 11 | public class HotCity { 12 | 13 | public static final String ID_FIELD_NAME = "_id"; 14 | public static final String CITY_NAME_FIELD_NAME = "name"; 15 | public static final String CITY_ID_FIELD_NAME = "posID"; 16 | 17 | @DatabaseField(columnName = ID_FIELD_NAME, generatedId = true) 18 | private int id; 19 | @DatabaseField(columnName = CITY_ID_FIELD_NAME) 20 | private int cityId; 21 | @DatabaseField(columnName = CITY_NAME_FIELD_NAME) 22 | private String cityName; 23 | 24 | public int getCityId() { 25 | return cityId; 26 | } 27 | 28 | public void setCityId(int cityId) { 29 | this.cityId = cityId; 30 | } 31 | 32 | public String getCityName() { 33 | return cityName; 34 | } 35 | 36 | public void setCityName(String cityName) { 37 | this.cityName = cityName; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 天气 3 | baron.zhanglei@gmail.com 4 | http://baronzhang.com 5 | 城市选择 6 | 城市管理 7 | @string/action_fabric_test 8 | 9 | 打开抽屉 10 | 关闭抽屉 11 | 12 | 设置 13 | 关于 14 | 反馈 15 | Fabric Test 16 | 正在导入城市数据… 17 | 18 | 图片描述 19 | 20 | 21 | "发布时间 " 22 | 23 | 详情 24 | 预报 25 | 污染指数 26 | 生活指数 27 | / 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.base; 2 | 3 | 4 | import android.os.Bundle; 5 | import androidx.annotation.Nullable; 6 | import androidx.fragment.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | /** 12 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 13 | */ 14 | public class BaseFragment extends Fragment { 15 | 16 | // private PublishSubject fragmentLifecycleSubject = PublishSubject.create(); 17 | 18 | @Override 19 | public void onCreate(@Nullable Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | } 22 | 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 25 | Bundle savedInstanceState) { 26 | return super.onCreateView(inflater, container, savedInstanceState); 27 | } 28 | 29 | @Override 30 | public void onDestroyView() { 31 | // fragmentLifecycleSubject.onNext(FragmentLifecycleEvent.DESTROY_VIEW); 32 | super.onDestroyView(); 33 | } 34 | 35 | @Override 36 | public void onDestroy() { 37 | super.onDestroy(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_index_clod.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 13 | 17 | 21 | 22 | 23 | 24 | 28 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_vector_weather2.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_index_dress.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/http/entity/mi/MiIndex.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.http.entity.mi; 2 | 3 | /** 4 | * 小米天气生活指数 5 | * 6 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 7 | * 16/2/25 8 | */ 9 | public class MiIndex { 10 | 11 | private String code; 12 | private String details; 13 | private String index; 14 | private String name; 15 | 16 | public String getCode() { 17 | return code; 18 | } 19 | 20 | public void setCode(String code) { 21 | this.code = code; 22 | } 23 | 24 | public String getDetails() { 25 | return details; 26 | } 27 | 28 | public void setDetails(String details) { 29 | this.details = details; 30 | } 31 | 32 | public String getIndex() { 33 | return index; 34 | } 35 | 36 | public void setIndex(String index) { 37 | this.index = index; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "MiIndex{" + 51 | "code='" + code + '\'' + 52 | ", details='" + details + '\'' + 53 | ", index='" + index + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_vector_weather.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_index_shopping.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_index_sport.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/http/configuration/ApiConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.http.configuration; 2 | 3 | 4 | import com.baronzhang.android.weather.data.http.ApiConstants; 5 | 6 | /** 7 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 8 | * 2016/12/10 9 | */ 10 | public class ApiConfiguration { 11 | 12 | private int dataSourceType; 13 | 14 | private ApiConfiguration(Builder builder) { 15 | initialize(builder); 16 | } 17 | 18 | public static Builder builder() { 19 | return new Builder(); 20 | } 21 | 22 | private void initialize(final Builder builder) { 23 | this.dataSourceType = builder.dataSourceType; 24 | } 25 | 26 | public int getDataSourceType() { 27 | return dataSourceType; 28 | } 29 | 30 | public static final class Builder { 31 | 32 | private int dataSourceType; 33 | 34 | private Builder() { 35 | } 36 | 37 | public ApiConfiguration build() { 38 | if (dataSourceType != ApiConstants.WEATHER_DATA_SOURCE_TYPE_KNOW 39 | && dataSourceType != ApiConstants.WEATHER_DATA_SOURCE_TYPE_MI 40 | && dataSourceType != ApiConstants.WEATHER_DATA_SOURCE_TYPE_ENVIRONMENT_CLOUD) { 41 | throw new IllegalStateException("The dataSourceType does not support!"); 42 | } 43 | return new ApiConfiguration(this); 44 | } 45 | 46 | public Builder dataSourceType(int dataSourceType) { 47 | this.dataSourceType = dataSourceType; 48 | return this; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/db/entities/adapter/WeatherAdapter.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.db.entities.adapter; 2 | 3 | import com.baronzhang.android.weather.data.db.entities.minimalist.AirQualityLive; 4 | import com.baronzhang.android.weather.data.db.entities.minimalist.LifeIndex; 5 | import com.baronzhang.android.weather.data.db.entities.minimalist.Weather; 6 | import com.baronzhang.android.weather.data.db.entities.minimalist.WeatherForecast; 7 | import com.baronzhang.android.weather.data.db.entities.minimalist.WeatherLive; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 13 | * 16/2/25 14 | */ 15 | public abstract class WeatherAdapter { 16 | 17 | public abstract String getCityId(); 18 | 19 | public abstract String getCityName(); 20 | 21 | public abstract String getCityNameEn(); 22 | 23 | public abstract WeatherLive getWeatherLive(); 24 | 25 | public abstract List getWeatherForecasts(); 26 | 27 | public abstract List getLifeIndexes(); 28 | 29 | public abstract AirQualityLive getAirQualityLive(); 30 | 31 | public Weather getWeather() { 32 | 33 | Weather weather = new Weather(); 34 | weather.setCityId(getCityId()); 35 | weather.setCityName(getCityName()); 36 | weather.setCityNameEn(getCityNameEn()); 37 | weather.setAirQualityLive(getAirQualityLive()); 38 | weather.setWeatherForecasts(getWeatherForecasts()); 39 | weather.setLifeIndexes(getLifeIndexes()); 40 | weather.setWeatherLive(getWeatherLive()); 41 | return weather; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/system/MIUIHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util.system; 2 | 3 | import android.app.Activity; 4 | import android.view.Window; 5 | 6 | import java.lang.reflect.Field; 7 | import java.lang.reflect.Method; 8 | 9 | /** 10 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 11 | * 2017/6/2 12 | */ 13 | class MIUIHelper implements SystemHelper { 14 | 15 | /** 16 | * 设置状态栏字体图标为深色,需要MIUI6以上 17 | * 18 | * @param isFontColorDark 是否把状态栏字体及图标颜色设置为深色 19 | * @return boolean 成功执行返回true 20 | */ 21 | @Override 22 | public boolean setStatusBarLightMode(Activity activity, boolean isFontColorDark) { 23 | 24 | Window window = activity.getWindow(); 25 | boolean result = false; 26 | if (window != null) { 27 | Class clazz = window.getClass(); 28 | try { 29 | int darkModeFlag = 0; 30 | Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); 31 | Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); 32 | darkModeFlag = field.getInt(layoutParams); 33 | Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); 34 | if (isFontColorDark) { 35 | extraFlagField.invoke(window, darkModeFlag, darkModeFlag);//状态栏透明且黑色字体 36 | } else { 37 | extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体 38 | } 39 | result = true; 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.base; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.appcompat.app.AppCompatActivity; 6 | import androidx.appcompat.app.AppCompatDelegate; 7 | import androidx.appcompat.widget.SearchView; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | 11 | /** 12 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 13 | */ 14 | public class BaseActivity extends AppCompatActivity { 15 | 16 | /* 17 | * 解决Vector兼容性问题 18 | * 19 | * First up, this functionality was originally released in 23.2.0, 20 | * but then we found some memory usage and Configuration updating 21 | * issues so we it removed in 23.3.0. In 23.4.0 (technically a fix 22 | * release) we’ve re-added the same functionality but behind a flag 23 | * which you need to manually enable. 24 | * 25 | * http://www.jianshu.com/p/e3614e7abc03 26 | */ 27 | static { 28 | AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); 29 | } 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | } 35 | 36 | @Override 37 | protected void onDestroy() { 38 | super.onDestroy(); 39 | } 40 | 41 | 42 | @Override 43 | public boolean onCreateOptionsMenu(Menu menu) { 44 | return super.onCreateOptionsMenu(menu); 45 | } 46 | 47 | @Override 48 | public boolean onOptionsItemSelected(MenuItem item) { 49 | int id = item.getItemId(); 50 | if (id == android.R.id.home) { 51 | finish(); 52 | return true; 53 | } 54 | return super.onOptionsItemSelected(item); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 26 | 27 | 35 | 36 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /library/src/main/java/com/baronzhang/android/library/util/system/FlymeHelper.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.library.util.system; 2 | 3 | import android.app.Activity; 4 | import android.view.Window; 5 | import android.view.WindowManager; 6 | 7 | import java.lang.reflect.Field; 8 | 9 | /** 10 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 11 | * 2017/6/2 12 | */ 13 | class FlymeHelper implements SystemHelper { 14 | 15 | /** 16 | * 设置状态栏图标为深色和魅族特定的文字风格 17 | * 可以用来判断是否为 Flyme 用户 18 | * 19 | * @param isFontColorDark 是否把状态栏字体及图标颜色设置为深色 20 | * @return boolean 成功执行返回 true 21 | */ 22 | @Override 23 | public boolean setStatusBarLightMode(Activity activity, boolean isFontColorDark) { 24 | Window window = activity.getWindow(); 25 | boolean result = false; 26 | if (window != null) { 27 | try { 28 | WindowManager.LayoutParams lp = window.getAttributes(); 29 | Field darkFlag = WindowManager.LayoutParams.class 30 | .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); 31 | Field flymeFlags = WindowManager.LayoutParams.class 32 | .getDeclaredField("meizuFlags"); 33 | darkFlag.setAccessible(true); 34 | flymeFlags.setAccessible(true); 35 | int bit = darkFlag.getInt(null); 36 | int value = flymeFlags.getInt(lp); 37 | if (isFontColorDark) { 38 | value |= bit; 39 | } else { 40 | value &= ~bit; 41 | } 42 | flymeFlags.setInt(lp, value); 43 | window.setAttributes(lp); 44 | result = true; 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/data/http/service/EnvironmentCloudWeatherService.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.data.http.service; 2 | 3 | import com.baronzhang.android.weather.data.http.entity.envicloud.EnvironmentCloudCityAirLive; 4 | import com.baronzhang.android.weather.data.http.entity.envicloud.EnvironmentCloudForecast; 5 | import com.baronzhang.android.weather.data.http.entity.envicloud.EnvironmentCloudWeatherLive; 6 | 7 | import retrofit2.http.GET; 8 | import retrofit2.http.Path; 9 | import rx.Observable; 10 | 11 | /** 12 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 13 | * 2017/2/16 14 | */ 15 | public interface EnvironmentCloudWeatherService { 16 | 17 | /** 18 | * 获取指定城市的实时天气 19 | *

20 | * API地址:http://service.envicloud.cn:8082/v2/weatherlive/YMFYB256AGFUZZE0ODQ3MZM1MZE2NTU=/101020100 21 | * 22 | * @param cityId 城市id 23 | * @return Observable 24 | */ 25 | @GET("/v2/weatherlive/YMFYB256AGFUZZE0ODQ3MZM1MZE2NTU=/{cityId}") 26 | Observable getWeatherLive(@Path("cityId") String cityId); 27 | 28 | /** 29 | * 获取指定城市7日天气预报 30 | *

31 | * API地址:http://service.envicloud.cn:8082/v2/weatherforecast/YMFYB256AGFUZZE0ODQ3MZM1MZE2NTU=/101020100 32 | * 33 | * @param cityId 城市id 34 | * @return Observable 35 | */ 36 | @GET("/v2/weatherforecast/YMFYB256AGFUZZE0ODQ3MZM1MZE2NTU=/{cityId}") 37 | Observable getWeatherForecast(@Path("cityId") String cityId); 38 | 39 | /** 40 | * 获取指定城市的实时空气质量 41 | *

42 | * API地址:http://service.envicloud.cn:8082/v2/cityairlive/YMFYB256AGFUZZE0ODQ3MZM1MZE2NTU=/101020100 43 | * 44 | * @param cityId 城市id 45 | * @return Observable 46 | */ 47 | @GET("/v2/cityairlive/YMFYB256AGFUZZE0ODQ3MZM1MZE2NTU=/{cityId}") 48 | Observable getAirLive(@Path("cityId") String cityId); 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_life_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 26 | 27 | 36 | 37 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/baronzhang/android/weather/feature/selectcity/SelectCityPresenter.java: -------------------------------------------------------------------------------- 1 | package com.baronzhang.android.weather.feature.selectcity; 2 | 3 | import android.content.Context; 4 | 5 | import com.baronzhang.android.weather.data.db.dao.CityDao; 6 | import com.baronzhang.android.weather.di.component.DaggerPresenterComponent; 7 | import com.baronzhang.android.weather.di.module.ApplicationModule; 8 | import com.baronzhang.android.weather.di.scope.ActivityScoped; 9 | 10 | import javax.inject.Inject; 11 | 12 | import rx.Observable; 13 | import rx.Subscription; 14 | import rx.android.schedulers.AndroidSchedulers; 15 | import rx.schedulers.Schedulers; 16 | import rx.subscriptions.CompositeSubscription; 17 | 18 | /** 19 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 20 | */ 21 | @ActivityScoped 22 | public final class SelectCityPresenter implements SelectCityContract.Presenter { 23 | 24 | private final SelectCityContract.View cityListView; 25 | 26 | private CompositeSubscription subscriptions; 27 | 28 | @Inject 29 | CityDao cityDao; 30 | 31 | @Inject 32 | SelectCityPresenter(Context context, SelectCityContract.View view) { 33 | 34 | this.cityListView = view; 35 | this.subscriptions = new CompositeSubscription(); 36 | cityListView.setPresenter(this); 37 | 38 | DaggerPresenterComponent.builder() 39 | .applicationModule(new ApplicationModule(context)) 40 | .build().inject(this); 41 | } 42 | 43 | @Override 44 | public void loadCities() { 45 | Subscription subscription = Observable.just(cityDao.queryCityList()) 46 | .subscribeOn(Schedulers.io()) 47 | .observeOn(AndroidSchedulers.mainThread()) 48 | .subscribe(cityListView::displayCities); 49 | subscriptions.add(subscription); 50 | } 51 | 52 | @Override 53 | public void subscribe() { 54 | loadCities(); 55 | } 56 | 57 | @Override 58 | public void unSubscribe() { 59 | subscriptions.clear(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | compileOptions { 6 | sourceCompatibility JavaVersion.VERSION_1_8 7 | targetCompatibility JavaVersion.VERSION_1_8 8 | } 9 | 10 | compileSdkVersion rootProject.ext.android.compileSdkVersion 11 | defaultConfig { 12 | applicationId rootProject.ext.android.applicationId 13 | minSdkVersion rootProject.ext.android.minSdkVersion 14 | targetSdkVersion rootProject.ext.android.targetSdkVersion 15 | versionCode rootProject.ext.android.versionCode 16 | versionName rootProject.ext.android.versionName 17 | 18 | vectorDrawables.useSupportLibrary = true 19 | } 20 | buildTypes { 21 | debug { 22 | buildConfigField("boolean", "LOG_DEBUG", "true") 23 | buildConfigField 'com.baronzhang.android.weather.util.StethoHelper', 'STETHO', 'new com.baronzhang.android.weather.DebugStethoHelper()' 24 | } 25 | 26 | release { 27 | buildConfigField("boolean", "LOG_DEBUG", "false") 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | buildConfigField 'com.baronzhang.android.weather.util.StethoHelper', 'STETHO', 'new com.baronzhang.android.weather.util.stetho.ReleaseStethoHelper()' 31 | } 32 | } 33 | 34 | lintOptions { 35 | abortOnError false 36 | } 37 | } 38 | 39 | dependencies { 40 | implementation fileTree(include: ['*.jar'], dir: 'libs') 41 | testImplementation 'junit:junit:4.12' 42 | 43 | implementation project(':library') 44 | implementation project(':widget') 45 | 46 | implementation rootProject.ext.dependencies["butterknife"] 47 | annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] 48 | 49 | implementation rootProject.ext.dependencies["dagger"] 50 | annotationProcessor rootProject.ext.dependencies["dagger-compiler"] 51 | 52 | implementation rootProject.ext.dependencies["retrofit2-fastjson-converter"] 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_index_car_wash.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_drawer_menu_head.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 20 | 21 | 28 | 29 | 39 | 40 |