Skip to content

Instantly share code, notes, and snippets.

View rahulkhatri19's full-sized avatar
🎯
Focusing

Rahul Khatri rahulkhatri19

🎯
Focusing
View GitHub Profile
@rahulkhatri19
rahulkhatri19 / Git Commands.md
Last active September 23, 2022 04:06
Basic git commands

Basic git command

  • General commands: create branch, add changes to git, commit/save changes, push code

    $ git checkout -b [branch name] // create branch - git checkout -b master

    $ git add . // add code to git

$ git commit -m "message" // commit chages

@rahulkhatri19
rahulkhatri19 / Sample Data
Created April 24, 2019 11:19
Sample Data in XML element like TextView, RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
@rahulkhatri19
rahulkhatri19 / item_sample
Created April 24, 2019 11:21
Layout for Sample Data in RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
#D81B60 // just first line of with # and hexa value of color
Lorium Ipsum // put the text in first line
Step to create it
Go to App -> New -> Sample Data Directory
It will Create sample data foler
sampledata -> New -> File // Take Text File
Json file write file name end with .json
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.AlertDialogActivity">
<Button
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.example.flipkotlinfirst.R
import com.example.flipkotlinfirst.util.AlertDialogUtility
import kotlinx.android.synthetic.main.activity_alert_dialog.*
import kotlinx.android.synthetic.main.dialog_layout.view.*
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white"/>
<corners android:radius="16dp"/>
</shape>
import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.example.flipkotlinfirst.R
import kotlinx.android.synthetic.main.alert_custom_layout.view.*
class AlertDialogUtility {
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"