diff --git a/app/src/main/java/com/example/testbeacon/Home.java b/app/src/main/java/com/example/testbeacon/Home.java index 0b63969..25edca0 100644 --- a/app/src/main/java/com/example/testbeacon/Home.java +++ b/app/src/main/java/com/example/testbeacon/Home.java @@ -9,19 +9,14 @@ import android.view.View; import android.view.ViewGroup; -/** - * A simple {@link Fragment} subclass. - * Use the {@link Home#newInstance} factory method to - * create an instance of this fragment. - */ +// Home Fragment (PreferenceFragment) which is embedded in MainActivity shows detected beacon +// on fragment swiperefreshlayout is places public class Home 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; @@ -29,15 +24,7 @@ public Home() { // 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 Home. - */ - // TODO: Rename and change types and number of parameters + public static Home newInstance(String param1, String param2) { Home fragment = new Home(); Bundle args = new Bundle(); @@ -63,6 +50,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, return inflater.inflate(R.layout.fragment_home, container, false); } + // this method is called after the fragment is created (user navigates to fragment) @Override public void onViewCreated(View view, Bundle savedInstanceState) { // event listener of swipe refresh layout (home fragment) starts beacon scanning @@ -71,6 +59,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) { @Override public void onRefresh() { ((MainActivity)getActivity()).scanClicked(((MainActivity)getActivity()).findViewById(R.id.fragment_home)); + // when beacon is detected refreshing animation will be stopped //pullToRefresh.setRefreshing(false); } }); diff --git a/app/src/main/java/com/example/testbeacon/MainActivity.java b/app/src/main/java/com/example/testbeacon/MainActivity.java index 763d358..66bdefd 100644 --- a/app/src/main/java/com/example/testbeacon/MainActivity.java +++ b/app/src/main/java/com/example/testbeacon/MainActivity.java @@ -58,7 +58,9 @@ import org.json.JSONException; import org.json.JSONObject; - +// Activity with Bottom Navigation View +// the App consists of this single Activity +// in the View of the Activity Fragments will be embedded public class MainActivity extends AppCompatActivity implements BeaconConsumer, RangeNotifier { protected static final String TAG = "MainActivity"; private static final int PERMISSION_REQUEST_FINE_LOCATION = 1; diff --git a/app/src/main/java/com/example/testbeacon/Settings.java b/app/src/main/java/com/example/testbeacon/Settings.java index cb570d1..a22739c 100644 --- a/app/src/main/java/com/example/testbeacon/Settings.java +++ b/app/src/main/java/com/example/testbeacon/Settings.java @@ -8,19 +8,13 @@ import androidx.preference.PreferenceFragmentCompat; import androidx.preference.SwitchPreference; -/** - * A simple {@link Fragment} subclass. - * Use the {@link Settings#newInstance} factory method to - * create an instance of this fragment. - */ +// Settings Fragment (PreferenceFragment) which is embedded in MainActivity public class Settings extends PreferenceFragmentCompat { - // 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; @@ -28,15 +22,6 @@ public Settings() { // 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 settings. - */ - // TODO: Rename and change types and number of parameters public static Settings newInstance(String param1, String param2) { Settings fragment = new Settings(); Bundle args = new Bundle(); diff --git a/app/src/main/java/com/example/testbeacon/UserProfile.java b/app/src/main/java/com/example/testbeacon/UserProfile.java index 1620329..a77d99a 100644 --- a/app/src/main/java/com/example/testbeacon/UserProfile.java +++ b/app/src/main/java/com/example/testbeacon/UserProfile.java @@ -7,19 +7,13 @@ import androidx.fragment.app.Fragment; -/** - * A simple {@link Fragment} subclass. - * Use the {@link UserProfile#newInstance} factory method to - * create an instance of this fragment. - */ +// User Fragment which is embedded in MainActivity public class UserProfile 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; @@ -27,15 +21,6 @@ public UserProfile() { // 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 user_profile. - */ - // TODO: Rename and change types and number of parameters public static UserProfile newInstance(String param1, String param2) { UserProfile fragment = new UserProfile(); Bundle args = new Bundle();