-
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.
Error handling, splashScreen and app icon
- Loading branch information
Showing
65 changed files
with
513 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 +1,26 @@ | ||
package com.awto.randomjoke | ||
|
||
import android.app.Application | ||
import android.util.Log | ||
import com.awto.randomjoke.util.NetworkMonitoringUtil | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class MyApplication : Application(){ | ||
class MyApplication : Application() { | ||
|
||
val TAG: String = MyApplication::class.java.simpleName | ||
var mNetworkMonitoringUtil: NetworkMonitoringUtil? = null | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
Log.d( | ||
TAG, | ||
"onCreate() called" | ||
) | ||
|
||
mNetworkMonitoringUtil = NetworkMonitoringUtil(applicationContext) | ||
mNetworkMonitoringUtil!!.checkNetworkState() | ||
mNetworkMonitoringUtil!!.registerNetworkCallbackEvents() | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/awto/randomjoke/data/local/NetworkStateManager.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,45 @@ | ||
package com.awto.randomjoke.data.local; | ||
|
||
import android.os.Looper; | ||
import android.util.Log; | ||
|
||
import androidx.lifecycle.LiveData; | ||
import androidx.lifecycle.MutableLiveData; | ||
|
||
public class NetworkStateManager { | ||
public static final String TAG = NetworkStateManager.class.getSimpleName(); | ||
|
||
private static NetworkStateManager INSTANCE; | ||
private static final MutableLiveData<Boolean> activeNetworkStatusMLD = new MutableLiveData<>(); | ||
|
||
private NetworkStateManager() {} | ||
|
||
public static synchronized NetworkStateManager getInstance() { | ||
if (INSTANCE == null) { | ||
Log.d(TAG, "getInstance() called: Creating new instance"); | ||
INSTANCE = new NetworkStateManager(); | ||
} | ||
return INSTANCE; | ||
} | ||
|
||
/** | ||
* Updates the active network status live-data | ||
*/ | ||
public void setNetworkConnectivityStatus(boolean connectivityStatus) { | ||
Log.d(TAG, "setNetworkConnectivityStatus() called with: connectivityStatus = [" + connectivityStatus + "]"); | ||
|
||
if (Looper.myLooper() == Looper.getMainLooper()) { | ||
activeNetworkStatusMLD.setValue(connectivityStatus); | ||
} else { | ||
activeNetworkStatusMLD.postValue(connectivityStatus); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the current network status | ||
*/ | ||
public LiveData<Boolean> getNetworkConnectivityStatus() { | ||
Log.d(TAG, "getNetworkConnectivityStatus() called"); | ||
return activeNetworkStatusMLD; | ||
} | ||
} |
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
Oops, something went wrong.