// Update topap resit

parent 1f190cc1
...@@ -49,7 +49,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -49,7 +49,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
TextView textView_receiver,textView_sender; TextView textView_receiver,textView_sender;
Button button_operator,button_topap; Button button_operator,button_topap;
TextInputEditText et_reference; TextInputEditText et_reference;
String session = "",operatorId="",retails_value = "",value="",whosale_price =""; String session = "",operatorId="",retails_value = "",value="",whosale_price ="",destinationCurrency="";
StandardProgressDialog standardProgressDialog; StandardProgressDialog standardProgressDialog;
ArrayAdapter<String> spinnerNationalityAdapter; ArrayAdapter<String> spinnerNationalityAdapter;
LinearLayout linear_sender,linear_reference; LinearLayout linear_sender,linear_reference;
...@@ -58,6 +58,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -58,6 +58,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
ArrayList<String> operatorNames; ArrayList<String> operatorNames;
ArrayList<String> valueNames; ArrayList<String> valueNames;
boolean status_operator = false; boolean status_operator = false;
String current_topap_operator = "",current_operator_id="";
TextView textView_amount,textView_topapRate,textView_serviceFee,textView_totalAmout;
LinearLayout linear_details;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -78,6 +81,13 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -78,6 +81,13 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
linear_sender = findViewById(R.id.linear_sender); linear_sender = findViewById(R.id.linear_sender);
linear_reference = findViewById(R.id.linear_reference); 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); imageView_back.setOnClickListener(this);
button_operator.setOnClickListener(this); button_operator.setOnClickListener(this);
button_topap.setOnClickListener(this); button_topap.setOnClickListener(this);
...@@ -221,7 +231,13 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -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("senderMobileNo",textView_sender.getText().toString()+""+editText_sender.getText().toString());
params.put("product",value); params.put("product",value);
params.put("smscontent",et_reference.getText().toString()); params.put("smscontent",et_reference.getText().toString());
params.put("operatorId",operatorId);
if(operatorId.equals("")){
params.put("operatorId",current_operator_id);
}else {
params.put("operatorId",operatorId);
}
return params; return params;
} }
...@@ -259,8 +275,11 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -259,8 +275,11 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
standardProgressDialog.dismiss(); standardProgressDialog.dismiss();
Log.d("RESPONSE ",response);
try { try {
JSONObject obj = new JSONObject(response); JSONObject obj = new JSONObject(response);
current_topap_operator = obj.getString("operator");
current_operator_id = obj.getString("operatorId");
showDialogOperator(obj.getString("countryId")); showDialogOperator(obj.getString("countryId"));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -309,6 +328,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -309,6 +328,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
public void onClick(View v) { public void onClick(View v) {
mDialogOperator.dismiss(); mDialogOperator.dismiss();
status_operator = false; status_operator = false;
linear_details.setVisibility(View.GONE);
} }
}); });
...@@ -317,6 +337,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -317,6 +337,7 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
public void onClick(View v) { public void onClick(View v) {
mDialogOperator.dismiss(); mDialogOperator.dismiss();
status_operator = true; status_operator = true;
linear_details.setVisibility(View.VISIBLE);
} }
}); });
...@@ -341,6 +362,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -341,6 +362,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
operatorOnselect(mView,spinner_operator,countryId,spinner_value); 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.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) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -475,6 +499,9 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -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){ 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", StringRequest stringRequest = new StringRequest(GET, BasedUrl.URL_STAGING +"topup/operator/"+operatorId+"/product",
new com.android.volley.Response.Listener<String>() { new com.android.volley.Response.Listener<String>() {
@Override @Override
...@@ -494,13 +521,17 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -494,13 +521,17 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList
value = spinner; value = spinner;
retails_value = arrs.getString(i); retails_value = arrs.getString(i);
whosale_price = who.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);
} }
} }
} }
}catch (JSONException e){ }catch (JSONException e){
e.printStackTrace(); e.printStackTrace();
} }
...@@ -535,4 +566,12 @@ public class TopapActivity extends AppCompatActivity implements View.OnClickList ...@@ -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 @@ ...@@ -4,9 +4,10 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:background="@android:color/white"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:orientation="vertical"
tools:context=".Activity.TopapActivity"> tools:context=".Activity.TopapActivity">
<LinearLayout <LinearLayout
...@@ -47,150 +48,259 @@ ...@@ -47,150 +48,259 @@
</LinearLayout> </LinearLayout>
<LinearLayout <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_margin="30dp"
android:background="@android:color/white"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:gravity="center"
android:text="Destination Info"
android:textColor="@android:color/black"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Select Country :" />
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:id="@+id/spinner_country"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/custom_spinner_topap_activity" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:layout_margin="30dp"
android:background="@android:color/white"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/textView_receiver" android:id="@+id/textView3"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5dp" android:layout_marginBottom="25dp"
android:text="+6" android:gravity="center"
android:text="Destination Info"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:textSize="16sp" /> android:textSize="18sp" />
<EditText <LinearLayout
android:id="@+id/editText_receiver"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:layout_marginBottom="10dp"
android:inputType="number" android:orientation="vertical">
android:paddingRight="10dp" />
</LinearLayout>
</LinearLayout>
<Button <TextView
android:id="@+id/button_operator" android:id="@+id/textView4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginBottom="5dp"
android:background="@color/colorBackground" android:text="Select Country :" />
android:text="choose operator"
android:textColor="@android:color/white" />
<LinearLayout <com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:id="@+id/linear_sender" android:id="@+id/spinner_country"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="50dp"
android:layout_marginTop="25dp" android:background="@drawable/custom_spinner_topap_activity" />
android:orientation="vertical">
<LinearLayout </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView <LinearLayout
android:id="@+id/textView_sender" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5dp" android:orientation="vertical">
android:text="+6"
android:textColor="@android:color/black"
android:textSize="16sp" />
<EditText <LinearLayout
android:id="@+id/editText_sender" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView_receiver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="+6"
android:textColor="@android:color/black"
android:textSize="16sp" />
<EditText
android:id="@+id/editText_receiver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:paddingRight="10dp" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/button_operator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:layout_marginTop="10dp"
android:hint="Sender Phone Number" android:background="@color/colorBackground"
android:inputType="number" /> android:text="choose operator"
</LinearLayout> android:textColor="@android:color/white" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linear_reference" android:id="@+id/linear_details"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginTop="10dp" android:layout_marginTop="20dp"
android:orientation="vertical"> android:layout_marginBottom="10dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout <LinearLayout
android:id="@+id/till_reference" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_height="wrap_content"> 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>
<android.support.design.widget.TextInputEditText <LinearLayout
android:id="@+id/et_reference" android:id="@+id/linear_sender"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:hint="Reference Text" android:layout_marginTop="25dp"
android:inputType="textEmailAddress" android:orientation="vertical">
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout> <LinearLayout
</LinearLayout> android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button <TextView
android:id="@+id/button_topap" android:id="@+id/textView_sender"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginRight="5dp"
android:background="@color/colorBackground" android:text="+6"
android:text="TOP UP" android:textColor="@android:color/black"
android:textColor="@android:color/white" /> android:textSize="16sp" />
<EditText
android:id="@+id/editText_sender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Sender Phone Number"
android:inputType="number" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_reference"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/till_reference"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/et_reference"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Reference Text"
android:inputType="textEmailAddress"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Button
android:id="@+id/button_topap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/colorBackground"
android:text="TOP UP"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </ScrollView>
</LinearLayout> </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