Skip to content

Instantly share code, notes, and snippets.

View shubhamnikam's full-sized avatar
🎯
focusing

Shubham Nikam shubhamnikam

🎯
focusing
View GitHub Profile
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:33
Implicit Intent - Open Map
intentMaps.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String latitude = "0";
String longitude = "0";
String query = "1600 Amphitheatre Parkway, CA";
String zoomLevel = "10";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:34
Implicit Intent - Open Camera
intentCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, 1);
}
}
});
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:34
Implicit Intent - Phone Call
intentPhoneCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_CALL);
String phoneNumber = "1234567890";
intent.setData(Uri.parse("tel:" + phoneNumber));
if (intent.resolveActivity(getPackageManager()) != null) {
if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.READ_CONTACTS)) {
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:35
Implicit Intent - SMS
intentSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
String phoneNumber = "1234567890";
String message = "hey there...";
intent.setData(Uri.parse("smsto:" + phoneNumber));
intent.putExtra("sms_body", message);
if (intent.resolveActivity(getPackageManager()) != null) {
@shubhamnikam
shubhamnikam / activity_main.xml
Created January 24, 2019 18:09
shimmer activity_main
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:shimmer="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"
tools:context=".MainActivity">
@shubhamnikam
shubhamnikam / book_list_item.xml
Created January 24, 2019 18:14
shimmer book_list_item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:padding="@dimen/activity_padding_horizontal">
@shubhamnikam
shubhamnikam / book_list_placeholder.xml
Created January 24, 2019 18:17
shimmer book_list_placeholder.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_padding">
<!-- placeholder layout -->
<View
android:id="@+id/thumbnail"
android:layout_width="@dimen/placeholder_image"
@shubhamnikam
shubhamnikam / BookItem.java
Created January 24, 2019 18:19
shimmer BookItem.java
package com.theappnerds.shubham.myshimmer;
public class BookItem {
int id;
String name;
String description;
double price;
String thumbnail;
String author;
package com.theappnerds.shubham.myshimmer;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
package com.theappnerds.shubham.myshimmer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;