Coder Social home page Coder Social logo

muhammadisa / lifemark Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 12.12 MB

:earth_americas: a simple tool for checking internet connection with observable or without observable.

License: MIT License

Kotlin 100.00%
internet-connection internet-connection-checker internet-connection-helper kotlin connectivity reactive-connectivity internet android-internet-stats

lifemark's Introduction

Welcome to Lifemark ๐Ÿ‘‹

Version License: MIT documentation: yes maintained: yes

Short introduction, this is very simple internet checker, you can execute a function when the device disconnected and otherwise, you can check is connected to the internet for once on execution.

Demo

Install

For installation just add this code in your app build.gradle file

implementation 'com.github.muhammadisa:lifemark:1.0.1'

Contribute?

Read the terms https://github.com/muhammadisa/lifemark/blob/master/CONTRIBUTING.md

Need Example?

Just click this link https://github.com/muhammadisa/lifemark/tree/master/example/src/main/java/com/xoxoer/example

Simple Usage

  1. Forever Checking

    val networkConnection = Lifemark(applicationContext)
    networkConnection.ObservableNetworkCondition()
    	.observe(this@MainActivity, Observer { isConnected ->
    	if (isConnected) {
            // do something when device connected to internet
    	} else {
            // do something when device disconnected to internet
    	}
    })
  2. Checking for once execution

    val networkConnection = Lifemark(applicationContext)
    if(networkConnection.isNetworkConnected()){
        // do something when device connected to internet
    }else{
        // do something when device disconnected to internet
    }
Full Example
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val networkConnection = Lifemark(applicationContext)

        // Forever Checking example
        networkConnection.ObservableNetworkCondition()
            .observe(this@MainActivity, Observer { isConnected ->
                if (isConnected) {
                    disconnected_layout.visibility = View.GONE
                    connected_layout.visibility = View.VISIBLE
                } else {
                    connected_layout.visibility = View.GONE
                    disconnected_layout.visibility = View.VISIBLE
                }
            })

        if (networkConnection.isNetworkConnected()) {
            // do something when device connected to internet
            Log.d("INTERNET_CHECKER", "true")
        } else {
            // do something when device disconnected to internet
            Log.d("INTERNET_CHECKER", "false")
        }
    }

}

Author

๐Ÿ‘ค Dimas Prasetya

๐Ÿ‘ค Muhammad Isa Wijaya Kusuma

Show your support

Give a โญ๏ธ if this project helped you!


This README was generated with โค๏ธ by readme-md-generator

lifemark's People

Contributors

muhammadisa avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

lifemark's Issues

Failed to resolve: com.github.muhammadisa:lifemark:1.0.1

Your project looks great, just having slight trouble with the gradle file.....

with your gradle file:
the example project uses> implementation project(":lifemarklibrary")
would like to use suggested> implementation 'com.github.muhammadisa:lifemark:1.0.1'

getting error > Failed to resolve: com.github.muhammadisa:lifemark:1.0.1
Using Android Studio Artic Fox 2020.3.1

1.tried commenting out one line suggested by others in the gradle.properties

Use R8 instead of ProGuard for code shrinking.

#comment-out-for-lifemark? android.enableR8.fullMode=true
results=still getting same error.

  1. replaced one line in your build.gradle (:example) with this one
    implementation 'com.github.muhammadisa:lifemark:1.0.1'
    //implementation project(":lifemarklibrary")
    build results ---------------------
    Executing tasks: [:example:assembleDebug] in project C:\krg\android\001_BestExample\del\Lifemark-master
    FAILURE: Build failed with an exception.
  • What went wrong:
    Could not determine the dependencies of task ':example:compileDebugJavaWithJavac'.

Could not resolve all task dependencies for configuration ':example:debugCompileClasspath'.
Could not find com.github.muhammadisa:lifemark:1.0.1.
Required by:
project :example

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  • Get more help at https://help.gradle.org
    BUILD FAILED in 564ms

any suggestions?
thank you, K

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.