Skip to content

Instantly share code, notes, and snippets.

View rajumark's full-sized avatar
💬
Writing program that write programs.(KSP)

Raju Shingadiya rajumark

💬
Writing program that write programs.(KSP)
View GitHub Profile
@rajumark
rajumark / SightFragment.java
Created November 5, 2019 06:12 — forked from joinAero/SightFragment.java
Android - Fragment for handling view after it has been created and visible to user for the first time.
package cc.cubone.turbo.core.app;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
/**
* Fragment for handling view after it has been created and visible to user for the first time.
*
* <p>Specially in {@link android.support.v4.view.ViewPager}, the page will be created beforehand
@rajumark
rajumark / OnSwipeTouchListener.java
Last active November 26, 2019 05:58
working swipe listner android just visit starting part of file how to use
package moozy.com.moozy.gestures;
import android.content.Context;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
public class OnSwipeTouchListener implements OnTouchListener {
@rajumark
rajumark / code.kt
Created November 26, 2019 09:21
get recyclerview center item position based on layoutmanager
private fun giveMeCenterPosition(): Int {
val firstPos = layoutManager!!.findFirstVisibleItemPosition()
val lastPos = layoutManager!!.findLastVisibleItemPosition()
val middle = abs(lastPos - firstPos) / 2 + firstPos
return middle
}
@rajumark
rajumark / AndroidManifest.xml
Created November 26, 2019 11:42
disable split screen support in android app
<application
android:resizeableActivity="false"
buildFeatures {
viewBinding true
}
// activity and lifecycle
implementation 'androidx.activity:activity-ktx:1.5.1'
implementation 'androidx.fragment:fragment-ktx:1.5.2'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation 'androidx.lifecycle:lifecycle-common-java8:2.5.1'
@rajumark
rajumark / ACTION_OPEN_DOCUMENT_TREE
Created December 7, 2022 17:45
MediaStore handle file android
http://www.java2s.com/example/java-api/android/provider/documentscontract/builddocumenturiusingtree-2-0.html
@rajumark
rajumark / gist:27327b4eb9c5744de704b392981646b0
Created December 7, 2022 17:54
pick folder using system tree view then use it
val dirRequest =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri: Uri? ->
uri?.let { folderUri ->
contentResolver.takePersistableUriPermission(
folderUri,
Intent.FLAG_GRANT_READ_URI_PERMISSION
)
//use picked uri android