This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void uploadFromFile(String path) { | |
Helper.showDialog(this); | |
Uri file = Uri.fromFile(new File(path)); | |
StorageReference imageRef = folderRef.child(file.getLastPathSegment()); | |
mUploadTask = imageRef.putFile(file); | |
mUploadTask.addOnFailureListener(new OnFailureListener() { | |
@Override | |
public void onFailure(@NonNull Exception exception) { | |
Helper.dismissDialog(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void uploadFromFile(String path) { | |
Uri file = Uri.fromFile(new File(path)); | |
StorageReference imageRef = folderRef.child(file.getLastPathSegment()); | |
StorageMetadata metadata = new StorageMetadata.Builder() | |
.setContentType("image/jpg") | |
.setCustomMetadata("country", "Thailand" | |
.build(); | |
UploadTask uploadTask = imageRef.putFile(file, metadata); | |
Helper.initProgressDialog(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void downloadInMemory() { | |
//long ONE_MEGABYTE = 1024 * 1024; | |
Helper.showDialog(this); | |
imageRef.getBytes(Long.MAX_VALUE).addOnSuccessListener(new OnSuccessListener<byte[]>() { | |
@Override | |
public void onSuccess(byte[] bytes) { | |
Helper.dismissDialog(); | |
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); | |
mImageView.setImageBitmap(bitmap); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void downloadInLocalFile() { | |
File dir = new File(Environment.getExternalStorageDirectory() + "/photos"); | |
final File file = new File(dir, UUID.randomUUID().toString() + ".png"); | |
try { | |
if (!dir.exists()) { | |
dir.mkdir(); | |
} | |
file.createNewFile(); | |
} catch (IOException e) { | |
e.printStackTrace(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void downloadDataViaUrl() { | |
Helper.showDialog(this); | |
imageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { | |
@Override | |
public void onSuccess(Uri uri) { | |
Helper.dismissDialog(); | |
mTextView.setText(uri.toString()); | |
} | |
}).addOnFailureListener(new OnFailureListener() { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void deleteFile() { | |
Helper.showDialog(this); | |
imageRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() { | |
@Override | |
public void onSuccess(Void aVoid) { | |
Helper.dismissDialog(); | |
mImageView.setImageDrawable(null); | |
mTextView.setText(String.format("%s was deleted.", imageRef.getPath())); | |
} | |
}).addOnFailureListener(new OnFailureListener() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getMetadata() { | |
Helper.showDialog(this); | |
imageRef.getMetadata().addOnSuccessListener(new OnSuccessListener<StorageMetadata>() { | |
@Override | |
public void onSuccess(StorageMetadata storageMetadata) { | |
Helper.dismissDialog(); | |
mTextView.setText(String.format("Country: %s", storageMetadata.getCustomMetadata("country"))); | |
} | |
}).addOnFailureListener(new OnFailureListener() { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void updateMetaData() { | |
Helper.showDialog(this); | |
StorageMetadata metadata = new StorageMetadata.Builder().setCustomMetadata("country", "Thailand").build(); | |
imageRef.updateMetadata(metadata).addOnSuccessListener(new OnSuccessListener<StorageMetadata>() { | |
@Override | |
public void onSuccess(StorageMetadata storageMetadata) { | |
Helper.dismissDialog(); | |
mTextView.setText(String.format("Country: %s", storageMetadata.getCustomMetadata("country"))); | |
} | |
}).addOnFailureListener(new OnFailureListener() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent intent = new AppInviteInvitation.IntentBuilder("Send App Invitation") | |
.setMessage("Special season for this app is starting now, try it and get 100 baht") | |
.setDeepLink(Uri.parse("http://example.com/offer/100_baht")) | |
.setCustomImage(Uri.parse("https://appjoy.org/wp-content/uploads/2016/06/firebase-invites-logo.png")) | |
.setCallToActionText("Install") | |
.build(); | |
startActivityForResult(intent, REQUEST_INVITE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent intent = new AppInviteInvitation.IntentBuilder("Send App Invitation") | |
.setMessage("Special season for this app is starting now, try it and get 100 baht") | |
.setDeepLink(Uri.parse("http://example.com/offer/100_baht")) | |
.build(); | |
startActivityForResult(intent, REQUEST_INVITE); |