package com.app.army.tab; /** * Created by army on 8/31/2017. */ import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class Tab4Weight extends Fragment { EditText firstNumber; EditText secondNumber; TextView addResult; Button btnAdd; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab4weight, container, false); firstNumber = (EditText)view.findViewById(R.id.txtNumber1); secondNumber = (EditText)view.findViewById(R.id.txtNumber2); addResult = (TextView)view.findViewById(R.id.txtResult); btnAdd = (Button)view.findViewById(R.id.btnAdd); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(!TextUtils.isEmpty(firstNumber.getText().toString())&&!TextUtils.isEmpty(secondNumber.getText().toString())){ String value1= firstNumber.getText().toString(); String value2= secondNumber.getText().toString(); int a=Integer.parseInt((value1)); int b=Integer.parseInt((value2)); int sum= getCoordinates(a,b); Toast.makeText(getActivity(),"Weight in Kg: " + String.valueOf(sum),Toast.LENGTH_LONG).show(); }else { Toast.makeText(getActivity(), "value is empty", Toast.LENGTH_SHORT).show(); } } private int getCoordinates (int coordA, int coordB){ int results = 0; if (coordA < 7000 && coordB < 30 && coordB > -45) { results = 7400; } else { if (coordA==8000 && coordB ==30) { results = 7100; } else { if (coordA==9000 && coordB ==30) { results = 6850; } else { if (coordA==9000 && coordB ==20) { results = 7100; } else { if (coordA==9000 && coordB ==10) { results = 7350; } else { if (coordA==10000 && coordB ==30) { results = 6850; } else { if (coordA==10000 && coordB ==20) { results = 6800; } else { if (coordA==10000 && coordB ==10) { results = 7100; } else { if (coordA==10000 && coordB ==0) { results = 7350; } else { if (coordA==11000 && coordB ==20) { results = 6550; } else { if (coordA==11000 && coordB ==10) { results = 6800; } else { if (coordA==11000 && coordB ==0) { results = 7080; } else { if (coordA==11000 && coordB == -10) { results = 7360; } else { if (coordA==12000 && coordB ==20) { results = 6380; } else { if (coordA==12000 && coordB ==10) { results = 6510; } else { if (coordA==12000 && coordB ==0) { results = 6800; } else { if (coordA==12000 && coordB == -10) { results = 7100; } else { if (coordA==12000 && coordB == -20) { results = 7350; } else { if (coordA==13000 && coordB ==20) { results = 6010; } else { if (coordA==13000 && coordB ==10) { results = 6260; } else { if (coordA==13000 && coordB ==0) { results = 6510; } else { if (coordA==13000 && coordB == -10) { results = 6800; } else { if (coordA==13000 && coordB == -20) { results = 7080; } else { if (coordA==13000 && coordB == -30) { results = 7400; } else { if (coordA==14000 && coordB ==20) { results = 5780; } else { if (coordA==14000 && coordB ==15) { results = 5900; } else { if (coordA==14000 && coordB ==10) { results = 6000; } else { if (coordA==14000 && coordB ==0) { results = 6250; } else { if (coordA==14000 && coordB == -10) { results = 6510; } else { if (coordA==14000 && coordB == -20) { results = 6800; } else { if (coordA==14000 && coordB ==-30) { results = 7100; } else { if (coordA==15000 && coordB ==20) { results = 5550; } else { if (coordA==15000 && coordB ==15) { results = 5250; } else { if (coordA==15000 && coordB ==10) { results = 5260; } else { if (coordA==15000 && coordB ==0) { results = 6000; } else { if (coordA==15000 && coordB == -10) { results = 6250; } else { if (coordA==15000 && coordB == -20) { results = 6510; } else { if (coordA==15000 && coordB == -30) { results = 6800; } else { if (coordA==15000 && coordB == -40) { results = 7100; } else { if (coordA==15000 && coordB == -45) { results = 7290; } else { if (coordA==16000 && coordB ==15) { results = 5400; } else { if (coordA==16000 && coordB ==10) { results = 5520; } else { if (coordA==16000 && coordB ==0) { results = 5760; } else { if (coordA==16000 && coordB == -10) { results = 6000; } else { if (coordA==16000 && coordB == -20) { results = 6280; } else { if (coordA==16000 && coordB == -30) { results = 6510; } else { if (coordA==16000 && coordB == -40) { results = 6820; } else { if (coordA==16000 && coordB == -45) { results = 7000; } else { if (coordA==17000 && coordB ==15) { results = 5200; } else { if (coordA==17000 && coordB ==10) { results = 5300; } else { if (coordA==17000 && coordB ==0) { results = 5510; } else { if (coordA==17000 && coordB == -10) { results = 5780; } else { if (coordA==17000 && coordB == -20) { results = 6000; } else { if (coordA==17000 && coordB == -30) { results = 6280; } else { if (coordA==17000 && coordB == -40) { results = 6550; } else { if (coordA==17000 && coordB == -45) { results = 6710; } else { if (coordA==18000 && coordB ==10) { results = 5100; } else { if (coordA==18000 && coordB ==0) { results = 5300; } else { if (coordA==18000 && coordB == -10) { results = 5520; } else { if (coordA==18000 && coordB == -20) { results = 5750; } else { if (coordA==18000 && coordB == -30) { results = 6000; } else { if (coordA==18000 && coordB == -40) { results = 6290; } else { if (coordA==18000 && coordB == -45) { results = 6450; } else { if (coordA==19000 && coordB ==10) { results = 4900; } else { if (coordA==19000 && coordB ==0) { results = 5080; } else { if (coordA==19000 && coordB == -10) { results = 5800; } else { if (coordA==19000 && coordB == -20) { results = 5500; } else { if (coordA==19000 && coordB == -30) { results = 5250; } else { if (coordA==19000 && coordB == -40) { results = 5780; } else { if (coordA==19000 && coordB == -45) { results = 5900; } else { if (coordA==20000 && coordB ==10) { results = 4700; } else { if (coordA==20000 && coordB ==0) { results = 4890; } else { if (coordA==20000 && coordB == -10) { results = 5080; } else { if (coordA==20000 && coordB == -20) { results = 5300; } else { if (coordA==20000 && coordB == -30) { results = 5520; } else { if (coordA==20000 && coordB == -40) { results = 5780; } else { if (coordA==20000 && coordB == -45) { results = 5900; } else { if (coordA==8000 && coordB ==20) { results = 7380; } else { if (coordA==8000 && coordB <20) { results = 7400; } else { if (coordA==9000 && coordB <10) { results = 7400; } else { if (coordA==10000 && coordB <0) { results = 7400; } else { if (coordA==11000 && coordB < -10) { results = 7400; } else { if (coordA==12000 && coordB < -20) { results = 7400; } else { if (coordA==13000 && coordB < -30) { results = 7400; } else { if (coordA==14000 && coordB < -40 ) { results = 7400; } else { if (coordA==0 && coordB ==0) { results = 0; } else { if (coordA==0 && coordB ==0) { results = 7400; } else { if (coordA==0 && coordB ==0) { results = 7400; } else { if (coordA==0 && coordB ==0) { results = 7400; } else { if (coordA==0 && coordB ==0) { results = 7400; } else { if (coordA==0 && coordB ==0) { results = 7400; } else { Toast.makeText(getActivity(),"Error data Input" ,Toast.LENGTH_LONG).show(); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } return results; } }); firstNumber.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { int jumlah = Integer.parseInt(firstNumber.getText().toString()); if( firstNumber.getText().toString().equals("")||jumlah > 10001 && jumlah < 10999) { firstNumber.setText("11000"); return; } else { if (firstNumber.getText().toString().equals("") || jumlah > 11001 && jumlah < 11999) { firstNumber.setText("12000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 12001 && jumlah < 12999) { firstNumber.setText("13000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 13001 && jumlah < 13999) { firstNumber.setText("14000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 14001 && jumlah < 14999) { firstNumber.setText("15000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 15001 && jumlah < 15999) { firstNumber.setText("16000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 16001 && jumlah < 16999) { firstNumber.setText("17000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 17001 && jumlah < 17999) { firstNumber.setText("18000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 18001 && jumlah < 18999) { firstNumber.setText("19000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 19001 && jumlah < 19999) { firstNumber.setText("20000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("7000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 7001 && jumlah < 7999) { firstNumber.setText("8000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 8001 && jumlah < 8999) { firstNumber.setText("9000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 9001 && jumlah < 9999) { firstNumber.setText("10000"); } else { if (firstNumber.getText().toString().equals("") || jumlah > 0 && jumlah < 0) { firstNumber.setText("0"); } } } } } } } } } } } } } } } } } } } } } } }); return view; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)