Archived
Adapted PlanFragment into a superclass inherited by GeneralPlanFragment and PersonalPlanFragment, changed text layout attribute for dialogues
This commit is contained in:
@@ -290,8 +290,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
sdf.applyPattern(newDateFormat)
|
||||
val sb = StringBuilder()
|
||||
val lastupdated = sb.append(mContext.getText(R.string.lastupdatedK)).append(sdf.format(d)).toString()
|
||||
Snackbar.make(snackbarview, lastupdated, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show()
|
||||
Snackbar.make(snackbarview, lastupdated, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,8 +301,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
pullToRefresh.isRefreshing = false
|
||||
} catch (ignored: Exception) {}
|
||||
val snackbarview = v.findViewById<View>(R.id.coordination)
|
||||
Snackbar.make(snackbarview, mContext.getText(R.string.nointernet), Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show()
|
||||
Snackbar.make(snackbarview, mContext.getText(R.string.nointernet), Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.Observer
|
||||
|
||||
class GeneralPlanFragment : PlanFragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
substViewModel.allSubst?.observe(this, Observer<List<Subst>> {
|
||||
mAdapter.setSubst(it)
|
||||
recyclerView.scheduleLayoutAnimation()
|
||||
bottomSheetText.text = prefs.getString("informational", getString(R.string.noinfo))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -244,11 +244,11 @@ class Main : AppCompatActivity(R.layout.activity_main) {
|
||||
}
|
||||
lateinit var fragment: Fragment
|
||||
if (prefs.getBoolean("defaultPersonalised", false)) {
|
||||
fragment = mPlanFragment(true)
|
||||
fragment = PersonalPlanFragment()
|
||||
bottomNav.selectedItemId = R.id.personal
|
||||
toolbarTxt.text = userPlan
|
||||
} else {
|
||||
fragment = mPlanFragment(false)
|
||||
fragment = GeneralPlanFragment()
|
||||
bottomNav.selectedItemId = R.id.plan
|
||||
toolbarTxt.text = getString(R.string.app_name)
|
||||
}
|
||||
@@ -259,11 +259,11 @@ class Main : AppCompatActivity(R.layout.activity_main) {
|
||||
lateinit var fragment: Fragment
|
||||
when (item.itemId) {
|
||||
R.id.plan -> {
|
||||
fragment = mPlanFragment(false)
|
||||
fragment = GeneralPlanFragment()
|
||||
toolbarTxt.text = getString(R.string.app_name)
|
||||
}
|
||||
R.id.personal -> {
|
||||
fragment = mPlanFragment(true)
|
||||
fragment = PersonalPlanFragment()
|
||||
toolbarTxt.text = userPlan
|
||||
}
|
||||
R.id.menu -> {
|
||||
@@ -327,14 +327,6 @@ class Main : AppCompatActivity(R.layout.activity_main) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun mPlanFragment(ispersonal: Boolean): PlanFragment {
|
||||
val f = PlanFragment()
|
||||
val bdl = Bundle(1)
|
||||
bdl.putBoolean("ispersonal", ispersonal)
|
||||
f.arguments = bdl
|
||||
return f
|
||||
}
|
||||
|
||||
private fun loadFragment(fragment: Fragment): Boolean {
|
||||
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, fragment).commit()
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.Observer
|
||||
|
||||
class PersonalPlanFragment : PlanFragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
smileydown = view.findViewById(R.id.smileydown)
|
||||
smileydowntext = view.findViewById(R.id.smileydowntext)
|
||||
linearsmiley = view.findViewById(R.id.linearsmiley)
|
||||
|
||||
substViewModel.allSubst?.observe(this, Observer<List<Subst>> {
|
||||
planCardList.clear()
|
||||
smileydown.visibility = View.GONE
|
||||
smileydowntext.visibility = View.GONE
|
||||
linearsmiley.visibility = View.GONE
|
||||
persPlanEmpty = true
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
for (i in 0 until it.size) {
|
||||
if (prefs.getString("courses", "").isEmpty() && prefs.getString("classes", "").isNotEmpty()) {
|
||||
if (it[i].group.isNotEmpty() && !it[i].group.equals("")) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group) || it[i].group.contains(prefs.getString("classes", "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
persPlanEmpty = false
|
||||
}
|
||||
}
|
||||
} else if (prefs.getString("classes", "").isNotEmpty() && prefs.getString("courses", "").isNotEmpty()) {
|
||||
if (!it[i].group.equals("") && !it[i].course.equals("")) {
|
||||
if (prefs.getString("courses", "").contains(it[i].course)) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group) || it[i].group.contains(prefs.getString("classes", "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
persPlanEmpty = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
planCardList.sortWith(Comparator { lhs, rhs -> Integer.compare(rhs.priority, lhs.priority) })
|
||||
recyclerView.scheduleLayoutAnimation()
|
||||
mAdapter.setSubst(planCardList)
|
||||
|
||||
handler.postDelayed({
|
||||
if (persPlanEmpty) {
|
||||
recyclerView.visibility = View.GONE
|
||||
smileydown.visibility = View.VISIBLE
|
||||
smileydowntext.visibility = View.VISIBLE
|
||||
linearsmiley.visibility = View.VISIBLE
|
||||
linearsmiley.scheduleLayoutAnimation()
|
||||
}
|
||||
}, 64)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,23 +18,22 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class PlanFragment : Fragment(R.layout.plan) {
|
||||
private lateinit var recyclerView: RecyclerView
|
||||
private lateinit var mAdapter: CardAdapter
|
||||
open class PlanFragment : Fragment(R.layout.plan) {
|
||||
lateinit var recyclerView: RecyclerView
|
||||
lateinit var mAdapter: CardAdapter
|
||||
private lateinit var layoutManager: GridLayoutManager
|
||||
private val planCardList = ArrayList<Subst>()
|
||||
private lateinit var bottomSheetText: TextView
|
||||
private lateinit var substViewModel: SubstViewModel
|
||||
private lateinit var mContext: Context
|
||||
private lateinit var prefs: SharedPreferences
|
||||
private lateinit var edit: SharedPreferences.Editor
|
||||
private var personal = false
|
||||
val planCardList = ArrayList<Subst>()
|
||||
lateinit var bottomSheetText: TextView
|
||||
lateinit var substViewModel: SubstViewModel
|
||||
lateinit var mContext: Context
|
||||
lateinit var prefs: SharedPreferences
|
||||
lateinit var edit: SharedPreferences.Editor
|
||||
|
||||
private lateinit var smileydown: TextView
|
||||
private lateinit var smileydowntext: TextView
|
||||
private lateinit var linearsmiley: LinearLayout
|
||||
private var persPlanEmpty: Boolean = true
|
||||
private val handler = Handler()
|
||||
lateinit var smileydown: TextView
|
||||
lateinit var smileydowntext: TextView
|
||||
lateinit var linearsmiley: LinearLayout
|
||||
var persPlanEmpty: Boolean = true
|
||||
val handler = Handler()
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
@@ -62,16 +61,10 @@ class PlanFragment : Fragment(R.layout.plan) {
|
||||
recyclerView.layoutManager = layoutManager
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
personal = arguments!!.getBoolean("ispersonal")
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val pullToRefresh = view.findViewById<SwipeRefreshLayout>(R.id.pullToRefresh)
|
||||
bottomSheetText = view.rootView.findViewById(R.id.bottom_sheet_text)
|
||||
|
||||
bottomSheetText.text = prefs.getString("informational", getString(R.string.noinfo))
|
||||
|
||||
recyclerView = view.findViewById(R.id.linearRecycler)
|
||||
@@ -96,12 +89,6 @@ class PlanFragment : Fragment(R.layout.plan) {
|
||||
mAdapter = CardAdapter(planCardList)
|
||||
recyclerView.adapter = mAdapter
|
||||
|
||||
if (personal) {
|
||||
smileydown = view.findViewById(R.id.smileydown)
|
||||
smileydowntext = view.findViewById(R.id.smileydowntext)
|
||||
linearsmiley = view.findViewById(R.id.linearsmiley)
|
||||
}
|
||||
|
||||
if (prefs.getInt("firstTimeOpening", 0) == 2) {
|
||||
if (!prefs.getBoolean("notif", false)) {
|
||||
pullToRefresh.isRefreshing = true
|
||||
@@ -116,52 +103,6 @@ class PlanFragment : Fragment(R.layout.plan) {
|
||||
bottomSheetText.text = prefs.getString("informational", getString(R.string.noinfo))
|
||||
}
|
||||
substViewModel = ViewModelProviders.of(this).get(SubstViewModel::class.java)
|
||||
substViewModel.allSubst?.observe(this, Observer<List<Subst>> {
|
||||
if (personal) {
|
||||
planCardList.clear()
|
||||
smileydown.visibility = View.GONE
|
||||
smileydowntext.visibility = View.GONE
|
||||
linearsmiley.visibility = View.GONE
|
||||
persPlanEmpty = true
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
for (i in 0 until it.size) {
|
||||
if (prefs.getString("courses", "").isEmpty() && prefs.getString("classes", "").isNotEmpty()) {
|
||||
if (it[i].group.isNotEmpty() && !it[i].group.equals("")) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group) || it[i].group.contains(prefs.getString("classes", "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
persPlanEmpty = false
|
||||
}
|
||||
}
|
||||
} else if (prefs.getString("classes", "").isNotEmpty() && prefs.getString("courses", "").isNotEmpty()) {
|
||||
if (!it[i].group.equals("") && !it[i].course.equals("")) {
|
||||
if (prefs.getString("courses", "").contains(it[i].course)) {
|
||||
if (prefs.getString("classes", "").contains(it[i].group) || it[i].group.contains(prefs.getString("classes", "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
persPlanEmpty = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
planCardList.sortWith(Comparator { lhs, rhs -> Integer.compare(rhs.priority, lhs.priority) })
|
||||
recyclerView.scheduleLayoutAnimation()
|
||||
mAdapter.setSubst(planCardList)
|
||||
|
||||
handler.postDelayed({
|
||||
if (persPlanEmpty) {
|
||||
recyclerView.visibility = View.GONE
|
||||
smileydown.visibility = View.VISIBLE
|
||||
smileydowntext.visibility = View.VISIBLE
|
||||
linearsmiley.visibility = View.VISIBLE
|
||||
linearsmiley.scheduleLayoutAnimation()
|
||||
}
|
||||
}, 64)
|
||||
}
|
||||
} else {
|
||||
mAdapter.setSubst(it)
|
||||
recyclerView.scheduleLayoutAnimation()
|
||||
}
|
||||
bottomSheetText.text = prefs.getString("informational", getString(R.string.noinfo))
|
||||
})
|
||||
|
||||
pullToRefresh.setOnRefreshListener {
|
||||
pullToRefresh.isRefreshing = true
|
||||
|
||||
@@ -200,7 +200,7 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
|
||||
"\n • jsoup HTML parser © 2009-2018 Jonathan Hedley, licensed under the open source MIT Licence" +
|
||||
"\n\nFont:\n • Manrope © 2018-2019 Michael Sharanda, licensed under the SIL Open Font Licence 1.1" +
|
||||
"\n\nIcons:\n • bqlqn\n • fjstudio\n • Freepik\n • Smashicons\n • © 2013-2019 Freepik Company S.L., licensed under Creative Commons BY 3.0" +
|
||||
"\n\nMarketing & Publishing:\n • Leon Becker\n • Alex Lick\n • Batuhan Özcan\n • Erich Kerkesner")
|
||||
"\n\nAdditional help:\n • Leon Becker\n • Alex Lick\n • Batuhan Özcan\n • Erich Kerkesner")
|
||||
}
|
||||
R.id.btnTerms -> {
|
||||
createDialog("Terms & Conditions", "These terms automatically apply to anyone using this app - therefore, please make sure to read them carefully before using the app. Copying or modifying parts of the app or the entire app, as well as creating derivative versions, is prohibited without permission. This app is intellectual property of the developer.\n" +
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
app:popupTheme="@style/AppThemeLight.PopupOverlay"
|
||||
app:titleTextColor="@color/accent"
|
||||
app:contentInsetStart="0dp"
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
|
||||
app:layout_collapseMode="pin"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
android:textSize="22sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/datingPink"
|
||||
android:text="@string/dating"/>
|
||||
android:text="@string/dating"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="22sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/textcolor"/>
|
||||
android:textColor="@color/textcolor"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="22sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/textcolor"/>
|
||||
android:textColor="@color/textcolor"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="22sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/textcolor"/>
|
||||
android:textColor="@color/textcolor"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="22sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/textcolor"/>
|
||||
android:textColor="@color/textcolor"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:textSize="22sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/textcolor"/>
|
||||
android:textColor="@color/textcolor"
|
||||
android:textAlignment="center"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -123,18 +123,12 @@
|
||||
<string name="courseWat">WAT</string>
|
||||
<string name="courseFor">Special Education</string>
|
||||
<string name="courseWp">WP & "Methodenstunde"</string>
|
||||
|
||||
<string name="clearall">Clear all</string>
|
||||
<string name="allcolourscleared">Colours for all courses have been cleared</string>
|
||||
|
||||
<string name="chromecompatible">No Chrome-compatible browser found</string>
|
||||
<string name="noyoutube">YouTube app not found</string>
|
||||
|
||||
<string name="showinfo">Show info tab in navigation bar</string>
|
||||
<string name="swipeindependent">Independent of swipe gesture</string>
|
||||
|
||||
<string name="lastupdatedK">"Last updated: "</string>
|
||||
|
||||
<string name="darkmode2">Enables night mode</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user