diff --git a/app/build.gradle b/app/build.gradle index 6fa24b9..9cbc32d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,10 +24,12 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:design:28.0.0' + implementation 'com.android.support:support-v4:28.0.0' + implementation 'android.arch.lifecycle:extensions:1.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt index 359ecaa..d93fea7 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt @@ -1,21 +1,19 @@ package cy.agorise.bitsybitshareswallet.activities -import android.support.design.widget.Snackbar import android.support.v7.app.AppCompatActivity import android.support.v4.app.Fragment import android.support.v4.app.FragmentManager import android.support.v4.app.FragmentPagerAdapter import android.os.Bundle -import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem -import android.view.View -import android.view.ViewGroup import cy.agorise.bitsybitshareswallet.R +import cy.agorise.bitsybitshareswallet.fragments.BalancesFragment +import cy.agorise.bitsybitshareswallet.fragments.MerchantsFragment +import cy.agorise.bitsybitshareswallet.fragments.TransactionsFragment import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.fragment_main.view.* class MainActivity : AppCompatActivity() { @@ -74,9 +72,11 @@ class MainActivity : AppCompatActivity() { inner class SectionsPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { override fun getItem(position: Int): Fragment { - // getItem is called to instantiate the fragment for the given page. - // Return a PlaceholderFragment (defined as a static inner class below). - return PlaceholderFragment.newInstance(position + 1) + return when (position) { + 0 -> BalancesFragment() + 1 -> TransactionsFragment() + else -> MerchantsFragment() + } } override fun getCount(): Int { @@ -86,44 +86,9 @@ class MainActivity : AppCompatActivity() { override fun getPageTitle(position: Int): CharSequence? { return when (position) { - 0 -> "" - 1 -> "Transactions" - else -> "Merchants" - } - } - } - - /** - * A placeholder fragment containing a simple view. - */ - class PlaceholderFragment : Fragment() { - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - val rootView = inflater.inflate(R.layout.fragment_main, container, false) - rootView.section_label.text = getString(R.string.section_format, arguments?.getInt(ARG_SECTION_NUMBER)) - return rootView - } - - companion object { - /** - * The fragment argument representing the section number for this - * fragment. - */ - private val ARG_SECTION_NUMBER = "section_number" - - /** - * Returns a new instance of this fragment for the given section - * number. - */ - fun newInstance(sectionNumber: Int): PlaceholderFragment { - val fragment = PlaceholderFragment() - val args = Bundle() - args.putInt(ARG_SECTION_NUMBER, sectionNumber) - fragment.arguments = args - return fragment + 0 -> "" + 1 -> getString(R.string.title_transactions) + else -> getString(R.string.title_merchants) } } } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt new file mode 100644 index 0000000..8d2d455 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt @@ -0,0 +1,34 @@ +package cy.agorise.bitsybitshareswallet.fragments + +import android.arch.lifecycle.ViewModelProviders +import android.os.Bundle +import android.support.v4.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup + +import cy.agorise.bitsybitshareswallet.R +import cy.agorise.bitsybitshareswallet.viewmodels.BalancesViewModel + +class BalancesFragment : Fragment() { + + companion object { + fun newInstance() = BalancesFragment() + } + + private lateinit var viewModel: BalancesViewModel + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.balances_fragment, container, false) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + viewModel = ViewModelProviders.of(this).get(BalancesViewModel::class.java) + // TODO: Use the ViewModel + } + +} diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt new file mode 100644 index 0000000..827c985 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt @@ -0,0 +1,34 @@ +package cy.agorise.bitsybitshareswallet.fragments + +import android.arch.lifecycle.ViewModelProviders +import android.os.Bundle +import android.support.v4.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup + +import cy.agorise.bitsybitshareswallet.R +import cy.agorise.bitsybitshareswallet.viewmodels.MerchantsViewModel + +class MerchantsFragment : Fragment() { + + companion object { + fun newInstance() = MerchantsFragment() + } + + private lateinit var viewModel: MerchantsViewModel + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.merchants_fragment, container, false) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + viewModel = ViewModelProviders.of(this).get(MerchantsViewModel::class.java) + // TODO: Use the ViewModel + } + +} diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt new file mode 100644 index 0000000..aaf4fff --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt @@ -0,0 +1,34 @@ +package cy.agorise.bitsybitshareswallet.fragments + +import android.arch.lifecycle.ViewModelProviders +import android.os.Bundle +import android.support.v4.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup + +import cy.agorise.bitsybitshareswallet.R +import cy.agorise.bitsybitshareswallet.viewmodels.TransactionsViewModel + +class TransactionsFragment : Fragment() { + + companion object { + fun newInstance() = TransactionsFragment() + } + + private lateinit var viewModel: TransactionsViewModel + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.transactions_fragment, container, false) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + viewModel = ViewModelProviders.of(this).get(TransactionsViewModel::class.java) + // TODO: Use the ViewModel + } + +} diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/BalancesViewModel.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/BalancesViewModel.kt new file mode 100644 index 0000000..ca17066 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/BalancesViewModel.kt @@ -0,0 +1,7 @@ +package cy.agorise.bitsybitshareswallet.viewmodels + +import android.arch.lifecycle.ViewModel + +class BalancesViewModel : ViewModel() { + // TODO: Implement the ViewModel +} diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/MerchantsViewModel.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/MerchantsViewModel.kt new file mode 100644 index 0000000..870444d --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/MerchantsViewModel.kt @@ -0,0 +1,7 @@ +package cy.agorise.bitsybitshareswallet.viewmodels + +import android.arch.lifecycle.ViewModel; + +class MerchantsViewModel : ViewModel() { + // TODO: Implement the ViewModel +} diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt new file mode 100644 index 0000000..0ec12f3 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt @@ -0,0 +1,7 @@ +package cy.agorise.bitsybitshareswallet.viewmodels + +import android.arch.lifecycle.ViewModel; + +class TransactionsViewModel : ViewModel() { + // TODO: Implement the ViewModel +} diff --git a/app/src/main/res/layout/balances_fragment.xml b/app/src/main/res/layout/balances_fragment.xml new file mode 100644 index 0000000..20be945 --- /dev/null +++ b/app/src/main/res/layout/balances_fragment.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml deleted file mode 100644 index 29759ef..0000000 --- a/app/src/main/res/layout/fragment_main.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/merchants_fragment.xml b/app/src/main/res/layout/merchants_fragment.xml new file mode 100644 index 0000000..bdd66aa --- /dev/null +++ b/app/src/main/res/layout/merchants_fragment.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/transactions_fragment.xml b/app/src/main/res/layout/transactions_fragment.xml new file mode 100644 index 0000000..743ce9d --- /dev/null +++ b/app/src/main/res/layout/transactions_fragment.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 62c929f..6893cbf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,4 +5,6 @@ Tab 3 Settings Hello World from section: %1$d + Transactions + Merchants