Skip to content

Instantly share code, notes, and snippets.

View akshaymukadam's full-sized avatar

Akshay Mukadam akshaymukadam

View GitHub Profile
@akshaymukadam
akshaymukadam / PermissionCheck.kt
Created August 18, 2019 08:53
Permission Check request permission
if (ContextCompat.checkSelfPermission(this, $PERMISSION$)
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
$PERMISSION$)) {
TODO("Show Explainantion if needed")
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
@akshaymukadam
akshaymukadam / LaunchIntent.kt
Created August 18, 2019 08:44
Launch Activity
fun launch$POSTFIX$(context: Context, $PARAM1$: $DATATYPE1$, $PARAM2$: $DATATYPE2$) {
Intent(context, $TARGETINTENT$::class.java)
intent.`package` = context.packageName
intent.putExtra($KEY1$, $PARAM1$)
intent.putExtra($KEY2$, $PARAM2$)
context.startActivity(intent)
}
@akshaymukadam
akshaymukadam / IntentInstance.kt
Last active August 18, 2019 09:21
returnsIntentInstance
fun get$PREFIX$Intent(context: Context, $PARAM1$: $DATATYPE1$, $PARAM2$: $DATATYPE2$): Intent {
Intent(context, $ACTIVITY$::class.java)
intent.`package` = context.packageName
intent.putExtra($NAME1$, $PARAM1$)
intent.putExtra($NAME2$, $PARAM2$)
return intent
}
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
class ${NAME}(val list: List<$DataType>) : RecyclerView.Adapter<${NAME}.$Viewholder>() {
override fun onCreateViewHolder(container: ViewGroup, viewType: Int): $Viewholder {
@akshaymukadam
akshaymukadam / ViewModel.kt
Created August 17, 2019 08:58
ViewModel IntelliJ template
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "") package ${PACKAGE_NAME} #end
import android.arch.lifecycle.ViewModel
class ${NAME} : ViewModel() {
}
@akshaymukadam
akshaymukadam / live_template_linear_layout.xml
Created August 15, 2019 12:34
Live template for LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/$id$"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
@akshaymukadam
akshaymukadam / linear_layout_template.xml
Last active August 15, 2019 12:32
Template for creating linear layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/${layoutId}"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<!--${SUBSTITTE}--> it allows to assign value to the required params