diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt index 4fb0651af..bf65fbeef 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt @@ -60,7 +60,6 @@ class AboutFragment : Fragment() { view.our_team_rv?.layoutManager = GridLayoutManager(context, 3) view.alumni_rv?.layoutManager = GridLayoutManager(context, 3) val members = arrayListOf("Rohan Chhaya", "Julius Snipes", "Aaron Mei", "Trini Feng", "Vedha Avali") - val alumni = arrayListOf("Marta GarcĂ­a Ferreiro", "Varun Ramakrishnan", "Sahit Penmatcha", "Anna Wang", "Sophia Ye", "Awad Irfan", "Liz Powell", "Davies Lumumba", "Anna Jiang", "Ali Krema") view.our_team_rv?.adapter = AboutAdapter(members) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt index aa8decd26..59699baf0 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt @@ -26,7 +26,6 @@ class DiningHolderFragment : Fragment() { super.onCreate(savedInstanceState) mActivity = activity as MainActivity mActivity.closeKeyboard() - } @RequiresApi(Build.VERSION_CODES.M) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt index dbae8c0cb..82ef219dd 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt @@ -68,30 +68,6 @@ class FitnessFragment : Fragment() { internetConnectionFitness?.visibility = View.GONE } - // get API data - val labs = MainActivity.studentLifeInstance - labs.gymData.subscribe({ gyms -> - mActivity.runOnUiThread { - gym_list?.adapter = FitnessAdapter(gyms) - // get rid of loading screen - loadingPanel?.visibility = View.GONE - if (gyms.size > 0) { - no_results?.visibility = View.GONE - } else { - no_results?.visibility = View.VISIBLE - } - // stop refreshing - gym_refresh_layout?.isRefreshing = false - } - }, { throwable -> - mActivity.runOnUiThread { - throwable.printStackTrace() - Toast.makeText(activity, "Could not load gym information", Toast.LENGTH_LONG).show() - loadingPanel?.visibility = View.GONE - no_results?.visibility = View.VISIBLE - gym_refresh_layout?.isRefreshing = false - } - }) } override fun onResume() { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt new file mode 100644 index 000000000..e0884feda --- /dev/null +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt @@ -0,0 +1,69 @@ +package com.pennapps.labs.pennmobile + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.fragment.app.Fragment +import com.google.android.material.appbar.AppBarLayout +import com.google.android.material.tabs.TabLayoutMediator +import com.pennapps.labs.pennmobile.adapters.FitnessPagerAdapter +import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.utils.Utils + +import kotlinx.android.synthetic.main.fragment_fitness_holder.pager +import kotlinx.android.synthetic.main.fragment_fitness_holder.tabLayout + +class FitnessHolderFragment: Fragment() { + private lateinit var mActivity : MainActivity + private lateinit var mView : View + private lateinit var pagerAdapter : FitnessPagerAdapter + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + mActivity = activity as MainActivity + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + super.onCreateView(inflater, container, savedInstanceState) + return inflater.inflate(R.layout.fragment_fitness_holder, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + mView = view + // initialize app bar and swipe refresh + initAppBar() + + pagerAdapter = FitnessPagerAdapter(this) + pager?.adapter = pagerAdapter + pager.isUserInputEnabled = false + TabLayoutMediator(tabLayout, pager) { tab, position -> + if (position == 0) { + tab.text = "Pottruck" + } else { + tab.text = "Favorites" + } + }.attach() + } + + /** + * Initialize the app bar of the fragment and + * fills in the textViews for the title/date + */ + private fun initAppBar() { + val appBarLayout : AppBarLayout = mView.findViewById(R.id.appbar_home_holder) + val titleView : TextView = mView.findViewById(R.id.title_view) + val dateView : TextView = mView.findViewById(R.id.date_view) + + (appBarLayout.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() + titleView.text = getString(R.string.fitness) + dateView.text = Utils.getCurrentSystemTime() + } +} \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessPreferencesFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessPreferencesFragment.kt new file mode 100644 index 000000000..0b6cc0ce7 --- /dev/null +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessPreferencesFragment.kt @@ -0,0 +1,66 @@ +package com.pennapps.labs.pennmobile + +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.fragment.app.DialogFragment +import androidx.recyclerview.widget.RecyclerView +import com.pennapps.labs.pennmobile.adapters.FitnessPreferenceAdapter +import com.pennapps.labs.pennmobile.classes.FitnessPreferenceViewModel + +interface CloseListener { + fun updateAdapters() +} + +class FitnessPreferencesFragment(private val dataModel: FitnessPreferenceViewModel, + private val listener: CloseListener) : DialogFragment() { + + private lateinit var mActivity : MainActivity + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + mActivity = activity as MainActivity + return inflater.inflate(R.layout.fragment_fitness_preferences, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val prefAdapter = FitnessPreferenceAdapter(dataModel) + + val recyclerView: RecyclerView = view.findViewById(R.id.fitness_preference_recycler_view) + recyclerView.adapter = prefAdapter + + val cancelText : TextView = view.findViewById(R.id.fitness_fragment_pref_cancel) + cancelText.setOnClickListener { + dataModel.restorePreferences() + dialog?.dismiss() + } + + val saveText : TextView = view.findViewById(R.id.fitness_fragment_pref_save) + saveText.setOnClickListener { + dataModel.updatePositionMap() + dataModel.updateRemotePreferences(mActivity) + listener.updateAdapters() + + dialog?.dismiss() + } + } + + override fun onStart() { + super.onStart() + val dialog = dialog + + if (dialog != null) { + val width = ViewGroup.LayoutParams.MATCH_PARENT + val height = ViewGroup.LayoutParams.MATCH_PARENT + dialog.window!!.setLayout(width, height) + } + } + +} \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt index 248d75830..5919e2b00 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt @@ -59,7 +59,6 @@ class PennCourseAlertCreateAlertFragment : Fragment() { // hideInternetErrorBar(view) } - val sp = PreferenceManager.getDefaultSharedPreferences(activity) val pennKey = sp.getString(getString(R.string.pennkey), null) val bearerToken = "Bearer " + sp.getString(getString(R.string.access_token), "").toString() @@ -80,9 +79,10 @@ class PennCourseAlertCreateAlertFragment : Fragment() { viewModel.userInfo.observe(viewLifecycleOwner, Observer { val formattedPhoneNumber = viewModel.userInfo.value?.profile?.phone?.drop(2) val email = viewModel.userInfo.value?.profile?.email + phoneNumberEditText.text = - Editable.Factory.getInstance().newEditable(formattedPhoneNumber) - emailEditText.text = Editable.Factory.getInstance().newEditable(email) + Editable.Factory.getInstance().newEditable(formattedPhoneNumber?: "") + emailEditText.text = Editable.Factory.getInstance().newEditable(email?: "") }) val alertButton = view.findViewById