Git Product home page Git Product logo

live-tools's Introduction

Live-Tools

Live-Tools is a library project which aims to convert some Android device features to LiveData.

List

live-orientation

Observes orientation change even if device is forced to portrait mode. It works based on sensors.

OrientationLiveData(this)
      .observe(this, Observer {
           it?.let {
               Toast.makeText(this, it.name, Toast.LENGTH_SHORT).show()
           }
      })

live-location

Observes location changes. It observers coarse and fine location internally. If user's GPS setting is disabled, live-location notifies you about this. If location permission is needed, live-location checks this internally and notifies you about this.

locationLiveData = LocationLiveData(this)
locationLiveData.observe(this,
        Observer {
            when (it?.status) {
                LocationData.Status.PERMISSION_REQUIRED -> // request permission. (it.permissionList)
                LocationData.Status.ENABLE_SETTINGS -> //enable location settings (it.resolvableApiException)
                LocationData.Status.LOCATION_SUCCESS -> // location is ready to use (it.location)
            }
        })

//Start observing
locationLiveData.start()

live-battery

Observes battery changes, state, scale, level and plug info.

BatteryLiveData(this)
                .observe(this, Observer {
                    it?.let {
                        Toast.makeText(this, "Status: " + it.status +
                                " Plug: " + it.plug +
                                " Level: " + it.level +
                                " Scale: " + it.scale +
                                " Percentage " + it.percentage, Toast.LENGTH_LONG).show()
                    }
})

live-media-selector

Observes picked camera or gallery image uri.

MediaSelectorLiveData(this)
      .observe(this, Observer {
                when (it?.status) {
                    MediaData.Status.MEDIA_SUCCESS -> { it.uri }
                    MediaData.Status.PERMISSION_REQUIRED -> { it.permissionList }
                    MediaData.Status.ERROR -> { it.exception }
                }
            })
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
      mediaSelectorLiveData.onActivityResult(requestCode, resultCode, data)
}
mediaSelectorLiveData.openCamera()
mediaSelectorLiveData.openGallery()

Dependency

maven { url 'https://jitpack.io' }
dependencies {
    implementation 'com.github.savepopulation:live-tools:v1.0.1'
}

Contributors:

Mert Şimşek
Efe Budak
Taylan Sbrcn
Aykut Asil

List of Apps using Live-Tools:

Phone Lab

live-tools's People

Contributors

iammert avatar savepopulation avatar storytelcase avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.