Skip to content

Instantly share code, notes, and snippets.

View kabirnayeem99's full-sized avatar
🌦️

Naimul Kabir kabirnayeem99

🌦️
View GitHub Profile
import android.graphics.Matrix
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
@inan-mahmud
inan-mahmud / base_screen.dart
Last active April 19, 2022 11:48
A simple base ui class in flutter and how to implement it.
import 'package:flutter/material.dart';
abstract class BaseScreen extends StatefulWidget {
const BaseScreen({Key? key}) : super(key: key);
}
@dev4jam
dev4jam / network_service.dart
Created March 21, 2022 06:57
Full source code of the Network Service
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:io';
part 'NetworkRequestBody.freezed.dart';
part 'NetworkResponse.freezed.dart';
class AccessTokenResponse {
String? accessToken;
AccessTokenResponse.fromJson(Map<String, dynamic> json) {
accessToken = json['access_token'];
@abircse
abircse / MyCustomDialog.kt
Last active December 25, 2021 08:24
A Custom Wrapper class for handle dialog & bottom sheet dialog including viewbinding.
object MyCustomDialog {
fun <V : ViewDataBinding> showCustomBottomSheetDialog(
activity: Activity,
@LayoutRes layoutId: Int,
setCancelable: Boolean = false,
onSuccess: (Dialog, V) -> Unit
) {
val layout =
DataBindingUtil.inflate<V>(LayoutInflater.from(activity), layoutId, null, false)
@iamriajul
iamriajul / ConnectivityUtil.kt
Created April 26, 2021 05:19
Android Kotlin utility class for checking device's network connectivity and speed and internet availability. - You may use this with DI system easily.
package org.dailyislam.android.utilities
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkInfo
import android.telephony.TelephonyManager
import java.net.InetAddress
class ConnectivityUtil(private val applicationContext: Context) {
@ChristopherME
ChristopherME / recyclerview-fix-leak-extension.kt
Last active March 25, 2023 14:05
This extension method is a solution for a memory leak problem with recyclerviews.
/**
* Set the adapter and call [clearReference] extension function in one call.
* Use this extension if the current Fragment is going to be REPLACED. (When using fragmentTransaction.add is not necessary) the back stack.
*/
fun <VH : RecyclerView.ViewHolder> RecyclerView.setNullableAdapter(
adapter: RecyclerView.Adapter<VH>
) {
this.adapter = adapter
this.clearReference()
class RPSCustomPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()
..color = Colors.blue
..style = PaintingStyle.stroke;
// Code for path
// From here ....
Path path = Path();
path.moveTo(size.width * 0.07, size.height * 0.08);
private fun getClient(): WebViewClient {
return object : WebViewClient() {
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
): WebResourceResponse? {
return super.shouldInterceptRequest(view, request)
}
override fun shouldInterceptRequest(view: WebView?, url: String?): WebResourceResponse? {
@Ahwar
Ahwar / Convert Android ImageProxy to Bitmap in Java.java
Created September 8, 2020 06:32
This Java code converts android's ImageProxy to Bitmap.
private Bitmap toBitmap(Image image) {
Image.Plane[] planes = image.getPlanes();
ByteBuffer yBuffer = planes[0].getBuffer();
ByteBuffer uBuffer = planes[1].getBuffer();
ByteBuffer vBuffer = planes[2].getBuffer();
int ySize = yBuffer.remaining();
int uSize = uBuffer.remaining();
int vSize = vBuffer.remaining();
@yusufceylan
yusufceylan / HuaweiLocationManager.kt
Created September 7, 2020 12:36
Huawei Location Manager Wrapper
/**
* Wrapper class for handling Location related methods
*/
class HuaweiLocationManager constructor(private val context : Context) {
//region vars
private val mFusedLocationProviderClient: FusedLocationProviderClient by lazy {
LocationServices.getFusedLocationProviderClient(context)
}