// Update topap resit

parent 1f190cc1
......@@ -49,7 +49,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
TextView textView_receiver,textView_sender;
Button button_operator,button_topap;
TextInputEditText et_reference;
String session = "",operatorId="",retails_value = "",value="",whosale_price ="";
String session = "",operatorId="",retails_value = "",value="",whosale_price ="",destinationCurrency="";
StandardProgressDialog standardProgressDialog;
ArrayAdapter<String> spinnerNationalityAdapter;
LinearLayout linear_sender,linear_reference;
......@@ -58,6 +58,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
ArrayList<String> operatorNames;
ArrayList<String> valueNames;
boolean status_operator = false;
String current_topap_operator = "",current_operator_id="";
TextView textView_amount,textView_topapRate,textView_serviceFee,textView_totalAmout;
LinearLayout linear_details;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -78,6 +81,13 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
linear_sender = findViewById(R.id.linear_sender);
linear_reference = findViewById(R.id.linear_reference);
linear_details = findViewById(R.id.linear_details);
textView_amount = findViewById(R.id.textView_amount);
textView_topapRate = findViewById(R.id.textView_topapRate);
textView_serviceFee = findViewById(R.id.textView_serviceFee);
textView_totalAmout = findViewById(R.id.textView_totalAmout);
linear_details.setVisibility(View.GONE);
imageView_back.setOnClickListener(this);
button_operator.setOnClickListener(this);
button_topap.setOnClickListener(this);
......@@ -221,7 +231,13 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
params.put("senderMobileNo",textView_sender.getText().toString()+""+editText_sender.getText().toString());
params.put("product",value);
params.put("smscontent",et_reference.getText().toString());
if(operatorId.equals("")){
params.put("operatorId",current_operator_id);
}else {
params.put("operatorId",operatorId);
}
return params;
}
......@@ -259,8 +275,11 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
@Override
public void onResponse(String response) {
standardProgressDialog.dismiss();
Log.d("RESPONSE ",response);
try {
JSONObject obj = new JSONObject(response);
current_topap_operator = obj.getString("operator");
current_operator_id = obj.getString("operatorId");
showDialogOperator(obj.getString("countryId"));
} catch (JSONException e) {
e.printStackTrace();
......@@ -309,6 +328,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
public void onClick(View v) {
mDialogOperator.dismiss();
status_operator = false;
linear_details.setVisibility(View.GONE);
}
});
......@@ -317,6 +337,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
public void onClick(View v) {
mDialogOperator.dismiss();
status_operator = true;
linear_details.setVisibility(View.VISIBLE);
}
});
......@@ -341,6 +362,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
operatorOnselect(mView,spinner_operator,countryId,spinner_value);
}
spinner_operator.setAdapter(new ArrayAdapter<String>(mView.getContext(), android.R.layout.simple_spinner_dropdown_item, operatorNames));
spinner_operator.setSelection(getIndex(spinner_operator, current_topap_operator));
getSpinnerValue(mView,spinner_value,current_operator_id);
Log.d("current_operator_id",current_operator_id);
}
} catch (JSONException e) {
e.printStackTrace();
......@@ -475,6 +499,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
}
public void valueOnselect(final View mView, final Spinner spinner_operator, final Spinner spinner_value){
if(operatorId.equals("")){
operatorId = current_operator_id;
}
StringRequest stringRequest = new StringRequest(GET, BasedUrl.URL_STAGING +"topup/operator/"+operatorId+"/product",
new com.android.volley.Response.Listener<String>() {
@Override
......@@ -494,10 +521,14 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
value = spinner;
retails_value = arrs.getString(i);
whosale_price = who.getString(i);
destinationCurrency = obj.getString("destinationCurrency");
textView_amount.setText(value+" "+destinationCurrency);
textView_topapRate.setText(retails_value+" "+destinationCurrency);
textView_serviceFee.setText("0 MYR");
textView_totalAmout.setText(retails_value+" "+destinationCurrency);
Log.d("VALUE",value);
Log.d("retails_value",retails_value);
Log.d("WHOSALE PRICE ",whosale_price);
}
}
}
......@@ -535,4 +566,12 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
}
private int getIndex(Spinner spinner, String myString){
for (int i=0;i<spinner.getCount();i++){
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)){
return i;
}
}
return 0;
}
}
......@@ -4,9 +4,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/white"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
tools:context=".Activity.TopapActivity">
<LinearLayout
......@@ -47,6 +48,15 @@
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -129,6 +139,104 @@
android:text="choose operator"
android:textColor="@android:color/white" />
<LinearLayout
android:id="@+id/linear_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textView19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Top Up Amount" />
<TextView
android:id="@+id/textView_amount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textView19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Top Up Rate" />
<TextView
android:id="@+id/textView_topapRate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textView19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Service Fee" />
<TextView
android:id="@+id/textView_serviceFee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textView19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Total Amount" />
<TextView
android:id="@+id/textView_totalAmout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_sender"
android:layout_width="match_parent"
......@@ -193,4 +301,6 @@
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment