Skip to content

Instantly share code, notes, and snippets.

View chydee's full-sized avatar
:octocat:

Desmond Ngwuta Chidiebere chydee

:octocat:
View GitHub Profile
@chydee
chydee / Others.kt
Created August 26, 2021 14:49
OTP Behaviour
private fun clearInputs() {
val colorStateList = ColorStateList.valueOf(Color.RED)
binding.apply {
otp1.text.clear()
otp2.text.clear()
otp3.text.clear()
otp4.text.clear()
otp5.text.clear()
@chydee
chydee / AlarmReceiver.kt
Created December 29, 2020 11:01
Create Periodic Tasks With AlarmManager and JobIntentService
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.chydee.notekeeper.data.DBHelper
import com.chydee.notekeeper.data.DBHelperImpl
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
class AlarmReceiver : BroadcastReceiver() {
@chydee
chydee / CallingClass.kt
Created December 25, 2020 01:20
Check And Report Internet Connctivity In RealTime
val networkMonitor = NetworkMonitorUtil(requireContext())
override fun onStart() {
super.onStart()
networkMonitor.register()
}
override fun onStop() {
super.onStop()
networkMonitor.unregister()
@chydee
chydee / MainActivity.java
Created August 31, 2020 14:08
Render 3D Objects or Scene in android without ARCore
//Classes declaration
private Node sketchNode;
private Scene scene;
private SceneView sceneView;
private StorageReference modelRef;
private FirebaseStorage storage;
private RelativeLayout sceneContainer;
private ModelRenderable renderable;
//End of Classes declaration
@chydee
chydee / ConnectivityMonitor.kt
Created May 19, 2020 07:36 — forked from iRYO400/ConnectivityMonitor.kt
Check Internet Connection [API21+][API29+ supported] Lifecycle aware
import android.content.Context
import android.content.Context.CONNECTIVITY_SERVICE
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
@chydee
chydee / PULL_REQUEST_TEMPLATE
Created March 28, 2020 10:38 — forked from riggaroo/PULL_REQUEST_TEMPLATE
Pull request template format. Add this file to your .github folder
<!--- Provide a general summary of your changes in the Title above -->
<!--- If there is no changelog entry, label this PR as trivial to bypass the Danger warning -->
## Description
<!--- Describe your changes in detail -->
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
@chydee
chydee / AsyncTaskLoader For Dummy
Created June 10, 2019 08:35
A Dummy's guide to AsycTaskLoader
#Step by step tutorial on how to define and use AsyncTaskLoader.
**************************************************************
This class performs the same function as the AsyncTask, but a bit better.
It can handle Activity configuration changes more easily, and it behaves within the life cycles of Fragments and Activities.
STEP 1: Implement LoaderManager.LoaderCallbacks<String> on MainActivity then implement and override the following methods:
onCreateLoader, onLoadFinished and onLoaderReset
STEP 2: Inside onCreateLoader() return a new AsyncTaskLoader<String> as an anonymous inner class with this as the constructor's parameter and override loadInBackground & onStartLoadinginside anonymous inner class
STEP 3: In your MainActivity define two constant
command usage
git init Creates an empty Git repository in the specified directory.
git clone <repository name> Clones a repository located at <repository name> onto your local machine.
git add <directory> Stages only the specified changes for the next commit. Replace <directory> with a <file> to change a specific file.
git add . Stages new files and modifications without deletions
git add -A Stages all changes
git add -all Equivalent to git add -A
git add -u Stages modifications and deletions without adding new files
git add --update Equivalent to git add -u
git commit -m ”<message>” Commits the staged snapshot. replace <message> with the commit message.
@chydee
chydee / Code for releaseMediaPlayer from NumbersActivity.java Copy over the releaseMediaPlayer() helper method from the NumbersActivity into the NumbersFragment.
/**
* Clean up the media player by releasing its resources.
*/
private void releaseMediaPlayer() {
// If the media player is not null, then it may be currently playing a sound.
if (mMediaPlayer != null) {
// Regardless of the current state of the media player, release its resources
// because we no longer need it.
mMediaPlayer.release();