Awesome Open Source
Awesome Open Source

EasyAndroid

Toast,Log


EasyAndroid``

1.

copy

2.

.

100. 50

  1. jitpack
maven { url 'https://jitpack.io' }

lastest_version =

implementation "com.github.yjfnypeu:EasyAndroid:$lastest_version"

Application

EasyAndroid.init(application)

Attention!!!

,

```copy`

copy

EasyAndroidApplication Context EasyAndroid.getApplicationContext()application context

EasyGuideLayer

  • View
// 
val item = GuideItem.newInstance(view, padding)
    .setLayout(guideLayout)// View
    .setGravity(Gravity.LEFT)// View
    .setOffsetProvider(provider)// View
    .setHighLightShape(GuideItem.SHAPE_RECT)// 
    .setOnViewAttachedListener(listener)// View
    .setOnDrawHighLightCallback(callback)// 
    .setOnHighLightClickListener(listener)// 


// 
EasyGuideLayer.with(activity)
    .setBackgroundColor(color)// 
    .setOnGuideShownListener(lambda)// 
    .addItem(item)// 
    .setDismissOnClickOutside(false)// 
    .setDismissIfNoItems(true)// 
    .show()// 

EasyImageGetter

  • placeholde
  • error
  • uriassets
// html
private val html =
"""
<h5>asset</h5>
<img src="file:///android_asset/imagegetter/cat.png">
<h5>http</h5>
<img src="http://www.w3school.com.cn/i/eg_tulip.jpg">
""".trimIndent()

// TextView
private val textView:TextView = getTextView()

EasyImageGetter.create()
    // 
    .setPlaceHolder(R.drawable.placeholder)
    // 
    .setError(R.drawable.error)
    // htmltv
    .loadHtml(html, textView)

EasyMedia

Vicent9920

val photo = EasyMedia()// EasyMedia
    // 
    .setCrop(true|false)
    // 
    .setImgPath(imgPath:String)

// 
photo.setCallback { file:File ->
    // TODO 
}

// 
photo.setError { error:Exception ->
    // TODO
}

// 
photo.takePhoto(activity)

// 
photo.selectPhoto(activity)

EasySharedPreferences

SharedPreferences

  • SPkey
  • SharedPreferences
  • SharedPreferences
// SharedPreferencesuser_infousername, age, address

// 1. 
@PreferenceRename("user_info")
class User:PreferenceSupport() {
    var username:String
    var age:Int
    var address:String
}

// 2. 
val user = EasySharedPreferences.load(User::class.java)

// 3. 

// loaduser
user.age = 16
user.username = "haoge"

// applySharedPreferences
user.apply()

EasyDimension

// 10dppx
EasyDimension.withDIP(10).toPX()
// 30spMM
EasyDimension.withSP(30).toMM()

EasyFormatter

loglog

  • Set/List/Map/JSON/POJO
// 
val any:Any = create()
// formatter
val result:String = EasyFormatter.DEFAULT.format(any)

EasyLog

  • UI
  • : crash
  • EasyFormatter
  • TAG.
  • ''
val any:Any = create()// 
EasyLog.DEFAULT.d(any)// log. Log.d()

EasyToast

Toast

  1. toast

https://juejin.im/post/5b0638336fb9a07aa9261ce6

val message:String = create()// 
EasyToast.DEFAULT.show(message)// 
EasyToast.create(layoutID:Int, tvID:Int, duration:Int).show(message)// 

EasyReflect

https://juejin.im/post/5b1de20c6fb9a01e701000cb

// Test
class Test private constructor(private val name:String) {
    private fun wrap(name:String):String = "$name"
}

// Reflect
var reflect = EasyReflect.create(Test::class.java).instance("")

// name
reflect.setField("name", "EasyReflect")
// name"EasyReflect"
val value = reflect.getValue("name")

// wrapvalue
reflect.call("wrap", value)
// wrap: "EasyReflect"
val result = reflect.callWithReturn("wrap", value).get<String>()

EasyActivityResult

onActivityResult

  • ****:
  • requestCode: requestCode,
  • ****:

https://juejin.im/post/5b21d019e51d4506d93701ba

EasyActivityResult.startActivity(activity, Intent(activity, DemoActivity::class.java),
        { resultCode:Int, data:Intent? ->
            // 
        })

EasyPermissions

6.0+

  • Activity

https://juejin.im/post/5b1a2a326fb9a01e5d32f208

EasyPermissions.create(// 
    Manifest.permission.WRITE_EXTERNAL_STORAGE,
    Manifest.permission.WRITE_CALENDAR,
    Manifest.permission.WRITE_CONTACTS
    )
    // 
    .rational { permission, chain ->
        AlertDialog.Builder(this)
                .setTitle("")
                .setMessage("\n$permission")
                .setNegativeButton("", {_, _ -> chain.cancel() })
                .setPositiveButton("", {_, _ -> chain.process() })
                .show()

        [email protected] true
    }
    // 
    .callback { grant ->
        EasyToast.DEFAULT.show("${if (grant) "" else ""}")
    }
    // 
    .alwaysDenyNotifier(object : PermissionAlwaysDenyNotifier() {
        AlertDialog.Builder(activity)
                .setTitle("")
                .setMessage(":\n\n")
                .setPositiveButton("", { _, _ ->  goSetting(activity)})
                .setNegativeButton("", {_,_ -> cancel(activity)})
                .show()
    })
    // 
    .request()

EasyExecutor

  • ****: catchcrash
  • ****:
  • ****:
  • ****:
  • ****:
  • ****: UI
// 1. 
val executor =
    // sizesize <= 0
    // newCachedThreadPool
    EasyExecutor.newBuilder(size)
            .setName(name)// 
            .setPriority(priority)// 
            .onStart {threadName -> } // 
            .onSuccess {threadName -> }// 
            .onError {threadName, throwable -> }// 
            .setDeliver(deliver)// 
            .build()// 

// 2. 
executor.execute(runnable:Runnable)// 

// 
executor.asyncResult(result:(T) -> Unit) // 
    .asyncTask(task:(Notifier) -> T)// 

executor.setDelay(delay).execute(runnable)// 

EasyBundle

Bundle````````

  1. Bundleapi
  2. Bundle

https://juejin.im/post/5b2c65bde51d45587d2dd86f

// 1. bundle
EasyBundle.create(bundle)// bundle
    .put(key, value)// 

// 2. bundle
EasyBundle.create(bundle).get<User>("user")

// 3. 
class ExampleActivity:BaseActivity() {
    // intentnamename
    @BundleField
    var name:String? = null
}

MVP

https://juejin.im/post/5b4ee27ff265da0f98314f01

MVP

  • Presenter
  • P
// 1. 
interface CustomView:MVPView {
    // PV
    fun updateUI()
}

// 2. Presenter
class CustomPresenter(view:CustomView):MVPPresenter(view) {
    // V
    fun requestData() {
        // TODO viewV
    }
}

// 3. V(Activity or Fragment),Presenter
class CustomActivity:BaseMVPActivity, CustomView {

    // presenterpersenter
    val persenter = CustomPresenter(this)
    override fun createPresenters() = arrayOf(presenter)
    override fun updateUI() {// TODO }

    fun initPage() {
        // Presenter
        presenter?.requestData()
    }
}

# EasyBundle
-keepclasseswithmembernames class * {
    @com.haoge.easyandroid.easy.BundleField <fields>;
}

# EasySharedPreferences
-keep class * implements com.haoge.easyandroid.easy.PreferenceSupport { *; }

QQ: 108895031

License

apache license 2.0


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Html (275,330
Kotlin (53,268
Bundle (32,021
Guide (12,562
Permission (11,524
Qq (4,953
Mvp (3,616
Reflection (2,435
Toast (2,139
Jitpack (1,407
Sharedpreferences (330
Dimensions (135
Activityresult (13