Skip to content

Instantly share code, notes, and snippets.

View Tarek-Bohdima's full-sized avatar

Tarek Bohdima Tarek-Bohdima

View GitHub Profile
@sonique6784
sonique6784 / CustomViewTest.kt
Created June 15, 2021 13:15
Jetpack Compose: CustomViewTest
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.test.assertTrue
@sonique6784
sonique6784 / CustomView.kt
Created June 15, 2021 13:13
Jetpack Compose: Custom View
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
data class DataCustomView(
val title: String,
val description: String
// RecyclerView Adapter implemented as ListAdapter and DiffCallback
class Mydapter(
private val clickListener: (String) -> Unit
) :
ListAdapter<MyUiModel, MyViewHolder>(MyDiffCallback()) {
override fun onCreateViewHolder(
parent: ViewGroup,
position: Int
@ExNDY
ExNDY / ActivityClass.java
Last active November 18, 2020 17:15
Monitoring network connection for Android ( API 24+ ) with using LiveData
public class Activity extends AppCompatActivity{
...
private NetworkConnectionMonitor connectionMonitor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
...
connectionMonitor = new NetworkConnectionMonitor(getApplicationContext());
@JakeSteam
JakeSteam / MyClass.kt
Last active March 23, 2024 19:24
Accessing Android app secrets from GitHub Actions using Gradle (https://blog.jakelee.co.uk/accessing-android-app-secret-from-github-actions-using-gradle/)
package uk.co.jakelee.apodwallpaper.example
import uk.co.jakelee.apodwallpaper.BuildConfig
class MyClass() {
val key = BuildConfig.APOD_API_KEY
}
@stevecondylios
stevecondylios / resize-image-in-github-issue-github-flavored-markdown.md
Last active April 27, 2024 19:04
How to Resize an Image in a Github Issue (e.g. Github flavored Markdown)

How to Resize an Image in Github README.md (i.e. Github Flavored Markdown)

Percentage:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width=50% height=50%>

Pixels:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width="150" height="280">

private fun GeofencePickerClick() {
checkIfUserEnabledLocationNetwork() // don't call it unless you're sure that the user granted location permission
}
private fun checkIfUserEnabledLocationNetwork() {
val responseTask = getLocationNetworkTask()!!
responseTask.addOnSuccessListener { startMapActivity() }
.addOnFailureListener {
val apiException = it as ApiException
when (apiException.statusCode) {
@PasanBhanu
PasanBhanu / CheckNetwork.java
Last active July 25, 2023 13:28
Check Internet Connection in Android (API Level 29) Using Network Callback
/*
You need to call the below method once. It register the callback and fire it when there is a change in network state.
Here I used a Global Static Variable, So I can use it to access the network state in anyware of the application.
*/
// You need to pass the context when creating the class
public CheckNetwork(Context context) {
this.context = context;
}
@bchiang7
bchiang7 / github_signing_commits_with_gpg.md
Last active December 15, 2022 07:45
Signing GitHub Commits with GPG