-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Thooooor/KeepPieces into master
- Loading branch information
Showing
21 changed files
with
903 additions
and
96 deletions.
There are no files selected for viewing
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
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
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
57 changes: 57 additions & 0 deletions
57
app/src/main/java/com/keeppieces/android/ui/blank/BlankFragment.kt
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.keeppieces.android.ui.blank | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.keeppieces.android.MainActivity | ||
import com.keeppieces.android.R | ||
import com.keeppieces.android.ui.PrimaryCategory.PrimaryCategoryOverviewFragment | ||
import com.keeppieces.android.ui.account.AccountFragment | ||
import com.keeppieces.android.ui.member.MemberFragment | ||
import com.keeppieces.android.ui.overview.getParentActivity | ||
import kotlinx.android.synthetic.main.fragment_account.* | ||
import kotlinx.android.synthetic.main.fragment_blank.* | ||
|
||
|
||
const val AccountPage = 1 | ||
const val MemberPage = 2 | ||
const val CategoryPage = 3 | ||
|
||
class BlankFragment(var startDate: String, var endDate: String) : Fragment() { | ||
var currentType: Int = AccountPage | ||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
return inflater.inflate(R.layout.fragment_blank, container, false) | ||
} | ||
|
||
override fun onActivityCreated(savedInstanceState: Bundle?) { | ||
super.onActivityCreated(savedInstanceState) | ||
setFragment(AccountPage, startDate, endDate) | ||
changeFab.setOnClickListener { | ||
when (currentType) { | ||
AccountPage -> setFragment(CategoryPage, startDate, endDate) | ||
CategoryPage -> setFragment(MemberPage, startDate, endDate) | ||
MemberPage -> setFragment(AccountPage, startDate, endDate) | ||
else -> setFragment(AccountPage, startDate, endDate) | ||
} | ||
} | ||
} | ||
|
||
private fun setFragment(typePage:Int, startDate: String, endDate: String) { | ||
val fragmentManager = getParentActivity<MainActivity>().supportFragmentManager | ||
val transition = fragmentManager.beginTransaction() | ||
val newFragment = when (typePage) { | ||
AccountPage -> AccountFragment(startDate, endDate) | ||
MemberPage -> MemberFragment(startDate, endDate) | ||
CategoryPage -> PrimaryCategoryOverviewFragment(startDate, endDate) | ||
else -> PrimaryCategoryOverviewFragment(startDate, endDate) | ||
} | ||
transition.replace(R.id.childBlankFragment, newFragment) | ||
transition.commit() | ||
currentType = typePage | ||
} | ||
} |
Oops, something went wrong.