Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:
Answer: As a user navigates through, out of, and back to your app, the Activity instances in your app transition through different states in their lifecycle.
To navigate transitions between stages of the activity lifecycle, the Activity class provides a core set of six callbacks: onCreate()
, onStart()
, onResume()
, onPause()
, onStop()
, and onDestroy()
. The system invokes each of these callbacks as an activity enters a new state.
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
@ExperimentalCoroutinesApi | |
inline fun <reified T> DatabaseReference.observeValue(): Flow<NetworkResponse<List<T>>> = | |
callbackFlow { | |
val listener = object : ValueEventListener { | |
override fun onCancelled(error: DatabaseError) { | |
trySend(NetworkResponse.Failure(message = error.message)) | |
} | |
override fun onDataChange(snapshot: DataSnapshot) { | |
val hostList = arrayListOf<T>() |
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
private val onDownloadCompleteReceiver = object : BroadcastReceiver() { | |
override fun onReceive(context: Context?, intent: Intent?) { | |
if (intent == null) { | |
log("onDownloadComplete intent is: $intent") | |
return | |
} | |
if (intent.action == DownloadManager.ACTION_DOWNLOAD_COMPLETE) { | |
val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) | |
val downloadedFileURI = mDownloadManager?.getUriForDownloadedFile(id) | |
viewModel.enqueuedDownloadingTasksIds.let { enqueuedTasks -> |
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
package com.parrychat.android.ui.call | |
import android.Manifest | |
import android.annotation.SuppressLint | |
import android.os.Bundle | |
import android.util.Log | |
import android.view.LayoutInflater | |
import android.view.MotionEvent | |
import android.view.SurfaceView | |
import android.view.View |
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
FLAG_GRANT_READ_URI_PERMISSION, | |
FLAG_GRANT_WRITE_URI_PERMISSION, | |
FLAG_FROM_BACKGROUND, | |
FLAG_DEBUG_LOG_RESOLUTION, | |
FLAG_EXCLUDE_STOPPED_PACKAGES, | |
FLAG_INCLUDE_STOPPED_PACKAGES, | |
FLAG_GRANT_PERSISTABLE_URI_PERMISSION, | |
FLAG_GRANT_PREFIX_URI_PERMISSION, | |
FLAG_DEBUG_TRIAGED_MISSING, | |
FLAG_IGNORE_EPHEMERAL, |
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
package com.rohit.healthOn.ui.homeScreen | |
import android.os.Bundle | |
import android.os.VibrationEffect | |
import android.os.Vibrator | |
import androidx.activity.viewModels | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.core.view.isVisible | |
import androidx.lifecycle.lifecycleScope | |
import androidx.navigation.NavController |
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
package com.rohit.healthOn.ui.homeScreen | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.viewModelScope | |
import com.rohit.healthOn.data.repo.AuthRepo | |
import com.rohit.healthOn.data.repo.SleepRepo | |
import com.rohit.healthOn.data.repo.WaterRepo | |
import com.rohit.healthOn.util.ERROR_TYPE | |
import com.rohit.healthOn.util.Resource | |
import dagger.hilt.android.lifecycle.HiltViewModel |
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
package com.rohit.healthOn.ui.homeScreen.dashboardScreen | |
import android.os.Bundle | |
import android.view.View | |
import androidx.fragment.app.Fragment | |
import androidx.fragment.app.viewModels | |
import androidx.lifecycle.lifecycleScope | |
import com.google.android.material.tabs.TabLayoutMediator | |
import com.rohit.healthOn.R | |
import com.rohit.healthOn.databinding.FragmentDashboardBinding |
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
package com.rohit.healthOn.ui.homeScreen.dashboardScreen.sleep | |
import android.os.Bundle | |
import android.view.View | |
import androidx.core.view.isVisible | |
import androidx.fragment.app.Fragment | |
import androidx.fragment.app.viewModels | |
import androidx.lifecycle.lifecycleScope | |
import com.rohit.healthOn.R | |
import com.rohit.healthOn.databinding.FragmentSleepDashboardBinding |