Giter VIP home page Giter VIP logo

utils-android's Introduction

Android-Utils: A Collection of Android Utils

License Version Code Grade Build Min Sdk Version

1. Introcution

This project is mainly used to collect utils classes useful in Android development, for example, log, crash collection, resources, attr, runtime permission, toast etc so that to accelerate your Android evelopment.

2. Use in your project

2.1 Add dependency

This project is published to jCenter, so you can easily use it in your project.

First, you need to add jcenter in your project:

repositories { mavenCentral() }

then, add dependencies in your project:

implementation "com.github.Shouheng88:utils-core:$latest-version"

If you want to use the kotlin extension based on utils classes, use the dependency below:

implementation "com.github.Shouheng88:utils-ktx:$latest-version"

2.2 Initialize

You need initialize utils in your application. This is mainly used to get a global context to make utils methods more convenient, and it will cost too much time of launching your App.

public class SampleApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        // initialize your library
        UtilsApp.init(this);
    }
}

2.2 Fetures and functions

The utils classes was divided into multiple groups:

No Class Group Desc
1 ActivityUtils App Activity start, close, aniation, builder
2 AppUtils App App install, uninstall, get information
3 IntentUtils App Intent to launch App, market etc
4 ResUtils Resources Image, Text, and other resources
5 EncodeUtils Encode base64 and url encode
6 EncryptUtils Encrypt md5 sha256 encrypt
7 RegexUtils Data Regex
8 StringUtils Data String process
9 TimeUtils Data Date and time process
10 DeviceUtils Device Device info, imei, model etc
11 NetworkUtils Device Network info, type etc
12 ShellUtils Device Shell
13 PermissionUtils Permission Android runtime permission
14 CrashHelper Stability crash
15 L Stability log output, format etc
16 FileUtils Storage File, visit, move, delete etc
17 PathUtils Storage Get directory paths
18 IOUtils Storage IO
19 KV Storage Sharedpreference
20 ImageUtils ui Image process, scale, roate etc
21 ToastUtils ui Toast
22 ViewUtils ui View info etc

2.3 Use Utils-ktx

utils-ktx is a kotlin extension based on Android-Utils, which is used to simplify usages of utils classes. For example, if you want to get a drawable, tint it and then display it in ImageView. One line is enough:

iv.icon = drawableOf(R.drawable.ic_add_circle).tint(Color.WHITE)

If you want to request runtime permission in Activity, what you need to do is only writing one line below,

checkStoragePermission {  /* got permission */ }

As for avoding continous click, you only need one line,

btnRateIntro.onDebouncedClick { /* do something */ }

All in all, by utils-ktx you can significantly lower the difficulty of development.

2.3 Proguard rules

# Add MMKV classname
-keepnames class com.tencent.mmkv.MMKV

3、About

3.1 Change log

Log

License

Copyright (c) 2019-2021 wsh.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

utils-android's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

utils-android's Issues

需求池

  1. SPUtils getInstance 方法重命名为 get,getInstance 太长
  2. LogUtils 类重命名为 L,LogUtils 太长
  3. 应用前后台切换的监听
  4. 动画工具类修改名称
  5. 权限工具类增加自定义权限名称的接口

bug

方法错误,返回值没有!!

fun View.toBitmap() { ImageUtils.view2Bitmap(this) }

新增需求

  • 平板检测相关的逻辑添加到 utils
  • let 等的增强版本 letOrElse 便捷方法

代码缩进等相关的快捷方法

SpannableString(binding.tvLog.text).apply {
    setSpan(UnderlineSpan(), 0, binding.tvLog.text.length, 0)
}

TODO

        (binding.vp.getChildAt(0) as? RecyclerView)?.overScrollMode = RecyclerView.OVER_SCROLL_NEVER

add a convinent method for ViewPager2 to set overScrollMode

快捷方法调整

/Users/shouhwang/.gradle/caches/modules-2/files-2.1/com.github.Shouheng88/utils-ktx/2.8.7/3d16a937b3877b2a49b6d05a9c49cb4667b181fa/utils-ktx-2.8.7-sources.jar!/me/shouheng/utils/ktx/StringKtx.kt:67

fun String.safeToInt(str: String, def: Int = 0): Int = try { str.toInt() } catch (e: NumberFormatException) { def }

fun String.safeToLong(str: String, def: Long = 0): Long = try { str.toLong() } catch (e: NumberFormatException) { def }

fun String.safeToFloat(str: String, def: Float = 0f): Float = try { str.toFloat() } catch (e: NumberFormatException) { def }

fun String.safeToDouble(str: String, def: Double = .0): Double = try { str.toDouble() } catch (e: NumberFormatException) { def }

写错了,应该用 this 就行

bug

me.shouheng.utils.ui.BarUtils#setNavBarLightMode(android.app.Activity, boolean)

activity utils

activity 启动动画

增加 noanimation 使用


            activity.overridePendingTransition(0, 0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.