Commit 3ed223b8 authored by Anupama Balasooriya's avatar Anupama Balasooriya

Edit the code of display price Activity

parent 3576bd59
......@@ -15,7 +15,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SmartServiceAssistant">
<activity android:name=".insurance.insurance_view"></activity>
<activity android:name=".spareparts.StoresListActivity"></activity>
<activity android:name=".insurance.insurance_view" />
<activity android:name=".spareparts.SuggestYoutubeVideos" />
<!--
The API key for Google Maps-based APIs is defined as a string resource.
......@@ -29,9 +30,6 @@
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".spareparts.NearBySparePartsShopsGoogleMapsActivity"
android:label="@string/title_activity_near_by_spare_parts_shops_google_maps" />
<activity android:name=".spareparts.DisplayPriceActivity" />
<activity android:name=".spareparts.SparePartsMainActivity" />
<activity android:name=".repairmethods.RepairMethodsMainActivity" />
......
......@@ -3,9 +3,11 @@ package com.sliit.smartserviceassistant.spareparts;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.sliit.smartserviceassistant.R;
......@@ -14,6 +16,13 @@ public class DisplayPriceActivity extends AppCompatActivity {
private Button btn_map;
private Button btn_videos;
private String model;
private String type;
private String part;
private String year;
private TextView topic;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -24,20 +33,35 @@ public class DisplayPriceActivity extends AppCompatActivity {
btn_map.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DisplayPriceActivity.this, NearBySparePartsShopsGoogleMapsActivity.class);
Intent intent = new Intent(DisplayPriceActivity.this, StoresListActivity.class);
startActivity(intent);
}
});
// Get vehicle details from the main activity interface
model = getIntent().getStringExtra("key_model");
type = getIntent().getStringExtra("key_type");
part = getIntent().getStringExtra("key_part");
year = getIntent().getStringExtra("key_year");
// Youtube videos button
btn_videos = findViewById(R.id.btn_launch_videos);
btn_videos.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DisplayPriceActivity.this, SuggestYoutubeVideos.class);
startActivity(intent);
getUrl("https://www.youtube.com/results?search_query=" +
model + "+" + type + "+" + part + "+replacement");
}
});
topic = findViewById(R.id.txt_spare_part_name);
topic.setText(model + " " + type + " " + part + " for the year of " + year);
}
private void getUrl(String s) {
Uri uri = Uri.parse(s);
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
}
\ No newline at end of file
package com.sliit.smartserviceassistant.spareparts;
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.sliit.smartserviceassistant.R;
import java.util.ArrayList;
public class NearBySparePartsShopsGoogleMapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
ArrayList<LatLng> latLngs = new ArrayList<LatLng>();
LatLng dakshinaMotors = new LatLng(6.185639, 80.105074);
LatLng chahurangaMotors = new LatLng(6.186211, 80.104618);
LatLng dileepaHardware = new LatLng(6.1897859942116735, 80.0984899699444);
LatLng sushanMotors = new LatLng(6.148218882191242, 80.13912346921445);
LatLng suyumiLanka = new LatLng(6.255964395543169, 80.06585197979837);
LatLng dnEnterprice = new LatLng(6.249309427114979, 80.06619530255035);
LatLng mallikaMotors = new LatLng(6.2726867628748835, 80.03718453000494);
LatLng mmwMotors = new LatLng(6.1455469752984, 80.10035586213846);
LatLng thilakMotors = new LatLng(6.149643156228272, 80.15271258181758);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_near_by_spare_parts_shops_google_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
latLngs.add(dakshinaMotors);
latLngs.add(chahurangaMotors);
latLngs.add(dileepaHardware);
latLngs.add(sushanMotors);
latLngs.add(suyumiLanka);
latLngs.add(dnEnterprice);
latLngs.add(mallikaMotors);
latLngs.add(mmwMotors);
latLngs.add(thilakMotors);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
Toast toast = Toast.makeText(getApplicationContext(),
"Launching GoogleMaps",
Toast.LENGTH_SHORT);
toast.show();
// Add a marker into locations and move the camera
for (int i = 0; i < latLngs.size(); i++) {
mMap.addMarker(new MarkerOptions().position(latLngs.get(i)));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLngs.get(i), 11.0f));
}
}
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ public class SparePartsMainActivity extends AppCompatActivity {
private Spinner spin_vehicle_model;
private Spinner spin_vehicle_type;
private Spinner spin_part_type;
private Spinner spin_year;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -60,12 +61,32 @@ public class SparePartsMainActivity extends AppCompatActivity {
adapter_part_type.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s3.setAdapter(adapter_part_type);
// Select year spinner
spin_year = findViewById(R.id.spin_year);
String[] arraySpinner_year = new String[] {
"2021", "2022", "2023", "2024", "2025"
};
Spinner s4 = (Spinner) findViewById(R.id.spin_year);
ArrayAdapter<String> adapter_year = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, arraySpinner_year);
adapter_part_type.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s4.setAdapter(adapter_year);
// Search button
btn_search = findViewById(R.id.btn_search);
btn_search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String model = String.valueOf(spin_vehicle_model.getSelectedItem());
String type = String.valueOf(spin_vehicle_type.getSelectedItem());
String part = String.valueOf(spin_part_type.getSelectedItem());
String year = String.valueOf(spin_year.getSelectedItem());
Intent intent = new Intent(SparePartsMainActivity.this, DisplayPriceActivity.class);
intent.putExtra("key_model", model);
intent.putExtra("key_type", type);
intent.putExtra("key_part", part);
intent.putExtra("key_year", year);
startActivity(intent);
}
});
......
package com.sliit.smartserviceassistant.spareparts;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.sliit.smartserviceassistant.R;
public class StoresListActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stores_list);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".spareparts.NearBySparePartsShopsGoogleMapsActivity" />
\ No newline at end of file
......@@ -90,13 +90,34 @@
android:layout_height="30dp">
</Spinner>
<!-- Select the year -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt_year"
android:text="For the year of:"
android:textSize="20dp"
android:layout_marginTop="40dp"
android:layout_below="@+id/spin_spare_part">
</TextView>
<Spinner
android:id="@+id/spin_year"
android:layout_marginTop="20dp"
android:layout_below="@id/txt_year"
android:layout_alignParentRight="true"
android:layout_width="match_parent"
android:layout_height="40dp">
</Spinner>
<!-- Search button -->
<Button
android:id="@+id/btn_search"
android:text="SEARCH"
android:textSize="20dp"
android:layout_marginTop="50dp"
android:layout_below="@id/spin_spare_part"
android:layout_marginTop="60dp"
android:layout_marginBottom="50dp"
android:layout_below="@id/spin_year"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Button>
......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".spareparts.StoresListActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_marginTop="60dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</LinearLayout>
</ScrollView>
\ 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