Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Paras Sidhu sidhuparas

🏠
Working from home
View GitHub Profile
View HorLayoutManager.kt
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/storyModeRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
val layoutManager =
CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true)
View ItemClickSupport.java
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class ItemClickSupport {
private final RecyclerView mRecyclerView;
private OnItemClickListener mOnItemClickListener;
private OnItemLongClickListener mOnItemLongClickListener;
private View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
View MainActivity.java
import android.app.Activity;
import android.app.Application;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
View activity_sandwich.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context=".ScrollingActivity">
<android.support.design.widget.AppBarLayout
View content_sandwich.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@sidhuparas
sidhuparas / MyFile.java
Created Mar 29, 2018
This is just a cool code.
View MyFile.java
private void addShortcut(String path1, String pdfName) {
File file = new File(path1);
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setDataAndType(path, "application/pdf");
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, pdfName);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
View myUriFunction.java
Uri requiredUri = Uri.parse("https://developer.android.com/guide/components/intents-common.html").buildUpon()
.appendQueryParameter("utm_source","udacity")
.appendQueryParameter("utm_medium", "course")
.appendQueryParameter("utm_campaign", "android_basics")
.fragment("Phone")
.build();
View PinPdfFiles.java
//Pre-Oreo
private void addShortcut(String path1, String pdfName) {
File file = new File(path1);
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setDataAndType(path, "application/pdf");
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, pdfName);