-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed find course fragment, according to mockup.
- Loading branch information
Showing
6 changed files
with
152 additions
and
140 deletions.
There are no files selected for viewing
80 changes: 34 additions & 46 deletions
80
...ugmentedRealityKit/app/src/main/java/dk/aau/sw805f18/ar/fragments/FindCourseFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,65 @@ | ||
package dk.aau.sw805f18.ar.fragments; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.AdapterView; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Button; | ||
import android.widget.ListView; | ||
import android.widget.ProgressBar; | ||
import android.widget.Spinner; | ||
|
||
import java.util.ArrayList; | ||
|
||
import dk.aau.sw805f18.ar.R; | ||
import dk.aau.sw805f18.ar.main.MainActivity; | ||
import dk.aau.sw805f18.ar.models.Course; | ||
|
||
|
||
public class FindCourseFragment extends Fragment { | ||
private Button mSearchBtn; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_find_course, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
|
||
mSearchBtn = getView().findViewById(R.id.course_search_nearby); | ||
mSearchBtn.setOnClickListener(view1 -> { | ||
// Shows progressbar | ||
ProgressBar pb = getView().findViewById(R.id.course_search_nearby_progressbar); | ||
pb.setVisibility(View.VISIBLE); | ||
mSearchBtn.setEnabled(false); | ||
|
||
ArrayList<Course> courses = findNearbyCourses(); | ||
ListView lv = getView().findViewById(R.id.course_search_list); | ||
|
||
// ArrayAdapter for populating listview | ||
ArrayAdapter<Course> adapter = new ArrayAdapter<>(getContext(), R.layout.list_item_course, courses); | ||
lv.setAdapter(adapter); | ||
|
||
// Removing progressbar and viewing listview | ||
pb.setVisibility(View.GONE); | ||
lv.setVisibility(View.VISIBLE); | ||
mSearchBtn.setEnabled(true); | ||
|
||
lv.setOnItemClickListener((parent, view2, position, id) -> { | ||
|
||
}); | ||
}); | ||
Spinner distance = getView().findViewById(R.id.find_course_distance_spinner); | ||
Spinner type = getView().findViewById(R.id.find_course_type_spinner); | ||
Spinner age = getView().findViewById(R.id.find_course_age_spinner); | ||
|
||
ArrayAdapter<CharSequence> distanceAdapter = ArrayAdapter.createFromResource(getContext(), | ||
R.array.find_course_distance_spinner_array, | ||
android.R.layout.simple_spinner_item); | ||
|
||
distanceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | ||
distance.setAdapter(distanceAdapter); | ||
|
||
ArrayAdapter<CharSequence> ageAdapter = ArrayAdapter.createFromResource(getContext(), | ||
R.array.find_course_age_spinner_array, | ||
android.R.layout.simple_spinner_item); | ||
|
||
ageAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | ||
age.setAdapter(ageAdapter); | ||
|
||
ArrayAdapter<String> typeAdapter = new ArrayAdapter<>(getContext(), | ||
android.R.layout.simple_spinner_item, | ||
getTypeItems()); | ||
|
||
typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | ||
type.setAdapter(typeAdapter); | ||
} | ||
|
||
/** | ||
* Finds courses based on GPS location. | ||
* TODO: implement GPS functionality. Current version is mock data. | ||
* | ||
* @return ArrayList of Courses | ||
*/ | ||
private ArrayList<Course> findNearbyCourses() { | ||
ArrayList<Course> toReturn = new ArrayList<>(); | ||
toReturn.add(new Course("the cool game")); | ||
toReturn.add(new Course("the boring game")); | ||
toReturn.add(new Course("not actually a game")); | ||
toReturn.add(new Course("the AR game")); | ||
return toReturn; | ||
private ArrayList<String> getTypeItems() { | ||
ArrayList<String> typeArray = new ArrayList<>(); | ||
typeArray.add("night event"); | ||
typeArray.add("halloween event"); | ||
typeArray.add("christmas event"); | ||
typeArray.add("sunshine event"); | ||
|
||
return typeArray; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 91 additions & 89 deletions
180
MultiplayerAugmentedRealityKit/app/src/main/res/layout/fragment_find_course.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,101 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout> | ||
<FrameLayout 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=".fragments.FindCourseFragment"> | ||
<android.support.constraint.ConstraintLayout 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"> | ||
|
||
<SearchView | ||
android:id="@+id/searchView" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="32dp" | ||
android:background="@color/grey_1" | ||
android:iconifiedByDefault="false" | ||
android:queryHint="Moooojn" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.0" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<android.support.constraint.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<android.support.design.widget.TextInputEditText | ||
android:id="@+id/course_id_input" | ||
android:layout_width="0dp" | ||
android:layout_height="47dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="28dp" | ||
android:focusedByDefault="false" | ||
android:hint="@string/course_id" | ||
app:layout_constraintEnd_toStartOf="@+id/button" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:targetApi="o" /> | ||
<ListView | ||
android:id="@+id/listView" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginBottom="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="8dp" | ||
app:layout_constraintBottom_toTopOf="@+id/find_course_divider1" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.0" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/find_course_age_spinner" | ||
app:layout_constraintVertical_bias="1.0" /> | ||
|
||
<Button | ||
android:id="@+id/button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="28dp" | ||
android:layout_weight="1" | ||
android:text="@string/course_id_ok" | ||
android:background="@android:color/transparent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/course_id_input" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
<Spinner | ||
android:id="@+id/find_course_distance_spinner" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="16dp" | ||
app:layout_constraintEnd_toStartOf="@+id/find_course_type_spinner" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/searchView" /> | ||
|
||
<View | ||
android:id="@+id/view" | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="16dp" | ||
android:background="@android:color/darker_gray" | ||
android:visibility="visible" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/course_id_input" /> | ||
<Spinner | ||
android:id="@+id/find_course_type_spinner" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="16dp" | ||
app:layout_constraintEnd_toStartOf="@+id/find_course_age_spinner" | ||
app:layout_constraintStart_toEndOf="@+id/find_course_distance_spinner" | ||
app:layout_constraintTop_toBottomOf="@+id/searchView" /> | ||
|
||
<Button | ||
android:id="@+id/course_search_nearby" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/course_nearby" | ||
android:background="@android:color/transparent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/view" /> | ||
<Spinner | ||
android:id="@+id/find_course_age_spinner" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="16dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/find_course_type_spinner" | ||
app:layout_constraintTop_toBottomOf="@+id/searchView" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/course_search_nearby_progressbar" | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="32dp" | ||
android:visibility="gone" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.498" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/course_search_nearby" /> | ||
<View | ||
android:id="@+id/find_course_divider1" | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:layout_marginBottom="8dp" | ||
android:background="@color/divider" | ||
app:layout_constraintBottom_toTopOf="@+id/find_course_join_by_code" /> | ||
|
||
<ListView | ||
android:id="@+id/course_search_list" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginBottom="16dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:visibility="gone" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/course_search_nearby" /> | ||
<android.support.design.widget.TextInputEditText | ||
android:id="@+id/find_course_join_by_code" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:layout_marginStart="8dp" | ||
android:hint="hint" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/find_course_join_by_code_button" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</android.support.constraint.ConstraintLayout> | ||
<Button | ||
android:id="@+id/find_course_join_by_code_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="16dp" | ||
android:layout_marginEnd="8dp" | ||
android:text="Button" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
</FrameLayout> | ||
</layout> | ||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters