Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
update new day/night method and delete some feature
Browse files Browse the repository at this point in the history
  • Loading branch information
谢晨成 authored and 谢晨成 committed Jul 9, 2016
1 parent 8d04d9b commit 14cbe6f
Show file tree
Hide file tree
Showing 26 changed files with 280 additions and 246 deletions.
27 changes: 5 additions & 22 deletions README_EN.md
Expand Up @@ -2,25 +2,6 @@

[中文版](https://github.com/xcc3641/SeeWeather/blob/master/README.md)[English](https://github.com/xcc3641/SeeWeather/blob/master/README_EN.md)


### Foreword

SeeWeather is my first relatively mature application,going on-line in the October 2015.And then I answered this question [how to learn Android by oneself](https://www.zhihu.com/question/26417244/answer/70193822) in the ZhiHu platform

Because my code was poorly written, I decided to refactor the whole project and made a new look to show SeeWeather Version 2.0.

If you find any problems and suggestion,you can e-mail me or open issues at any time.


**Attention**

**If you want to pull the project to run, you should apply for API at [和风天气](http://www.heweather.com/) and add it in Setting.java**

**If the application crashes, pleace e-mail the log(`/Android/data/com.xiecc.seeWeather/cache/Log`) to me**

- **open-source project is valuable, hope to give me a star for support**


### Brief introduction
SeeWeather is an following ** Material Design** Weather application.Use the least Permission to do the best with the least experience.

Expand Down Expand Up @@ -70,7 +51,7 @@ Kuan:http://www.coolapk.com/apk/com.xiecc.seeWeather


### TODO
I am a little busy in this semester,preparing for the job interview, but I will still complete to-do.

- [ ] Widget
- [ ] Notification
- [ ] Prettier Weather Icons
Expand All @@ -91,6 +72,7 @@ City Data:CSDN
City Orientation: 高德地图

#### Open-source project

1. [Rxjava](https://github.com/ReactiveX/RxJava)
2. [RxAndroid](https://github.com/ReactiveX/RxAndroid)
3. [Retrofit](https://github.com/square/retrofit)
Expand Down Expand Up @@ -138,8 +120,9 @@ _ _ _
### LICENSE

Copyright 2016 HugoXie Licensed under the Apache License, Version 2.0 (the \"License\")
you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


** Pictures from the network, the copyright belongs to the original author.**
Expand Down
19 changes: 1 addition & 18 deletions app/app.iml
Expand Up @@ -96,14 +96,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.bumptech.glide/okhttp3-integration/1.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.moduth/blockcanary-android/1.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.moduth/blockcanary-core/1.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-tasks/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-analytics-impl/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-analytics/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-common/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-core/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.firebase/firebase-iid/9.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.squareup.leakcanary/leakcanary-android/1.4-beta2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tbruyelle.rxpermissions/rxpermissions/0.7.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/crashreport/2.1.7/jars" />
Expand All @@ -118,7 +110,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
Expand All @@ -133,14 +124,12 @@
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="firebase-iid-9.0.0" level="project" />
<orderEntry type="library" exported="" name="blockcanary-android-1.2.1" level="project" />
<orderEntry type="library" exported="" name="gson-2.6.1" level="project" />
<orderEntry type="library" exported="" name="okio-1.6.0" level="project" />
<orderEntry type="library" exported="" name="okhttp3-integration-1.4.0" level="project" />
<orderEntry type="library" exported="" name="haha-2.0.2" level="project" />
<orderEntry type="library" exported="" name="recyclerview-animators-2.2.3" level="project" />
<orderEntry type="library" exported="" name="play-services-base-9.0.0" level="project" />
<orderEntry type="library" exported="" name="nativecrashreport-2.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-24.0.0" level="project" />
Expand All @@ -149,30 +138,24 @@
<orderEntry type="library" exported="" name="systembartint-1.0.3" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-24.0.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.7.0" level="project" />
<orderEntry type="library" exported="" name="firebase-common-9.0.0" level="project" />
<orderEntry type="library" exported="" name="firebase-core-9.0.0" level="project" />
<orderEntry type="library" exported="" name="leakcanary-android-1.4-beta2" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-24.0.0" level="project" />
<orderEntry type="library" exported="" name="rxpermissions-0.7.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-9.0.0" level="project" />
<orderEntry type="library" exported="" name="leakcanary-analyzer-1.4-beta2" level="project" />
<orderEntry type="library" exported="" name="retrofit-2.0.2" level="project" />
<orderEntry type="library" exported="" name="play-services-tasks-9.0.0" level="project" />
<orderEntry type="library" exported="" name="adapter-rxjava-2.0.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-24.0.0" level="project" />
<orderEntry type="library" exported="" name="rxandroid-1.1.0" level="project" />
<orderEntry type="library" exported="" name="converter-gson-2.0.2" level="project" />
<orderEntry type="library" exported="" name="rxjava-1.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.0.0" level="project" />
<orderEntry type="library" exported="" name="rxjava-1.1.1" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-24.0.0" level="project" />
<orderEntry type="library" exported="" name="AMap_Location_v2.3.0_20160112" level="project" />
<orderEntry type="library" exported="" name="logging-interceptor-3.0.1" level="project" />
<orderEntry type="library" exported="" name="firebase-analytics-impl-9.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="okhttp-3.2.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="leakcanary-watcher-1.4-beta2" level="project" />
<orderEntry type="library" exported="" name="firebase-analytics-9.0.0" level="project" />
<orderEntry type="library" exported="" name="blockcanary-core-1.2.1" level="project" />
</component>
</module>
4 changes: 2 additions & 2 deletions app/build.gradle
Expand Up @@ -74,7 +74,7 @@ dependencies {
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
// compile 'com.squareup.okio:okio:1.6.0'

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
compile 'com.jakewharton:butterknife:7.0.1'
Expand All @@ -89,6 +89,6 @@ dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'

compile 'com.google.firebase:firebase-core:9.0.0'

}

62 changes: 37 additions & 25 deletions app/src/main/java/com/xiecc/seeWeather/base/BaseActivity.java
Expand Up @@ -2,9 +2,8 @@

import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.support.v7.app.AppCompatDelegate;
import android.view.WindowManager;
import com.readystatesoftware.systembartint.SystemBarTintManager;
import com.xiecc.seeWeather.common.ACache;
Expand All @@ -26,23 +25,11 @@ public class BaseActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//overridePendingTransition(R.anim.zoom_enter,R.anim.zoom_exit);
if (savedInstanceState==null){
setTheme(this);
}
aCache = ACache.get(getApplication());
mSetting = Setting.getInstance();
/**
* http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/1122/3712.html
* 在BaseActivity.java里:我们通过判断当前sdk_int大于4.4(kitkat),则通过代码的形式设置status bar为透明
* (这里其实可以通过values-v19 的sytle.xml里设置windowTranslucentStatus属性为true来进行设置,但是在某些手机会不起效,所以采用代码的形式进行设置)。
* 还需要注意的是我们这里的AppCompatAcitivity是android.support.v7.app.AppCompatActivity支持包中的AppCompatAcitivity,
* 也是为了在低版本的android系统中兼容toolbar。
*/
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Window window = getWindow();
// // Translucent status bar
// window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
// WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
// WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//}
}

public CompositeSubscription getCompositeSubscription() {
Expand All @@ -68,6 +55,7 @@ public void setContentView(int layoutResID) {
* 设置状态栏颜色
* 也就是所谓沉浸式状态栏
*/
@Deprecated
public void setStatusBarColor(int color) {
/**
* Android4.4以上 但是抽屉有点冲突,目前就重写一个方法暂时解决4.4的问题
Expand All @@ -92,14 +80,6 @@ public void setStatusBarColorForKitkat(int color) {
}
}

public void showSnackbar(View view, String s) {
Snackbar.make(view, s, Snackbar.LENGTH_SHORT).show();
}

public void showSnackbar(View view, String s, boolean ture) {
Snackbar.make(view, s, Snackbar.LENGTH_LONG).show();
}

@Override
protected void onStop() {
super.onStop();
Expand All @@ -112,4 +92,36 @@ protected void onDestroy() {
this.mCompositeSubscription.unsubscribe();
}
}

public static void setDayTheme(AppCompatActivity activity) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
activity.getDelegate().setLocalNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
// 调用 recreate() 使设置生效
activity.recreate();
}

public static void setNightTheme(AppCompatActivity activity) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
activity.getDelegate().setLocalNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
// 调用 recreate() 使设置生效
activity.recreate();
}

public void setTheme(boolean isNights, AppCompatActivity activity) {
if (isNights) {
setNightTheme(activity);
} else {
setDayTheme(activity);
}
}

public void setTheme(AppCompatActivity activity) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
activity.recreate();
}
}
Expand Up @@ -2,6 +2,7 @@

import android.app.Application;
import android.content.Context;
import android.support.v7.app.AppCompatDelegate;
import com.github.moduth.blockcanary.BlockCanary;
import com.squareup.leakcanary.LeakCanary;
import com.tencent.bugly.crashreport.CrashReport;
Expand All @@ -17,6 +18,11 @@ public class BaseApplication extends Application {
public static String cacheDir = "";
public static Context mAppContext = null;

static {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
}

@Override
public void onCreate() {
super.onCreate();
Expand All @@ -37,6 +43,8 @@ public void onCreate() {
} else {
cacheDir = getApplicationContext().getCacheDir().toString();
}


}

private boolean ExistSDCard() {
Expand Down
Expand Up @@ -58,7 +58,12 @@ protected void setAppBarAlpha(float alpha) {
mAppBar.setAlpha(alpha);
}

@Override public boolean onOptionsItemSelected(MenuItem item) {
public Toolbar getToolbar() {
return mToolbar;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
Expand All @@ -74,5 +79,4 @@ protected void hideOrShowToolbar() {
.start();
mIsHidden = !mIsHidden;
}

}
@@ -0,0 +1,94 @@
package com.xiecc.seeWeather.common.utils;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AccelerateDecelerateInterpolator;

/**
* Created by HugoXie on 16/7/7.
*
* Email: Hugo3641@gamil.com
* GitHub: https://github.com/xcc3641
* Info: 焦点在 fab 上的 reveal 动画,切换 activity 使用
*/
public class RevealAnimUtil {

public interface OnRevealAnimationListener {
void onRevealHide();

void onRevealShow();
}

// 显示
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animateRevealShow(final Context context, final View view, final FloatingActionButton fab,
final int startRadius, @ColorRes final int color,
final OnRevealAnimationListener listener) {
// 获得开始焦点 fab 中心
int cx = (fab.getLeft() + fab.getRight()) / 2;
int cy = (fab.getTop() + fab.getBottom()) / 2;

float finalRadius = (float) Math.hypot(view.getWidth(), view.getHeight());

// 设置圆形显示动画
Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, finalRadius);
anim.setDuration(500);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.setVisibility(View.INVISIBLE);
//切换代码在动画开始时执行比较好
listener.onRevealShow();
}

@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
view.setBackgroundColor(ContextCompat.getColor(context, color));
view.setVisibility(View.VISIBLE);
}
});
anim.start();
}

// 圆圈凝聚效果
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animateRevealHide(
final Context context, final View view,
final int finalRadius, @ColorRes final int color,
final OnRevealAnimationListener listener
) {
int cx = (view.getLeft() + view.getRight()) / 2;
int cy = (view.getTop() + view.getBottom()) / 2;
int initialRadius = view.getWidth();
// 与入场动画的区别就是圆圈起始和终止的半径相反
Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, finalRadius);
anim.setDuration(300);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
view.setBackgroundColor(ContextCompat.getColor(context, color));
}

@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
listener.onRevealHide();
view.setVisibility(View.INVISIBLE);
}
});
anim.start();
}
}
Expand Up @@ -18,8 +18,6 @@ public static void load(Context context, @DrawableRes int imageRes, ImageView vi
Glide.with(context).load(imageRes).crossFade().into(view);
}



public static void clear(Context context) {
Glide.get(context).clearMemory();
}
Expand Down

0 comments on commit 14cbe6f

Please sign in to comment.