Skip to content

Instantly share code, notes, and snippets.

View sam43's full-sized avatar
🏠
Working from home

A S M Sayem sam43

🏠
Working from home
View GitHub Profile
@sam43
sam43 / AndroidCamera2TouchToFocus.java
Created March 9, 2023 06:53 — forked from royshil/AndroidCamera2TouchToFocus.java
How to implement Touch-to-Focus in Android using Camera2 APIs
//Override in your touch-enabled view (this can be differen than the view you use for displaying the cam preview)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
final int actionMasked = motionEvent.getActionMasked();
if (actionMasked != MotionEvent.ACTION_DOWN) {
return false;
}
if (mManualFocusEngaged) {
Log.d(TAG, "Manual focus already engaged");
return true;
@sam43
sam43 / README.md
Created March 9, 2023 02:28 — forked from granthenke/README.md
Gradle task to invalidate the cache for a single passed dependency

Gradle Invalidate Task

Note: This is just a quickly hacked together task

To Use:

  • Paste the task below in a gradle build file
  • Call gradle invalidate -Pdependency=group:name:version substituting the dependency you want to invalidate.
@sam43
sam43 / RetrofitCached.java
Created June 26, 2022 13:15 — forked from bapspatil/RetrofitCached.java
Make Retrofit work offline with caching
package bapspatil.pantheon.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import java.io.IOException;
import bapspatil.pantheon.network.RetrofitAPI;
import okhttp3.Cache;
@sam43
sam43 / StringUtils.kt
Created June 12, 2022 17:27 — forked from jongha/StringUtils.kt
Remove trailing zeros in Kotlin
object StringUtils {
fun format(context: Context?, value: Float?): String? {
return trimZero(context?.resources?.getString(R.string.float_format, value ?: 0f))
}
fun format(context: Context?, value: Int?): String? {
return trimZero(context?.resources?.getString(R.string.int_format, value ?: 0))
}
fun trimTrailingZero(value: String?): String? {
@sam43
sam43 / BaseStation.java
Created April 26, 2022 09:00 — forked from eslamfaisal/BaseStation.java
An example to get cell towers info on Android
package com.mirrordust.gpscellinfodemo;
public class BaseStation {
private int mcc; // Mobile Country Code
private int mnc; // Mobile Network Code
private int lac; // Location Area Code or TAC(Tracking Area Code) for LTE
@sam43
sam43 / lib crash
Created February 10, 2022 07:38
PreviewTimeBar lib
02/10 13:36:14: Launching 'app' on samsung SM-A505F.
Install successfully finished in 5 s 489 ms.
$ adb shell am start -n "com.bongobd.demo/com.bongobd.demo.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 25935 on device 'samsung-sm_a505f-R58M848MENN'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/ActivityThread: handleBindApplication()++ app=com.bongobd.demo
D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar
D/ActivityThread: handleBindApplication() -- skipGraphicsSupport=false
D/ActivityThread: ActivityThread::handleMakeApplication() data=AppBindData{appInfo=ApplicationInfo{eabdb33 com.bongobd.demo}} appContext=android.app.ContextImpl@8680ef0 appContext.mOpPackageName=com.bongobd.demo appContext.mBasePackageName=com.bongobd.demo appContext.mPackageInfo=android.app.LoadedApk@67bac69 data.restrictedBa
@sam43
sam43 / AppModule.kt
Created January 23, 2022 12:34
CURL interceptor class to log the CURL command from an API request
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Provides
@Singleton
fun provideRetrofit(client: OkHttpClient): Retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
@sam43
sam43 / android_topics_to_learn.txt
Last active January 12, 2022 06:07
Important links for android learnings
https://betterprogramming.pub/unit-testing-api-specific-code-on-android-cee08dd2dd1
https://premsinghsodha7.medium.com/kotlin-how-to-write-code-more-readable-and-clean-best-practices-ac6cac160f3d
*** https://kapilvij.medium.com/kotlin-interview-cheat-sheet-c62e7850ba73
https://medium.com/@bhakadepatil/design-patterns-in-android-with-kotlin-a64484665eeb
https://medium.com/androiddevelopers/dependency-injection-on-android-with-hilt-67b6031e62d
https://medium.com/androiddevelopers/room-coroutines-422b786dc4c5
https://proandroiddev.com/how-we-reduced-our-gradle-build-times-by-over-80-51f2b6d6b05b
https://www.raywenderlich.com/7109-test-driven-development-tutorial-for-android-getting-started
Unit and Espresso Testing: https://www.youtube.com/watch?v=3weiK_qKuSI&ab_channel=DJMalone
MVI: https://medium.com/@soundhar.p03/android-mvi-architecture-230cd30e40b4
@sam43
sam43 / git-command.rm
Created November 3, 2021 03:33
Git basic and important commands for use
# This command sets the author name and email address respectively to be used with your commits.
# command : 'git config'
Usage:
git config –global user.name “[name]”
git config –global user.email “[email address]”
# Initialize git
Usage:
git init [repository name]
# Git clone repository
package com.fourshop.customer.utils.extentions
import android.os.Handler
import androidx.annotation.DimenRes
import androidx.annotation.DrawableRes
import androidx.appcompat.widget.AppCompatImageView
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners