Skip to content

Instantly share code, notes, and snippets.

View griajobag's full-sized avatar
🏠
Working from home

Putu Guna griajobag

🏠
Working from home
View GitHub Profile
private void displayImage(){
progressDialog.setMessage("Displaying image");
progressDialog.show();
try {
StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("photo_profile").child("my_photo");
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
progressDialog.dismiss();
Glide.with(MainActivity.this)
StorageReference ref = storageReference.child("photo_profile").child(String.valueOf(System.currentTimeMillis()));
StorageReference ref = storageReference.child("photo_profile").child("my_photo");
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
progressDialog.show();
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Uri resultUri = result.getUri();
uploadImage(resultUri);
Toast.makeText(this, "URI : " + resultUri.toString(), Toast.LENGTH_SHORT).show();
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.setAutoZoomEnabled(true)
.setAspectRatio(1, 1)
.setCropShape(CropImageView.CropShape.OVAL)
.setRequestedSize(1280, 1280)
.start(this);
package com.putuguna.insertimagetofstorage;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
tools:context=".MainActivity">
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.putuguna.insertimagetofstorage"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
@griajobag
griajobag / MainActivity.java
Created January 22, 2018 10:57
Firebase UI
package com.androidbie.firebasephonenumberverification;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;