diff --git a/PennMobile/build.gradle b/PennMobile/build.gradle index 4140cb0c..e1a0df41 100644 --- a/PennMobile/build.gradle +++ b/PennMobile/build.gradle @@ -65,7 +65,6 @@ dependencies { implementation 'androidx.multidex:multidex:2.0.1' implementation 'com.google.maps:google-maps-services:0.13.0' implementation 'org.jsoup:jsoup:1.13.1' - implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.percentlayout:percentlayout:1.0.0' implementation 'androidx.exifinterface:exifinterface:1.2.0' implementation 'androidx.preference:preference-ktx:1.1.1' @@ -73,7 +72,7 @@ dependencies { implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'joda-time:joda-time:2.10.6' implementation 'org.apache.commons:commons-lang3:3.10' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.2.0' implementation 'com.jakewharton:butterknife:10.2.1' implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 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 aa8decd2..59699baf 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 dbae8c0c..82ef219d 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 00000000..6d1acfb3 --- /dev/null +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt @@ -0,0 +1,71 @@ +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.appcompat.widget.Toolbar +import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.fragment.app.Fragment +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout +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 = "Other Facilities" + } + }.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/MainActivity.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt index 0084f86e..1de149df 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt @@ -134,7 +134,7 @@ class MainActivity : AppCompatActivity() { fragment = HomeFragment() } "Dining" -> fragment = DiningHolderFragment() - "PCA" -> fragment = PennCourseAlertHolderFragment() + "PCA" -> fragment = FitnessHolderFragment() "GSR" -> fragment = GsrTabbedFragment() "Laundry" -> fragment = LaundryFragment() "More" -> fragment = MoreFragment() 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 248d7583..5919e2b0 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