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 May 10, 2020 11:16
After upload a file in Android Firebase Storage. Get the file download Url.
StorageReference fileRef = mStorageRef.child(System.currentTimeMillis() + "." + "jpg");
fileRef.putFile(mImageUri)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//upload success in firebase storage
Toast.makeText(MainActivity.this, "Upload success", Toast.LENGTH_SHORT).show();
//setup to get download url
Task<Uri> downloadUri = taskSnapshot.getMetadata().getReference().getDownloadUrl();
@shubhamnikam
shubhamnikam / TodoAdapter.java
Last active July 6, 2019 18:36
RecyclerView Adapter Swipe Right/Left
public void deleteCurrentTodoItem(final int position) {
mRealm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
//needed appropriate action for db manipulation
//I've used realmDb so, use next line if your using realmDb
//and need to deleteItem from db
//otherwise write your code to implement required functionality
mRealmTodoList.deleteFromRealm(position);
notifyDataSetChanged();
@shubhamnikam
shubhamnikam / TodoActivity.java
Last active July 6, 2019 18:37
RecyclerView Swipe Right/Left
private void deleteTodoItem() {
//Swipe to delete currentTodo Item
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0,
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
//private Drawable icon = ContextCompat.getDrawable(getApplicationContext(),R.drawable.icon_delete);
private ColorDrawable background = new ColorDrawable(Color.RED);
@Override
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;
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;
@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;
@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 / 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 / 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 / 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) {