-
Notifications
You must be signed in to change notification settings - Fork 0
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
15 changed files
with
240 additions
and
41 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
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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.maxis7567.msvolley" /> | ||
package="com.maxis7567.msvolley" > | ||
|
||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
</manifest> |
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
5 changes: 5 additions & 0 deletions
5
msvolley/src/main/java/com/maxis7567/msvolley/LocalError.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,5 @@ | ||
package com.maxis7567.msvolley; | ||
|
||
public interface LocalError { | ||
void error(String message); | ||
} |
52 changes: 52 additions & 0 deletions
52
msvolley/src/main/java/com/maxis7567/msvolley/NetworkCheck.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,52 @@ | ||
package com.maxis7567.msvolley; | ||
|
||
|
||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
import android.net.ConnectivityManager; | ||
import android.net.Network; | ||
import android.net.NetworkCapabilities; | ||
import android.net.NetworkInfo; | ||
import android.os.Build; | ||
|
||
|
||
public class NetworkCheck { | ||
|
||
public static boolean isNetworkAvailable(Context context) { | ||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | ||
return hasInternetConnection(context); | ||
}else { | ||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); | ||
|
||
return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); | ||
} | ||
} | ||
public static boolean isOnline() { | ||
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; | ||
} | ||
@TargetApi(Build.VERSION_CODES.M) | ||
public static boolean hasInternetConnection(final Context context) { | ||
final ConnectivityManager connectivityManager = (ConnectivityManager)context. | ||
getSystemService(Context.CONNECTIVITY_SERVICE); | ||
|
||
final Network network; | ||
|
||
network = connectivityManager.getActiveNetwork(); | ||
final NetworkCapabilities capabilities = connectivityManager | ||
.getNetworkCapabilities(network); | ||
|
||
return capabilities != null | ||
&& capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); | ||
|
||
|
||
} | ||
} | ||
|
27 changes: 27 additions & 0 deletions
27
msvolley/src/main/java/com/maxis7567/msvolley/PhpLaravelError.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,27 @@ | ||
package com.maxis7567.msvolley; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class PhpLaravelError { | ||
@SerializedName("message") | ||
private String message; | ||
@SerializedName("errors") | ||
private JsonObject errors; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public JsonObject getErrors() { | ||
return errors; | ||
} | ||
|
||
public void setErrors(JsonObject errors) { | ||
this.errors = errors; | ||
} | ||
} |
Oops, something went wrong.