diff --git a/.gitignore b/.gitignore index 07940e1..aa68de2 100644 --- a/.gitignore +++ b/.gitignore @@ -226,4 +226,5 @@ build/ dist/ node_modules/ aws-exports.js -awsconfiguration.json \ No newline at end of file +awsconfiguration.json +.idea/caches/ diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser deleted file mode 100644 index c6505fe..0000000 Binary files a/.idea/caches/build_file_checksums.ser and /dev/null differ diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser deleted file mode 100644 index 0fc4ad4..0000000 Binary files a/.idea/caches/gradle_models.ser and /dev/null differ diff --git a/README.md b/README.md index bfacb31..1ac76cc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## APK To download and play Zombie Tag click the zombie below -[![Build Status](https://github.com/JavaAwesome/JavaTag/blob/Dev/app/src/main/res/mipmap-hdpi/ic_launcher_round.png)](https://github.com/JavaAwesome/JavaTag/blob/Dev/zombietag.apk) +[![Download App](https://github.com/JavaAwesome/JavaTag/blob/Dev/app/src/main/res/mipmap-hdpi/ic_launcher_round.png)](https://github.com/JavaAwesome/JavaTag/blob/Dev/zombietag.apk) ## Team Members * Ahren Swett @@ -23,6 +23,8 @@ To make an android app where players can see one another on a map and tag one an ## Instructions to run the app on your phone + + ### Contribute No contribution guidelines at this point. diff --git a/app/src/main/java/com/javaawesome/tag/MainActivity.java b/app/src/main/java/com/javaawesome/tag/MainActivity.java index 00acfc5..cdd74a4 100644 --- a/app/src/main/java/com/javaawesome/tag/MainActivity.java +++ b/app/src/main/java/com/javaawesome/tag/MainActivity.java @@ -53,7 +53,8 @@ import static android.Manifest.permission.ACCESS_FINE_LOCATION; public class MainActivity extends AppCompatActivity implements SessionAdapter.OnSessionInteractionListener { - protected static String photoBucketPath = "https://javatag091c7e33ab0441e4bdf34cbdf68d2bd1-local.s3-us-west-2.amazonaws.com/"; + // final is a good idea for a variable like this that you don't ever want to accidentally change + protected static final String photoBucketPath = "https://javatag091c7e33ab0441e4bdf34cbdf68d2bd1-local.s3-us-west-2.amazonaws.com/"; private final String TAG = "javatag"; RecyclerView recyclerNearbySessions; SessionAdapter sessionAdapter; @@ -107,7 +108,7 @@ public void onError(Exception e) { sessions = new LinkedList<>(); // initialize recycler view to display nearby game sessions - // TODO: have recycler view filter sessions by distance to user + // I think this was completed with the call to filter--so this is an out of date comment. recyclerNearbySessions = findViewById(R.id.recycler_nearby_sessions); recyclerNearbySessions.setLayoutManager(new LinearLayoutManager(this)); this.sessionAdapter = new SessionAdapter(this.sessions, this); @@ -119,7 +120,6 @@ protected void onResume() { super.onResume(); Log.i(TAG, "onresume called"); if (checkGpsStatus()) { -// getCurrentUserLocation(); checkIfPlayerAlreadyExistInDatabase(); } else { buildAlertMessageNoGps(); @@ -127,10 +127,13 @@ protected void onResume() { } // Create new game session and go to map page - public void goToMap(View view) { + // Called when the new session button is tapped, so it should probably have a clearer name! + public void createAndGoToNewSession(View view) { // TODO: check if player already exist in the database + // didn't we check if the player existed in onResume? Why do we need to call it again now? + // Or is this just a leftover todo? EditText sessionName = findViewById(R.id.editText_session_name); - Log.i(TAG, "goToMap: "+sessionName.getText()); + Log.i(TAG, "createAndGoToNewSession: "+sessionName.getText()); if(sessionName.getText().length()>0) { CreateSessionInput input = CreateSessionInput.builder() .title(sessionName.getText().toString()) @@ -143,10 +146,7 @@ public void goToMap(View view) { @Override public void onResponse(@Nonnull Response response) { sessionId = response.data().createSession().id(); - Intent goToMapIntent = new Intent(MainActivity.this, MapsActivity.class); - goToMapIntent.putExtra("sessionId", sessionId); - goToMapIntent.putExtra("userID", playerId); - MainActivity.this.startActivity(goToMapIntent); + joinExistingGameSession(sessionId); } @Override @@ -164,14 +164,7 @@ public void goToUserPage(View view){ Intent goToUserPage = new Intent(this, UserProfile.class); this.startActivity(goToUserPage.putExtra("playerId",playerId)); } - - //////// TEST BUTTON ///// - public void onTestyClick(View view) { - startActivity(new Intent(MainActivity.this, NotificationActivity.class)); - } - - - + // dead code 💀 // Direct users to sign in page private void signInUser() { @@ -198,42 +191,15 @@ public void signoutCurrentUser(View view) { } // onclick method for button to join existing game sessions + // If you make this a bit more generic, it'll work for new sessions and existing ones! @Override - public void joinExistingGameSession(ListSessionsQuery.Item session) { + public void joinExistingGameSession(String sessionId) { Intent goToMapIntent = new Intent(this, MapsActivity.class); - goToMapIntent.putExtra("sessionId", session.id()); + goToMapIntent.putExtra("sessionId", sessionId); goToMapIntent.putExtra("userID", playerId); this.startActivity(goToMapIntent); } -// @Override -// public void addPlayerToChosenGame(final ListSessionsQuery.Item session) { -//// Query -// CreatePlayerInput playerInput = CreatePlayerInput.builder() -// .playerSessionId(session.id()) -// .isIt(false) -// .lat(currentUserLocation.latitude) -// .lon(currentUserLocation.longitude) -// .username(AWSMobileClient.getInstance().getUsername()) -// .build(); -// CreatePlayerMutation createPlayerMutation = CreatePlayerMutation.builder().input(playerInput).build(); -// awsAppSyncClient.mutate(createPlayerMutation).enqueue((new GraphQLCall.Callback() { -// @Override -// public void onResponse(@Nonnull Response response) { -// String userID = response.data().createPlayer().id(); -// Log.i(TAG, "player mutation happened! ... inside of a session mutation"); -// Intent goToMapIntent = new Intent(MainActivity.this, MapsActivity.class); -// goToMapIntent.putExtra("sessionId", session.id()); -// goToMapIntent.putExtra("userID", userID); -// Log.i("veach", session.id() + "\n" +userID); -// } -// @Override -// public void onFailure(@Nonnull ApolloException e) { -// Log.i(TAG, "mutation of player failed, boohoo!"); -// } -// })); -// } - // get all sessions private void queryAllSessions() { Log.i(TAG, "query all sessions"); diff --git a/app/src/main/java/com/javaawesome/tag/MapsActivity.java b/app/src/main/java/com/javaawesome/tag/MapsActivity.java index a34c40e..826a212 100644 --- a/app/src/main/java/com/javaawesome/tag/MapsActivity.java +++ b/app/src/main/java/com/javaawesome/tag/MapsActivity.java @@ -68,9 +68,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback GetSessionQuery.GetSession currentSession; LatLng startingPoint; - final static long REFRESHRATE = 3*1000; - final static int SUBJECT = 0; - Handler locationHandler; + // Lots of leftover, unused variables around in this code; I wish they'd been removed. LocationCallback mLocationCallback; private FusedLocationProviderClient mFusedLocationClient; final private int tagDistance = 50; @@ -81,6 +79,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback BitmapDescriptor playerpin; List players; private final String TAG = "javatag"; + // The inconsistency of playerID vs sessionId (in capitalization) is annoying. String playerID; Player player; String sessionId; @@ -113,15 +112,17 @@ protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Session ID for map is: " + sessionId + "the player Id is " + playerID); associateUserWithSession(); - - // Pull user ID from MainActivity - // If player comes from the recyclerView it will come through as null so we will create a new player - // Else the player created the game and we will query the player object -// if (playerID == null) { -// createPlayer(); -// } else { -// queryForPlayerObject(); -// } + // so what this actually starts is: + // associateUserWithSession + // makes request to dynamo + // then calls queryForSelectedSession + // which simultaneously calls initializeMarkers and queryForPlayerObject + // queryForPlayerObject gets the current player's data, and sets it to be part of the players list + // initializeMarkers does the same exact work, and the current player should already be in that players list! + // this is why I was getting "two" players in my single player game! + // I think this is rendering the current player twice!!! + // But regardless, this is QUITE complicated and all kicked off by calling associateUserWithSession here; that feels + // like a lot of work for a method with such a short name! "renderGame" might be more accurate than "associateUserWithSession"! //Stuff doesn't start running until the map is ready in onMapReady(Map stuff) mLocationCallback = new LocationCallback() { @@ -133,7 +134,9 @@ public void onLocationResult(LocationResult locationResult) { return; } - updateMarkerAndCircleForAllPlayers(players); + // I think it's odd that we call this here, instead of when updates come in from + // our subscription to Dynamo. + updateMarkerAndCircleForAllPlayers(); sendUserLocationQuery(locationResult); } @@ -388,7 +391,8 @@ private LocationRequest getLocationRequest() { } // Creates markers and circles for each player in the list for that session - private void initializeMarkersAndCirclesForPlayers(List players) { + // Since this only ever operates on the instance variable, it doesn't need a param. + private void initializeMarkersAndCirclesForPlayers() { Log.i(TAG, "made it to initialized markers"); for(Player player: players) { Marker marker = mMap.addMarker(new MarkerOptions() @@ -424,8 +428,8 @@ private void initializeMarkersAndCirclesForPlayers(List players) { .strokeWidth(5)); } - - private void updateMarkerAndCircleForAllPlayers(List players) { + // Since this only ever operates on the instance variable, it doesn't need a parameter. + private void updateMarkerAndCircleForAllPlayers() { Log.i(TAG, "updating markers"); Log.i(TAG, "How many players? " + players.size()); @@ -451,15 +455,9 @@ private void updateMarkerAndCircleForAllPlayers(List players) { Log.i(TAG, "In the updateMarkerAndCircleForAllPlayers"); playersJustGotTagged.add(player); -// player.getMarker().setIcon(zombiepin); -// player.getCircle().setStrokeColor(itColor); - -// mMap.addCircle(player.getCircle()); + // This thing with a bunch of commented out lines with the occasional close curly + // brace in the middle is quite annoying! I'd prefer to just remove these lines. } -// else { -// player.getMarker().setIcon(playerpin); -// player.getCircle().setStrokeColor(notItColor); -// } } //TODO add the player instance is it update, only updates the player list so far for(Player player : players){ @@ -545,39 +543,6 @@ private void queryForSelectedSession(String sessionId) { .enqueue(getSessionCallBack); } - // Make a Player - private void createPlayer() { - Log.i(TAG, "Making a player with " + sessionId + " " + startingPoint.toString()); - CreatePlayerInput input = CreatePlayerInput.builder() - .playerSessionId(sessionId) - .lat(startingPoint.latitude) - .lon(startingPoint.longitude) - .username(AWSMobileClient.getInstance().getUsername()) - .isIt(false) - .build(); - CreatePlayerMutation createPlayerMutation = CreatePlayerMutation.builder().input(input).build(); - - awsAppSyncClient.mutate(createPlayerMutation).enqueue(new GraphQLCall.Callback() { - @Override - public void onResponse(@Nonnull Response response) { - Log.i(TAG, "made it to creating a new player"); - playerID = response.data().createPlayer().id(); - player = new Player(); - player.setId(playerID); - player.setIt(false); - player.setUsername(AWSMobileClient.getInstance().getUsername()); - List bananas = new LinkedList<>(); - bananas.add(startingPoint); - player.setLocations(bananas); - } - - @Override - public void onFailure(@Nonnull ApolloException e) { - Log.e(TAG, "couldn't make a new player"); - } - }); - } - // Query for Player private void queryForPlayerObject() { GetPlayerQuery query = GetPlayerQuery.builder().id(playerID).build(); @@ -642,13 +607,8 @@ public void onResponse(@Nonnull final Response response) { //once the session ID and starting loc are in place, then make the first player. queryForPlayerObject(); -// if (playerID == null) { -// createPlayer(); -// } else { -// queryForPlayerObject(); -// } - Log.i(TAG, "Made it to the after the if/else within getSessionCallBack"); + // there is no if/else here... this is defintitely an out of date comment //converting from GetSessionItems to players players = playerConverter(currentSession.players().items()); @@ -663,7 +623,7 @@ public void handleMessage(Message inputMessage){ } catch (InterruptedException e) { e.printStackTrace(); } - initializeMarkersAndCirclesForPlayers(players); + initializeMarkersAndCirclesForPlayers(); } }; @@ -685,10 +645,4 @@ private List playerConverter(List incomingList){ return outGoingList; }; - // TODO: Build onDestroy that deletes user data from DB -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// } - } diff --git a/app/src/main/java/com/javaawesome/tag/SessionAdapter.java b/app/src/main/java/com/javaawesome/tag/SessionAdapter.java index 7a93f5d..df2173f 100644 --- a/app/src/main/java/com/javaawesome/tag/SessionAdapter.java +++ b/app/src/main/java/com/javaawesome/tag/SessionAdapter.java @@ -1,8 +1,6 @@ package com.javaawesome.tag; import android.content.DialogInterface; -import android.content.Intent; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -40,8 +38,7 @@ public void onClick(View view) { .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { -// listener.addPlayerToChosenGame(holder.session); - listener.joinExistingGameSession(holder.session); + listener.joinExistingGameSession(holder.session.id()); //TODO: Save the users ID to the database based on the session that they clicked } }) @@ -55,12 +52,10 @@ public static class SessionViewHolder extends RecyclerView.ViewHolder { ListSessionsQuery.Item session; TextView sessionTitle; -// TextView numberOfPlayers; public SessionViewHolder(@NonNull View itemView) { super(itemView); this.sessionTitle = itemView.findViewById(R.id.session_title); -// this.numberOfPlayers = itemView.findViewById(R.id.session_total_players); } } @@ -69,7 +64,6 @@ public void onBindViewHolder(@NonNull SessionAdapter.SessionViewHolder holder, i ListSessionsQuery.Item sessionAtPosition = this.sessions.get(position); holder.session = sessionAtPosition; holder.sessionTitle.setText(sessionAtPosition.title()); -// holder.numberOfPlayers.setText("Population: " + sessionAtPosition.players()); } @Override @@ -78,7 +72,6 @@ public int getItemCount() { } public static interface OnSessionInteractionListener { - public void joinExistingGameSession(ListSessionsQuery.Item session); -// public void addPlayerToChosenGame(ListSessionsQuery.Item session); + public void joinExistingGameSession(String sessionId); } } diff --git a/app/src/main/java/com/javaawesome/tag/ShowMeYourFace.java b/app/src/main/java/com/javaawesome/tag/ShowMeYourFace.java index 0df2782..6d366a3 100644 --- a/app/src/main/java/com/javaawesome/tag/ShowMeYourFace.java +++ b/app/src/main/java/com/javaawesome/tag/ShowMeYourFace.java @@ -1,20 +1,15 @@ package com.javaawesome.tag; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.camera.core.CameraX; import androidx.camera.core.ImageCapture; import androidx.camera.core.ImageCaptureConfig; -import androidx.camera.core.ImageProxy; import androidx.camera.core.Preview; import androidx.camera.core.PreviewConfig; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.os.Environment; import android.Manifest; import android.content.Intent; @@ -23,16 +18,12 @@ import android.util.Log; import android.util.Size; import android.view.TextureView; -import android.view.View; -import android.widget.ImageView; import android.widget.Toast; -import com.amazonaws.amplify.generated.graphql.GetPlayerQuery; import com.amazonaws.amplify.generated.graphql.UpdatePlayerMutation; import com.amazonaws.mobile.client.AWSMobileClient; import com.amazonaws.mobile.config.AWSConfiguration; import com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient; -import com.amazonaws.mobileconnectors.appsync.fetcher.AppSyncResponseFetchers; import com.amazonaws.mobileconnectors.s3.transferutility.TransferListener; import com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver; import com.amazonaws.mobileconnectors.s3.transferutility.TransferState; @@ -53,25 +44,20 @@ public class ShowMeYourFace extends AppCompatActivity { + // weird to have the tag reference a single person! private static final String TAG = "ahren:javatag"; private static boolean upload = false; private ImageCapture imageCapture; final CameraX.LensFacing camera = CameraX.LensFacing.FRONT; -// set to absolute path eventualy +// set to absolute path eventually String profPicPath = null; // String s3path = null; - String userPhoto; AWSAppSyncClient mAWSAppSyncClient; // created by picSnap File profilePic = null; - - public static boolean isUpload() { - return upload; - } - public static void setUpload(boolean upload) { ShowMeYourFace.upload = upload; } @@ -105,9 +91,13 @@ protected void onCreate(Bundle savedInstanceState) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){ + // This check isn't being used correctly at all! If the user should see an explanation + // of why the permission is necessary, you're instead silently logging and refusing to + // let them either accept or deny the permission. if(ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) { Log.i(TAG, "onCreate: permission not granted"); + // You should cite where this comes from! https://developer.android.com/training/permissions/requesting // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. @@ -121,8 +111,6 @@ protected void onCreate(Bundle savedInstanceState) { //************************************ Setup Buttons ********************************************** FloatingActionButton picSnap = findViewById(R.id.picSnap); -// FloatingActionButton switchCamera = findViewById(R.id.fab_switch_camera);, -// FloatingActionButton fab_flash = findViewById(R.id.fab_flash); // ********************************** Setup Camera ********************************************** bindCamera(); @@ -130,7 +118,7 @@ protected void onCreate(Bundle savedInstanceState) { //*************************************** Shutter Button Action **************************************** picSnap.setOnClickListener(event -> { -// put picture localy in the phone +// put picture locally in the phone s3path = AWSMobileClient.getInstance().getUsername()+ "profilePic.png"; profilePic = new File(Environment.getExternalStorageDirectory() + "/" + s3path); // @@ -142,6 +130,7 @@ protected void onCreate(Bundle savedInstanceState) { public void onError( @NonNull ImageCapture.ImageCaptureError imageCaptureError, @NonNull String message, Throwable cause) { // TODO: insert your code here. + // please, really, do something if there is an error. } @Override @@ -156,61 +145,7 @@ public void onImageSaved(@NonNull File file) { }); }); - - -// @Override -// public void onClick(View view){ -// File file = new File(Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".png"); -// imageCapture.takePicture(file, new ImageCapture.OnImageSavedListener(){ -// @Override -// public void onImageSaved(@NonNull File file) { -// String msg = "Pic captured at " + file.getAbsolutePath(); -// Toast.makeText(getBaseContext(), msg,Toast.LENGTH_LONG).show(); -// } -// -// @Override -// public void onError(@NonNull ImageCapture.ImageCaptureError imageCaptureError, @NonNull String message, @Nullable Throwable cause) { -// } -// }); -// } -// ImageCaptureConfig imageCaptureConfig = new ImageCaptureConfig.Builder().setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY) -// .setTargetRotation(getWindowManager().getDefaultDisplay().getRotation()).build(); -// final ImageCapture imgCap = new ImageCapture(imageCaptureConfig); - - - - - - - - -//***************************** Turn Off / On Flash*********************************************** -// Adapted from Kotlin code at https://gabrieltanner.org/blog/android-camerax -// fab_flash.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// FlashMode flashMode = imageCapture.getFlashMode(); -// if (flashMode == FlashMode.ON) { -// imageCapture.setFlashMode(FlashMode.OFF); -// } else { -// imageCapture.setFlashMode(FlashMode.ON); -// } -// } -// }); - -// ******************* Changes the lens direction if the button is clicked **************************** - -// switchCamera.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// if (CameraX.LensFacing.FRONT == camera) { -// camera = CameraX.LensFacing.BACK; -// } else { -// camera[0] = CameraX.LensFacing.FRONT; -// } -// bindCamera(); -// } -// }); + // PLEASE get rid of the zombie code! } } @@ -222,8 +157,6 @@ private void bindCamera(){ final TextureView textureView = findViewById(R.id.view_finder); Size screen = new Size(textureView.getWidth(), textureView.getHeight()); //size of the screen - - PreviewConfig config = new PreviewConfig.Builder() .setLensFacing(camera) .setTargetResolution(screen) @@ -234,6 +167,9 @@ private void bindCamera(){ preview.setOnPreviewOutputUpdateListener(new Preview.OnPreviewOutputUpdateListener() { @Override public void onUpdated(@NonNull Preview.PreviewOutput previewOutput) { + // All of these "your code here"-style comments make it clear that this code came + // from an outside source, and that you didn't even read the code closely enough + // to notice that these comments were weird. // Your code here. For example, use textureView.setSurfaceTexture(previewOutput.getSurfaceTexture()); } @@ -248,7 +184,7 @@ public void onUpdated(@NonNull Preview.PreviewOutput previewOutput) { imageCapture = new ImageCapture(config2); -// Causes camera u=instance to only exist on this activity is started and destroyed on start and finish +// Causes camera instance to only exist on this activity is started and destroyed on start and finish CameraX.bindToLifecycle(this, imageCapture, preview); } @@ -316,31 +252,5 @@ public void onFailure(@Nonnull ApolloException e) { } }); } -// private void queryForPlayerObject(String playerId) { -// GetPlayerQuery query = GetPlayerQuery.builder().id(playerId).build(); -// mAWSAppSyncClient.query(query) -// .responseFetcher(AppSyncResponseFetchers.NETWORK_ONLY) -// .enqueue(new GraphQLCall.Callback() { -// @Override -// public void onResponse(@Nonnull Response response) { -// Log.i(TAG, "made it to making a query for player object"); -// userPhoto = response.data().getPlayer().Photo(profile pic); -// } -// -// @Override -// public void onFailure(@Nonnull ApolloException e) { -// -// } -// }); -// } } -//// **************** Checks to see if flash is present on the current camera and ********************* -// try { -// CameraInfo cameraInfo = CameraX.getCameraInfo(camera); -// LiveData isFlashAvailable = cameraInfo.isFlashAvailable(); -// fab_flash.setVisibility(isFlashAvailable.getValue() ? View.VISIBLE : View.INVISIBLE); -// } catch (CameraInfoUnavailableException e) { -// Log.w(TAG, "Cannot get flash available information", e); -// fab_flash.setVisibility(View.VISIBLE); -// } diff --git a/app/src/main/java/com/javaawesome/tag/picturePreview.java b/app/src/main/java/com/javaawesome/tag/picturePreview.java index 28a20d0..4b7a456 100644 --- a/app/src/main/java/com/javaawesome/tag/picturePreview.java +++ b/app/src/main/java/com/javaawesome/tag/picturePreview.java @@ -15,6 +15,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton; +// Really odd that this class name doesn't use UpperCamelCase! public class picturePreview extends AppCompatActivity { @Override diff --git a/app/src/main/java/com/javaawesome/tag/recycler_view_sessions.java b/app/src/main/java/com/javaawesome/tag/recycler_view_sessions.java index 7525998..bc0ade3 100644 --- a/app/src/main/java/com/javaawesome/tag/recycler_view_sessions.java +++ b/app/src/main/java/com/javaawesome/tag/recycler_view_sessions.java @@ -10,101 +10,8 @@ import android.view.View; import android.view.ViewGroup; - -/** - * A simple {@link Fragment} subclass. - * Activities that contain this fragment must implement the - * {@link recycler_view_sessions.OnFragmentInteractionListener} interface - * to handle interaction events. - * Use the {@link recycler_view_sessions#newInstance} factory method to - * create an instance of this fragment. - */ +// why is this class named in snake_case, this is not python (hiss) +// also it appears that none of this code is used at all? so why does it exist? public class recycler_view_sessions extends Fragment { - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - private OnFragmentInteractionListener mListener; - - public recycler_view_sessions() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment recycler_view_sessions. - */ - // TODO: Rename and change types and number of parameters - public static recycler_view_sessions newInstance(String param1, String param2) { - recycler_view_sessions fragment = new recycler_view_sessions(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_recycler_view_sessions, container, false); - } - - // TODO: Rename method, update argument and hook method into UI event - public void onButtonPressed(Uri uri) { - if (mListener != null) { - mListener.onFragmentInteraction(uri); - } - } - - @Override - public void onAttach(Context context) { - super.onAttach(context); - if (context instanceof OnFragmentInteractionListener) { - mListener = (OnFragmentInteractionListener) context; - } else { - throw new RuntimeException(context.toString() - + " must implement OnFragmentInteractionListener"); - } - } - - @Override - public void onDetach() { - super.onDetach(); - mListener = null; - } - /** - * This interface must be implemented by activities that contain this - * fragment to allow an interaction in this fragment to be communicated - * to the activity and potentially other fragments contained in that - * activity. - *

- * See the Android Training lesson Communicating with Other Fragments for more information. - */ - public interface OnFragmentInteractionListener { - // TODO: Update argument type and name - void onFragmentInteraction(Uri uri); - } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ab0136e..f23c7f8 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -39,7 +39,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="24dp" - android:onClick="goToMap" + android:onClick="createAndGoToNewSession" android:text="@string/start_new_game_button" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"