├── .classpath
├── .gitignore
├── .project
├── .settings
└── org.eclipse.core.resources.prefs
├── AndroidManifest.xml
├── README.md
├── assets
└── area.db
├── bin
├── AndroidManifest.xml
├── classes
│ └── com
│ │ └── akasuna
│ │ └── kweather
│ │ ├── BootReceiver.class
│ │ ├── BuildConfig.class
│ │ ├── Config.class
│ │ ├── DB.class
│ │ ├── MyApp.class
│ │ ├── R$attr.class
│ │ ├── R$drawable.class
│ │ ├── R$id.class
│ │ ├── R$layout.class
│ │ ├── R$menu.class
│ │ ├── R$string.class
│ │ ├── R$style.class
│ │ ├── R$xml.class
│ │ ├── R.class
│ │ ├── SelectArea$1.class
│ │ ├── SelectArea$AsyncLoader.class
│ │ ├── SelectArea$UpdateData.class
│ │ ├── SelectArea.class
│ │ ├── WeatherActivity$1.class
│ │ ├── WeatherActivity$UpdateData.class
│ │ ├── WeatherActivity.class
│ │ ├── WeatherWidget$UpdateData.class
│ │ ├── WeatherWidget.class
│ │ └── WeatherWidgetConfig.class
├── jarlist.cache
└── res
│ ├── drawable-hdpi
│ ├── ic_launcher.png
│ ├── ic_menu_about.png
│ ├── ic_menu_refresh.png
│ ├── ic_menu_settings.png
│ └── widget_background.png
│ ├── drawable-ldpi
│ └── ic_launcher.png
│ └── drawable-mdpi
│ └── ic_launcher.png
├── gen
└── com
│ └── akasuna
│ └── kweather
│ ├── BuildConfig.java
│ └── R.java
├── proguard.cfg
├── project.properties
├── res
├── drawable-hdpi
│ ├── ic_launcher.png
│ ├── ic_menu_about.png
│ ├── ic_menu_refresh.png
│ ├── ic_menu_settings.png
│ ├── kweather_screen.jpg
│ ├── kweather_screen2.jpg
│ ├── w0.gif
│ ├── w1.gif
│ ├── w10.gif
│ ├── w11.gif
│ ├── w12.gif
│ ├── w13.gif
│ ├── w14.gif
│ ├── w15.gif
│ ├── w16.gif
│ ├── w17.gif
│ ├── w18.gif
│ ├── w19.gif
│ ├── w2.gif
│ ├── w20.gif
│ ├── w21.gif
│ ├── w22.gif
│ ├── w23.gif
│ ├── w24.gif
│ ├── w25.gif
│ ├── w26.gif
│ ├── w27.gif
│ ├── w28.gif
│ ├── w29.gif
│ ├── w3.gif
│ ├── w30.gif
│ ├── w31.gif
│ ├── w4.gif
│ ├── w5.gif
│ ├── w6.gif
│ ├── w7.gif
│ ├── w8.gif
│ ├── w9.gif
│ └── widget_background.png
├── drawable-ldpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── layout
│ ├── list_item.xml
│ ├── main.xml
│ ├── weather_list.xml
│ ├── weatherwidgetconfig.xml
│ └── widget.xml
├── menu
│ └── menu.xml
├── values
│ ├── strings.xml
│ └── styles.xml
└── xml
│ └── widget_stuff.xml
└── src
└── com
└── akasuna
└── kweather
├── BootReceiver.java
├── Config.java
├── DB.java
├── Func.java
├── MyApp.java
├── SelectArea.java
├── WeatherActivity.java
├── WeatherWidget.java
└── WeatherWidgetConfig.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 |
15 | # Local configuration file (sdk path, etc)
16 | local.properties
17 |
18 | # Eclipse project files
19 | .classpath
20 | .project
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Intellij project files
26 | *.iml
27 | *.ipr
28 | *.iws
29 | .idea/
30 |
31 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | KWeather
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/com/akasuna/kweather/Func.java=UTF-8
3 | encoding//src/com/akasuna/kweather/SelectArea.java=UTF-8
4 | encoding//src/com/akasuna/kweather/WeatherActivity.java=UTF-8
5 | encoding//src/com/akasuna/kweather/WeatherWidget.java=UTF-8
6 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
41 |
42 |
49 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # KWeather
2 |
3 | KWeather 是一个 Android 平台上开发天气预报程序的示例,可以提供中国大陆及香港、澳门、台湾各城市实时天气,所有数据来源于中国国家气象局,准确率相当高。
4 |
5 | 
6 | 
7 |
--------------------------------------------------------------------------------
/assets/area.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/assets/area.db
--------------------------------------------------------------------------------
/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
41 |
42 |
49 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/BootReceiver.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/BootReceiver.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/BuildConfig.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/Config.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/Config.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/DB.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/DB.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/MyApp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/MyApp.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$attr.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$drawable.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$id.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$layout.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$menu.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$string.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$style.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R$xml.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R$xml.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/R.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/SelectArea$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/SelectArea$1.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/SelectArea$AsyncLoader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/SelectArea$AsyncLoader.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/SelectArea$UpdateData.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/SelectArea$UpdateData.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/SelectArea.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/SelectArea.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/WeatherActivity$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/WeatherActivity$1.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/WeatherActivity$UpdateData.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/WeatherActivity$UpdateData.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/WeatherActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/WeatherActivity.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/WeatherWidget$UpdateData.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/WeatherWidget$UpdateData.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/WeatherWidget.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/WeatherWidget.class
--------------------------------------------------------------------------------
/bin/classes/com/akasuna/kweather/WeatherWidgetConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/classes/com/akasuna/kweather/WeatherWidgetConfig.class
--------------------------------------------------------------------------------
/bin/jarlist.cache:
--------------------------------------------------------------------------------
1 | # cache for current jar dependecy. DO NOT EDIT.
2 | # format is
3 | # Encoding is UTF-8
4 |
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_menu_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-hdpi/ic_menu_about.png
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_menu_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-hdpi/ic_menu_refresh.png
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_menu_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-hdpi/ic_menu_settings.png
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/widget_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-hdpi/widget_background.png
--------------------------------------------------------------------------------
/bin/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gen/com/akasuna/kweather/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.akasuna.kweather;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/gen/com/akasuna/kweather/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.akasuna.kweather;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int ic_launcher=0x7f020000;
15 | public static final int ic_menu_about=0x7f020001;
16 | public static final int ic_menu_refresh=0x7f020002;
17 | public static final int ic_menu_settings=0x7f020003;
18 | public static final int kweather_screen=0x7f020004;
19 | public static final int kweather_screen2=0x7f020005;
20 | public static final int w0=0x7f020006;
21 | public static final int w1=0x7f020007;
22 | public static final int w10=0x7f020008;
23 | public static final int w11=0x7f020009;
24 | public static final int w12=0x7f02000a;
25 | public static final int w13=0x7f02000b;
26 | public static final int w14=0x7f02000c;
27 | public static final int w15=0x7f02000d;
28 | public static final int w16=0x7f02000e;
29 | public static final int w17=0x7f02000f;
30 | public static final int w18=0x7f020010;
31 | public static final int w19=0x7f020011;
32 | public static final int w2=0x7f020012;
33 | public static final int w20=0x7f020013;
34 | public static final int w21=0x7f020014;
35 | public static final int w22=0x7f020015;
36 | public static final int w23=0x7f020016;
37 | public static final int w24=0x7f020017;
38 | public static final int w25=0x7f020018;
39 | public static final int w26=0x7f020019;
40 | public static final int w27=0x7f02001a;
41 | public static final int w28=0x7f02001b;
42 | public static final int w29=0x7f02001c;
43 | public static final int w3=0x7f02001d;
44 | public static final int w30=0x7f02001e;
45 | public static final int w31=0x7f02001f;
46 | public static final int w4=0x7f020020;
47 | public static final int w5=0x7f020021;
48 | public static final int w6=0x7f020022;
49 | public static final int w7=0x7f020023;
50 | public static final int w8=0x7f020024;
51 | public static final int w9=0x7f020025;
52 | public static final int widget_background=0x7f020026;
53 | }
54 | public static final class id {
55 | public static final int about=0x7f080017;
56 | public static final int bwidgetconfig=0x7f08000f;
57 | public static final int etwidgetconfig=0x7f08000e;
58 | public static final int imgDayWeatherImage=0x7f080003;
59 | public static final int imgImg=0x7f080010;
60 | public static final int imgNightWeatherImage=0x7f080009;
61 | public static final int set=0x7f080016;
62 | public static final int tvArea=0x7f080000;
63 | public static final int tvCity=0x7f080012;
64 | public static final int tvDate=0x7f080001;
65 | public static final int tvDay=0x7f080002;
66 | public static final int tvDayTemp=0x7f080005;
67 | public static final int tvDayWeatherDesc=0x7f080004;
68 | public static final int tvDayWindDesc=0x7f080006;
69 | public static final int tvDayWindValue=0x7f080007;
70 | public static final int tvNight=0x7f080008;
71 | public static final int tvNightTemp=0x7f08000b;
72 | public static final int tvNightWeatherDesc=0x7f08000a;
73 | public static final int tvNightWindDesc=0x7f08000c;
74 | public static final int tvNightWindValue=0x7f08000d;
75 | public static final int tvTemp=0x7f080011;
76 | public static final int tvTempF=0x7f080014;
77 | public static final int tvWeather=0x7f080013;
78 | public static final int update=0x7f080015;
79 | }
80 | public static final class layout {
81 | public static final int list_item=0x7f030000;
82 | public static final int main=0x7f030001;
83 | public static final int weather_list=0x7f030002;
84 | public static final int weatherwidgetconfig=0x7f030003;
85 | public static final int widget=0x7f030004;
86 | }
87 | public static final class menu {
88 | public static final int menu=0x7f070000;
89 | }
90 | public static final class string {
91 | public static final int app_name=0x7f050001;
92 | public static final int hello=0x7f050000;
93 | }
94 | public static final class style {
95 | public static final int text_shadow=0x7f060000;
96 | }
97 | public static final class xml {
98 | public static final int widget_stuff=0x7f040000;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-8
12 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_menu_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/ic_menu_about.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_menu_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/ic_menu_refresh.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_menu_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/ic_menu_settings.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/kweather_screen.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/kweather_screen.jpg
--------------------------------------------------------------------------------
/res/drawable-hdpi/kweather_screen2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/kweather_screen2.jpg
--------------------------------------------------------------------------------
/res/drawable-hdpi/w0.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w0.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w1.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w10.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w10.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w11.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w11.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w12.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w12.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w13.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w13.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w14.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w14.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w15.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w15.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w16.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w17.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w17.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w18.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w18.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w19.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w19.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w2.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w20.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w20.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w21.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w21.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w22.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w22.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w23.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w23.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w24.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w24.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w25.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w25.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w26.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w26.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w27.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w27.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w28.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w28.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w29.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w29.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w3.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w30.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w30.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w31.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w31.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w4.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w5.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w6.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w6.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w7.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w8.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/w9.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/w9.gif
--------------------------------------------------------------------------------
/res/drawable-hdpi/widget_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-hdpi/widget_background.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsalongstory/KWeather/750e7bdc5b697364a8dae5b898405145f8e492d6/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/res/layout/weather_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
26 |
27 |
33 |
34 |
39 |
40 |
46 |
47 |
53 |
54 |
60 |
61 |
67 |
68 |
69 |
74 |
75 |
81 |
82 |
87 |
88 |
94 |
95 |
101 |
102 |
108 |
109 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/res/layout/weatherwidgetconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/res/layout/widget.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
26 |
27 |
34 |
35 |
44 |
45 |
59 |
60 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World, WeatherActivity!
5 | KWeather
6 |
7 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/res/xml/widget_stuff.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/BootReceiver.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | public class BootReceiver extends BroadcastReceiver {
8 |
9 | @Override
10 | public void onReceive(Context context, Intent intent) {
11 | // TODO Auto-generated method stub
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/Config.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 |
4 | public class Config {
5 | public static final String DB_PATH = "/data/data/com.akasuna.kweather/databases/";
6 | public static final String DB_NAME = "area.db";
7 |
8 | public static final String URL = "http://www.weather.com.cn/data/sk/areano.html";
9 | public static final String URLExt = "http://m.weather.com.cn/data/areano.html";
10 |
11 | public static String strJSON = "";
12 | public static String strJSONExt = "";
13 | public static String strUpdateTime = "";
14 | }
15 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/DB.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import android.database.Cursor;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | public class DB {
7 |
8 | private static DB db = new DB();
9 |
10 | private DB() {
11 |
12 | }
13 |
14 | public static DB GetDB() {
15 | return db;
16 | }
17 |
18 | private SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(Config.DB_PATH + Config.DB_NAME,null);
19 |
20 | // Execute SELECT statement
21 | public Cursor rawQuery(String SQLCommandText) {
22 | Cursor cursor = database.rawQuery(SQLCommandText, null);
23 | return cursor;
24 | }
25 |
26 | // Execute UPDATE statement
27 | public void execSQL(String SQLCommandText) {
28 | database.execSQL(SQLCommandText);
29 | }
30 |
31 | public void close() {
32 | //this.database.close();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/Func.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.io.UnsupportedEncodingException;
7 | import java.net.URI;
8 | import java.net.URISyntaxException;
9 |
10 | import org.apache.http.HttpResponse;
11 | import org.apache.http.client.ClientProtocolException;
12 | import org.apache.http.client.HttpClient;
13 | import org.apache.http.client.methods.HttpGet;
14 | import org.apache.http.impl.client.DefaultHttpClient;
15 | import org.json.JSONException;
16 | import org.json.JSONObject;
17 |
18 | import android.appwidget.AppWidgetManager;
19 | import android.content.ComponentName;
20 | import android.database.Cursor;
21 | import android.widget.RemoteViews;
22 |
23 | public class Func {
24 |
25 | // Get JSON data
26 | public static String GetWeatherInfo(String url) {
27 | BufferedReader in = null;
28 | String data = "";
29 | url += "?t=" + System.currentTimeMillis();
30 | System.out.println("the url is " + url);
31 |
32 | //url = "http://akasuna.com/p.php?url=" + url;
33 | //System.out.println("new url is " + url);
34 | HttpClient client = new DefaultHttpClient();
35 | try {
36 | URI website = new URI(url);
37 | HttpGet request = new HttpGet();
38 | request.setURI(website);
39 | HttpResponse response = client.execute(request);
40 | in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
41 | StringBuffer sb = new StringBuffer("");
42 | String l = "";
43 | String nl = System.getProperty("line.separator");
44 | while ((l = in.readLine()) != null) {
45 | sb.append(l + nl);
46 | }
47 | in.close();
48 | data = sb.toString();
49 | System.out.println("json is " + data);
50 | return data;
51 | } catch (URISyntaxException e) {
52 | // TODO Auto-generated catch block
53 | e.printStackTrace();
54 | System.out.println(e.toString());
55 | } catch (ClientProtocolException e) {
56 | // TODO Auto-generated catch block
57 | e.printStackTrace();
58 | System.out.println(e.toString());
59 | } catch (IOException e) {
60 | // TODO Auto-generated catch block
61 | e.printStackTrace();
62 | System.out.println(e.toString());
63 | }
64 | System.out.println("json is " + data);
65 | return data;
66 | }
67 |
68 | // Get area no
69 | public static String Check_position_no() {
70 | String areano = "";
71 | DB db = DB.GetDB();
72 | Cursor cursor = db.rawQuery("select setvalue from settings where setkey = 'position_no'");
73 | if (cursor.getCount() > 0) {
74 | cursor.moveToFirst();
75 | byte bytes[] = cursor.getBlob(0);
76 |
77 | try {
78 | areano = new String(bytes, "utf-8").trim();
79 | } catch (UnsupportedEncodingException e) {
80 | // TODO Auto-generated catch block
81 | e.printStackTrace();
82 | }
83 | }
84 | cursor.close();
85 | db.close();
86 | return areano;
87 | }
88 |
89 | // Save JSON to database
90 | public static void SaveJSON() {
91 | String strJSON = "";
92 | String strJSONExt = "";
93 |
94 | strJSON = GetWeatherInfo(Config.URL.replace("areano", Check_position_no()));
95 | strJSONExt = GetWeatherInfo(Config.URLExt.replace("areano", Check_position_no()));
96 |
97 | try {
98 | JSONObject weather = new JSONObject(strJSON).getJSONObject("weatherinfo");
99 | JSONObject weatherExt = new JSONObject(strJSONExt).getJSONObject("weatherinfo");
100 |
101 | System.out.println("city is " + weather.getString("city"));
102 | if (weather.getString("city").length() > 0 && weatherExt.getString("city").length() > 0) {
103 | String strSQL = "update weatherinfo set json = '" + strJSON.replace("'", "''") + "', datetime = datetime(CURRENT_TIMESTAMP,'localtime') where type = 0";
104 | DB db = DB.GetDB();
105 | db.execSQL(strSQL);
106 | db.close();
107 |
108 | DB s1 = DB.GetDB();
109 | strSQL = "insert into weatherinfo (json, datetime, type) values ('" + strJSON.replace("'", "''") + "', datetime(CURRENT_TIMESTAMP,'localtime'), 2)";
110 | s1.execSQL(strSQL);
111 | s1.close();
112 | }
113 |
114 | System.out.println("city is " + weatherExt.getString("city"));
115 | if (weather.getString("city").length() > 0 && weatherExt.getString("city").length() > 0) {
116 | String strSQL = "update weatherinfo set json = '" + strJSONExt.replace("'", "''") + "', datetime = datetime(CURRENT_TIMESTAMP,'localtime') where type = 1";
117 | DB db = DB.GetDB();
118 | db.execSQL(strSQL);
119 | db.close();
120 |
121 | DB s1 = DB.GetDB();
122 | strSQL = "insert into weatherinfo (json, datetime, type) values ('" + strJSONExt.replace("'", "''") + "', datetime(CURRENT_TIMESTAMP,'localtime'), 3)";
123 | s1.execSQL(strSQL);
124 | s1.close();
125 | }
126 | } catch (JSONException e) {
127 | // TODO Auto-generated catch block
128 | e.printStackTrace();
129 | System.out.println(e.toString());
130 | }
131 | }
132 |
133 | public static String[] GetJSON(Integer type) {
134 | String[] Ret = { "", "" };
135 | String strSQL = "select json, datetime from weatherinfo where type = " + type;
136 | DB db = DB.GetDB();
137 | Cursor cursor = db.rawQuery(strSQL);
138 | if (cursor.getCount() > 0) {
139 | cursor.moveToFirst();
140 | try {
141 | Ret[0] = new String(cursor.getBlob(0), "utf-8").trim();
142 | Ret[1] = new String(cursor.getBlob(1), "utf-8").trim();
143 | } catch (UnsupportedEncodingException e) {
144 | // TODO Auto-generated catch block
145 | e.printStackTrace();
146 | }
147 | }
148 | cursor.close();
149 | db.close();
150 | return Ret;
151 | }
152 |
153 | public static void UpdateWidget(android.content.Context content) {
154 | String strJSON = "";
155 | String strTime = "";
156 | String strJSONExt = "";
157 | String strTimeExt = "";
158 |
159 | String[] s1 = GetJSON(0);
160 | String[] s2 = GetJSON(1);
161 |
162 | strJSON = s1[0];
163 | strTime = s1[1];
164 | strJSONExt = s2[0];
165 | strTimeExt = s2[1];
166 |
167 |
168 | System.out.println("aaa");
169 | System.out.println(strTime + " --> " + strJSON);
170 | System.out.println(strTimeExt + " --> " + strJSONExt);
171 | System.out.println("bbb");
172 |
173 | String strCity1 = "";
174 | String strCity2 = "";
175 | Integer ImgID = 0;
176 | String strCurrTemp = "";
177 | String strTemp = "";
178 | String strWeather = "";
179 |
180 | try {
181 | JSONObject weather1 = new JSONObject(strJSON).getJSONObject("weatherinfo");
182 | JSONObject weather2 = new JSONObject(strJSONExt).getJSONObject("weatherinfo");
183 |
184 | //String strUpdateTime = weather1.getString("time").replace(":", "");
185 | // Get city name
186 | strCity1 = weather1.getString("city");
187 | strCity2 = weather2.getString("city");
188 | if (strCity1.trim().length() > 0 && strCity2.trim().length() > 0 && strCity1.trim().equals(strCity2.trim())) {
189 |
190 | ImgID = weather2.getInt("img1");
191 | if (ImgID.equals(0)) {
192 | ImgID = R.drawable.w0;
193 | } else if (ImgID.equals(1)) {
194 | ImgID = R.drawable.w1;
195 | } else if (ImgID.equals(2)) {
196 | ImgID = R.drawable.w2;
197 | } else if (ImgID.equals(3)) {
198 | ImgID = R.drawable.w3;
199 | } else if (ImgID.equals(4)) {
200 | ImgID = R.drawable.w4;
201 | } else if (ImgID.equals(5)) {
202 | ImgID = R.drawable.w5;
203 | } else if (ImgID.equals(6)) {
204 | ImgID = R.drawable.w6;
205 | } else if (ImgID.equals(7)) {
206 | ImgID = R.drawable.w7;
207 | } else if (ImgID.equals(8)) {
208 | ImgID = R.drawable.w8;
209 | } else if (ImgID.equals(9)) {
210 | ImgID = R.drawable.w9;
211 | } else if (ImgID.equals(10)) {
212 | ImgID = R.drawable.w10;
213 | } else if (ImgID.equals(11)) {
214 | ImgID = R.drawable.w11;
215 | } else if (ImgID.equals(12)) {
216 | ImgID = R.drawable.w12;
217 | } else if (ImgID.equals(13)) {
218 | ImgID = R.drawable.w13;
219 | } else if (ImgID.equals(14)) {
220 | ImgID = R.drawable.w14;
221 | } else if (ImgID.equals(15)) {
222 | ImgID = R.drawable.w5;
223 | } else if (ImgID.equals(16)) {
224 | ImgID = R.drawable.w16;
225 | } else if (ImgID.equals(17)) {
226 | ImgID = R.drawable.w17;
227 | } else if (ImgID.equals(18)) {
228 | ImgID = R.drawable.w8;
229 | } else if (ImgID.equals(19)) {
230 | ImgID = R.drawable.w19;
231 | } else if (ImgID.equals(20)) {
232 | ImgID = R.drawable.w20;
233 | } else if (ImgID.equals(21)) {
234 | ImgID = R.drawable.w21;
235 | } else if (ImgID.equals(22)) {
236 | ImgID = R.drawable.w22;
237 | } else if (ImgID.equals(23)) {
238 | ImgID = R.drawable.w23;
239 | } else if (ImgID.equals(24)) {
240 | ImgID = R.drawable.w24;
241 | } else if (ImgID.equals(25)) {
242 | ImgID = R.drawable.w25;
243 | } else if (ImgID.equals(26)) {
244 | ImgID = R.drawable.w26;
245 | } else if (ImgID.equals(27)) {
246 | ImgID = R.drawable.w27;
247 | } else if (ImgID.equals(28)) {
248 | ImgID = R.drawable.w28;
249 | } else if (ImgID.equals(29)) {
250 | ImgID = R.drawable.w29;
251 | } else if (ImgID.equals(30)) {
252 | ImgID = R.drawable.w30;
253 | } else if (ImgID.equals(31)) {
254 | ImgID = R.drawable.w31;
255 | }
256 |
257 | strCurrTemp = weather1.getString("temp") + "°";
258 |
259 | strWeather = weather2.getString("weather1");
260 |
261 | strTemp = weather2.getString("temp1").replace("℃", "°");
262 |
263 | AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(content.getApplicationContext());
264 | ComponentName thisWidget = new ComponentName(content.getApplicationContext(), WeatherWidget.class);
265 | int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
266 |
267 | RemoteViews remoteViews = new RemoteViews(content.getApplicationContext().getPackageName(), R.layout.widget);
268 | remoteViews.setImageViewResource(R.id.imgImg, ImgID);
269 | remoteViews.setTextViewText(R.id.tvTemp, strCurrTemp);
270 |
271 | remoteViews.setTextViewText(R.id.tvCity, strCity1 + (strTime.trim().length() == 19 ? "" + strTime.trim().substring(11, 16).replace(":", "") : ""));
272 |
273 | remoteViews.setTextViewText(R.id.tvWeather, strWeather);
274 | remoteViews.setTextViewText(R.id.tvTempF, strTemp.replace("~", " ~ "));
275 |
276 | appWidgetManager.updateAppWidget(allWidgetIds, remoteViews);
277 |
278 | System.out.println("update widget over!");
279 | }
280 | } catch (JSONException e) {
281 | // TODO Auto-generated catch block
282 | e.printStackTrace();
283 | }
284 | }
285 | }
286 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/MyApp.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import android.content.Context;
4 |
5 | public class MyApp extends android.app.Application {
6 | private static MyApp instance;
7 |
8 | public MyApp() {
9 | instance = this;
10 | }
11 |
12 | public static Context getContext() {
13 | return instance;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/SelectArea.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.util.ArrayList;
5 |
6 | import android.app.AlertDialog;
7 | import android.app.ListActivity;
8 | import android.app.ProgressDialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.database.Cursor;
13 | import android.os.AsyncTask;
14 | import android.os.Bundle;
15 | import android.view.View;
16 | import android.widget.AdapterView;
17 | import android.widget.AdapterView.OnItemClickListener;
18 | import android.widget.ArrayAdapter;
19 | import android.widget.ListView;
20 | import android.widget.Toast;
21 |
22 | public class SelectArea extends ListActivity implements OnItemClickListener {
23 |
24 | String[] no = null;
25 | String[] name = null;
26 | String[] position_no = null;
27 | String Level = "";
28 | String NewLevel = "";
29 |
30 | ArrayList data = new ArrayList();
31 | ArrayList newdata = new ArrayList();
32 | ListView lv;
33 |
34 | String ErrMSG = "";
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | // TODO Auto-generated method stub
39 | super.onCreate(savedInstanceState);
40 |
41 | try {
42 | lv = getListView();
43 | data.add("Loading...");
44 | lv.setAdapter(new ArrayAdapter(this, R.layout.list_item, data));
45 |
46 | lv.setTextFilterEnabled(true);
47 | lv.setOnItemClickListener(this);
48 |
49 | Intent intent = getIntent();
50 | Level = intent.getStringExtra("NewLevel");
51 | String strno = intent.getStringExtra("no");
52 |
53 | if (Level == null) {
54 | Level = "";
55 | }
56 |
57 | String strSQLCommandText = "";
58 |
59 | if (Level.equalsIgnoreCase("")) {
60 | NewLevel = "c";
61 | strSQLCommandText = "select no,name from province";
62 | } else if (Level.equalsIgnoreCase("c")) {
63 | NewLevel = "a";
64 | strSQLCommandText = "select no,name from city where no like '" + strno + "%'";
65 | } else if (Level.equalsIgnoreCase("a")) {
66 | strSQLCommandText = "select no,name,position_no from area where no like '" + strno + "%'";
67 | } else {
68 | strSQLCommandText = "";
69 | }
70 |
71 | new AsyncLoader().execute(strSQLCommandText);
72 | } catch (Exception e) {
73 | Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
74 | }
75 |
76 | }
77 |
78 | @Override
79 | public void onItemClick(AdapterView> arg0, View arg1, final int arg2, long arg3) {
80 | // TODO Auto-generated method stub
81 | Intent intent = new Intent();
82 | intent.putExtra("no", no[arg2]);
83 |
84 | if (Level.equalsIgnoreCase("a")) {
85 | new AlertDialog.Builder(this)
86 | .setCancelable(false)
87 | .setTitle("设置")
88 | .setMessage("将所属地区设置为 " + name[arg2] + " ?")
89 | .setPositiveButton("是", new DialogInterface.OnClickListener() {
90 |
91 | @Override
92 | public void onClick(DialogInterface dialog, int which) {
93 | // TODO Auto-generated method stub
94 | DB db = DB.GetDB();
95 | db.execSQL("update settings set setvalue = '" + position_no[arg2] + "' where setkey = 'position_no'");
96 | db.close();
97 | Toast.makeText(getApplicationContext(), "正在设置...", Toast.LENGTH_LONG).show();
98 | String areano = Func.Check_position_no();
99 | if(areano.length() > 0) {
100 | new UpdateData(SelectArea.this).execute(getApplicationContext());
101 | }
102 |
103 | }
104 | })
105 | .setNegativeButton("否", null)
106 | .show();
107 | } else {
108 | intent.putExtra("NewLevel", NewLevel);
109 | intent.setClass(SelectArea.this, SelectArea.class);
110 | startActivity(intent);
111 | }
112 | }
113 |
114 | class AsyncLoader extends AsyncTask {
115 |
116 | @Override
117 | protected Void doInBackground(String... sql) {
118 | // TODO Auto-generated method stub
119 | try {
120 | DB db = DB.GetDB();
121 | Cursor cursor = db.rawQuery(sql[0]);
122 | int count = cursor.getCount();
123 | if (count > 0) {
124 | no = new String[count];
125 | name = new String[count];
126 | if (Level.equalsIgnoreCase("a")) {
127 | position_no = new String[count];
128 | }
129 | int i = 0;
130 | for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
131 | byte byte_no[] = cursor.getBlob(0);
132 | byte byte_name[] = cursor.getBlob(1);
133 | try {
134 | no[i] = new String(byte_no, "utf-8").trim();
135 | name[i] = new String(byte_name, "utf-8").trim();
136 | if (Level.equalsIgnoreCase("a")) {
137 | position_no[i] = new String(cursor.getBlob(2), "utf-8").trim();
138 | }
139 | } catch (UnsupportedEncodingException e) {
140 | // TODO Auto-generated catch block
141 | e.printStackTrace();
142 | }
143 | newdata.add(name[i]);
144 | i++;
145 | }
146 | }
147 | cursor.close();
148 | db.close();
149 | } catch (Exception e) {
150 | ErrMSG = e.toString();
151 | }
152 | return null;
153 | }
154 |
155 | @Override
156 | protected void onPostExecute(Void result) {
157 | // TODO Auto-generated method stub
158 | super.onPostExecute(result);
159 | lv.setAdapter(new ArrayAdapter(SelectArea.this, R.layout.list_item, newdata));
160 | if (ErrMSG.length() > 0) {
161 | Toast.makeText(getApplicationContext(), ErrMSG, Toast.LENGTH_LONG).show();
162 | }
163 | }
164 | }
165 |
166 | class UpdateData extends AsyncTask {
167 | SelectArea a;
168 | private ProgressDialog progressDlg;
169 | UpdateData(SelectArea a) {
170 | this.a = a;
171 | }
172 |
173 | @Override
174 | protected Void doInBackground(Context... c) {
175 | // TODO Auto-generated method stub
176 | Func.SaveJSON();
177 | Func.UpdateWidget(c[0]);
178 | return null;
179 | }
180 |
181 | @Override
182 | protected void onPostExecute(Void result) {
183 | // TODO Auto-generated method stub
184 | super.onPostExecute(result);
185 | progressDlg.cancel();
186 | }
187 |
188 | @Override
189 | protected void onPreExecute() {
190 | // TODO Auto-generated method stub
191 | super.onPreExecute();
192 |
193 | progressDlg = new ProgressDialog(a);
194 | progressDlg.setMessage("正在设置...");
195 | progressDlg.setCancelable(false);
196 | progressDlg.show();
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/WeatherActivity.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.OutputStream;
8 |
9 | import android.app.Activity;
10 | import android.app.AlertDialog;
11 | import android.app.ProgressDialog;
12 | import android.content.Context;
13 | import android.content.DialogInterface;
14 | import android.content.Intent;
15 | import android.os.AsyncTask;
16 | import android.os.Bundle;
17 | import android.view.Menu;
18 | import android.view.MenuInflater;
19 | import android.view.MenuItem;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | public class WeatherActivity extends Activity {
24 |
25 | TextView tvArea = null;
26 | String strJSON = "";
27 | String strJSONExt = "";
28 |
29 | /** Called when the activity is first created. */
30 | @Override
31 | public void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.main);
34 |
35 | tvArea = (TextView) findViewById(R.id.tvArea);
36 |
37 | // Check if the database exists before copying
38 | try {
39 | boolean initialiseDatabase = (new File(Config.DB_PATH + Config.DB_NAME)).exists();
40 | if (initialiseDatabase == false) {
41 | CheckDBFile();
42 | }
43 |
44 | // Check_position_no();
45 | String areano = Func.Check_position_no();
46 | System.out.println("areano is " + areano);
47 | if (areano.length() > 0) {
48 | new UpdateData(this).execute(getApplicationContext());
49 | } else {
50 | Intent intent = new Intent();
51 | intent.setClass(WeatherActivity.this, SelectArea.class);
52 | startActivity(intent);
53 | }
54 |
55 | } catch (Exception e) {
56 | Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
57 | }
58 | }
59 |
60 | private void CheckDBFile() {
61 | File f = new File(Config.DB_PATH);
62 | if (!f.exists()) {
63 | f.mkdir();
64 | }
65 |
66 | // Open the .db file in your assets directory
67 | try {
68 | InputStream is = getBaseContext().getAssets().open(Config.DB_NAME);
69 | // Copy the database into the destination
70 | OutputStream os = new FileOutputStream(Config.DB_PATH + Config.DB_NAME);
71 | byte[] buffer = new byte[1024];
72 | int length;
73 | while ((length = is.read(buffer)) > 0) {
74 | os.write(buffer, 0, length);
75 | }
76 |
77 | os.flush();
78 | os.close();
79 | is.close();
80 |
81 | } catch (IOException e) {
82 | // TODO Auto-generated catch block
83 | e.printStackTrace();
84 | Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
85 | }
86 | }
87 |
88 | @Override
89 | public boolean onCreateOptionsMenu(Menu menu) {
90 | // TODO Auto-generated method stub
91 | super.onCreateOptionsMenu(menu);
92 |
93 | MenuInflater blowup = getMenuInflater();
94 | blowup.inflate(R.menu.menu, menu);
95 |
96 | return true;
97 | }
98 |
99 | @Override
100 | public boolean onOptionsItemSelected(MenuItem item) {
101 | // TODO Auto-generated method stub
102 |
103 | switch (item.getItemId()) {
104 | case R.id.about:
105 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
106 | builder.setTitle("关于").setMessage("本程序提供中国大陆及港澳台地区天气预报,数据源来自于气象局。\n\nlichao2012@gmail.com").setPositiveButton("知道了", new DialogInterface.OnClickListener() {
107 |
108 | @Override
109 | public void onClick(DialogInterface arg0, int arg1) {
110 | // TODO Auto-generated method stub
111 | }
112 |
113 | }).show();
114 | break;
115 | case R.id.set:
116 | Intent intent = new Intent();
117 | intent.setClass(WeatherActivity.this, SelectArea.class);
118 | startActivity(intent);
119 | break;
120 | case R.id.update:
121 | String areano = Func.Check_position_no();
122 | if (areano.length() > 0) {
123 | new UpdateData(this).execute(getApplicationContext());
124 | }
125 | }
126 |
127 | return false;
128 | }
129 |
130 | private void setTextView() {
131 | String strJSON = "";
132 | String strTime = "";
133 | String strJSONExt = "";
134 | String strTimeExt = "";
135 |
136 | String[] s1 = Func.GetJSON(0);
137 | String[] s2 = Func.GetJSON(1);
138 |
139 | strJSON = s1[0];
140 | strTime = s1[1];
141 | strJSONExt = s2[0];
142 | strTimeExt = s2[1];
143 |
144 | tvArea.setText(strTime + "\n" + strJSON + "\n\n" + strTimeExt + "\n" + strJSONExt + "\n\n\n\n");
145 | }
146 |
147 | class UpdateData extends AsyncTask {
148 | WeatherActivity weatherActivity;
149 | private ProgressDialog progressDlg;
150 |
151 | UpdateData(WeatherActivity weatherActivity) {
152 | this.weatherActivity = weatherActivity;
153 | }
154 |
155 | @Override
156 | protected Void doInBackground(Context... c) {
157 | // TODO Auto-generated method stub
158 |
159 | Func.SaveJSON();
160 | Func.UpdateWidget(c[0]);
161 |
162 | return null;
163 | }
164 |
165 | @Override
166 | protected void onPostExecute(Void result) {
167 | // TODO Auto-generated method stub
168 | super.onPostExecute(result);
169 | setTextView();
170 | progressDlg.cancel();
171 | }
172 |
173 | @Override
174 | protected void onPreExecute() {
175 | // TODO Auto-generated method stub
176 | super.onPreExecute();
177 |
178 | progressDlg = new ProgressDialog(weatherActivity);
179 | progressDlg.setMessage("正在刷新...");
180 | progressDlg.setCancelable(true);
181 | progressDlg.show();
182 | }
183 |
184 | }
185 | }
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/WeatherWidget.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import android.appwidget.AppWidgetManager;
4 | import android.appwidget.AppWidgetProvider;
5 | import android.content.Context;
6 | import android.os.AsyncTask;
7 | import android.widget.Toast;
8 |
9 | public class WeatherWidget extends AppWidgetProvider {
10 | String strJSON = "";
11 | String strJSONExt = "";
12 |
13 | @Override
14 | public void onDeleted(Context context, int[] appWidgetIds) {
15 | // TODO Auto-generated method stub
16 | super.onDeleted(context, appWidgetIds);
17 | Toast.makeText(context, "拜拜", Toast.LENGTH_LONG).show();
18 | }
19 |
20 | @Override
21 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
22 | // TODO Auto-generated method stub
23 | super.onUpdate(context, appWidgetManager, appWidgetIds);
24 |
25 | new UpdateData(context).execute(context);
26 | }
27 |
28 | @Override
29 | public void onEnabled(Context context) {
30 | // TODO Auto-generated method stub
31 | super.onEnabled(context);
32 | Toast.makeText(context, "Hello!", Toast.LENGTH_LONG).show();
33 | System.out.println("Widget onEnabled");
34 | }
35 |
36 | class UpdateData extends AsyncTask {
37 | android.content.Context content;
38 |
39 | UpdateData(android.content.Context c) {
40 | content = c;
41 | }
42 |
43 | @Override
44 | protected Void doInBackground(Context... c) {
45 | // TODO Auto-generated method stub
46 | Func.SaveJSON();
47 | Func.UpdateWidget(c[0]);
48 | return null;
49 | }
50 |
51 | @Override
52 | protected void onPostExecute(Void result) {
53 | // TODO Auto-generated method stub
54 | super.onPostExecute(result);
55 | Toast.makeText(content, "widget updated!", Toast.LENGTH_LONG).show();
56 | }
57 |
58 | @Override
59 | protected void onPreExecute() {
60 | // TODO Auto-generated method stub
61 | super.onPreExecute();
62 | Toast.makeText(content, "widget updating!", Toast.LENGTH_LONG).show();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/akasuna/kweather/WeatherWidgetConfig.java:
--------------------------------------------------------------------------------
1 | package com.akasuna.kweather;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | public class WeatherWidgetConfig extends Activity {
7 |
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | // TODO Auto-generated method stub
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.weatherwidgetconfig);
13 | finish();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------