-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
244 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/app/kiti/com/kitiapp/utils/ConnectionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package app.kiti.com.kitiapp.utils; | ||
|
||
import android.content.Context; | ||
import android.net.ConnectivityManager; | ||
|
||
/** | ||
* Created by Ankit on 2/4/2018. | ||
*/ | ||
|
||
public class ConnectionUtils { | ||
|
||
public static boolean isConnected(Context context) { | ||
|
||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
final android.net.NetworkInfo mobileData = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); | ||
final android.net.NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | ||
if (mobileData.isConnected()) { | ||
return true; | ||
} else if (wifi.isConnected()) { | ||
return true; | ||
} | ||
|
||
// context.startActivity(new Intent(context, ErrorSplash.class)); | ||
// ((AppCompatActivity) context).finish(); | ||
|
||
return false; | ||
} | ||
|
||
// for wifi service [where login is required before internet ] | ||
private static boolean isWorking() { | ||
try { | ||
Process p1 = Runtime.getRuntime().exec("ping -c 1 www.google.com"); | ||
int returnVal = p1.waitFor(); | ||
return (returnVal == 0); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return false; | ||
} | ||
|
||
} | ||
|
57 changes: 57 additions & 0 deletions
57
app/src/main/java/app/kiti/com/kitiapp/utils/ConnectivityErrorDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package app.kiti.com.kitiapp.utils; | ||
|
||
import android.app.Activity; | ||
import android.app.Dialog; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.Window; | ||
import android.widget.TextView; | ||
|
||
import app.kiti.com.kitiapp.R; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
/** | ||
* Created by Ankit on 4/21/2018. | ||
*/ | ||
|
||
public class ConnectivityErrorDialog extends Dialog { | ||
|
||
public Activity c; | ||
public Dialog d; | ||
@BindView(R.id.tryAgain) | ||
TextView tryAgain; | ||
private TextView tryButton; | ||
|
||
public ConnectivityErrorDialog(Activity a) { | ||
super(a); | ||
this.c = a; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
setContentView(R.layout.connectivity_error_dialog); | ||
ButterKnife.bind(this); | ||
tryAgain.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if(tryAgainListener!=null){ | ||
tryAgainListener.onTryAgain(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private TryAgainListener tryAgainListener; | ||
|
||
public void setTryAgainListener(TryAgainListener tryAgainListener) { | ||
this.tryAgainListener = tryAgainListener; | ||
} | ||
|
||
public interface TryAgainListener{ | ||
void onTryAgain(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> | ||
|
||
<size android:width="10dp" android:height="10dp"/> | ||
<solid android:color="@color/colorPrimary"/> | ||
<corners android:radius="4dp"/> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="match_parent" | ||
android:padding="16dp" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:layout_margin="36dp" | ||
android:textColor="#e72d2d2d" | ||
android:gravity="center_horizontal" | ||
android:text="Please check your internet connectivity." | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
<TextView | ||
android:id="@+id/tryAgain" | ||
android:text="Try Again" | ||
android:textSize="18sp" | ||
android:gravity="center" | ||
android:padding="8dp" | ||
android:textColor="#ffffff" | ||
android:background="@drawable/try_again_bg" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters