Skip to content

Commit 9d6e0c7

Browse files
committed
Project: Initial commit
Signed-off-by: Fung <fython@163.com>
0 parents  commit 9d6e0c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1589
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Fung Go (fython)
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.

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Kotlinyan
2+
3+
> Make Kotlin Android app development easier and more elegant
4+
>
5+
> 让 Kotlin Android 应用开发更加简单、优雅
6+
7+
[English Documentation (Sorry... It is unfinished)](README-EN.md)
8+
9+
## 简介
10+
11+
日常开发 Android 应用中,有些功能实现我们常常需要写许多代码,整理成一些 Utils 类。
12+
13+
Kotlinyan 是烧饼自己整理的一些比较常用的方法实现(Utils),由 Kotlin 语言编写,利用扩展方法的特性使得在使用 Kotlin 编写 Android 应用时更加高效。
14+
15+
## 模块引入
16+
17+
目前 Kotlinyan 库由两个模块组成,未来会添加更多的模块、功能,可根据自身需求选择引入到自己的开发项目中。
18+
19+
- `library-common` : Android 常用方法扩展
20+
- `library-picasso-support` : Picasso 扩展,为 ImageView 提供更加简单的 Lazy Load 方法
21+
22+
## 使用方法
23+
24+
稍后会写出详细的文档。
25+
26+
## 讨论
27+
28+
目前不提供讨论交流群,可以直接通过 Telegram [@fython](https://t.me/fython) 联系我。
29+
30+
也欢迎直接提出 Pull Request 或 Issues。
31+
32+
## 开源协议
33+
34+
```
35+
MIT License
36+
37+
Copyright (c) 2017 Fung Go (fython)
38+
39+
Permission is hereby granted, free of charge, to any person obtaining a copy
40+
of this software and associated documentation files (the "Software"), to deal
41+
in the Software without restriction, including without limitation the rights
42+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43+
copies of the Software, and to permit persons to whom the Software is
44+
furnished to do so, subject to the following conditions:
45+
46+
The above copyright notice and this permission notice shall be included in all
47+
copies or substantial portions of the Software.
48+
49+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55+
SOFTWARE.
56+
```

build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
ext.kotlin_version = '1.1.2'
5+
repositories {
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:2.2.2'
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
jcenter()
17+
}
18+
}
19+
20+
task clean(type: Delete) {
21+
delete rootProject.buildDir
22+
}

demo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

demo/build.gradle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
4+
android {
5+
compileSdkVersion TARGET_SDK_VERSION.toInteger()
6+
buildToolsVersion BUILD_TOOLS_VERSION
7+
8+
defaultConfig {
9+
applicationId "moe.feng.kotlinyan"
10+
minSdkVersion 21
11+
targetSdkVersion TARGET_SDK_VERSION.toInteger()
12+
versionCode 1
13+
versionName "1.0"
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
23+
sourceSets {
24+
main.java.srcDirs += 'src/main/kotlin'
25+
}
26+
}
27+
28+
dependencies {
29+
compile fileTree(dir: 'libs', include: ['*.jar'])
30+
compile 'com.android.support:appcompat-v7:25.3.1'
31+
compile 'com.android.support:support-v13:25.3.1'
32+
compile 'com.android.support:design:25.3.1'
33+
34+
compile project(':library-common')
35+
compile project(':library-picasso-support')
36+
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
37+
compile "org.jetbrains.anko:anko:0.10.1"
38+
}
39+
repositories {
40+
mavenCentral()
41+
}

demo/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in G:\adt\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+
#}

demo/src/main/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="moe.feng.kotlinyan">
3+
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
6+
<application
7+
android:allowBackup="true"
8+
android:label="@string/app_name"
9+
android:icon="@mipmap/ic_launcher"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
13+
<activity android:name=".MainActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN"/>
16+
17+
<category android:name="android.intent.category.LAUNCHER"/>
18+
</intent-filter>
19+
</activity>
20+
21+
</application>
22+
23+
</manifest>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package moe.feng.kotlinyan
2+
3+
import android.app.Fragment
4+
import android.app.FragmentManager
5+
import android.os.Bundle
6+
import android.support.design.widget.TabLayout
7+
import android.support.v13.app.FragmentPagerAdapter
8+
import android.support.v4.view.ViewPager
9+
import android.support.v7.app.AppCompatActivity
10+
import android.view.Menu
11+
import moe.feng.kotlinyan.common.AndroidExtensions
12+
import moe.feng.kotlinyan.common.ColorExtensions
13+
import org.jetbrains.anko.find
14+
15+
class MainActivity : AppCompatActivity(), AndroidExtensions, ColorExtensions {
16+
17+
val tabLayout by lazy { find<TabLayout>(R.id.tab_layout) }
18+
val viewPager by lazy { find<ViewPager>(R.id.view_pager) }
19+
20+
override fun onCreate(savedInstanceState: Bundle?) {
21+
super.onCreate(savedInstanceState)
22+
setContentView(R.layout.activity_main)
23+
24+
supportActionBar?.elevation = 0f
25+
26+
viewPager.adapter = PagerAdapter(fragmentManager)
27+
tabLayout.setupWithViewPager(viewPager)
28+
}
29+
30+
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
31+
menuInflater.inflate(R.menu.menu_main, menu)
32+
33+
/**
34+
* Tint menu items easily
35+
*/
36+
menu?.tintItemsColor(resources.color[R.color.grey_material_control])
37+
38+
return super.onCreateOptionsMenu(menu)
39+
}
40+
41+
private class PagerAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm) {
42+
43+
val items = arrayOf<Pair<String, Fragment>>(
44+
"ViewExtension" to ViewExtDemoFragment(),
45+
"NetworkExtension" to NetworkExtDemoFragment(),
46+
"PicassoExtension" to PicassoExtDemoFragment()
47+
)
48+
49+
override fun getPageTitle(position: Int): CharSequence = items[position].first
50+
51+
override fun getItem(position: Int): Fragment = items[position].second
52+
53+
override fun getCount(): Int = items.size
54+
55+
}
56+
57+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package moe.feng.kotlinyan
2+
3+
import android.app.Fragment
4+
import android.os.Bundle
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import moe.feng.kotlinyan.common.AndroidExtensions
9+
import moe.feng.kotlinyan.common.NetworkExtensions
10+
11+
class NetworkExtDemoFragment : Fragment(), NetworkExtensions, AndroidExtensions {
12+
13+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View
14+
= inflater.inflate(R.layout.fragment_network_ext, container, false)
15+
16+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
17+
18+
}
19+
20+
}

0 commit comments

Comments
 (0)