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 / DoublyLinkedList.c
Created January 20, 2017 09:00 — forked from mycodeschool/DoublyLinkedList.c
Doubly Linked List implementation in C
/* Doubly Linked List implementation */
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node* next;
struct Node* prev;
};
/*
* BottomNavigationLayout library for Android
* Copyright (c) 2016. Nikola Despotoski (http://github.com/NikolaDespotoski).
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sam43
sam43 / CollapsingTitleLayout.java
Created September 5, 2016 06:37 — forked from chrisbanes/CollapsingTitleLayout.java
CollapsingTitleLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sam43
sam43 / README.md
Created August 25, 2016 05:12 — forked from gabrielemariotti/README.md
A SectionedGridRecyclerViewAdapter: use this class to realize a simple sectioned grid `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@sam43
sam43 / index.php
Last active April 28, 2016 20:21 — forked from imran103019/index.php
Primary
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("http://hdechalange-solve.appspot/challenge/003/endpoint",
{
id: "id103019"