Skip to content

Commit

Permalink
Setup example
Browse files Browse the repository at this point in the history
  • Loading branch information
muddassir235 committed Aug 28, 2020
1 parent b455c48 commit 4ca9c27
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ android {
}

dependencies {
implementation project(":connection_checker")
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.muddassir.connection_checker_app">

Expand All @@ -7,6 +8,14 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.muddassir.connection_checker_app

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.muddassir.connection_checker.ConnectionChecker
import com.muddassir.connection_checker.ConnectivityListener
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), ConnectivityListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val connectionChecker = ConnectionChecker(this, lifecycle)
connectionChecker.connectivityListener = this
connectionChecker.startChecking()
}

override fun onConnected() {
connection_status_tv.text = "Connected"
}

override fun onConnectionSlow() {
connection_status_tv.text = "Slow Internet Connection"
}

override fun onDisconnected() {
connection_status_tv.text = "Disconnected"
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/connection_status_tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/connected"
android:gravity="center"
android:textSize="23dp"
android:fontFamily="monospace"
xmlns:android="http://schemas.android.com/apk/res/android" />
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Connection Checker</string>
<string name="connected">Connected</string>
</resources>

0 comments on commit 4ca9c27

Please sign in to comment.