-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
561 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
## 0.0.3 | ||
|
||
- realized geo search. | ||
- 实现 Geo 搜索 | ||
|
||
## 0.0.2 | ||
- 实现 逐天天气查询 | ||
- 实现 逐时天气查询 | ||
- 实现 中国地区未来2小时内每5分钟降水查询 | ||
|
||
- realized daily weather query. | ||
- realized hourly weather query. | ||
- realized Precipitation query every 5 minutes in the next 2 hours in China. | ||
- 实现 逐天天气查询 | ||
- 实现 逐时天气查询 | ||
- 实现 中国地区未来2小时内每5分钟降水查询 | ||
|
||
## 0.0.1 | ||
|
||
- 实现 实时天气查询。 | ||
- realized now weather query. | ||
- 实现 实时天气查询。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
android/src/main/kotlin/com/fluttercandies/flutter_qweather/ApiGeo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package com.fluttercandies.flutter_qweather; | ||
|
||
import android.content.Context; | ||
|
||
import com.google.gson.Gson; | ||
import com.qweather.sdk.bean.base.Lang; | ||
import com.qweather.sdk.bean.base.Range; | ||
import com.qweather.sdk.bean.base.Type; | ||
import com.qweather.sdk.bean.geo.GeoBean; | ||
import com.qweather.sdk.bean.geo.GeoPoiBean; | ||
import com.qweather.sdk.view.QWeather; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import io.flutter.plugin.common.MethodChannel; | ||
|
||
public class ApiGeo { | ||
/// 城市信息查询 | ||
protected static void geoCityLookup(Context context, Object arguments, final MethodChannel.Result result) { | ||
@SuppressWarnings("unchecked") | ||
HashMap<String, Object> param = (HashMap<String, Object>) arguments; | ||
String location = (String) param.get("location"); | ||
String range = (String) param.get("range"); | ||
Integer number = (Integer) param.get("number"); | ||
assert range != null && number != null; | ||
QWeather.OnResultGeoListener onResultGeoListener = new QWeather.OnResultGeoListener() { | ||
@Override | ||
public void onError(Throwable throwable) { | ||
DebugPrint.print("geoCityLookup onError: " + throwable.getLocalizedMessage()); | ||
result.success(null); | ||
} | ||
|
||
@Override | ||
public void onSuccess(GeoBean geoBean) { | ||
Gson gson = new Gson(); | ||
String jsonStr = gson.toJson(geoBean); | ||
jsonStr = jsonStr.replace("locationBean", "locations"); | ||
DebugPrint.print("geoCityLookup onSuccess: " + jsonStr); | ||
result.success(gson.fromJson(jsonStr, Map.class)); | ||
} | ||
}; | ||
QWeather.getGeoCityLookup(context, location, Range.valueOf(range.toUpperCase()), number, Lang.ZH_HANS, onResultGeoListener); | ||
} | ||
|
||
/// 热门城市查询 | ||
protected static void getGeoTopCity(Context context, Object arguments, final MethodChannel.Result result) { | ||
@SuppressWarnings("unchecked") | ||
HashMap<String, Object> param = (HashMap<String, Object>) arguments; | ||
String range = (String) param.get("range"); | ||
Integer number = (Integer) param.get("number"); | ||
assert range != null && number != null; | ||
QWeather.OnResultGeoListener onResultGeoListener = new QWeather.OnResultGeoListener() { | ||
@Override | ||
public void onError(Throwable throwable) { | ||
DebugPrint.print("getGeoTopCity onError: " + throwable.getLocalizedMessage()); | ||
result.success(null); | ||
} | ||
|
||
@Override | ||
public void onSuccess(GeoBean geoBean) { | ||
Gson gson = new Gson(); | ||
String jsonStr = gson.toJson(geoBean); | ||
jsonStr = jsonStr.replace("locationBean", "locations"); | ||
DebugPrint.print("getGeoTopCity onSuccess: " + jsonStr); | ||
result.success(gson.fromJson(jsonStr, Map.class)); | ||
} | ||
}; | ||
QWeather.getGeoTopCity(context, number, Range.valueOf(range.toUpperCase()), Lang.ZH_HANS, onResultGeoListener); | ||
} | ||
|
||
/// POI信息搜索 | ||
protected static void geoPoiLookup(Context context, Object arguments, final MethodChannel.Result result) { | ||
@SuppressWarnings("unchecked") | ||
HashMap<String, Object> param = (HashMap<String, Object>) arguments; | ||
String location = (String) param.get("location"); | ||
String city = (String) param.get("city"); | ||
String type = (String) param.get("type"); | ||
Integer number = (Integer) param.get("number"); | ||
assert type != null && number != null; | ||
QWeather.OnResultGeoPoiListener onResultGeoPoiListener = new QWeather.OnResultGeoPoiListener() { | ||
@Override | ||
public void onError(Throwable throwable) { | ||
DebugPrint.print("geoPoiLookup onError: " + throwable.getLocalizedMessage()); | ||
result.success(null); | ||
} | ||
|
||
@Override | ||
public void onSuccess(GeoPoiBean geoPoiBean) { | ||
Gson gson = new Gson(); | ||
String jsonStr = gson.toJson(geoPoiBean); | ||
jsonStr = jsonStr.replace("poiList", "locations"); | ||
DebugPrint.print("geoPoiLookup onSuccess: " + jsonStr); | ||
result.success(gson.fromJson(jsonStr, Map.class)); | ||
} | ||
}; | ||
QWeather.getGeoPoiLookup(context, location, city, number, Type.valueOf(type.toUpperCase()), Lang.ZH_HANS, onResultGeoPoiListener); | ||
} | ||
|
||
/// POI范围搜索 | ||
protected static void geoPoiRangeLookup(Context context, Object arguments, final MethodChannel.Result result) { | ||
@SuppressWarnings("unchecked") | ||
HashMap<String, Object> param = (HashMap<String, Object>) arguments; | ||
String location = (String) param.get("location"); | ||
String type = (String) param.get("type"); | ||
Integer radius = (Integer) param.get("radius"); | ||
Integer number = (Integer) param.get("number"); | ||
assert type != null && number != null && radius != null; | ||
QWeather.OnResultGeoPoiListener onResultGeoPoiListener = new QWeather.OnResultGeoPoiListener() { | ||
@Override | ||
public void onError(Throwable throwable) { | ||
DebugPrint.print("geoPoiRangeLookup onError: " + throwable.getLocalizedMessage()); | ||
result.success(null); | ||
} | ||
|
||
@Override | ||
public void onSuccess(GeoPoiBean geoPoiBean) { | ||
Gson gson = new Gson(); | ||
String jsonStr = gson.toJson(geoPoiBean); | ||
jsonStr = jsonStr.replace("poiList", "locations"); | ||
DebugPrint.print("geoPoiRangeLookup onSuccess: " + jsonStr); | ||
result.success(gson.fromJson(jsonStr, Map.class)); | ||
} | ||
}; | ||
QWeather.getGeoPoiRange(context, location, radius, number, Type.valueOf(type.toUpperCase()), Lang.ZH_HANS, onResultGeoPoiListener); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// ApiGeo.h | ||
// flutter_qweather | ||
// | ||
// Created by CyJay on 2021/5/31. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <Flutter/Flutter.h> | ||
#import <QWeather/QWeather.h> | ||
|
||
|
||
@interface ApiGeo : NSObject | ||
/// 城市信息查询 | ||
+ (void) geoCityLookup:(id)param result:(FlutterResult)result; | ||
/// 热门城市查询 | ||
+ (void) getGeoTopCity:(id)param result:(FlutterResult)result; | ||
/// POI信息搜索 | ||
+ (void) geoPoiLookup:(id)param result:(FlutterResult)result; | ||
/// POI范围搜索 | ||
+ (void) geoPoiRangeLookup:(id)param result:(FlutterResult)result; | ||
@end |
Oops, something went wrong.