Get id data ( pemanggilan data)
Asslamualaikum waroh matullohiwabakatu
salam sejahtera bagi kita semua
kali ini saya akan memberikan sedikit pengalaman saya di android studio yah biar pun hanya sedikit akan saya bagikan ..
ini konsep android yang intinya untuk memanggil sebuah data yang berdasarkan id itu sendiri dimana kita akan eksekusi nomor id sebagai peran utama.
disini kita akan langsung aja yaa,,,,,,,,, memberi source code mudah mudahan mudah dipahami karana saya pemula
berikut tampilan design
untuk source design
input_data_keluar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:tools = "http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d2d2dc"
tools:context=".Proses_input_output"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/namajudul"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Form Data Operasi Pergerakan"
android:textColor="#000"
android:textStyle="bold" />
<View
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="4dp"
android:layout_gravity="center"
android:background="#ef1e2c" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="65dp"
android:orientation="horizontal">
<Button
android:id="@+id/cekk"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cek"
tools:text="Cek" />
<android.support.design.widget.TextInputLayout
android:id="@+id/kd"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/Kimap_keluar"
android:layout_width="239dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#FDF8F8"
android:ems="10"
android:hint="Kimap">
<requestFocus />
</AutoCompleteTextView>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/scan"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="[I|I|I]" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="190dp"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/Keluar"
android:layout_width="187dp"
android:layout_height="wrap_content"
android:checked="true"
android:onClick="onRadioButtonClicked"
android:text="@string/Keluar"
tools:text="Kerluar" />
<RadioButton
android:id="@+id/Masuk"
android:layout_width="188dp"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="@string/Masuk"
tools:text="Masuk" />
</RadioGroup>
<TextView
android:id="@+id/operator"
android:layout_width="74dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/ID"
android:layout_width="14dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="ID"
android:textSize="30dp"
android:textStyle="italic" />
</LinearLayout>
<EditText
android:id="@+id/Nama_Produk_Keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textColor="#000"
android:hint="Nama_Produk"
android:background="#FDF8F8"
android:inputType="textPersonName" />
<EditText
android:id="@+id/Type_keluar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:ems="10"
android:hint="Type"
android:textColor="#000"
android:background="#FDF8F8"
android:inputType="textPersonName" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Input Jumlah Stock Barang"
android:textColor="#000"
android:textStyle="bold" />
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_gravity="center"
android:background="#ffe944" />
<EditText
android:id="@+id/Jumlah_Awal_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="10"
android:gravity=""
android:hint="Jumlah_Awal_keluar"
android:background="#FDF8F8"
android:textColor="#000"
android:inputType="textPersonName" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="@+id/Jumlah_ww"
android:layout_width="199dp"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputan_Jumlah_keluar"
android:layout_width="166dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Jumlah_keluar"
android:textColor="#000"
android:inputType="numberDecimal" />
android:background="#FDF8F8"
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/Jumlah"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputan_Jumlah_Masuk"
android:layout_width="197dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Jumlah_Masuk"
android:textColor="#000"
android:inputType="numberDecimal" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/Jumlah1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/Jumlah_Hasil_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Jumlah_Hasil_keluar"
android:textColor="#000"
android:inputType="number" />
</LinearLayout>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Keterangan Traking"
android:textColor="#000"
android:textStyle="bold" />
<View
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_gravity="center"
android:background="#ffef44" />
<android.support.design.widget.TextInputLayout
android:id="@+id/No_T"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/No_Transfortir_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="No. Plat Polisi"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/No_cont"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/No_continer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="No. Container"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/kode_k"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/Kode_keluar_Data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="No. Doc"
android:inputType="textPersonName|number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/Ket"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/Keterangan_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Keterangan"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/np"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/Nama_Perusahaan"
android:layout_width="259dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_weight="1"
android:ems="10"
android:hint="Nama Perusahaan">
</AutoCompleteTextView>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/fresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Bersihkan" />
<Button
android:id="@+id/proses_keluar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Proseskan Data" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/Edit_aktivitas"
android:layout_width="67dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ubah_Data" />
<Button
android:id="@+id/hapus_aktivitas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hapus_Data" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
bagian java ya
Proses_input_output.java
package com.example.heru_hardadi_pc.warehouse_apps_01;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.example.heru_hardadi_pc.warehouse_apps_01.GETdata.AmbilData;
import com.example.heru_hardadi_pc.warehouse_apps_01.GETdata.AmbilData.JSONObjectResult;
import com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta.Constant;
import com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta.PostRequestHandler;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
public class Proses_input_output extends AppCompatActivity {
private View btnScan;
String url = "https://heruonline.com/ANDROID/SKRIPSI/Tampilkan_data_berdasakan_kimap.php";
// String url = "https://heruweb.000webhostapp.com/ANDROID/kamus.php";
Button cek, refresh, Prosesk, edit_data_proses, delete_data_proses;
TextView A14_OP, A1_idl, A15_namajudul;
EditText A2_Kimap, A3_Namaproduk, A4_typk, A7_inputjumlah_masuk, A5_jumlah_Awal, A8_jumlahhasil_calcualtion, A13_Nama_perus, A6_inputjumlah_keluar, A9_No_polisi, A11_No_documnt, A12_keterangank, A10_container;
String str = "string abc touppercase";
RadioGroup radioGroupInOutk;
RadioButton In, Out;
private View view;
DrawerLayout drawer;
private AutoCompleteTextView KIMAP_AUTO,NamaPT_AUTO;
String[] Kode_Prod ={"A070101618",
"A070101640",
"A070201618",
"A070201640",
"A070202118",
"A070202140",
"A070101525",
"A070101540",
"A070201740",
"A070201725",
"A070100940",
"A070200025",
"A070200625",
"A070200640",
"A070202340",
"A070202325",
"A070201918",
"A070201825",
"A070201840",
"A070100625",
"A070200040",
"A070105016",
"A070105125",
"A070105140",
"A070106025",
"A070106040",
"A070105925",
"A070105940",
"A070102324",
"A070102340",
"A070102915",
"A070102641",
"A070102615",
"A070102825",
"A070107340",
"A070107341",
"A070107440",
"A070107441",
"A070106716",
"A070106740",
"A070106741",
"A070106840",
"A070106841",
"A070107916",
"A070132025",
"A070101016",
"A070101040",
"A070202425",
"A070202440",
"A070110825",
"A070110855",
"A070110840",
"A070111425",
"A070111440",
"A070110025",
"A070110041",
"A070110055",
"A070109625",
"A070109641",
"A070109655",
"A070109661",
"A070112055",
"A070103330",
"A070103340",
"A070103347",
"A070103355",
"A070207518",
"A070207513",
"A070112918",
"A070113015",
"A070113025",
"A070207425",
"A070207415",
"A070113218",
"A070113233",
"A070113512",
"A070113918",
"A070115425",
"A070115725",
"A070115761",
"A070113315",
"A070115125",
"A070156640",
"A070156103",
"A060102660",
"A060103760",
"A060105560",
"A060106060",
"A070182264",
"A070182064",
"A060130060",
"A070130862",
"A070176161",
"A070177362",
"A070177162",
"A070112061",
"A070202416",
"A070184561",
"A070146361",
"A070184540"};
String[] Kode_Perusahaan ={"POLRES ACEH SINGKIL",
"POLTABES MS.MEDAN",
"POLRES SERDANG BEDAGAI",
"POLRESTA PADANG SIDEMP",
"POLRES LANGKAT",
"PT . SUTAN KASIM",
"PT . PATRA LOGISTIK (PT. Bima Parama)",
"PT . PATRA LOGISTIK (PT. SIER)",
"PT . KANDE AGUNG",
"PT . PATRA LOGISTIK",
"PT . EKA PRIMA SEMESTA",
"PT . PUTRABANGGA KIRANA ANUGRAH",
"PT . SERDANG JAYA",
"PT . LARIS SUMUT MAKMUR",
"PT . POLA RAYA",
"PT . SUBHIKSA",
"PT . Citra Bintang Familindo",
"PT . SAMUDRA JAYA RAYA",
"PT . WARUNA NUSA SENTANA",
"PT . Arta Cimandiri Cemerlang",
"PT . SPBU COCO",
"POL. HUBANG HASUDUTAN",
"POLRES TNH KARO",
"LANUD MEDAN",
"POLRES PAKPAK BARAT",
"BDH SAKTKER KPPP BELAWAN",
"PT . DC BRIGHT",
"PT. Abadi Mitra Andhika",
"PT. Nasional Usba Transport",
"PT. Wita Sarana Anugerah",
"PT. Jasa Transportasi Patuma",
"PT. Kaye Adang Ekspress",
"PT. Mega Prima Pertamindo",
"PT. Citra Bina Jasa Samudera",
"PT. Riau Muda Jasaguna",
"PT. Putera Sejahtera Abadi",
"PT. Desmandiri Perkasa",
"PT. Patra Niaga",
"PT. Wyranda Utama",
"PT . PATRA LOGISTIK",
"PT . PATRA LOGISTIK (DESMANDIRI)",
"PT . INDRA ANGKOA LUB",
"POLRES TAPANULI UTARA",
"DIT LANTAS POLDASU MEDAN",
"POL LAB BATU",
"POL HUBANG HASUDUTAN",
"POL SIBOLGA",
"POLRESTA BINJAI",
"DITPOLAIR POLDA NAD",
"POLRES SIMALUNGUN",
"POLRES ACEH TAMIANG",
"POLRES TOBA SAMOSIR",
"BENSATKER DIT POLAIR POLDASU",
"POLRES ASAHAN",
"POLRES TANAH KARO",
"POLRES MADINA",
"Polres Tapanuli Selatan",
"POLRES TANJUNG BALAI",
"POLRES KPP BELAWAN",
"POLRES DELI SERDANG",
"ROSARORAS POLDASU MEDAN",
"OWN USE SRM I",
"POLRES NIAS",
"POLRES BATU BARA",
"POLRES TAPANULI TENGAh",
"POLRES DAIRI",
"PT . PATRA LOGISTIK (PT. Putera Sejahtera Abadi)",
"BENSATKER DIT POLAIR SUMUT",
"PT . PATRA LOGISTIK (PT. Putera sejahtera abadi)",
"OWN uSE SR 1",
"PT.MINAMASGEMERLANG",
"POLRES GAYO LUWES",
"OWN USE SR I",
"POLRES NIAS GUNUNG SITOLI",
"POL PEMANATANG SIANTAR",
"POLRES TAPANULI UTARA",
"POLRES BIREUEN",
"POLRES ACEH TENGGARA",
"POLRES ACEH TENGAH",
"PSP BENER MERIAH",
"PT . POS LOGISTIK INDONESIA (AST)",
"PT . PATRA LOGISTIK (PT. AMA)",
"PT . ELNUSA PETROFIN",
"PT . POS LOGISTIK INDONESIA (KSP)",
"PT. PATRA LOGISTIK (WIDYA)",
"PT. PADANG PALMA PERMAI",
"LANUD MAIMUN SALEH",
"BRIMOP POLDA SUMUT",
"PORESTA SIBOLGA",
"PT . PERTAMINA LUBRICANT",
"PT. REZEKI PUTRA ENERGI",
"PT. PATRA LOGISTIK (BELAWAN B)",
"POLRES SAMOSIR",
"ROLOG POLDASU",
"BEND. SATKER DIT SAMAPTA POLDA SUMUT",
"PT. PERTAMINA LUBRICANT",
"POLRES LHOKSEUMAWE",
"POLRES NIAS SELATAN TELUK DALAM",
"BEND.RUTIN BIRO LOGISTIK POLDA SUMUT",
"POLRES ASAHAN KISARAN"};
int counter = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.input_data_keluar);
btnScan = (View) findViewById(R.id.scan);
A15_namajudul = (TextView) findViewById(R.id.namajudul);
// mink = (TextView) findViewById(R.id.min);
radioGroupInOutk = (RadioGroup) findViewById(R.id.radiogroup);
Out = (RadioButton) findViewById(R.id.Keluar);
In = (RadioButton) findViewById(R.id.Masuk);
edit_data_proses = (Button) findViewById(R.id.Edit_aktivitas);
delete_data_proses = (Button) findViewById(R.id.hapus_aktivitas);
refresh = (Button) findViewById(R.id.fresh);
cek = (Button) findViewById(R.id.cekk);
Prosesk = (Button) findViewById(R.id.proses_keluar);
A1_idl = (TextView) findViewById(R.id.ID);
A14_OP = (TextView) findViewById(R.id.operator);
A13_Nama_perus = (EditText) findViewById(R.id.Nama_Perusahaan);
A10_container = (EditText) findViewById(R.id.No_continer);
A10_container.setEnabled(false);
A2_Kimap = (EditText) findViewById(R.id.Kimap_keluar);
A2_Kimap.setText("");
A3_Namaproduk = (EditText) findViewById(R.id.Nama_Produk_Keluar);
A3_Namaproduk.setEnabled(false);
A4_typk = (EditText) findViewById(R.id.Type_keluar);
A4_typk.setEnabled(false);
A5_jumlah_Awal = (EditText) findViewById(R.id.Jumlah_Awal_keluar);
A5_jumlah_Awal.setEnabled(false);
A9_No_polisi = (EditText) findViewById(R.id.No_Transfortir_keluar);
A11_No_documnt = (EditText) findViewById(R.id.Kode_keluar_Data);
A12_keterangank = (EditText) findViewById(R.id.Keterangan_keluar);
A8_jumlahhasil_calcualtion = (EditText) findViewById(R.id.Jumlah_Hasil_keluar);
A8_jumlahhasil_calcualtion.setEnabled(false);
//input jumlah keluar
A6_inputjumlah_keluar = (EditText) findViewById(R.id.inputan_Jumlah_keluar);
//input jumlah masuk
A7_inputjumlah_masuk = (EditText) findViewById(R.id.inputan_Jumlah_Masuk);
A7_inputjumlah_masuk.setEnabled(false);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
A1_idl.setText(bundle.getString("ID"));
A2_Kimap.setText(bundle.getString("KIMAP"));
A3_Namaproduk.setText(bundle.getString("NAMAPRODUK"));
A4_typk.setText(bundle.getString("TYPE"));
A5_jumlah_Awal.setText(bundle.getString("JUMLAHAWAL"));
A6_inputjumlah_keluar.setText(bundle.getString("JUMLAHKELUAR"));
A7_inputjumlah_masuk.setText(bundle.getString("JUMLAHMASUK"));
A8_jumlahhasil_calcualtion.setText(bundle.getString("JUMLAHHASIL"));
A9_No_polisi.setText(bundle.getString("NOPOLISI"));
A10_container.setText(bundle.getString("NOCONTAINER"));
A11_No_documnt.setText(bundle.getString("NODOCH"));
A12_keterangank.setText(bundle.getString("KETERANGAN"));
A13_Nama_perus.setText(bundle.getString("NAMAPERUSAHAAN"));
A14_OP.setText(bundle.getString("STATUS"));
A15_namajudul.setText(bundle.getString("TANGGAL"));
}
A6_inputjumlah_keluar.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
A8_jumlahhasil_calcualtion.setText(addNumbers());
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
A7_inputjumlah_masuk.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
A8_jumlahhasil_calcualtion.setText(addNumbers1());
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
KIMAP_AUTO = (AutoCompleteTextView) findViewById(R.id.Kimap_keluar);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, Kode_Prod);
NamaPT_AUTO = (AutoCompleteTextView) findViewById(R.id.Nama_Perusahaan);
ArrayAdapter adapter1 = new ArrayAdapter(this, android.R.layout.simple_list_item_1, Kode_Perusahaan);
KIMAP_AUTO.setAdapter(adapter);
NamaPT_AUTO.setAdapter(adapter1);
KIMAP_AUTO.setThreshold(1);
NamaPT_AUTO.setThreshold(1);
cek.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AmbilData ambilData = new AmbilData();
ambilData.init(A2_Kimap.getText().toString(), url, Proses_input_output.this, jres);
//Kimapk.setText("");
}
});
Prosesk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(A8_jumlahhasil_calcualtion.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A8_jumlahhasil_calcualtion.setError("Inputan data belum sempurna");
}
if(A2_Kimap.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A2_Kimap.setError("diperlukan inputan data!");
}if(A8_jumlahhasil_calcualtion.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A8_jumlahhasil_calcualtion.setError("proses belum selesai");
}if(A9_No_polisi.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A9_No_polisi.setError("Inputan data belum sempurna");
}if(A11_No_documnt.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A11_No_documnt.setError("Inputan data belum sempurna");
}
else{
if(A15_namajudul.getText().toString().equals("Form Data Operasi Pergerakan")){
proses_data();
link_ke_list();
}
else {
Toast.makeText(getApplicationContext(), "Ini proses Delete and update",Toast.LENGTH_SHORT).show();
Prosesk.setVisibility(View.VISIBLE);
Prosesk.setBackgroundColor(Color.BLACK);
counter--;
Prosesk.setText(Integer.toString(counter));
if (counter == 0) {
Prosesk.setEnabled(false);
}
}
}
}
});
refresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//A1_idl.setText("");
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.setText("");
A9_No_polisi.setText("");
A10_container.setText("");
A11_No_documnt.setText("");
A12_keterangank.setText("");
A13_Nama_perus.setText("");
A14_OP.setText("");
A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
}
});
edit_data_proses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pr0ses_edit();
}
});
delete_data_proses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pr0ses_hapus();
}
});
btnScan.setOnClickListener(onClickListener()); }
private View.OnClickListener onClickListener() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException ex) {
ex.printStackTrace();
//if you haven't install barcodeScanner app, download it from Google Play
downloadScanBarcode();
}
}
};
}
private void pr0ses_hapus() {
String idpr = A1_idl.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("id_history", idpr);
Log.d("HashMap", requestedParams.get("id_history"));
Toast.makeText(getApplicationContext(), "Success!! Deleted ID : " + requestedParams.get("id_history"), Toast.LENGTH_LONG).show();
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.Proseskan_Deleting, requestedParams);
postRequestHandler.execute();
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.setText("");
A9_No_polisi.setText("");
A10_container.setText("");
A11_No_documnt.setText("");
A12_keterangank.setText("");
A13_Nama_perus.setText("");
A14_OP.setText("");
A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
// halaman_sebelumnya(view);
}
public void halaman_sebelumnya(View view) {
Intent intent = new Intent(Proses_input_output.this, MainActivity.class);
startActivity(intent);
}
private void pr0ses_edit() {
String IDS = A1_idl.getText().toString();
// String AKSI = A14_OP.getText().toString();
String TGL = A15_namajudul.getText().toString();
String AKSI = ((RadioButton) findViewById(radioGroupInOutk.getCheckedRadioButtonId())).getText().toString();
String KIMAP = A2_Kimap.getText().toString();
String NAMAPRODUK = A3_Namaproduk.getText().toString();
String TYPE = A4_typk.getText().toString();
String JUMLAH_AWAL = A5_jumlah_Awal.getText().toString();
String JUMLAH_KELUAR = A6_inputjumlah_keluar.getText().toString();
String JUMLAH_MASUK = A7_inputjumlah_masuk.getText().toString();
String JUMLAH_HASIL = A8_jumlahhasil_calcualtion.getText().toString();
String NAMA_PERUSAHAAN = A13_Nama_perus.getText().toString();
String NOPOLISI = A9_No_polisi.getText().toString();
String NOKONTAINER = A10_container.getText().toString();
String NODOCUMNT = A11_No_documnt.getText().toString();
String NAMAPERUSAHAAN = A12_keterangank.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("id_history", IDS);
requestedParams.put("tanggalh", TGL);
requestedParams.put("Statush", AKSI);
requestedParams.put("Kimaph", KIMAP);
requestedParams.put("Nama_produkh", NAMAPRODUK);
requestedParams.put("Typeh", TYPE);
requestedParams.put("jumlah_awal", JUMLAH_AWAL);
requestedParams.put("jumlah_masuk", JUMLAH_MASUK);
requestedParams.put("jumlah_keluar", JUMLAH_KELUAR);
requestedParams.put("Jumlah_hasil", JUMLAH_HASIL);
requestedParams.put("Nama_Perusahaan", NAMA_PERUSAHAAN);
requestedParams.put("No_polisih", NOPOLISI);
requestedParams.put("No_doch", NODOCUMNT);
requestedParams.put("No_container", NOKONTAINER);
requestedParams.put("Keteranganh", NAMAPERUSAHAAN);
Log.d("HashMap", requestedParams.get("id_history"));
Toast.makeText(getApplicationContext(), "Success!!: " + requestedParams.get("id_history"), Toast.LENGTH_LONG).show();
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.Proseskan_Editing, requestedParams);
postRequestHandler.execute();
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.setText("");
A9_No_polisi.setText("");
A10_container.setText("");
A11_No_documnt.setText("");
A12_keterangank.setText("");
A13_Nama_perus.setText("");
A14_OP.setText("");
A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
//halaman_riwayat(view);
}
public void halaman_riwayat(View view) {
Intent intent = new Intent(Proses_input_output.this, MainActivity.class);
startActivity(intent);
}
private void link_ke_list() {
String idpr = A1_idl.getText().toString();
String kode = A2_Kimap.getText().toString();
String nama = A3_Namaproduk.getText().toString();
String jumlah = A8_jumlahhasil_calcualtion.getText().toString();
String types = A4_typk.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("id", idpr);
requestedParams.put("Kd_produk", kode);
requestedParams.put("Nama", nama);
requestedParams.put("Jumlah", jumlah);
requestedParams.put("Status", types);
Log.d("HashMap", requestedParams.get("id"));
Toast.makeText(getApplicationContext(), "Success!! : " + requestedParams.get("id"), Toast.LENGTH_LONG).show();
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.getText().clear();
// A9_No_polisi.setText("");
// A10_container.setText("");
// A11_No_documnt.setText("");
// A12_keterangank.setText("");
// A13_Nama_perus.setText("");
// A14_OP.setText("");
// A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.edit_url, requestedParams);
postRequestHandler.execute();
}
private void proses_data() {
String AKSI = ((RadioButton) findViewById(radioGroupInOutk.getCheckedRadioButtonId())).getText().toString();
String KIMAP = A2_Kimap.getText().toString();
String NAMAPRODUK = A3_Namaproduk.getText().toString();
String TYPE = A4_typk.getText().toString();
String JUMLAH_AWAL = A5_jumlah_Awal.getText().toString();
String JUMLAH_KELUAR = A6_inputjumlah_keluar.getText().toString();
String JUMLAH_MASUK = A7_inputjumlah_masuk.getText().toString();
String JUMLAH_HASIL = A8_jumlahhasil_calcualtion.getText().toString();
String NAMA_PERUSAHAAN = A13_Nama_perus.getText().toString();
String NOPOLISI = A9_No_polisi.getText().toString();
String NOKONTAINER = A10_container.getText().toString();
String NODOCUMNT = A11_No_documnt.getText().toString();
String NAMAPERUSAHAAN = A12_keterangank.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("Statush", AKSI);
requestedParams.put("Kimaph", KIMAP);
requestedParams.put("Nama_produkh", NAMAPRODUK);
requestedParams.put("Typeh", TYPE);
requestedParams.put("jumlah_awal", JUMLAH_AWAL);
requestedParams.put("jumlah_masuk", JUMLAH_MASUK);
requestedParams.put("jumlah_keluar", JUMLAH_KELUAR);
requestedParams.put("Jumlah_hasil", JUMLAH_HASIL);
requestedParams.put("Nama_Perusahaan", NAMA_PERUSAHAAN);
requestedParams.put("No_polisih", NOPOLISI);
requestedParams.put("No_doch", NODOCUMNT);
requestedParams.put("No_container", NOKONTAINER);
requestedParams.put("Keteranganh", NAMAPERUSAHAAN);
Log.d("HashMap", requestedParams.get("Statush"));
Toast.makeText(getApplicationContext(), "Success!!: " + requestedParams.get("Statush"), Toast.LENGTH_LONG).show();
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.Proseskan_data, requestedParams);
postRequestHandler.execute();
}
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch (view.getId()) {
case R.id.Masuk:
if (checked)
// Same day service
A6_inputjumlah_keluar.setEnabled(false);
A7_inputjumlah_masuk.setEnabled(true);
A14_OP.setText("+");
A14_OP.setTextColor(Color.parseColor("#4CAF50"));//HIJAU
A14_OP.setBackgroundColor(Color.parseColor("#ffffff"));//White
A10_container.setEnabled(true);
// Out.setEnabled(false);
// In.setEnabled(true);
break;
case R.id.Keluar:
if (checked)
// Next day delivery
// In.setEnabled(false);
// Out.setEnabled(true);
A14_OP.setText("-");
A14_OP.setTextColor(Color.parseColor("#F44336"));//MERAH
A14_OP.setBackgroundColor(Color.parseColor("#ffffff"));//White
A10_container.setEnabled(false);
A6_inputjumlah_keluar.setEnabled(true);
A7_inputjumlah_masuk.setEnabled(false);
break;
}
}
private String addNumbers() {
Double number1;
Double number2;
if (A5_jumlah_Awal.getText().toString() != "" && A5_jumlah_Awal.getText().length() > 0) {
number1 = Double.valueOf(Float.valueOf(A5_jumlah_Awal.getText().toString()));
} else {
number1 = Double.valueOf(Float.valueOf(String.valueOf(0)));
}
if (A6_inputjumlah_keluar.getText().toString() != "" && A6_inputjumlah_keluar.getText().length() > 0) {
number2 = Double.valueOf(Float.valueOf(A6_inputjumlah_keluar.getText().toString()));
} else {
number2 = Double.valueOf(Float.valueOf(String.valueOf(0)));
}
return Double.toString(number1 - number2);
}
private String addNumbers1() {
Double number3;
Double number4;
if (A5_jumlah_Awal.getText().toString() != "" && A5_jumlah_Awal.getText().length() > 0) {
number3 = Double.valueOf(Float.valueOf(A5_jumlah_Awal.getText().toString()));
} else {
number3 = Double.valueOf(Float.valueOf(0));
}
if (A7_inputjumlah_masuk.getText().toString() != "" && A7_inputjumlah_masuk.getText().length() > 0) {
number4 = Double.valueOf(Float.valueOf(A7_inputjumlah_masuk.getText().toString()));
} else {
number4 = Double.valueOf(Float.valueOf(0));
}
return Double.toString(number3 + number4);
}
JSONObjectResult jres = new JSONObjectResult() {
@Override
public void gotJSONObject(JSONObject jsonObject) {
try {
JSONArray jsonArray = jsonObject.getJSONArray("u259130893_whs");
for (int i = 0; i < jsonArray.length(); i++) {
A1_idl.setText(jsonArray.getJSONObject(i).getString("id"));
A3_Namaproduk.setText(jsonArray.getJSONObject(i).getString("Nama"));
A5_jumlah_Awal.setText(jsonArray.getJSONObject(i).getString("Jumlah"));
A4_typk.setText(jsonArray.getJSONObject(i).getString("status"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
private void downloadScanBarcode() {
Uri uri = Uri.parse("market://search?q=pname:" + "com.google.zxing.client.android");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
ex.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
//format.setText(data.getStringExtra("SCAN_RESULT_FORMAT"));
A2_Kimap.setText(data.getStringExtra("SCAN_RESULT"));
} else if (resultCode == RESULT_CANCELED) {
// format.setText("Press a button to start a scan.");
A2_Kimap.setText("Scan cancelled.");
}
}
}
}
PostRequestHandler.java
package com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta;
import android.os.AsyncTask;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
/**
* Created by DELL on 12/20/2017.
*/
public class PostRequestHandler extends AsyncTask<Void, Void, String> {
// Request URL
String url;
// Key, Value pair
HashMap<String, String> requestedParams;
public PostRequestHandler(String url, HashMap<String, String> params){
this.url = url;
this.requestedParams = params;
// Log.d("Input Box", designation);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
//progressBar.setVisibility(View.VISIBLE);
}
@Override
protected String doInBackground(Void... voids) {
// Now Send a post request
BackgroundWorker backgroundWorker = new BackgroundWorker();
try {
String s = backgroundWorker.postRequestHandler(url, requestedParams);
// Log.d("HashMap--------", requestedParams.get("salary"));
// Log.d("Results------", s.toString());
// Toast.makeText(getApplicationContext(), s.toString(), Toast.LENGTH_LONG).show();
return s.toString();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//progressBar.setVisibility(GONE);
//Toast.makeText(getApplicationContext, "Result : " + s, Toast.LENGTH_LONG).show();
//Toast.makeText(getBaseContext(), s, Toast.LENGTH_LONG).show();
}
}
Constant.java
package com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta;
public class Constant {
private static final String BASE_PATH = "http://192.168.43.233/ANDROID/DB_SKRIPSI/Input_data_product/";
// private static final String BASE_PATH = "https://heruonline.com/ANDROID/SKRIPSI/";
// private static final String BASE_PATH = "https://heruweb.000webhostapp.com/ANDROID/DB_SKRIPSI/Input_data_product/";
public static final String Simpan_URL = BASE_PATH + "add_data_produk.php";
// public static final String Simpan_URL = BASE_PATH + "insert_data.php";
public static final String edit_url = BASE_PATH + "Update_produk.php";
// public static final String edit_url = BASE_PATH + "insert_edit_data.php";
public static final String delete_url = BASE_PATH + "Delete_produk.php";
//public static final String delete_url = BASE_PATH + "insert_delete_data.php";
public static final String Proseskan_Editing = BASE_PATH + "Proseskan_Edit_history.php";
public static final String Proseskan_Deleting = BASE_PATH + "Proseskan_Delete_history.php";
public static final String Register_url = BASE_PATH + "register.php";
//public static final String Register_url = BASE_PATH + "Register.php";
public static final String Proseskan_data = "https://heruonline.com/ANDROID/SKRIPSI/list_history.php";
static final String POST_METHOD = "POST";
}
BackgroundWorker.java
package com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta;
import android.util.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* Created by DELL on 12/20/2017.
*/
public class BackgroundWorker {
// Make a POST Request Handler
public String postRequestHandler(String requestUrl, HashMap<String, String> requestedDataParams) throws UnsupportedEncodingException {
// Set an Empty URL obj in system
URL url;
// Set a String Builder to store result as string
StringBuilder stringBuilder = new StringBuilder();
try {
// Now Initialize URL
url = new URL(requestUrl);
// Make a HTTP url connection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Set Method Type
connection.setRequestMethod(Constant.POST_METHOD);
// Set Connection Time
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
// set Input output ok
connection.setDoInput(true);
connection.setDoOutput(true);
// Remove Caches
//connection.setUseCaches(false);
//connection.setDefaultUseCaches(false);
// Creating a url as String with params
StringBuilder url_string = new StringBuilder();
boolean ampersand = false;
for (Map.Entry<String, String> params : requestedDataParams.entrySet() ){
if (ampersand)
url_string.append("&");
else
ampersand = true;
url_string.append(URLEncoder.encode(params.getKey(), "UTF-8"));
url_string.append("=");
url_string.append(URLEncoder.encode(params.getValue(), "UTF-8"));
}
Log.d("Final Url===", url_string.toString());
//Creating an output stream
OutputStream outputStream = connection.getOutputStream();
// Write Output Steam
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
bufferedWriter.write(url_string.toString());
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
// Log.d("Response===", connection.getResponseMessage());
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK){
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
// Local String
String result;
while ((result = bufferedReader.readLine()) != null) {
stringBuilder.append(result);
}
// Log.d("Result===", result);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return stringBuilder.toString();
}
// Get Request Handler
public String getRequestHandler(String requestUrl){
// To Store response
StringBuilder stringBuilder = new StringBuilder();
try {
URL url = new URL(requestUrl);
// Open Connection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
// Local
String result;
while ((result = bufferedReader.readLine()) != null) {
stringBuilder.append(result + "\n");
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
AmbilData.java
package com.example.heru_hardadi_pc.warehouse_apps_01.GETdata;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class AmbilData extends AsyncTask<Object,Object,Object> {
JSONParser jsonParser;
JSONObject jsonObject;
ProgressDialog pg;
Context context;
JSONObjectResult jres;
public void init(String var,String url,Context con, JSONObjectResult jsonObjectResult){
context = con;
jres = jsonObjectResult;
AmbilData ambilData = this;
ambilData.execute(var,url);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pg = new ProgressDialog(context);
pg.setTitle("Loading");
pg.setMessage("Pengecekan Data..");
pg.show();
}
@Override
protected Object doInBackground(Object... params) {
jsonObject = null;
jsonParser = new JSONParser();
String kode = (String) params[0];
String kodelogin = (String) params[0];
String urls = (String) params[1];
List<NameValuePair> param = new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("kode",kode));
param.add(new BasicNameValuePair("kodelogin",kodelogin));
try {
jsonObject = jsonParser.getJsonObject("POST",urls,param);
} catch (IOException e) {
e.printStackTrace();
}
return jsonObject;
}
@Override
protected void onPostExecute(Object result) {
super.onPostExecute(result);
if(result != null){
JSONObject jObj = (JSONObject) result;
jres.gotJSONObject(jObj);
}else{
Toast.makeText(context, "Data tidak ditemukan atau belum terdaftar :(", Toast.LENGTH_LONG).show();
}
pg.dismiss();
}
public static abstract class JSONObjectResult{
public abstract void gotJSONObject(JSONObject jsonObject);
}
}
salam sejahtera bagi kita semua
kali ini saya akan memberikan sedikit pengalaman saya di android studio yah biar pun hanya sedikit akan saya bagikan ..
ini konsep android yang intinya untuk memanggil sebuah data yang berdasarkan id itu sendiri dimana kita akan eksekusi nomor id sebagai peran utama.
disini kita akan langsung aja yaa,,,,,,,,, memberi source code mudah mudahan mudah dipahami karana saya pemula
berikut tampilan design
untuk source design
input_data_keluar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:tools = "http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d2d2dc"
tools:context=".Proses_input_output"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/namajudul"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Form Data Operasi Pergerakan"
android:textColor="#000"
android:textStyle="bold" />
<View
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="4dp"
android:layout_gravity="center"
android:background="#ef1e2c" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="65dp"
android:orientation="horizontal">
<Button
android:id="@+id/cekk"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cek"
tools:text="Cek" />
<android.support.design.widget.TextInputLayout
android:id="@+id/kd"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/Kimap_keluar"
android:layout_width="239dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#FDF8F8"
android:ems="10"
android:hint="Kimap">
<requestFocus />
</AutoCompleteTextView>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/scan"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="[I|I|I]" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="190dp"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/Keluar"
android:layout_width="187dp"
android:layout_height="wrap_content"
android:checked="true"
android:onClick="onRadioButtonClicked"
android:text="@string/Keluar"
tools:text="Kerluar" />
<RadioButton
android:id="@+id/Masuk"
android:layout_width="188dp"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="@string/Masuk"
tools:text="Masuk" />
</RadioGroup>
<TextView
android:id="@+id/operator"
android:layout_width="74dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/ID"
android:layout_width="14dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="ID"
android:textSize="30dp"
android:textStyle="italic" />
</LinearLayout>
<EditText
android:id="@+id/Nama_Produk_Keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textColor="#000"
android:hint="Nama_Produk"
android:background="#FDF8F8"
android:inputType="textPersonName" />
<EditText
android:id="@+id/Type_keluar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:ems="10"
android:hint="Type"
android:textColor="#000"
android:background="#FDF8F8"
android:inputType="textPersonName" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Input Jumlah Stock Barang"
android:textColor="#000"
android:textStyle="bold" />
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_gravity="center"
android:background="#ffe944" />
<EditText
android:id="@+id/Jumlah_Awal_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="10"
android:gravity=""
android:hint="Jumlah_Awal_keluar"
android:background="#FDF8F8"
android:textColor="#000"
android:inputType="textPersonName" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="@+id/Jumlah_ww"
android:layout_width="199dp"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputan_Jumlah_keluar"
android:layout_width="166dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Jumlah_keluar"
android:textColor="#000"
android:inputType="numberDecimal" />
android:background="#FDF8F8"
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/Jumlah"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputan_Jumlah_Masuk"
android:layout_width="197dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Jumlah_Masuk"
android:textColor="#000"
android:inputType="numberDecimal" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/Jumlah1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/Jumlah_Hasil_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Jumlah_Hasil_keluar"
android:textColor="#000"
android:inputType="number" />
</LinearLayout>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Keterangan Traking"
android:textColor="#000"
android:textStyle="bold" />
<View
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_gravity="center"
android:background="#ffef44" />
<android.support.design.widget.TextInputLayout
android:id="@+id/No_T"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/No_Transfortir_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="No. Plat Polisi"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/No_cont"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/No_continer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="No. Container"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/kode_k"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/Kode_keluar_Data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="No. Doc"
android:inputType="textPersonName|number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/Ket"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/Keterangan_keluar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Keterangan"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/np"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/Nama_Perusahaan"
android:layout_width="259dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_weight="1"
android:ems="10"
android:hint="Nama Perusahaan">
</AutoCompleteTextView>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/fresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Bersihkan" />
<Button
android:id="@+id/proses_keluar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Proseskan Data" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/Edit_aktivitas"
android:layout_width="67dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ubah_Data" />
<Button
android:id="@+id/hapus_aktivitas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hapus_Data" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
bagian java ya
Proses_input_output.java
package com.example.heru_hardadi_pc.warehouse_apps_01;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.example.heru_hardadi_pc.warehouse_apps_01.GETdata.AmbilData;
import com.example.heru_hardadi_pc.warehouse_apps_01.GETdata.AmbilData.JSONObjectResult;
import com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta.Constant;
import com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta.PostRequestHandler;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
public class Proses_input_output extends AppCompatActivity {
private View btnScan;
String url = "https://heruonline.com/ANDROID/SKRIPSI/Tampilkan_data_berdasakan_kimap.php";
// String url = "https://heruweb.000webhostapp.com/ANDROID/kamus.php";
Button cek, refresh, Prosesk, edit_data_proses, delete_data_proses;
TextView A14_OP, A1_idl, A15_namajudul;
EditText A2_Kimap, A3_Namaproduk, A4_typk, A7_inputjumlah_masuk, A5_jumlah_Awal, A8_jumlahhasil_calcualtion, A13_Nama_perus, A6_inputjumlah_keluar, A9_No_polisi, A11_No_documnt, A12_keterangank, A10_container;
String str = "string abc touppercase";
RadioGroup radioGroupInOutk;
RadioButton In, Out;
private View view;
DrawerLayout drawer;
private AutoCompleteTextView KIMAP_AUTO,NamaPT_AUTO;
String[] Kode_Prod ={"A070101618",
"A070101640",
"A070201618",
"A070201640",
"A070202118",
"A070202140",
"A070101525",
"A070101540",
"A070201740",
"A070201725",
"A070100940",
"A070200025",
"A070200625",
"A070200640",
"A070202340",
"A070202325",
"A070201918",
"A070201825",
"A070201840",
"A070100625",
"A070200040",
"A070105016",
"A070105125",
"A070105140",
"A070106025",
"A070106040",
"A070105925",
"A070105940",
"A070102324",
"A070102340",
"A070102915",
"A070102641",
"A070102615",
"A070102825",
"A070107340",
"A070107341",
"A070107440",
"A070107441",
"A070106716",
"A070106740",
"A070106741",
"A070106840",
"A070106841",
"A070107916",
"A070132025",
"A070101016",
"A070101040",
"A070202425",
"A070202440",
"A070110825",
"A070110855",
"A070110840",
"A070111425",
"A070111440",
"A070110025",
"A070110041",
"A070110055",
"A070109625",
"A070109641",
"A070109655",
"A070109661",
"A070112055",
"A070103330",
"A070103340",
"A070103347",
"A070103355",
"A070207518",
"A070207513",
"A070112918",
"A070113015",
"A070113025",
"A070207425",
"A070207415",
"A070113218",
"A070113233",
"A070113512",
"A070113918",
"A070115425",
"A070115725",
"A070115761",
"A070113315",
"A070115125",
"A070156640",
"A070156103",
"A060102660",
"A060103760",
"A060105560",
"A060106060",
"A070182264",
"A070182064",
"A060130060",
"A070130862",
"A070176161",
"A070177362",
"A070177162",
"A070112061",
"A070202416",
"A070184561",
"A070146361",
"A070184540"};
String[] Kode_Perusahaan ={"POLRES ACEH SINGKIL",
"POLTABES MS.MEDAN",
"POLRES SERDANG BEDAGAI",
"POLRESTA PADANG SIDEMP",
"POLRES LANGKAT",
"PT . SUTAN KASIM",
"PT . PATRA LOGISTIK (PT. Bima Parama)",
"PT . PATRA LOGISTIK (PT. SIER)",
"PT . KANDE AGUNG",
"PT . PATRA LOGISTIK",
"PT . EKA PRIMA SEMESTA",
"PT . PUTRABANGGA KIRANA ANUGRAH",
"PT . SERDANG JAYA",
"PT . LARIS SUMUT MAKMUR",
"PT . POLA RAYA",
"PT . SUBHIKSA",
"PT . Citra Bintang Familindo",
"PT . SAMUDRA JAYA RAYA",
"PT . WARUNA NUSA SENTANA",
"PT . Arta Cimandiri Cemerlang",
"PT . SPBU COCO",
"POL. HUBANG HASUDUTAN",
"POLRES TNH KARO",
"LANUD MEDAN",
"POLRES PAKPAK BARAT",
"BDH SAKTKER KPPP BELAWAN",
"PT . DC BRIGHT",
"PT. Abadi Mitra Andhika",
"PT. Nasional Usba Transport",
"PT. Wita Sarana Anugerah",
"PT. Jasa Transportasi Patuma",
"PT. Kaye Adang Ekspress",
"PT. Mega Prima Pertamindo",
"PT. Citra Bina Jasa Samudera",
"PT. Riau Muda Jasaguna",
"PT. Putera Sejahtera Abadi",
"PT. Desmandiri Perkasa",
"PT. Patra Niaga",
"PT. Wyranda Utama",
"PT . PATRA LOGISTIK",
"PT . PATRA LOGISTIK (DESMANDIRI)",
"PT . INDRA ANGKOA LUB",
"POLRES TAPANULI UTARA",
"DIT LANTAS POLDASU MEDAN",
"POL LAB BATU",
"POL HUBANG HASUDUTAN",
"POL SIBOLGA",
"POLRESTA BINJAI",
"DITPOLAIR POLDA NAD",
"POLRES SIMALUNGUN",
"POLRES ACEH TAMIANG",
"POLRES TOBA SAMOSIR",
"BENSATKER DIT POLAIR POLDASU",
"POLRES ASAHAN",
"POLRES TANAH KARO",
"POLRES MADINA",
"Polres Tapanuli Selatan",
"POLRES TANJUNG BALAI",
"POLRES KPP BELAWAN",
"POLRES DELI SERDANG",
"ROSARORAS POLDASU MEDAN",
"OWN USE SRM I",
"POLRES NIAS",
"POLRES BATU BARA",
"POLRES TAPANULI TENGAh",
"POLRES DAIRI",
"PT . PATRA LOGISTIK (PT. Putera Sejahtera Abadi)",
"BENSATKER DIT POLAIR SUMUT",
"PT . PATRA LOGISTIK (PT. Putera sejahtera abadi)",
"OWN uSE SR 1",
"PT.MINAMASGEMERLANG",
"POLRES GAYO LUWES",
"OWN USE SR I",
"POLRES NIAS GUNUNG SITOLI",
"POL PEMANATANG SIANTAR",
"POLRES TAPANULI UTARA",
"POLRES BIREUEN",
"POLRES ACEH TENGGARA",
"POLRES ACEH TENGAH",
"PSP BENER MERIAH",
"PT . POS LOGISTIK INDONESIA (AST)",
"PT . PATRA LOGISTIK (PT. AMA)",
"PT . ELNUSA PETROFIN",
"PT . POS LOGISTIK INDONESIA (KSP)",
"PT. PATRA LOGISTIK (WIDYA)",
"PT. PADANG PALMA PERMAI",
"LANUD MAIMUN SALEH",
"BRIMOP POLDA SUMUT",
"PORESTA SIBOLGA",
"PT . PERTAMINA LUBRICANT",
"PT. REZEKI PUTRA ENERGI",
"PT. PATRA LOGISTIK (BELAWAN B)",
"POLRES SAMOSIR",
"ROLOG POLDASU",
"BEND. SATKER DIT SAMAPTA POLDA SUMUT",
"PT. PERTAMINA LUBRICANT",
"POLRES LHOKSEUMAWE",
"POLRES NIAS SELATAN TELUK DALAM",
"BEND.RUTIN BIRO LOGISTIK POLDA SUMUT",
"POLRES ASAHAN KISARAN"};
int counter = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.input_data_keluar);
btnScan = (View) findViewById(R.id.scan);
A15_namajudul = (TextView) findViewById(R.id.namajudul);
// mink = (TextView) findViewById(R.id.min);
radioGroupInOutk = (RadioGroup) findViewById(R.id.radiogroup);
Out = (RadioButton) findViewById(R.id.Keluar);
In = (RadioButton) findViewById(R.id.Masuk);
edit_data_proses = (Button) findViewById(R.id.Edit_aktivitas);
delete_data_proses = (Button) findViewById(R.id.hapus_aktivitas);
refresh = (Button) findViewById(R.id.fresh);
cek = (Button) findViewById(R.id.cekk);
Prosesk = (Button) findViewById(R.id.proses_keluar);
A1_idl = (TextView) findViewById(R.id.ID);
A14_OP = (TextView) findViewById(R.id.operator);
A13_Nama_perus = (EditText) findViewById(R.id.Nama_Perusahaan);
A10_container = (EditText) findViewById(R.id.No_continer);
A10_container.setEnabled(false);
A2_Kimap = (EditText) findViewById(R.id.Kimap_keluar);
A2_Kimap.setText("");
A3_Namaproduk = (EditText) findViewById(R.id.Nama_Produk_Keluar);
A3_Namaproduk.setEnabled(false);
A4_typk = (EditText) findViewById(R.id.Type_keluar);
A4_typk.setEnabled(false);
A5_jumlah_Awal = (EditText) findViewById(R.id.Jumlah_Awal_keluar);
A5_jumlah_Awal.setEnabled(false);
A9_No_polisi = (EditText) findViewById(R.id.No_Transfortir_keluar);
A11_No_documnt = (EditText) findViewById(R.id.Kode_keluar_Data);
A12_keterangank = (EditText) findViewById(R.id.Keterangan_keluar);
A8_jumlahhasil_calcualtion = (EditText) findViewById(R.id.Jumlah_Hasil_keluar);
A8_jumlahhasil_calcualtion.setEnabled(false);
//input jumlah keluar
A6_inputjumlah_keluar = (EditText) findViewById(R.id.inputan_Jumlah_keluar);
//input jumlah masuk
A7_inputjumlah_masuk = (EditText) findViewById(R.id.inputan_Jumlah_Masuk);
A7_inputjumlah_masuk.setEnabled(false);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
A1_idl.setText(bundle.getString("ID"));
A2_Kimap.setText(bundle.getString("KIMAP"));
A3_Namaproduk.setText(bundle.getString("NAMAPRODUK"));
A4_typk.setText(bundle.getString("TYPE"));
A5_jumlah_Awal.setText(bundle.getString("JUMLAHAWAL"));
A6_inputjumlah_keluar.setText(bundle.getString("JUMLAHKELUAR"));
A7_inputjumlah_masuk.setText(bundle.getString("JUMLAHMASUK"));
A8_jumlahhasil_calcualtion.setText(bundle.getString("JUMLAHHASIL"));
A9_No_polisi.setText(bundle.getString("NOPOLISI"));
A10_container.setText(bundle.getString("NOCONTAINER"));
A11_No_documnt.setText(bundle.getString("NODOCH"));
A12_keterangank.setText(bundle.getString("KETERANGAN"));
A13_Nama_perus.setText(bundle.getString("NAMAPERUSAHAAN"));
A14_OP.setText(bundle.getString("STATUS"));
A15_namajudul.setText(bundle.getString("TANGGAL"));
}
A6_inputjumlah_keluar.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
A8_jumlahhasil_calcualtion.setText(addNumbers());
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
A7_inputjumlah_masuk.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
A8_jumlahhasil_calcualtion.setText(addNumbers1());
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
KIMAP_AUTO = (AutoCompleteTextView) findViewById(R.id.Kimap_keluar);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, Kode_Prod);
NamaPT_AUTO = (AutoCompleteTextView) findViewById(R.id.Nama_Perusahaan);
ArrayAdapter adapter1 = new ArrayAdapter(this, android.R.layout.simple_list_item_1, Kode_Perusahaan);
KIMAP_AUTO.setAdapter(adapter);
NamaPT_AUTO.setAdapter(adapter1);
KIMAP_AUTO.setThreshold(1);
NamaPT_AUTO.setThreshold(1);
cek.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AmbilData ambilData = new AmbilData();
ambilData.init(A2_Kimap.getText().toString(), url, Proses_input_output.this, jres);
//Kimapk.setText("");
}
});
Prosesk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(A8_jumlahhasil_calcualtion.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A8_jumlahhasil_calcualtion.setError("Inputan data belum sempurna");
}
if(A2_Kimap.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A2_Kimap.setError("diperlukan inputan data!");
}if(A8_jumlahhasil_calcualtion.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A8_jumlahhasil_calcualtion.setError("proses belum selesai");
}if(A9_No_polisi.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A9_No_polisi.setError("Inputan data belum sempurna");
}if(A11_No_documnt.getText().toString().length()==0) {
//jika form tersebut belum di isi / masih kosong
A11_No_documnt.setError("Inputan data belum sempurna");
}
else{
if(A15_namajudul.getText().toString().equals("Form Data Operasi Pergerakan")){
proses_data();
link_ke_list();
}
else {
Toast.makeText(getApplicationContext(), "Ini proses Delete and update",Toast.LENGTH_SHORT).show();
Prosesk.setVisibility(View.VISIBLE);
Prosesk.setBackgroundColor(Color.BLACK);
counter--;
Prosesk.setText(Integer.toString(counter));
if (counter == 0) {
Prosesk.setEnabled(false);
}
}
}
}
});
refresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//A1_idl.setText("");
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.setText("");
A9_No_polisi.setText("");
A10_container.setText("");
A11_No_documnt.setText("");
A12_keterangank.setText("");
A13_Nama_perus.setText("");
A14_OP.setText("");
A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
}
});
edit_data_proses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pr0ses_edit();
}
});
delete_data_proses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pr0ses_hapus();
}
});
btnScan.setOnClickListener(onClickListener()); }
private View.OnClickListener onClickListener() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException ex) {
ex.printStackTrace();
//if you haven't install barcodeScanner app, download it from Google Play
downloadScanBarcode();
}
}
};
}
private void pr0ses_hapus() {
String idpr = A1_idl.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("id_history", idpr);
Log.d("HashMap", requestedParams.get("id_history"));
Toast.makeText(getApplicationContext(), "Success!! Deleted ID : " + requestedParams.get("id_history"), Toast.LENGTH_LONG).show();
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.Proseskan_Deleting, requestedParams);
postRequestHandler.execute();
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.setText("");
A9_No_polisi.setText("");
A10_container.setText("");
A11_No_documnt.setText("");
A12_keterangank.setText("");
A13_Nama_perus.setText("");
A14_OP.setText("");
A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
// halaman_sebelumnya(view);
}
public void halaman_sebelumnya(View view) {
Intent intent = new Intent(Proses_input_output.this, MainActivity.class);
startActivity(intent);
}
private void pr0ses_edit() {
String IDS = A1_idl.getText().toString();
// String AKSI = A14_OP.getText().toString();
String TGL = A15_namajudul.getText().toString();
String AKSI = ((RadioButton) findViewById(radioGroupInOutk.getCheckedRadioButtonId())).getText().toString();
String KIMAP = A2_Kimap.getText().toString();
String NAMAPRODUK = A3_Namaproduk.getText().toString();
String TYPE = A4_typk.getText().toString();
String JUMLAH_AWAL = A5_jumlah_Awal.getText().toString();
String JUMLAH_KELUAR = A6_inputjumlah_keluar.getText().toString();
String JUMLAH_MASUK = A7_inputjumlah_masuk.getText().toString();
String JUMLAH_HASIL = A8_jumlahhasil_calcualtion.getText().toString();
String NAMA_PERUSAHAAN = A13_Nama_perus.getText().toString();
String NOPOLISI = A9_No_polisi.getText().toString();
String NOKONTAINER = A10_container.getText().toString();
String NODOCUMNT = A11_No_documnt.getText().toString();
String NAMAPERUSAHAAN = A12_keterangank.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("id_history", IDS);
requestedParams.put("tanggalh", TGL);
requestedParams.put("Statush", AKSI);
requestedParams.put("Kimaph", KIMAP);
requestedParams.put("Nama_produkh", NAMAPRODUK);
requestedParams.put("Typeh", TYPE);
requestedParams.put("jumlah_awal", JUMLAH_AWAL);
requestedParams.put("jumlah_masuk", JUMLAH_MASUK);
requestedParams.put("jumlah_keluar", JUMLAH_KELUAR);
requestedParams.put("Jumlah_hasil", JUMLAH_HASIL);
requestedParams.put("Nama_Perusahaan", NAMA_PERUSAHAAN);
requestedParams.put("No_polisih", NOPOLISI);
requestedParams.put("No_doch", NODOCUMNT);
requestedParams.put("No_container", NOKONTAINER);
requestedParams.put("Keteranganh", NAMAPERUSAHAAN);
Log.d("HashMap", requestedParams.get("id_history"));
Toast.makeText(getApplicationContext(), "Success!!: " + requestedParams.get("id_history"), Toast.LENGTH_LONG).show();
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.Proseskan_Editing, requestedParams);
postRequestHandler.execute();
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.setText("");
A9_No_polisi.setText("");
A10_container.setText("");
A11_No_documnt.setText("");
A12_keterangank.setText("");
A13_Nama_perus.setText("");
A14_OP.setText("");
A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
//halaman_riwayat(view);
}
public void halaman_riwayat(View view) {
Intent intent = new Intent(Proses_input_output.this, MainActivity.class);
startActivity(intent);
}
private void link_ke_list() {
String idpr = A1_idl.getText().toString();
String kode = A2_Kimap.getText().toString();
String nama = A3_Namaproduk.getText().toString();
String jumlah = A8_jumlahhasil_calcualtion.getText().toString();
String types = A4_typk.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("id", idpr);
requestedParams.put("Kd_produk", kode);
requestedParams.put("Nama", nama);
requestedParams.put("Jumlah", jumlah);
requestedParams.put("Status", types);
Log.d("HashMap", requestedParams.get("id"));
Toast.makeText(getApplicationContext(), "Success!! : " + requestedParams.get("id"), Toast.LENGTH_LONG).show();
A2_Kimap.setText("");
A3_Namaproduk.setText("");
A4_typk.setText("");
A5_jumlah_Awal.setText("");
A6_inputjumlah_keluar.setText("");
A7_inputjumlah_masuk.setText("");
A8_jumlahhasil_calcualtion.getText().clear();
// A9_No_polisi.setText("");
// A10_container.setText("");
// A11_No_documnt.setText("");
// A12_keterangank.setText("");
// A13_Nama_perus.setText("");
// A14_OP.setText("");
// A15_namajudul.setText("");
A6_inputjumlah_keluar.setText("");
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.edit_url, requestedParams);
postRequestHandler.execute();
}
private void proses_data() {
String AKSI = ((RadioButton) findViewById(radioGroupInOutk.getCheckedRadioButtonId())).getText().toString();
String KIMAP = A2_Kimap.getText().toString();
String NAMAPRODUK = A3_Namaproduk.getText().toString();
String TYPE = A4_typk.getText().toString();
String JUMLAH_AWAL = A5_jumlah_Awal.getText().toString();
String JUMLAH_KELUAR = A6_inputjumlah_keluar.getText().toString();
String JUMLAH_MASUK = A7_inputjumlah_masuk.getText().toString();
String JUMLAH_HASIL = A8_jumlahhasil_calcualtion.getText().toString();
String NAMA_PERUSAHAAN = A13_Nama_perus.getText().toString();
String NOPOLISI = A9_No_polisi.getText().toString();
String NOKONTAINER = A10_container.getText().toString();
String NODOCUMNT = A11_No_documnt.getText().toString();
String NAMAPERUSAHAAN = A12_keterangank.getText().toString();
HashMap<String, String> requestedParams = new HashMap<>();
requestedParams.put("Statush", AKSI);
requestedParams.put("Kimaph", KIMAP);
requestedParams.put("Nama_produkh", NAMAPRODUK);
requestedParams.put("Typeh", TYPE);
requestedParams.put("jumlah_awal", JUMLAH_AWAL);
requestedParams.put("jumlah_masuk", JUMLAH_MASUK);
requestedParams.put("jumlah_keluar", JUMLAH_KELUAR);
requestedParams.put("Jumlah_hasil", JUMLAH_HASIL);
requestedParams.put("Nama_Perusahaan", NAMA_PERUSAHAAN);
requestedParams.put("No_polisih", NOPOLISI);
requestedParams.put("No_doch", NODOCUMNT);
requestedParams.put("No_container", NOKONTAINER);
requestedParams.put("Keteranganh", NAMAPERUSAHAAN);
Log.d("HashMap", requestedParams.get("Statush"));
Toast.makeText(getApplicationContext(), "Success!!: " + requestedParams.get("Statush"), Toast.LENGTH_LONG).show();
PostRequestHandler postRequestHandler = new PostRequestHandler(Constant.Proseskan_data, requestedParams);
postRequestHandler.execute();
}
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch (view.getId()) {
case R.id.Masuk:
if (checked)
// Same day service
A6_inputjumlah_keluar.setEnabled(false);
A7_inputjumlah_masuk.setEnabled(true);
A14_OP.setText("+");
A14_OP.setTextColor(Color.parseColor("#4CAF50"));//HIJAU
A14_OP.setBackgroundColor(Color.parseColor("#ffffff"));//White
A10_container.setEnabled(true);
// Out.setEnabled(false);
// In.setEnabled(true);
break;
case R.id.Keluar:
if (checked)
// Next day delivery
// In.setEnabled(false);
// Out.setEnabled(true);
A14_OP.setText("-");
A14_OP.setTextColor(Color.parseColor("#F44336"));//MERAH
A14_OP.setBackgroundColor(Color.parseColor("#ffffff"));//White
A10_container.setEnabled(false);
A6_inputjumlah_keluar.setEnabled(true);
A7_inputjumlah_masuk.setEnabled(false);
break;
}
}
private String addNumbers() {
Double number1;
Double number2;
if (A5_jumlah_Awal.getText().toString() != "" && A5_jumlah_Awal.getText().length() > 0) {
number1 = Double.valueOf(Float.valueOf(A5_jumlah_Awal.getText().toString()));
} else {
number1 = Double.valueOf(Float.valueOf(String.valueOf(0)));
}
if (A6_inputjumlah_keluar.getText().toString() != "" && A6_inputjumlah_keluar.getText().length() > 0) {
number2 = Double.valueOf(Float.valueOf(A6_inputjumlah_keluar.getText().toString()));
} else {
number2 = Double.valueOf(Float.valueOf(String.valueOf(0)));
}
return Double.toString(number1 - number2);
}
private String addNumbers1() {
Double number3;
Double number4;
if (A5_jumlah_Awal.getText().toString() != "" && A5_jumlah_Awal.getText().length() > 0) {
number3 = Double.valueOf(Float.valueOf(A5_jumlah_Awal.getText().toString()));
} else {
number3 = Double.valueOf(Float.valueOf(0));
}
if (A7_inputjumlah_masuk.getText().toString() != "" && A7_inputjumlah_masuk.getText().length() > 0) {
number4 = Double.valueOf(Float.valueOf(A7_inputjumlah_masuk.getText().toString()));
} else {
number4 = Double.valueOf(Float.valueOf(0));
}
return Double.toString(number3 + number4);
}
JSONObjectResult jres = new JSONObjectResult() {
@Override
public void gotJSONObject(JSONObject jsonObject) {
try {
JSONArray jsonArray = jsonObject.getJSONArray("u259130893_whs");
for (int i = 0; i < jsonArray.length(); i++) {
A1_idl.setText(jsonArray.getJSONObject(i).getString("id"));
A3_Namaproduk.setText(jsonArray.getJSONObject(i).getString("Nama"));
A5_jumlah_Awal.setText(jsonArray.getJSONObject(i).getString("Jumlah"));
A4_typk.setText(jsonArray.getJSONObject(i).getString("status"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
private void downloadScanBarcode() {
Uri uri = Uri.parse("market://search?q=pname:" + "com.google.zxing.client.android");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
ex.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
//format.setText(data.getStringExtra("SCAN_RESULT_FORMAT"));
A2_Kimap.setText(data.getStringExtra("SCAN_RESULT"));
} else if (resultCode == RESULT_CANCELED) {
// format.setText("Press a button to start a scan.");
A2_Kimap.setText("Scan cancelled.");
}
}
}
}
PostRequestHandler.java
package com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta;
import android.os.AsyncTask;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
/**
* Created by DELL on 12/20/2017.
*/
public class PostRequestHandler extends AsyncTask<Void, Void, String> {
// Request URL
String url;
// Key, Value pair
HashMap<String, String> requestedParams;
public PostRequestHandler(String url, HashMap<String, String> params){
this.url = url;
this.requestedParams = params;
// Log.d("Input Box", designation);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
//progressBar.setVisibility(View.VISIBLE);
}
@Override
protected String doInBackground(Void... voids) {
// Now Send a post request
BackgroundWorker backgroundWorker = new BackgroundWorker();
try {
String s = backgroundWorker.postRequestHandler(url, requestedParams);
// Log.d("HashMap--------", requestedParams.get("salary"));
// Log.d("Results------", s.toString());
// Toast.makeText(getApplicationContext(), s.toString(), Toast.LENGTH_LONG).show();
return s.toString();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//progressBar.setVisibility(GONE);
//Toast.makeText(getApplicationContext, "Result : " + s, Toast.LENGTH_LONG).show();
//Toast.makeText(getBaseContext(), s, Toast.LENGTH_LONG).show();
}
}
package com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta;
public class Constant {
private static final String BASE_PATH = "http://192.168.43.233/ANDROID/DB_SKRIPSI/Input_data_product/";
// private static final String BASE_PATH = "https://heruonline.com/ANDROID/SKRIPSI/";
// private static final String BASE_PATH = "https://heruweb.000webhostapp.com/ANDROID/DB_SKRIPSI/Input_data_product/";
public static final String Simpan_URL = BASE_PATH + "add_data_produk.php";
// public static final String Simpan_URL = BASE_PATH + "insert_data.php";
public static final String edit_url = BASE_PATH + "Update_produk.php";
// public static final String edit_url = BASE_PATH + "insert_edit_data.php";
public static final String delete_url = BASE_PATH + "Delete_produk.php";
//public static final String delete_url = BASE_PATH + "insert_delete_data.php";
public static final String Proseskan_Editing = BASE_PATH + "Proseskan_Edit_history.php";
public static final String Proseskan_Deleting = BASE_PATH + "Proseskan_Delete_history.php";
public static final String Register_url = BASE_PATH + "register.php";
//public static final String Register_url = BASE_PATH + "Register.php";
public static final String Proseskan_data = "https://heruonline.com/ANDROID/SKRIPSI/list_history.php";
static final String POST_METHOD = "POST";
}
package com.example.heru_hardadi_pc.warehouse_apps_01.PostRequest_Background_Consta;
import android.util.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* Created by DELL on 12/20/2017.
*/
public class BackgroundWorker {
// Make a POST Request Handler
public String postRequestHandler(String requestUrl, HashMap<String, String> requestedDataParams) throws UnsupportedEncodingException {
// Set an Empty URL obj in system
URL url;
// Set a String Builder to store result as string
StringBuilder stringBuilder = new StringBuilder();
try {
// Now Initialize URL
url = new URL(requestUrl);
// Make a HTTP url connection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Set Method Type
connection.setRequestMethod(Constant.POST_METHOD);
// Set Connection Time
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
// set Input output ok
connection.setDoInput(true);
connection.setDoOutput(true);
// Remove Caches
//connection.setUseCaches(false);
//connection.setDefaultUseCaches(false);
// Creating a url as String with params
StringBuilder url_string = new StringBuilder();
boolean ampersand = false;
for (Map.Entry<String, String> params : requestedDataParams.entrySet() ){
if (ampersand)
url_string.append("&");
else
ampersand = true;
url_string.append(URLEncoder.encode(params.getKey(), "UTF-8"));
url_string.append("=");
url_string.append(URLEncoder.encode(params.getValue(), "UTF-8"));
}
Log.d("Final Url===", url_string.toString());
//Creating an output stream
OutputStream outputStream = connection.getOutputStream();
// Write Output Steam
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
bufferedWriter.write(url_string.toString());
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
// Log.d("Response===", connection.getResponseMessage());
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK){
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
// Local String
String result;
while ((result = bufferedReader.readLine()) != null) {
stringBuilder.append(result);
}
// Log.d("Result===", result);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return stringBuilder.toString();
}
// Get Request Handler
public String getRequestHandler(String requestUrl){
// To Store response
StringBuilder stringBuilder = new StringBuilder();
try {
URL url = new URL(requestUrl);
// Open Connection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
// Local
String result;
while ((result = bufferedReader.readLine()) != null) {
stringBuilder.append(result + "\n");
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
AmbilData.java
package com.example.heru_hardadi_pc.warehouse_apps_01.GETdata;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class AmbilData extends AsyncTask<Object,Object,Object> {
JSONParser jsonParser;
JSONObject jsonObject;
ProgressDialog pg;
Context context;
JSONObjectResult jres;
public void init(String var,String url,Context con, JSONObjectResult jsonObjectResult){
context = con;
jres = jsonObjectResult;
AmbilData ambilData = this;
ambilData.execute(var,url);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pg = new ProgressDialog(context);
pg.setTitle("Loading");
pg.setMessage("Pengecekan Data..");
pg.show();
}
@Override
protected Object doInBackground(Object... params) {
jsonObject = null;
jsonParser = new JSONParser();
String kode = (String) params[0];
String kodelogin = (String) params[0];
String urls = (String) params[1];
List<NameValuePair> param = new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("kode",kode));
param.add(new BasicNameValuePair("kodelogin",kodelogin));
try {
jsonObject = jsonParser.getJsonObject("POST",urls,param);
} catch (IOException e) {
e.printStackTrace();
}
return jsonObject;
}
@Override
protected void onPostExecute(Object result) {
super.onPostExecute(result);
if(result != null){
JSONObject jObj = (JSONObject) result;
jres.gotJSONObject(jObj);
}else{
Toast.makeText(context, "Data tidak ditemukan atau belum terdaftar :(", Toast.LENGTH_LONG).show();
}
pg.dismiss();
}
public static abstract class JSONObjectResult{
public abstract void gotJSONObject(JSONObject jsonObject);
}
}
JSONParser.java
package com.example.heru_hardadi_pc.warehouse_apps_01.GETdata;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* Created by Andrya on 9/13/2015.
*/
public class JSONParser {
private JSONObject jsonObject;
String jsonString;
InputStream is;
public JSONObject getJsonObject(String method, String url, List<NameValuePair> param) throws IOException{
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
try {
httpPost.setEntity(new UrlEncodedFormEntity(param));
HttpResponse httpResponse = client.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}catch(UnsupportedEncodingException e){
e.printStackTrace();
}catch(ClientProtocolException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"));
StringBuilder sb = new StringBuilder();
String line = "";
while ((line = reader.readLine()) != null) {
sb.append(line + "/n");
}
jsonString = sb.toString();
jsonObject = null;
}catch(Exception e){
e.printStackTrace();
}
try {
jsonObject = new JSONObject(jsonString);
} catch (JSONException e) {
e.printStackTrace();
}
return jsonObject;
}
}
Comments
Post a Comment