RNetwork

Additional

Language
Kotlin
Version
v1.0.4-release (Sep 20, 2020)
Created
Mar 29, 2020
Updated
Sep 20, 2020
Owner
Rezwan (rrsaikat)
Contributor
Rezwan (rrsaikat)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

RNetwork

A light weight and lifecycle awared live internet connection status library using reactivenetwork and crouton.

How To

How does another developer add this as a dependency?

STEP 1: Reference your Bintray repository into project-level build.gradle:

    allprojects {
      repositories {
        // ...
        maven { url 'https://dl.bintray.com/rrsaikat/RNetwork' }
      }
    }

STEP 2: Reference the library itself in your module-level build.gradle:

    implementation 'com.rezwan.knetworklib:knetworklib:1.0.4'

STEP 3: KNetwork.initialize(this) - must declare this into Application.

    class App:Application() {
        override fun onCreate() {
            super.onCreate()
            KNetwork.initialize(this)
        }
    }

nb: Don't forget to register your custom Application class into your manifest.xml file.

        <manifest xmlns:android="http://schemas.android.com/apk/res/android">
          <application
            android:name=".App"
             ....>
           </application>
        </manifest>

STEP 4: KNetwork.bind(this, lifecycle) - bind the targeted activity in which you want to show network status.

    KNetwork.bind(this, lifecycle)
                   .setConnectivityListener(this)

NOTE:

  1. Enable java 8:

     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
    

Available additinal methods:

*  setSuccessLayout() - set your customized layout
*  setErrorLayout() - set your customized layout
*  showCroutons() - set false if you don't want to show croutons
*  showKNDialog() - set true for show dialog when net connection goes off.
*  setConnectivityListener() - connected, disconnected callback into activity
*  setInAnimation() - custom animation setup
*  setOutAnimation() - custom animation setup
*  setViewGroupResId() - targeted viewgroup to show network status views.

Example:

KNetwork.bind(this, lifecycle)
                .showKNDialog(true)
                .showCroutons(true)
                .setViewGroupResId(R.id.crouton_top) // by default we will show our croutons into top
                .setSuccessLayout(R.layout.custom_success_layout)
                .setErrorLayout(R.layout.custom_error_layout)
                .setConnectivityListener(this)

Example project is here for better understanding: GO TO Example

Video Sample (Installaion or setup)

GO TO Tutorial

Proguard

################ rxjava2 ###########
-dontwarn java.util.concurrent.Flow*
##### END ##############

##ReactNetwork####
-dontwarn com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
-dontwarn io.reactivex.functions.Function
-dontwarn rx.internal.util.**
-dontwarn sun.misc.Unsafe
##END#####

Apps that are used this library:

Author

👤 RRSaikat

Used Libraries

  1. ReactiveNetwork
  2. Crouton

License

  Copyright (c) 2020-present, RRsaikat

  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.