Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: app/src/main/java/project/isi/octaneo/activities/GasStationInfoActivity.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/java/project/isi/octaneo/activities/GasStationInfoActivity.java (revision 4d392dad7980837ac6a511ec539006ebc074fa03)
- +++ app/src/main/java/project/isi/octaneo/activities/GasStationInfoActivity.java (date 1527415097138)
- @@ -5,15 +5,16 @@
- import android.support.annotation.Nullable;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- +import android.view.View;
- import android.widget.CheckBox;
- import android.widget.EditText;
- import android.widget.RatingBar;
- import android.widget.TextView;
- -import android.view.View;
- import project.isi.octaneo.R;
- import project.isi.octaneo.adapters.GasStationCommentsAdapter;
- import project.isi.octaneo.adapters.GasStationFuelsAdapter;
- +import project.isi.octaneo.adapters.GasStationPaymentMethodsAdapter;
- import project.isi.octaneo.controllers.GasStationInfoController;
- import project.isi.octaneo.data.GasStation;
- import project.isi.octaneo.enums.IntentKey;
- @@ -33,6 +34,7 @@
- private CheckBox isForElectricCars;
- private RecyclerView gasStationFuels;
- private RecyclerView gasStationComments;
- + private RecyclerView gasStationPaymentMethods;
- private EditText commentBody;
- private RatingBar commentRate;
- @@ -50,6 +52,7 @@
- controller = new GasStationInfoController(this, new AsyncConnectionTaskFactory());
- controller.loadGasStationFuels(gasStation.id);
- controller.loadGasStationComments(gasStation.id);
- + controller.loadGasStationPaymentMethods(gasStation.id);
- }
- public void handleSubmitCommentClick(View view){
- @@ -68,6 +71,10 @@
- gasStationComments.setAdapter(adapter);
- }
- + public void setGasStationPaymentMethodsAdapter(GasStationPaymentMethodsAdapter adapter) {
- + gasStationComments.setAdapter(adapter);
- + }
- +
- private void initializeGui() {
- gasStationName = findViewById(R.id.gasStationName);
- gasStationAddress = findViewById(R.id.gasStationAddress);
- @@ -89,6 +96,10 @@
- gasStationComments = findViewById(R.id.gasStationOpinions);
- gasStationComments.setHasFixedSize(true);
- gasStationComments.setLayoutManager(new LinearLayoutManager(this));
- +
- + gasStationPaymentMethods = findViewById(R.id.gasStationPaymentMethods);
- + gasStationPaymentMethods.setHasFixedSize(true);
- + gasStationPaymentMethods.setLayoutManager(new LinearLayoutManager(this));
- }
- @SuppressLint("SetTextI18n")
- Index: app/src/main/java/project/isi/octaneo/adapters/GasStationPaymentMethodsAdapter.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/java/project/isi/octaneo/adapters/GasStationPaymentMethodsAdapter.java (date 1527341448673)
- +++ app/src/main/java/project/isi/octaneo/adapters/GasStationPaymentMethodsAdapter.java (date 1527341448673)
- @@ -0,0 +1,55 @@
- +package project.isi.octaneo.adapters;
- +
- +import android.content.Context;
- +import android.support.annotation.NonNull;
- +import android.support.v7.widget.RecyclerView;
- +import android.view.LayoutInflater;
- +import android.view.View;
- +import android.view.ViewGroup;
- +import android.widget.TextView;
- +
- +import java.util.List;
- +
- +import project.isi.octaneo.R;
- +
- +public class GasStationPaymentMethodsAdapter extends RecyclerView.Adapter<GasStationPaymentMethodsAdapter.ViewHolder> {
- + private Context context;
- + private List<String> paymentMethods;
- +
- + public GasStationPaymentMethodsAdapter(@NonNull Context context, List<String> paymentMethods) {
- + this.context = context;
- + this.paymentMethods = paymentMethods;
- + }
- +
- + @NonNull
- + @Override
- + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fuel_item, parent, false);
- + return new ViewHolder(view);
- + }
- +
- + @Override
- + public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
- + String paymentType = this.paymentMethods.get(position);
- + holder.paymentType.setText(paymentType);
- + }
- +
- + @Override
- + public int getItemCount() {
- + return paymentMethods.size();
- + }
- +
- + public void addPaymentMethods(List<String> paymentMethods) {
- + this.paymentMethods.addAll(paymentMethods);
- + notifyDataSetChanged();
- + }
- +
- + public class ViewHolder extends RecyclerView.ViewHolder {
- + private TextView paymentType;
- +
- + ViewHolder(View itemView) {
- + super(itemView);
- + paymentType = itemView.findViewById(R.id.paymentType);
- + }
- + }
- +}
- Index: app/src/main/java/project/isi/octaneo/controllers/GasStationInfoController.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/java/project/isi/octaneo/controllers/GasStationInfoController.java (revision 4d392dad7980837ac6a511ec539006ebc074fa03)
- +++ app/src/main/java/project/isi/octaneo/controllers/GasStationInfoController.java (date 1527341495188)
- @@ -14,6 +14,7 @@
- import project.isi.octaneo.activities.GasStationInfoActivity;
- import project.isi.octaneo.adapters.GasStationCommentsAdapter;
- import project.isi.octaneo.adapters.GasStationFuelsAdapter;
- +import project.isi.octaneo.adapters.GasStationPaymentMethodsAdapter;
- import project.isi.octaneo.data.Comment;
- import project.isi.octaneo.data.Fuel;
- import project.isi.octaneo.data.Response;
- @@ -32,8 +33,10 @@
- private List<Fuel> fuels;
- private List<Comment> comments;
- + private List<String> paymentMethods;
- private GasStationFuelsAdapter fuelsAdapter;
- private GasStationCommentsAdapter commentsAdapter;
- + private GasStationPaymentMethodsAdapter paymentAdapter;
- public GasStationInfoController(GasStationInfoActivity activity, AsyncConnectionTaskFactory taskFactory) {
- this.activity = activity;
- @@ -46,6 +49,10 @@
- this.comments = new ArrayList<>();
- this.commentsAdapter = new GasStationCommentsAdapter(activity, comments);
- this.activity.setGasStationCommentsAdapter(commentsAdapter);
- +
- + this.paymentMethods = new ArrayList<>();
- + this.paymentAdapter = new GasStationPaymentMethodsAdapter(activity, paymentMethods);
- + this.activity.setGasStationPaymentMethodsAdapter(paymentAdapter);
- }
- @Override
- @@ -63,6 +70,9 @@
- case SUBMIT_COMMENT:
- handleCommentSubmitResponse(response.responseContent);
- break;
- + case RETRIEVE_PAYMENT_METHODS:
- + handleReceivedGasStationPaymentMethods(response.responseContent);
- + break;
- }
- }
- @@ -90,6 +100,13 @@
- .execute(requestBuilder.build());
- }
- + public void loadGasStationPaymentMethods(long gasStationId) {
- + RequestBuilder requestBuilder = new RequestBuilder(activity.getString(R.string.retrievePaymentMethods));
- + requestBuilder.putParameter("stationId", String.valueOf(gasStationId));
- + connectionTaskFactory.create(this, AsyncConnectionTask.RequestType.RETRIEVE_PAYMENT_METHODS)
- + .execute(requestBuilder.build());
- + }
- +
- public void processSaveFuelPriceRequest(String fuelId, String price) {
- RequestBuilder requestBuilder = new RequestBuilder(activity.getString(R.string.fuelPriceUrl));
- requestBuilder.putParameter("fuelId", fuelId);
- @@ -149,6 +166,18 @@
- e.printStackTrace();
- }
- }
- +
- + private void handleReceivedGasStationPaymentMethods(String responseContent) {
- + try {
- + JSONObject responseJson = new JSONObject(responseContent);
- + int status = responseJson.getInt(ResponseStatus.Key.STATUS);
- + if (status == ResponseStatus.General.SUCCESS) {
- + handleSuccessfulRetrieveGasStationsPaymentMethod(responseJson.getString(ResponseStatus.Key.CONTENT));
- + }
- + } catch (JSONException e) {
- + e.printStackTrace();
- + }
- + }
- private void handleSuccessfulRetrieveGasStationsFuels(String responseContent) {
- Type listType = new TypeToken<List<Fuel>>() {
- @@ -156,6 +185,7 @@
- List<Fuel> fuels = new Gson().fromJson(responseContent, listType);
- fuelsAdapter.addFuels(fuels);
- }
- +
- private void handleSuccessfulRetrieveGasStationsComments(String responseContent) {
- Type listType = new TypeToken<List<Comment>>() {
- }.getType();
- @@ -163,6 +193,13 @@
- commentsAdapter.addComments(comments);
- }
- + private void handleSuccessfulRetrieveGasStationsPaymentMethod(String responseContent) {
- + Type listType = new TypeToken<List<String>>() {
- + }.getType();
- + List<String> paymentMethods = new Gson().fromJson(responseContent, listType);
- + paymentAdapter.addPaymentMethods(paymentMethods);
- + }
- +
- private void handleReceivedFuelPriceConfirm(String responseContent) {
- try {
- JSONObject jsonResponse = new JSONObject(responseContent);
- Index: app/src/main/java/project/isi/octaneo/source/AsyncConnectionTask.java
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/java/project/isi/octaneo/source/AsyncConnectionTask.java (revision 4d392dad7980837ac6a511ec539006ebc074fa03)
- +++ app/src/main/java/project/isi/octaneo/source/AsyncConnectionTask.java (date 1527341031671)
- @@ -105,5 +105,6 @@
- SAVE_FUEL_PRICE,
- SUBMIT_COMMENT,
- UPDATE_STATION_DESC,
- + RETRIEVE_PAYMENT_METHODS
- }
- }
- \ No newline at end of file
- Index: app/src/main/res/layout/activity_info_gas_station.xml
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/res/layout/activity_info_gas_station.xml (revision 4d392dad7980837ac6a511ec539006ebc074fa03)
- +++ app/src/main/res/layout/activity_info_gas_station.xml (date 1527415097117)
- @@ -1,6 +1,5 @@
- <?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:orientation="vertical"
- @@ -78,6 +77,17 @@
- android:id="@+id/gasStationFuels"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- +
- + <View
- + android:layout_width="match_parent"
- + android:layout_height="1dp"
- + android:layout_margin="@dimen/space5"
- + android:background="@color/colorDivider" />
- +
- + <android.support.v7.widget.RecyclerView
- + android:id="@+id/gasStationPaymentMethods"
- + android:layout_width="match_parent"
- + android:layout_height="match_parent" />
- <View
- android:layout_width="match_parent"
- Index: app/src/main/res/layout/payment_item.xml
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/res/layout/payment_item.xml (date 1527340614575)
- +++ app/src/main/res/layout/payment_item.xml (date 1527340614575)
- @@ -0,0 +1,14 @@
- +<?xml version="1.0" encoding="utf-8"?>
- +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:orientation="horizontal">
- +
- + <TextView
- + android:id="@+id/paymentType"
- + android:layout_width="wrap_content"
- + android:layout_height="wrap_content"
- + android:layout_marginEnd="@dimen/space10"
- + android:textSize="@dimen/h1" />
- +
- +</LinearLayout>
- \ No newline at end of file
- Index: app/src/main/res/values/strings.xml
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- app/src/main/res/values/strings.xml (revision 4d392dad7980837ac6a511ec539006ebc074fa03)
- +++ app/src/main/res/values/strings.xml (date 1527341081649)
- @@ -100,6 +100,7 @@
- <string name="fuelPriceUrl">http://&serverIP;:8000/addFuelPrice</string>
- <string name="addCommentUrl">http://&serverIP;:8000/addComment</string>
- <string name="stationDescriptionChangeUrl">http://&serverIP;:8000/updateDescription</string>
- + <string name="retrievePaymentMethods">http://&serverIP;:8000/getPaymentMethods</string>
- <!--Tags-->
- <string name="mapFragmentTag">MAP_FRAGMENT</string>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement