NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.aplikasipemeriksaan;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.aplikasipemeriksaan.api.ApiClient;
import com.example.aplikasipemeriksaan.model.DefaultResponse;
import com.example.aplikasipemeriksaan.storage.SharedPrefManager;
import com.squareup.picasso.Picasso;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class PengukurKecepatanActivity extends AppCompatActivity {

private static final String SHARED_PREF_NAME = "my_shared_preff";
private static final int PICK_IMAGE = 1;
private static final int REQUEST_WRITE_PERMISSION = 786;
static final int REQUEST_IMAGE_CAPTURE = 1;
private Uri mImageUri;
private String mediaPath;
private String postPath;
ImageView fotopk;
EditText receiver_msg;
Button btn_lanjutpk, btn_add_service;
AppCompatButton btn_choose_photo;
Intent intent = getIntent();
// String str = intent.getStringExtra("nokendaraan");

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_WRITE_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
confirmInput();
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pengukur_kecepatan);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

/*/ GET NOKENDARAAN
// create the get Intent object





// END GET NOKENDARAAN */

fotopk = findViewById(R.id.uploadgambarpk);

btn_lanjutpk = findViewById(R.id.btn_lanjutpk);
btn_choose_photo = findViewById(R.id.pilihgambar);

receiver_msg = (EditText) findViewById(R.id.nomorkendaraanpk);
// receiver_msg.setText(str);
btn_choose_photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
}
});

btn_lanjutpk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
requestPermission();
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == PICK_IMAGE && resultCode == RESULT_OK
&& data != null && data.getData() != null){

mImageUri = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};

Cursor cursor = getContentResolver().query(mImageUri, filePathColumn, null, null, null);

assert cursor != null;
cursor.moveToFirst();

int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
mediaPath = cursor.getString(columnIndex);
fotopk.setImageURI(data.getData());
cursor.close();

postPath = mediaPath;

Picasso.get().load(mImageUri).fit().into(fotopk);
//Toast.makeText(this, columnIndex, Toast.LENGTH_LONG).show();
}
}
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}


private void openFileChooser(){
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, PICK_IMAGE);
}

public void confirmInput() {

if (mediaPath != null) {
Toast.makeText(this, "Pilih gambar terlebih dahulu...", Toast.LENGTH_LONG).show();
} else {
File imageFile = new File(mediaPath);
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-file"), imageFile);
MultipartBody.Part partImage = MultipartBody.Part.createFormData("image", imageFile.getName(), requestBody);

User user = SharedPrefManager.getClient(this).getUser();
SharedPreferences preferences = getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);

//RequestBody username = RequestBody.create(MediaType.parse("text/plain"), user.getUsername());
RequestBody nokendaraan = RequestBody.create(MediaType.parse("text/plain"), receiver_msg.getText().toString().trim());

Call<DefaultResponse> call = ApiClient
.getInstance()
.getApi()
.tambahPengukurKecepatan(nokendaraan, partImage);
call.enqueue(new Callback<DefaultResponse>() {
@Override
public void onResponse(Call<DefaultResponse> call, Response<DefaultResponse> response) {
if (response.code() == 201) {
Intent tambahan = new Intent(PengukurKecepatanActivity.this, KacaSpionActivity.class);
startActivity(tambahan);
finish();
} else {
Toast.makeText(PengukurKecepatanActivity.this, "Terjadi kesalahan!", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onFailure(Call<DefaultResponse> call, Throwable t) {

}
});

}
}
private void requestPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_PERMISSION);
} else {
confirmInput();
}
}

}

//package com.example.aplikasipemeriksaan;
//
//import androidx.appcompat.app.AppCompatActivity;
//import androidx.appcompat.widget.AppCompatButton;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.util.Log;
//import android.view.View;
//import android.widget.Button;
//import android.widget.EditText;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.google.android.gms.cast.framework.media.ImagePicker;
//
//public class PengukurKecepatanActivity extends AppCompatActivity {
//
// AppCompatButton uploadbtn;
// EditText receiver_msg;
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_pengukur_kecepatan);
//
// uploadbtn = findViewById(R.id.pilihgambar);
// receiver_msg = (EditText) findViewById(R.id.nomorkendaraanpk);
//
// // create the get Intent object
// Intent intent = getIntent();
// String str = intent.getStringExtra("nokendaraan");
// receiver_msg.setText(str);
// }
//}
     
 
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.