2018-01-07 05:01:37 +11:00
|
|
|
package com.keylesspalace.tusky
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.support.design.widget.FloatingActionButton
|
2018-03-28 04:47:00 +11:00
|
|
|
import android.support.v4.app.Fragment
|
2018-01-07 05:01:37 +11:00
|
|
|
import android.support.v7.widget.Toolbar
|
|
|
|
import android.view.MenuItem
|
|
|
|
import android.widget.FrameLayout
|
|
|
|
import com.keylesspalace.tusky.fragment.TimelineFragment
|
|
|
|
import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
2018-03-28 04:47:00 +11:00
|
|
|
import dagger.android.AndroidInjector
|
|
|
|
import dagger.android.DispatchingAndroidInjector
|
|
|
|
import dagger.android.support.HasSupportFragmentInjector
|
|
|
|
import javax.inject.Inject
|
2018-01-07 05:01:37 +11:00
|
|
|
|
2018-03-28 04:47:00 +11:00
|
|
|
class ModalTimelineActivity : BaseActivity(), ActionButtonActivity, HasSupportFragmentInjector {
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
|
2018-01-07 05:01:37 +11:00
|
|
|
|
2018-03-28 04:47:00 +11:00
|
|
|
companion object {
|
2018-01-07 05:01:37 +11:00
|
|
|
private const val ARG_KIND = "kind"
|
|
|
|
private const val ARG_ARG = "arg"
|
2018-03-28 04:47:00 +11:00
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
fun newIntent(context: Context, kind: TimelineFragment.Kind,
|
|
|
|
argument: String?): Intent {
|
2018-01-07 05:01:37 +11:00
|
|
|
val intent = Intent(context, ModalTimelineActivity::class.java)
|
|
|
|
intent.putExtra(ARG_KIND, kind)
|
|
|
|
intent.putExtra(ARG_ARG, argument)
|
|
|
|
return intent
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-03-28 04:47:00 +11:00
|
|
|
|
2018-01-07 05:01:37 +11:00
|
|
|
lateinit var contentFrame: FrameLayout
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContentView(R.layout.activity_modal_timeline)
|
|
|
|
contentFrame = findViewById(R.id.content_frame)
|
|
|
|
|
|
|
|
val toolbar = findViewById<Toolbar>(R.id.toolbar)
|
|
|
|
setSupportActionBar(toolbar)
|
|
|
|
val bar = supportActionBar
|
|
|
|
if (bar != null) {
|
|
|
|
bar.title = getString(R.string.title_list_timeline)
|
|
|
|
bar.setDisplayHomeAsUpEnabled(true)
|
|
|
|
bar.setDisplayShowHomeEnabled(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (supportFragmentManager.findFragmentById(R.id.content_frame) == null) {
|
2018-03-28 04:47:00 +11:00
|
|
|
val kind = intent?.getSerializableExtra(ARG_KIND) as? TimelineFragment.Kind
|
|
|
|
?: TimelineFragment.Kind.HOME
|
2018-01-07 05:01:37 +11:00
|
|
|
val argument = intent?.getStringExtra(ARG_ARG)
|
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.content_frame, TimelineFragment.newInstance(kind, argument))
|
|
|
|
.commit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getActionButton(): FloatingActionButton? = null
|
|
|
|
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
|
|
if (item.itemId == android.R.id.home) {
|
|
|
|
onBackPressed()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2018-03-28 04:47:00 +11:00
|
|
|
|
|
|
|
override fun supportFragmentInjector(): AndroidInjector<Fragment> {
|
|
|
|
return dispatchingAndroidInjector
|
|
|
|
}
|
2018-01-07 05:01:37 +11:00
|
|
|
}
|