mirror of
https://github.com/xcc3641/SeeWeather.git
synced 2026-10-16 21:13:37 +08:00
get on the brucezz's bus
This commit is contained in:
+12
-11
@@ -65,14 +65,6 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
@@ -81,9 +73,16 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
@@ -107,7 +106,8 @@
|
||||
<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.3/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/crashreport/2.1.5/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.tencent.bugly/nativecrashreport/2.2.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/io.reactivex/rxandroid/1.1.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/jp.wasabeef/recyclerview-animators/2.2.3/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
@@ -140,8 +140,9 @@
|
||||
<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="crashreport-2.1.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-base-9.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="crashreport-2.1.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="nativecrashreport-2.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="animated-vector-drawable-23.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-23.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="recyclerview-v7-23.4.0" level="project" />
|
||||
|
||||
+3
-1
@@ -43,6 +43,7 @@ android {
|
||||
|
||||
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
retrolambda {
|
||||
@@ -72,7 +73,8 @@ dependencies {
|
||||
compile 'com.jakewharton:butterknife:7.0.1'
|
||||
compile 'jp.wasabeef:recyclerview-animators:2.2.3'
|
||||
|
||||
compile 'com.tencent.bugly:crashreport:latest.release'
|
||||
compile 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.1.5
|
||||
compile 'com.tencent.bugly:nativecrashreport:latest.release' //其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
|
||||
|
||||
debugCompile 'com.github.moduth:blockcanary-android:1.2.1'
|
||||
releaseCompile 'com.github.moduth:blockcanary-no-op:1.2.1'
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.transpant"/>
|
||||
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.view.WindowManager;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
import com.xiecc.seeWeather.common.ACache;
|
||||
import com.xiecc.seeWeather.modules.setting.Setting;
|
||||
import rx.subscriptions.CompositeSubscription;
|
||||
|
||||
/**
|
||||
* Created by hugo on 2015/12/16.
|
||||
@@ -19,6 +20,8 @@ public class BaseActivity extends AppCompatActivity {
|
||||
public ACache aCache;
|
||||
public Setting mSetting = null;
|
||||
|
||||
protected CompositeSubscription compositeSubscription = new CompositeSubscription();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -80,4 +83,16 @@ public class BaseActivity extends AppCompatActivity {
|
||||
public void showSnackbar(View view, String s, boolean ture) {
|
||||
Snackbar.make(view, s, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
//compositeSubscription.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
compositeSubscription.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,11 @@ public class BaseApplication extends Application {
|
||||
// 初始化 retrofit
|
||||
RetrofitSingleton.init();
|
||||
CrashHandler.init(new CrashHandler(getApplicationContext()));
|
||||
CrashReport.initCrashReport(getApplicationContext(), "900030389", false);
|
||||
CrashReport.initCrashReport(getApplicationContext(), "900028220", false);
|
||||
BlockCanary.install(this, new AppBlockCanaryContext()).start();
|
||||
LeakCanary.install(this);
|
||||
RxUtils.unifiedErrorHandler();
|
||||
//Thread.setDefaultUncaughtExceptionHandler(new MyUnCaughtExceptionHandler());
|
||||
|
||||
/**
|
||||
* 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.xiecc.seeWeather.base;
|
||||
|
||||
import rx.Observable;
|
||||
import rx.subjects.PublishSubject;
|
||||
import rx.subjects.SerializedSubject;
|
||||
import rx.subjects.Subject;
|
||||
|
||||
/**
|
||||
* RxBus
|
||||
* Created by YoKeyword on 2015/6/17.
|
||||
*/
|
||||
public class RxBus {
|
||||
|
||||
private static volatile RxBus instance;
|
||||
// 主题
|
||||
private final Subject bus;
|
||||
|
||||
// PublishSubject只会把在订阅发生的时间点之后来自原始Observable的数据发射给观察者
|
||||
public RxBus() {
|
||||
bus = new SerializedSubject<>(PublishSubject.create());
|
||||
}
|
||||
|
||||
// 单例RxBus
|
||||
public static RxBus getDefault() {
|
||||
if (instance == null) {
|
||||
synchronized (RxBus.class) {
|
||||
if (instance == null) {
|
||||
instance = new RxBus();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// 提供了一个新的事件
|
||||
public void post(Object o) {
|
||||
bus.onNext(o);
|
||||
}
|
||||
|
||||
// 根据传递的 eventType 类型返回特定类型(eventType)的 被观察者
|
||||
public <T> Observable<T> toObserverable(Class<T> eventType) {
|
||||
return bus.ofType(eventType);
|
||||
// 这里感谢小鄧子的提醒: ofType = filter + cast
|
||||
// return bus.filter(new Func1<Object, Boolean>() {
|
||||
// @Override
|
||||
// public Boolean call(Object o) {
|
||||
// return eventType.isInstance(o);
|
||||
// }
|
||||
// }) .cast(eventType);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.xiecc.seeWeather.common;
|
||||
|
||||
import android.content.Context;
|
||||
import com.xiecc.seeWeather.common.utils.Util;
|
||||
import com.xiecc.seeWeather.modules.setting.Setting;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
@@ -36,16 +37,15 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
PLog.e(TAG, ex.toString());
|
||||
PLog.e(TAG, collectCrashDeviceInfo());
|
||||
PLog.e(TAG, getCrashInfo(ex));
|
||||
|
||||
Setting mSetting = Setting.getInstance();
|
||||
mSetting.setCityName("北京");
|
||||
// 调用系统错误机制
|
||||
defaultHandler.uncaughtException(thread, ex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 得到程序崩溃的详细信息
|
||||
*
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
public String getCrashInfo(Throwable ex) {
|
||||
Writer result = new StringWriter();
|
||||
@@ -55,11 +55,8 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 收集程序崩溃的设备信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String collectCrashDeviceInfo() {
|
||||
|
||||
@@ -69,8 +66,5 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
String manufacturer = android.os.Build.MANUFACTURER;
|
||||
|
||||
return versionName + " " + model + " " + androidVersion + " " + manufacturer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.text.TextUtils;
|
||||
import com.xiecc.seeWeather.R;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -106,7 +108,7 @@ public class Util {
|
||||
* 安全的 String 返回
|
||||
*
|
||||
* @param prefix 默认字段
|
||||
* @param obj 拼接字段
|
||||
* @param obj 拼接字段 (需检查)
|
||||
*/
|
||||
public static String safeText(String prefix, String obj) {
|
||||
if (TextUtils.isEmpty(obj)) return "";
|
||||
@@ -114,7 +116,7 @@ public class Util {
|
||||
}
|
||||
|
||||
public static String safeText(String msg) {
|
||||
return safeText(msg, "");
|
||||
return safeText("", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,4 +145,17 @@ public class Util {
|
||||
city = safeText(city).replaceAll("(?:省|市|自治区|特别行政区|地区|盟)", "");
|
||||
return city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java 中有一个 Closeable 接口,标识了一个可关闭的对象,它只有一个 close 方法.
|
||||
*/
|
||||
public static void closeQuietly(Closeable closeable) {
|
||||
if (null != closeable) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,6 @@ public class RetrofitSingleton {
|
||||
private static OkHttpClient okHttpClient = null;
|
||||
private static final String TAG = RetrofitSingleton.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public static void init() {
|
||||
initOkHttp();
|
||||
initRetrofit();
|
||||
@@ -48,7 +45,7 @@ public class RetrofitSingleton {
|
||||
private static void initOkHttp() {
|
||||
// https://drakeet.me/retrofit-2-0-okhttp-3-0-config
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
okHttpClient = new OkHttpClient.Builder()
|
||||
.addInterceptor(interceptor)
|
||||
.retryOnConnectionFailure(true)
|
||||
@@ -77,7 +74,13 @@ public class RetrofitSingleton {
|
||||
|
||||
public Observable<Weather> fetchWeather(String city) {
|
||||
return apiService.mWeatherAPI(city, C.KEY)
|
||||
.filter(weatherAPI -> weatherAPI.mHeWeatherDataService30s.get(0).status.equals("ok"))
|
||||
//.filter(weatherAPI -> weatherAPI.mHeWeatherDataService30s.get(0).status.equals("ok"))
|
||||
.flatMap(weatherAPI -> {
|
||||
if (weatherAPI.mHeWeatherDataService30s.get(0).status.equals("no more requests")) {
|
||||
return Observable.error(new RuntimeException("/(ㄒoㄒ)/~~,API免费次数已用完"));
|
||||
}
|
||||
return Observable.just(weatherAPI);
|
||||
})
|
||||
.map(weatherAPI -> weatherAPI.mHeWeatherDataService30s.get(0))
|
||||
.compose(RxUtils.rxSchedulerHelper());
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DBManager {
|
||||
|
||||
|
||||
public void openDatabase() {
|
||||
PLog.e(TAG, DB_PATH + "/" + DB_NAME);
|
||||
//PLog.e(TAG, DB_PATH + "/" + DB_NAME);
|
||||
this.database = this.openDatabase(DB_PATH + "/" + DB_NAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xiecc.seeWeather.modules.city.db;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import com.xiecc.seeWeather.common.utils.Util;
|
||||
import com.xiecc.seeWeather.modules.city.domain.City;
|
||||
import com.xiecc.seeWeather.modules.city.domain.Province;
|
||||
import java.util.ArrayList;
|
||||
@@ -13,7 +14,6 @@ import java.util.List;
|
||||
*/
|
||||
public class WeatherDB {
|
||||
|
||||
|
||||
public WeatherDB() {
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class WeatherDB {
|
||||
list.add(province);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
Util.closeQuietly(cursor);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ public class WeatherDB {
|
||||
list.add(city);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
Util.closeQuietly(cursor);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import com.xiecc.seeWeather.R;
|
||||
import com.xiecc.seeWeather.base.BaseActivity;
|
||||
import com.xiecc.seeWeather.base.RxBus;
|
||||
import com.xiecc.seeWeather.common.PLog;
|
||||
import com.xiecc.seeWeather.common.utils.RxUtils;
|
||||
import com.xiecc.seeWeather.component.ImageLoader;
|
||||
@@ -24,7 +25,7 @@ import com.xiecc.seeWeather.modules.city.db.DBManager;
|
||||
import com.xiecc.seeWeather.modules.city.db.WeatherDB;
|
||||
import com.xiecc.seeWeather.modules.city.domain.City;
|
||||
import com.xiecc.seeWeather.modules.city.domain.Province;
|
||||
import com.xiecc.seeWeather.modules.setting.Setting;
|
||||
import com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import jp.wasabeef.recyclerview.animators.FadeInUpAnimator;
|
||||
@@ -112,8 +113,11 @@ public class ChoiceCityActivity extends BaseActivity {
|
||||
selectedCity = cityList.get(pos);
|
||||
Intent intent = new Intent();
|
||||
String cityName = selectedCity.CityName;
|
||||
intent.putExtra(Setting.CITY_NAME, cityName);
|
||||
setResult(2, intent);
|
||||
//intent.putExtra(Setting.CITY_NAME, cityName);
|
||||
//setResult(2, intent);
|
||||
mSetting.setCityName(cityName);
|
||||
RxBus.getDefault().post(new ChangeCityEvent());
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiecc.seeWeather.modules.main.domain;
|
||||
|
||||
/**
|
||||
* Created by HugoXie on 16/6/2.
|
||||
*
|
||||
* Email: Hugo3641@gamil.com
|
||||
* GitHub: https://github.com/xcc3641
|
||||
* Info:
|
||||
*/
|
||||
public class ChangeCityEvent {
|
||||
|
||||
String city;
|
||||
|
||||
public ChangeCityEvent() {
|
||||
}
|
||||
|
||||
public ChangeCityEvent(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
}
|
||||
@@ -46,14 +46,17 @@ import com.tbruyelle.rxpermissions.RxPermissions;
|
||||
import com.xiecc.seeWeather.R;
|
||||
import com.xiecc.seeWeather.base.BaseActivity;
|
||||
import com.xiecc.seeWeather.base.C;
|
||||
import com.xiecc.seeWeather.base.RxBus;
|
||||
import com.xiecc.seeWeather.common.PLog;
|
||||
import com.xiecc.seeWeather.common.utils.CheckVersion;
|
||||
import com.xiecc.seeWeather.common.utils.ToastUtil;
|
||||
import com.xiecc.seeWeather.common.utils.Util;
|
||||
import com.xiecc.seeWeather.component.ImageLoader;
|
||||
import com.xiecc.seeWeather.component.RetrofitSingleton;
|
||||
import com.xiecc.seeWeather.modules.about.ui.AboutActivity;
|
||||
import com.xiecc.seeWeather.modules.city.ui.ChoiceCityActivity;
|
||||
import com.xiecc.seeWeather.modules.main.adapter.WeatherAdapter;
|
||||
import com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent;
|
||||
import com.xiecc.seeWeather.modules.main.domain.Weather;
|
||||
import com.xiecc.seeWeather.modules.main.listener.HidingScrollListener;
|
||||
import com.xiecc.seeWeather.modules.service.AutoUpdateService;
|
||||
@@ -62,6 +65,7 @@ import com.xiecc.seeWeather.modules.setting.ui.SettingActivity;
|
||||
import java.util.Calendar;
|
||||
import rx.Observable;
|
||||
import rx.Observer;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
|
||||
// TODO: 16/5/18 config.gradle 未提示 整合 retrofit 的使用
|
||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener,
|
||||
@@ -114,13 +118,35 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
PLog.i("onStart");
|
||||
showEggs();
|
||||
compositeSubscription.add(
|
||||
RxBus.getDefault().toObserverable(ChangeCityEvent.class).observeOn(AndroidSchedulers.mainThread()).subscribe(
|
||||
changeCityEvent -> {
|
||||
mRefreshLayout.setRefreshing(true);
|
||||
load();
|
||||
}, throwable -> {
|
||||
PLog.e(throwable.getMessage())
|
||||
;
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
PLog.i("onRestart");
|
||||
//为了实现 Intent 重启使图标生效
|
||||
initIcon();
|
||||
// 修改 adapter 的初始化
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
PLog.i("onResume");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@@ -131,6 +157,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
PLog.i("onStop");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,10 +418,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
*/
|
||||
private Observable<Weather> fetchDataByNetWork() {
|
||||
String cityName = Util.replaceCity(mSetting.getCityName());
|
||||
PLog.i("网络请求");
|
||||
return RetrofitSingleton.getInstance()
|
||||
.fetchWeather(cityName)
|
||||
.onErrorReturn(throwable -> {
|
||||
PLog.e(throwable.getMessage());
|
||||
ToastUtil.showLong(throwable.getMessage());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -504,16 +533,16 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
//requestCode标示请求的标示 resultCode表示有数据
|
||||
if (requestCode == 1 && resultCode == 2) {
|
||||
mRefreshLayout.setRefreshing(true);
|
||||
mSetting.setCityName(data.getStringExtra(Setting.CITY_NAME));
|
||||
load();
|
||||
}
|
||||
}
|
||||
//@Override
|
||||
//protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// super.onActivityResult(requestCode, resultCode, data);
|
||||
// //requestCode标示请求的标示 resultCode表示有数据
|
||||
// if (requestCode == 1 && resultCode == 2) {
|
||||
// mRefreshLayout.setRefreshing(true);
|
||||
// mSetting.setCityName(data.getStringExtra(Setting.CITY_NAME));
|
||||
// load();
|
||||
// }
|
||||
//}
|
||||
|
||||
private void normalStyleNotification(Weather weather) {
|
||||
Intent intent = new Intent(MainActivity.this, MainActivity.class);
|
||||
|
||||
+3
-1
@@ -12,5 +12,7 @@
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
#Wed Apr 13 13:42:18 CST 2016
|
||||
#Sat May 28 20:20:10 CST 2016
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=1080
|
||||
android.useDeprecatedNdk=true
|
||||
|
||||
Reference in New Issue
Block a user