NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.StorageTask;
import com.theartofdev.edmodo.cropper.CropImage;
import java.util.HashMap;
public class Main4Activity extends AppCompatActivity {
Uri resim_uri;
String benimUri="";
StorageTask yukleme_gorevi;
StorageReference resimyukle_yol;
ImageView image_eklendi;
TextView gonder;
EditText edt_gonderi_hakkinda;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
image_eklendi =findViewById(R.id.eklenen_resim_gonderi);
edt_gonderi_hakkinda =findViewById(R.id.edt_gonderi_hakkinda);
gonder =findViewById(R.id.gonder);
resimyukle_yol= FirebaseStorage.getInstance().getReference("gonderiler");
gonder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resimYukle();
}
});
CropImage.activity()
.setAspectRatio(1,1)
.start(Main4Activity.this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE&&resultCode==RESULT_OK)
{
CropImage.ActivityResult result=CropImage.getActivityResult(data);
resim_uri=result.getUri();
image_eklendi.setImageURI(resim_uri);
}
else
{
Toast.makeText(this, "resim seçilemedi", Toast.LENGTH_SHORT).show();
}

}
private String dosyaUzantisiAl(Uri uri)
{
ContentResolver contentResolver = getContentResolver();
MimeTypeMap mime = MimeTypeMap.getSingleton();
return mime.getExtensionFromMimeType(contentResolver.getType(uri));
}
private void resimYukle()
{//resim yükleme kodları
final ProgressDialog progressDialog=new ProgressDialog(this);
progressDialog.setMessage("Gönderiliyor");
progressDialog.show();
if(resim_uri!=null)
{
final StorageReference dosyayolu=resimyukle_yol.child(System.currentTimeMillis()+"."+dosyaUzantisiAl(resim_uri));
yukleme_gorevi=dosyayolu.putFile(resim_uri);
yukleme_gorevi.continueWithTask(new Continuation() {
@Override
public Object then(@NonNull Task task) throws Exception {
if(!task.isSuccessful())
{
throw task.getException();//hata mesajı
}
return dosyayolu.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if(task.isSuccessful())
{
Uri indirmeUrisi=task.getResult();
benimUri =indirmeUrisi.toString();
DatabaseReference veriyolu=FirebaseDatabase.getInstance().getReference("Gonderiler");
String gonderiId=veriyolu.push().getKey();
HashMap<String,Object> hashMap=new HashMap<>();//çoklu gönderi için
hashMap.put("gonderiId",gonderiId);
hashMap.put("gonderiResmi",benimUri);
hashMap.put("gonderiHakkinda",edt_gonderi_hakkinda.getText().toString());
hashMap.put("gonderen", FirebaseAuth.getInstance().getCurrentUser().getUid());
veriyolu.child(gonderiId).setValue(hashMap);
progressDialog.dismiss();
startActivity(new Intent(Main4Activity.this,Main3Activity.class));
finish();
}
else
{
Toast.makeText(Main4Activity.this, "gönderme başarısız", Toast.LENGTH_SHORT).show();
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Main4Activity.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
else
{
Toast.makeText(this, "Seçilen resim yok", Toast.LENGTH_SHORT).show();
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.