diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java index 8c0b5ba..db50b0d 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -185,13 +185,15 @@ public abstract class BaseActivity int itemId = item.getItemId(); if (itemId == R.id.nav_map) { removeFragment(sharingFragment); + // startActivity(new Intent(this, MapActivity.class)); } else if (itemId == R.id.nav_profile) { // startActivity(new Intent(this, ProfileActivity.class)); setFragment(sharingFragment); } else if (itemId == R.id.nav_notif) { - startActivity(new Intent(this, NotificationsActivity.class)); + //startActivity(new Intent(this, NotificationsActivity.class)); + setFragment(sharingFragment); } //finish(); }, 300); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index 6926c8c..6aff006 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -67,10 +67,7 @@ public class MainActivity extends AppCompatActivity implements private BottomNavigationView mMainNav; private FrameLayout mMainFrame; private boolean isTutor; - private MapFragment mapFragment; private SharingFragment sharingFragment; - private NotificationFragment notificationFragment; - private ProfileFragment profileFragment;; private static final int REQUEST_PERMISSIONS = 100; boolean boolean_permission; @@ -121,7 +118,6 @@ public class MainActivity extends AppCompatActivity implements mapView.getMapAsync(this); configureconfigureNavigationDrawer(); - configureBottomNavigationView(); configureLogoutButton(); } @@ -172,43 +168,7 @@ public class MainActivity extends AppCompatActivity implements fragmentTransaction.commit(); } - private void configureBottomNavigationView(){ - mMainFrame = findViewById(R.id.main_frame); - mMainNav = findViewById(R.id.main_nav); - isTutor = PrefUtils.getIsTutor(getApplicationContext()); - - if (!isTutor) { - mMainNav.findViewById(R.id.nav_profile).setVisibility(View.GONE); - } - - mapFragment = new MapFragment(); - sharingFragment = new SharingFragment(); - notificationFragment = new NotificationFragment(); - profileFragment = new ProfileFragment(); - - // Default frag here -// setFragment(mapFragment); - mMainNav.setSelectedItemId(R.id.nav_map); - - /* code below is resposible for changing colours of tabs in main tab menu */ - mMainNav.setOnNavigationItemSelectedListener(item -> { - - switch (item.getItemId()) { - case R.id.nav_map: -// setFragment(mapFragment); - return true; - case R.id.nav_notif: - setFragment(notificationFragment); - return true; - case R.id.nav_profile: - setFragment(sharingFragment); - return true; - default: - return false; - } - }); - } private void configureLogoutButton(){ // Logout button diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java deleted file mode 100644 index d8c1e36..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.uam.wmi.findmytutor.activity; - - -import android.os.Bundle; -import android.app.Fragment; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.uam.wmi.findmytutor.R; -import com.uam.wmi.findmytutor.network.ApiClient; -import com.uam.wmi.findmytutor.service.CoordinateService; - -import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; - -/** - * A simple {@link Fragment} subclass. - */ -public class MapFragment extends Fragment { - private MapView mapView; - - - public MapFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_map, container, false); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - mapView = (MapView) view.findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - CoordinateService service = ApiClient.getClient(getApplicationContext()) - .create(CoordinateService.class); - } - - @Override - public void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - public void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - mapView.onDestroy(); - } - -// @Override -// public void onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - - -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java deleted file mode 100644 index 431777b..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.uam.wmi.findmytutor.activity; - - -import android.os.Bundle; -import android.app.Fragment; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.uam.wmi.findmytutor.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class NotificationFragment extends Fragment { - - - public NotificationFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_notification, container, false); - } - -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java index 30045ae..ceaca51 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java @@ -32,144 +32,49 @@ import io.reactivex.schedulers.Schedulers; public class NotificationsActivity extends BaseActivity { - private MapView mapView; - private CoordinateService coordinateService; - private CompositeDisposable disposable = new CompositeDisposable(); - private List coordinatesList = new ArrayList<>(); - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mapInit(savedInstanceState); - -// coordinateService = ApiClient.getClient(getApplicationContext()) -// .create(CoordinateService.class); - final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); - final String authToken = sharedPref.getString("authToken",null); - - coordinateService = RetrofitClientInstance.createService(CoordinateService.class,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiI2YjhmNzFiMS00NDM2LTQxZGQtYjg3MC1mNzZlNjdkNDM4NDMiLCJzdWIiOiJzdHJpbmciLCJqdGkiOiJiZGRjZTAwMC0xN2U4LTQwNDUtYWZiNS1kY2RkOWNhNDFiNmQiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJUdXRvciIsImV4cCI6MTU0MTcxNzk2MywiaXNzIjoiaHR0cDovL2ZpbmRteXR1dG9yLmNvbSIsImF1ZCI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20ifQ.JJVNeMAwwla6DJk6X8qZUgPFKJp-Epx55W9V_fIwpgg"); - - fetchTopCoords(); - } - - private void mapInit(Bundle savedInstanceState) { - // Mapbox access token is configured here. This needs to be called either in your application - // object or in the same activity which contains the mapview. - Mapbox.getInstance(this, getString(R.string.access_token)); - // This contains the MapView in XML and needs to be called after the access token is configured. - // setContentView(R.layout.activity_notifications); - - mapView = (MapView) findViewById(R.id.mapView2); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(MapboxMap mapboxMap) { - - final Marker marker = mapboxMap.addMarker(new MarkerViewOptions() - .position(new LatLng(64.900932, -18.167040))); - - mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { - @Override - public void onMapClick(@NonNull LatLng point) { - - // When the user clicks on the map, we want to animate the marker to that - // location. - ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position", - new LatLngEvaluator(), marker.getPosition(), point); - markerAnimator.setDuration(2000); - markerAnimator.start(); - } - }); - - } - }); - - } - - private void fetchTopCoords() { - disposable.add( - coordinateService.getTopCoordinates() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeWith(new DisposableSingleObserver>() { - @Override - public void onSuccess(List coordsList) { - - Log.d("mapTag", "co?"); - for (Coordinate element: - coordsList) { - Log.d("mapTag", element.getUserId()); - } - } - - @Override - public void onError(Throwable e) { - Log.e("Error",e.toString()); - } - }) - ); - } @Override protected void onStart() { super.onStart(); - mapView.onStart(); } @Override public void onResume() { super.onResume(); - mapView.onResume(); } @Override public void onPause() { super.onPause(); - mapView.onPause(); } @Override protected void onStop() { super.onStop(); - mapView.onStop(); } @Override public void onLowMemory() { super.onLowMemory(); - mapView.onLowMemory(); } @Override protected void onDestroy() { super.onDestroy(); - mapView.onDestroy(); - disposable.dispose(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); } - private static class LatLngEvaluator implements TypeEvaluator { - // Method is used to interpolate the marker animation. - private LatLng latLng = new LatLng(); - - @Override - public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) { - latLng.setLatitude(startValue.getLatitude() - + ((endValue.getLatitude() - startValue.getLatitude()) * fraction)); - latLng.setLongitude(startValue.getLongitude() - + ((endValue.getLongitude() - startValue.getLongitude()) * fraction)); - return latLng; - } - } @Override protected int getContentViewId() { return R.layout.activity_notifications; } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java deleted file mode 100644 index d994bfd..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.uam.wmi.findmytutor.activity; - - -import android.os.Bundle; -import android.app.Fragment; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.uam.wmi.findmytutor.R; - -/** - * A simple {@link Fragment} subclass. - */ -public class ProfileFragment extends Fragment { - - - public ProfileFragment() { - // Required empty public constructor - } - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_profile, container, false); - } - -} diff --git a/app/src/main/res/layout/activity_notifications.xml b/app/src/main/res/layout/activity_notifications.xml index be82ea7..e07b34b 100644 --- a/app/src/main/res/layout/activity_notifications.xml +++ b/app/src/main/res/layout/activity_notifications.xml @@ -9,24 +9,4 @@ tools:context=".activity.NotificationsActivity"> - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile.xml b/app/src/main/res/layout/fragment_profile.xml deleted file mode 100644 index f98dfe6..0000000 --- a/app/src/main/res/layout/fragment_profile.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file