├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── .travis.yml ├── LICENSE.md ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidfung │ │ └── openweathermap │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ │ └── com │ │ │ └── androidfung │ │ │ └── openweathermap │ │ │ ├── MainActivity.java │ │ │ └── MainActivityFragment.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── content_main.xml │ │ └── fragment_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── androidfung │ └── openweathermap │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidfung │ │ └── weather │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidfung │ │ │ └── weather │ │ │ ├── OpenWeatherMapApiHelper.java │ │ │ ├── model │ │ │ ├── WeatherRecord.java │ │ │ └── WeatherResponseModel.java │ │ │ └── network │ │ │ ├── CustomGsonObjectRequest.java │ │ │ ├── GsonRequest.java │ │ │ └── MultipartRequest.java │ └── res │ │ └── values │ │ ├── secrets.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── androidfung │ └── weather │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | OpenWeatherMap -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Android 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 1.8 67 | 68 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | sudo: false 4 | android: 5 | components: 6 | # Uncomment the lines below if you want to 7 | # use the latest revision of Android SDK Tools 8 | - platform-tools 9 | - tools 10 | 11 | # The BuildTools version used by your project 12 | - build-tools-25.0.2 13 | 14 | # The SDK version used to compile your project 15 | - android-25 16 | 17 | # Additional components 18 | #- extra-google-google_play_services 19 | - extra-google-m2repository 20 | - extra-android-m2repository 21 | - extra-android-support 22 | 23 | # Specify at least one system image, 24 | # if you need to run emulator(s) during your tests 25 | - sys-img-armeabi-v7a-android-22 26 | # - sys-img-armeabi-v7a-android-17 27 | 28 | licenses: 29 | - 'android-sdk-preview-license-.+' 30 | - 'android-sdk-license-.+' 31 | - 'google-gdk-license-.+' 32 | 33 | before_script: 34 | - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a 35 | - emulator -avd test -no-skin -no-audio -no-window & 36 | - android-wait-for-emulator 37 | - adb shell input keyevent 82 & 38 | 39 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Fung LAM 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Welcome to OpenWeatherMap-Android 2 | This is a wrapper of [OpenWeatherMap](http://openweathermap.org) for Android platform using Volley. 3 | 4 | ### Sample Application 5 | Sample Application is included in [app](https://github.com/seventhmoon/OpenWeatherMap-Android/tree/master/app) 6 | 7 | ### How to use 8 | OpenWeatherMapApiHelper helper = new OpenWeatherMapApiHelper(getContext()); 9 | helper.getWeather(22.25, 114.1667, new Response.Listener() { 10 | @Override 11 | public void onResponse(WeatherResponseModel response) { 12 | WeatherRecord record = response.getWeatherRecord(); 13 | textViewMessage.setText("Temperature: " + record.getTemperature() + "\nHumidity: " + record.getHumidity()); 14 | } 15 | }, new Response.ErrorListener() { 16 | @Override 17 | public void onErrorResponse(VolleyError error) { 18 | textViewMessage.setText(error.toString()); 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | buildToolsVersion "27.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.androidfung.openweathermap" 9 | minSdkVersion 21 10 | targetSdkVersion 27 11 | versionCode 1 12 | versionName "1.0" 13 | dataBinding { 14 | enabled = false 15 | } 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | packagingOptions { 28 | exclude 'META-INF/LICENSE' 29 | exclude 'META-INF/LICENSE-FIREBASE.txt' 30 | exclude 'META-INF/NOTICE' 31 | } 32 | } 33 | 34 | dependencies { 35 | compile fileTree(include: ['*.jar'], dir: 'libs') 36 | testCompile 'junit:junit:4.12' 37 | implementation 'com.android.support:appcompat-v7:27.0.2' 38 | implementation 'com.android.support:design:27.0.2' 39 | implementation 'com.android.volley:volley:1.1.0' 40 | compile project(':library') 41 | } 42 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\fung\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/androidfung/openweathermap/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.androidfung.openweathermap; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhmoon/OpenWeatherMap-Android/c82a1fdfd233d93f12a4dd046d0c25d76e704e65/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/androidfung/openweathermap/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidfung.openweathermap; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | Toolbar toolbar = findViewById(R.id.toolbar); 16 | setSupportActionBar(toolbar); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidfung/openweathermap/MainActivityFragment.java: -------------------------------------------------------------------------------- 1 | package com.androidfung.openweathermap; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.android.volley.Response; 12 | import com.android.volley.VolleyError; 13 | import com.androidfung.weather.OpenWeatherMapApiHelper; 14 | import com.androidfung.weather.model.WeatherRecord; 15 | import com.androidfung.weather.model.WeatherResponseModel; 16 | 17 | import org.w3c.dom.Text; 18 | 19 | /** 20 | * A placeholder fragment containing a simple view. 21 | */ 22 | public class MainActivityFragment extends Fragment { 23 | 24 | private TextView mTextViewMessage; 25 | 26 | public MainActivityFragment() { 27 | } 28 | 29 | @Override 30 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, 31 | Bundle savedInstanceState) { 32 | 33 | View rootView = inflater.inflate(R.layout.fragment_main, container, false); 34 | mTextViewMessage = rootView.findViewById(R.id.textview_message); 35 | 36 | OpenWeatherMapApiHelper helper = new OpenWeatherMapApiHelper(getActivity(), "API_KEY_HERE"); 37 | helper.getWeather(22.25, 114.1667, 38 | this::showInformation, 39 | this::showError 40 | ); 41 | 42 | return rootView; 43 | } 44 | 45 | private void showInformation(WeatherResponseModel response){ 46 | mTextViewMessage.setText(getString(R.string.Result, response.getWeatherRecord().getTemperature(),response.getWeatherRecord().getHumidity())); 47 | } 48 | 49 | private void showError(VolleyError error){ 50 | mTextViewMessage.setText(error.toString()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhmoon/OpenWeatherMap-Android/c82a1fdfd233d93f12a4dd046d0c25d76e704e65/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhmoon/OpenWeatherMap-Android/c82a1fdfd233d93f12a4dd046d0c25d76e704e65/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhmoon/OpenWeatherMap-Android/c82a1fdfd233d93f12a4dd046d0c25d76e704e65/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhmoon/OpenWeatherMap-Android/c82a1fdfd233d93f12a4dd046d0c25d76e704e65/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seventhmoon/OpenWeatherMap-Android/c82a1fdfd233d93f12a4dd046d0c25d76e704e65/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | OpenWeatherMap 3 | Settings 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |