Skip to content

Commit

Permalink
Merge pull request #588 from pennlabs/fitness
Browse files Browse the repository at this point in the history
Fitness
  • Loading branch information
meiron03 authored Oct 20, 2023
2 parents 6b9406c + 088d009 commit 6ee8ce7
Show file tree
Hide file tree
Showing 37 changed files with 1,894 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class DiningHolderFragment : Fragment() {
super.onCreate(savedInstanceState)
mActivity = activity as MainActivity
mActivity.closeKeyboard()

}

@RequiresApi(Build.VERSION_CODES.M)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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<Button>(R.id.pca_alert_button)
Expand Down
Loading

0 comments on commit 6ee8ce7

Please sign in to comment.