Skip to content

Commit 6b9706a

Browse files
committed
- typo.
- bug fix in volley client. - added more functionality to ConnectionDetector.java - minor bug fixes. - removed unnecessary dependencies.
1 parent a0347c7 commit 6b9706a

File tree

14 files changed

+99
-57
lines changed

14 files changed

+99
-57
lines changed

.idea/codeStyles/Project.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 29
5-
buildToolsVersion "29.0.3"
4+
compileSdkVersion 30
65

76
defaultConfig {
87
applicationId "com.devloops"
98
minSdkVersion 19
10-
targetSdkVersion 29
9+
targetSdkVersion 30
1110
versionCode 1
1211
versionName "1.0"
1312
multiDexEnabled = true
@@ -34,16 +33,17 @@ android {
3433

3534
dependencies {
3635
implementation fileTree(dir: "libs", include: ["*.jar"])
37-
implementation 'androidx.appcompat:appcompat:1.1.0'
38-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
36+
implementation project(path: ':base')
37+
38+
implementation 'androidx.appcompat:appcompat:1.2.0'
39+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
3940

4041
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
4142
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
4243

43-
implementation project(path: ':base')
4444
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
4545

46-
testImplementation 'junit:junit:4.13'
47-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
48-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
46+
testImplementation 'junit:junit:4.13.1'
47+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
48+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4949
}

app/src/main/java/com/devloops/activities/ui/activities/MainActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ private void attachFragment() {
4646
private void getExampleRequestVolley() {
4747
Map<String, String> headers = new HashMap<>();
4848

49-
Api.with(context).addHeaders(headers).get("",
50-
response -> {
49+
Api.with(context)
50+
.addHeaders(headers)
51+
.get("", response -> {
5152

5253
}, error -> {
5354

base/build.gradle

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ group = 'devloops.net'
44
version = '1.0'
55

66
android {
7-
compileSdkVersion 29
8-
buildToolsVersion "29.0.3"
7+
compileSdkVersion 30
98

109
defaultConfig {
1110
minSdkVersion 19
12-
targetSdkVersion 29
11+
targetSdkVersion 30
1312
versionCode 1
1413
versionName "1.0"
1514
multiDexEnabled = true
@@ -41,27 +40,14 @@ android {
4140

4241
dependencies {
4342
implementation fileTree(dir: "libs", include: ["*.jar"])
44-
implementation 'androidx.appcompat:appcompat:1.1.0'
45-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
43+
implementation 'androidx.appcompat:appcompat:1.2.0'
44+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
4645
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
4746
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
4847
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
4948
implementation "androidx.multidex:multidex:2.0.1"
5049
implementation 'androidx.recyclerview:recyclerview:1.1.0'
51-
52-
//navigation
53-
implementation 'androidx.navigation:navigation-fragment:2.3.0'
54-
implementation 'androidx.navigation:navigation-ui:2.3.0'
55-
56-
//fireBase
57-
implementation 'com.google.android.material:material:1.3.0-alpha01'
58-
implementation 'com.google.android.gms:play-services-places:17.0.0'
59-
implementation 'com.google.android.gms:play-services-maps:17.0.0'
60-
implementation 'com.google.android.libraries.places:places:2.3.0'
61-
implementation 'com.google.firebase:firebase-messaging:20.2.1'
62-
implementation 'com.google.firebase:firebase-core:17.4.3'
63-
implementation 'com.google.firebase:firebase-crashlytics:17.1.0'
64-
implementation 'com.google.firebase:firebase-analytics:17.4.3'
50+
implementation 'com.google.android.material:material:1.3.0-beta01'
6551

6652
//networking & image loaders
6753
implementation 'com.amitshekhar.android:android-networking:1.0.2'
@@ -85,9 +71,8 @@ dependencies {
8571
//pickers
8672
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
8773
implementation 'com.opensooq.supernova:gligar:1.1.0'
88-
implementation 'com.google.firebase:firebase-invites:17.0.0'
8974

90-
testImplementation 'junit:junit:4.13'
91-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
92-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
75+
testImplementation 'junit:junit:4.13.1'
76+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
77+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
9378
}

base/src/main/java/com/base/utils/Api.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.annotation.SuppressLint;
44
import android.content.Context;
55

6-
import com.android.volley.AuthFailureError;
76
import com.android.volley.Request;
87
import com.android.volley.toolbox.StringRequest;
98

@@ -39,6 +38,7 @@ public Api addHeaders(Map<String, String> headers) {
3938
if (headers == null) {
4039
this.headers = new HashMap<>();
4140
} else {
41+
this.headers = new HashMap<>();
4242
this.headers.putAll(headers);
4343
}
4444
return this;

base/src/main/java/com/base/utils/ConnectionDetector.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
import android.net.ConnectivityManager;
55
import android.net.NetworkInfo;
66

7-
import static android.net.NetworkInfo.State.CONNECTED;
8-
97
/**
108
* @author Odey M. Khalaf <[email protected]>
119
*/
1210
public class ConnectionDetector {
1311

14-
private Context _context;
12+
private final Context _context;
1513

1614
private ConnectionDetector(Context context) {
1715
this._context = context;
@@ -21,13 +19,30 @@ public static ConnectionDetector with(Context context) {
2119
return new ConnectionDetector(context);
2220
}
2321

24-
public boolean isConnectedToInternet() {
25-
ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
26-
if (connectivity != null) {
27-
NetworkInfo[] info = connectivity.getAllNetworkInfo();
28-
for (NetworkInfo anInfo : info)
29-
if (anInfo.getState() == CONNECTED) return true;
22+
public boolean isInternetConnected(Context context) {
23+
boolean isWifiConnected = false;
24+
boolean isMobileInternetConnected = false;
25+
if (context != null) {
26+
try {
27+
28+
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
29+
assert manager != null;
30+
NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
31+
if (activeNetwork != null) { // connected to the internet
32+
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
33+
// connected to wifi
34+
isWifiConnected = true;
35+
} else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
36+
// connected to the mobile provider's data plan
37+
isMobileInternetConnected = true;
38+
}
39+
}
40+
} catch (Exception e) {
41+
e.printStackTrace();
42+
}
43+
} else {
44+
Logger.d(Constants.TAG, "isInternetConnected() -> Context is null");
3045
}
31-
return false;
46+
return isWifiConnected || isMobileInternetConnected;
3247
}
3348
}

base/src/main/java/com/base/utils/DateTimeFormatter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
*/
1414
public class DateTimeFormatter {
1515

16-
public static String getHrViewFormmate(Calendar calendar) {
16+
public static String getHrViewFormat(Calendar calendar) {
1717
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mma", Locale.ENGLISH);
1818
return simpleDateFormat.format(calendar.getTime());
1919
}
2020

21-
public static String getDateViewFormmate(Calendar calendar) {
21+
public static String getDateViewFormat(Calendar calendar) {
2222
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
2323
return simpleDateFormat.format(calendar.getTime());
2424
}
2525

26-
public static String getDateViewFormateFromWS(String wsDate) {
26+
public static String getDateViewFormatFromWS(String wsDate) {
2727
SimpleDateFormat simpleDateFormatWS = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
2828
Date date = null;
2929
try {
@@ -39,7 +39,7 @@ public static String getDateViewFormateFromWS(String wsDate) {
3939
return "";
4040
}
4141

42-
public static String getDateWsFormateFromView(String wsDate) {
42+
public static String getDateWsFormatFromView(String wsDate) {
4343
@SuppressLint("SimpleDateFormat")
4444
SimpleDateFormat simpleDateFormatWS = new SimpleDateFormat("dd/MM/yyyy");
4545
Date date = null;
@@ -69,7 +69,7 @@ public static boolean validPastDate(String string) {
6969
}
7070

7171
@SuppressLint("SimpleDateFormat")
72-
public static String getDateAndTimeWsFormateFromView(String s) {
72+
public static String getDateAndTimeWsFormatFromView(String s) {
7373
SimpleDateFormat simpleDateFormatWS = new SimpleDateFormat("dd/MM/yyyy hh:mm aa");
7474
Date date = null;
7575
try {
@@ -86,7 +86,7 @@ public static String getDateAndTimeWsFormateFromView(String s) {
8686
}
8787

8888
@SuppressLint("SimpleDateFormat")
89-
public static String getDateAndTimeWsFormateFromWs(String s) {
89+
public static String getDateAndTimeWsFormatFromWs(String s) {
9090
SimpleDateFormat simpleDateFormatWS = new SimpleDateFormat("yyyy-MM-dd KK:mm:00", Locale.ENGLISH);
9191
Date date = null;
9292
try {
@@ -103,7 +103,7 @@ public static String getDateAndTimeWsFormateFromWs(String s) {
103103
}
104104

105105
@SuppressLint("SimpleDateFormat")
106-
public static String getDateViewFormateFromWsDateTime(String s) {
106+
public static String getDateViewFormatFromWsDateTime(String s) {
107107
SimpleDateFormat simpleDateFormatWS = new SimpleDateFormat("yyyy-MM-dd HH:mm:00", Locale.ENGLISH);
108108
Date date = null;
109109
try {
@@ -119,7 +119,7 @@ public static String getDateViewFormateFromWsDateTime(String s) {
119119
}
120120

121121
@SuppressLint("SimpleDateFormat")
122-
public static String getTimeViewFormateFromWsDateTime(String s) {
122+
public static String getTimeViewFormatFromWsDateTime(String s) {
123123
SimpleDateFormat simpleDateFormatWS = new SimpleDateFormat("yyyy-MM-dd HH:mm:00", Locale.ENGLISH);
124124
Date date = null;
125125
try {

0 commit comments

Comments
 (0)