mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-02-23 07:07:43 +01:00
rewrite fragments from views to casual support fragments
This commit is contained in:
parent
cd0c951c8e
commit
d629ccaf94
@ -58,8 +58,6 @@ class MainActivity : SimpleActivity() {
|
|||||||
if (config.preventPhoneFromSleeping) {
|
if (config.preventPhoneFromSleeping) {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
|
|
||||||
(viewpager.adapter as? ViewPagerAdapter)?.activityResumed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -99,7 +97,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
viewpager.adapter = ViewPagerAdapter(this)
|
viewpager.adapter = ViewPagerAdapter(supportFragmentManager)
|
||||||
viewpager.onPageChangeListener {
|
viewpager.onPageChangeListener {
|
||||||
main_tabs_holder.getTabAt(it)?.select()
|
main_tabs_holder.getTabAt(it)?.select()
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,34 @@
|
|||||||
package com.simplemobiletools.clock.adapters
|
package com.simplemobiletools.clock.adapters
|
||||||
|
|
||||||
import android.support.v4.view.PagerAdapter
|
import android.support.v4.app.Fragment
|
||||||
import android.view.View
|
import android.support.v4.app.FragmentManager
|
||||||
|
import android.support.v4.app.FragmentStatePagerAdapter
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.fragments.AlarmFragment
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.fragments.ClockFragment
|
||||||
import com.simplemobiletools.clock.fragments.MyViewPagerFragment
|
import com.simplemobiletools.clock.fragments.StopwatchFragment
|
||||||
import com.simplemobiletools.clock.helpers.TABS_COUNT
|
import com.simplemobiletools.clock.helpers.TABS_COUNT
|
||||||
|
|
||||||
class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
|
class ViewPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
|
||||||
private val fragments = HashMap<Int, MyViewPagerFragment>()
|
private val fragments = HashMap<Int, Fragment>()
|
||||||
|
|
||||||
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
override fun getItem(position: Int): Fragment {
|
||||||
val layout = getFragment(position)
|
val fragment = getFragment(position)
|
||||||
val fragment = activity.layoutInflater.inflate(layout, container, false) as MyViewPagerFragment
|
|
||||||
fragments[position] = fragment
|
fragments[position] = fragment
|
||||||
container.addView(fragment)
|
|
||||||
return fragment
|
return fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun destroyItem(container: ViewGroup, position: Int, item: Any) {
|
override fun destroyItem(container: ViewGroup, position: Int, item: Any) {
|
||||||
container.removeView(item as View)
|
fragments.remove(position)
|
||||||
|
super.destroyItem(container, position, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCount() = TABS_COUNT
|
override fun getCount() = TABS_COUNT
|
||||||
override fun isViewFromObject(view: View, item: Any) = view == item
|
|
||||||
|
|
||||||
private fun getFragment(position: Int) = when (position) {
|
private fun getFragment(position: Int) = when (position) {
|
||||||
0 -> R.layout.fragment_clock
|
0 -> ClockFragment()
|
||||||
1 -> R.layout.fragment_alarm
|
1 -> AlarmFragment()
|
||||||
else -> R.layout.fragment_stopwatch
|
2 -> StopwatchFragment()
|
||||||
}
|
else -> throw RuntimeException("Trying to fetch unknown fragment id $position")
|
||||||
|
|
||||||
fun activityResumed() {
|
|
||||||
fragments.values.forEach {
|
|
||||||
it.onActivityResume()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package com.simplemobiletools.clock.fragments
|
package com.simplemobiletools.clock.fragments
|
||||||
|
|
||||||
import android.content.Context
|
import android.os.Bundle
|
||||||
import android.util.AttributeSet
|
import android.support.v4.app.Fragment
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import android.view.LayoutInflater
|
||||||
import kotlinx.android.synthetic.main.fragment_alarm.view.*
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.simplemobiletools.clock.R
|
||||||
|
|
||||||
class AlarmFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class AlarmFragment : Fragment() {
|
||||||
override fun onFinishInflate() {
|
lateinit var view: ViewGroup
|
||||||
super.onFinishInflate()
|
|
||||||
context.updateTextColors(alarm_fragment)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResume() {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
view = inflater.inflate(R.layout.fragment_alarm, container, false) as ViewGroup
|
||||||
|
return view
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,61 @@
|
|||||||
package com.simplemobiletools.clock.fragments
|
package com.simplemobiletools.clock.fragments
|
||||||
|
|
||||||
import android.content.Context
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.AttributeSet
|
import android.support.v4.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.models.MyTimeZone
|
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import kotlinx.android.synthetic.main.fragment_clock.view.*
|
import kotlinx.android.synthetic.main.fragment_clock.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ClockFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class ClockFragment : Fragment() {
|
||||||
private val ONE_SECOND = 1000L
|
private val ONE_SECOND = 1000L
|
||||||
private var passedSeconds = 0
|
|
||||||
private var calendar = Calendar.getInstance()
|
|
||||||
|
|
||||||
|
private var passedSeconds = 0
|
||||||
|
private var isFirstResume = true
|
||||||
|
private var calendar = Calendar.getInstance()
|
||||||
private val updateHandler = Handler()
|
private val updateHandler = Handler()
|
||||||
|
|
||||||
override fun onFinishInflate() {
|
lateinit var view: ViewGroup
|
||||||
super.onFinishInflate()
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
view = inflater.inflate(R.layout.fragment_clock, container, false) as ViewGroup
|
||||||
val offset = calendar.timeZone.rawOffset
|
val offset = calendar.timeZone.rawOffset
|
||||||
passedSeconds = ((calendar.timeInMillis + offset) / 1000).toInt()
|
passedSeconds = ((calendar.timeInMillis + offset) / 1000).toInt()
|
||||||
updateCurrentTime()
|
updateCurrentTime()
|
||||||
updateDate()
|
updateDate()
|
||||||
setupViews()
|
setupViews()
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
|
||||||
|
if (!isFirstResume) {
|
||||||
|
setupViews()
|
||||||
|
}
|
||||||
|
isFirstResume = false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
updateHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
context.updateTextColors(clock_fragment)
|
val displayOtherTimeZones = context!!.config.displayOtherTimeZones
|
||||||
val displayOtherTimeZones = context.config.displayOtherTimeZones
|
view.apply {
|
||||||
time_zones_list.beVisibleIf(displayOtherTimeZones)
|
context!!.updateTextColors(clock_fragment)
|
||||||
clock_fab.beVisibleIf(displayOtherTimeZones)
|
time_zones_list.beVisibleIf(displayOtherTimeZones)
|
||||||
clock_fab.setOnClickListener {
|
clock_fab.beVisibleIf(displayOtherTimeZones)
|
||||||
fabClicked()
|
clock_fab.setOnClickListener {
|
||||||
|
fabClicked()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,14 +65,14 @@ class ClockFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
val seconds = passedSeconds % 60
|
val seconds = passedSeconds % 60
|
||||||
var format = "%02d:%02d"
|
var format = "%02d:%02d"
|
||||||
|
|
||||||
val formattedText = if (context.config.showSeconds) {
|
val formattedText = if (context!!.config.showSeconds) {
|
||||||
format += ":%02d"
|
format += ":%02d"
|
||||||
String.format(format, hours, minutes, seconds)
|
String.format(format, hours, minutes, seconds)
|
||||||
} else {
|
} else {
|
||||||
String.format(format, hours, minutes)
|
String.format(format, hours, minutes)
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_time.text = formattedText
|
view.clock_time.text = formattedText
|
||||||
|
|
||||||
if (hours == 0 && minutes == 0 && seconds == 0) {
|
if (hours == 0 && minutes == 0 && seconds == 0) {
|
||||||
updateDate()
|
updateDate()
|
||||||
@ -68,116 +90,15 @@ class ClockFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)
|
val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
val month = calendar.get(Calendar.MONTH)
|
val month = calendar.get(Calendar.MONTH)
|
||||||
|
|
||||||
val dayString = context.resources.getStringArray(R.array.week_days)[dayOfWeek]
|
val dayString = context!!.resources.getStringArray(R.array.week_days)[dayOfWeek]
|
||||||
val shortDayString = dayString.substring(0, Math.min(3, dayString.length))
|
val shortDayString = dayString.substring(0, Math.min(3, dayString.length))
|
||||||
val monthString = context.resources.getStringArray(R.array.months)[month]
|
val monthString = context!!.resources.getStringArray(R.array.months)[month]
|
||||||
|
|
||||||
val dateString = "$shortDayString, $dayOfMonth $monthString"
|
val dateString = "$shortDayString, $dayOfMonth $monthString"
|
||||||
clock_date.text = dateString
|
view.clock_date.text = dateString
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromWindow() {
|
|
||||||
super.onDetachedFromWindow()
|
|
||||||
updateHandler.removeCallbacksAndMessages(null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fabClicked() {
|
private fun fabClicked() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResume() {
|
|
||||||
setupViews()
|
|
||||||
}
|
|
||||||
|
|
||||||
val timezones = arrayListOf(
|
|
||||||
MyTimeZone(1, "GMT-11:00 Midway", "Pacific/Midway"),
|
|
||||||
MyTimeZone(2, "GMT-10:00 Honolulu", "Pacific/Honolulu"),
|
|
||||||
MyTimeZone(3, "GMT-09:00 Anchorage", "America/Anchorage"),
|
|
||||||
MyTimeZone(4, "GMT-08:00 Los Angeles", "America/Los_Angeles"),
|
|
||||||
MyTimeZone(5, "GMT-08:00 Tijuana", "America/Tijuana"),
|
|
||||||
MyTimeZone(6, "GMT-07:00 Phoenix", "America/Phoenix"),
|
|
||||||
MyTimeZone(7, "GMT-07:00 Chihuahua", "America/Chihuahua"),
|
|
||||||
MyTimeZone(8, "GMT-07:00 Denver", "America/Denver"),
|
|
||||||
MyTimeZone(9, "GMT-06:00 Costa Rica", "America/Costa_Rica"),
|
|
||||||
MyTimeZone(10, "GMT-06:00 Chicago", "America/Chicago"),
|
|
||||||
MyTimeZone(11, "GMT-06:00 Mexico City", "America/Mexico_City"),
|
|
||||||
MyTimeZone(12, "GMT-06:00 Regina", "America/Regina"),
|
|
||||||
MyTimeZone(13, "GMT-05:00 Bogota", "America/Bogota"),
|
|
||||||
MyTimeZone(14, "GMT-05:00 New York", "America/New_York"),
|
|
||||||
MyTimeZone(15, "GMT-04:30 Caracas", "America/Caracas"),
|
|
||||||
MyTimeZone(16, "GMT-04:00 Barbados", "America/Barbados"),
|
|
||||||
MyTimeZone(17, "GMT-04:00 Halifax", "America/Halifax"),
|
|
||||||
MyTimeZone(18, "GMT-04:00 Manaus", "America/Manaus"),
|
|
||||||
MyTimeZone(19, "GMT-03:30 St. John's", "America/St_Johns"),
|
|
||||||
MyTimeZone(20, "GMT-03:00 Santiago", "America/Santiago"),
|
|
||||||
MyTimeZone(21, "GMT-03:00 Recife", "America/Recife"),
|
|
||||||
MyTimeZone(22, "GMT-03:00 Sao Paulo", "America/Sao_Paulo"),
|
|
||||||
MyTimeZone(23, "GMT-03:00 Buenos Aires", "America/Buenos_Aires"),
|
|
||||||
MyTimeZone(24, "GMT-03:00 Nuuk", "America/Godthab"),
|
|
||||||
MyTimeZone(25, "GMT-03:00 Montevideo", "America/Montevideo"),
|
|
||||||
MyTimeZone(26, "GMT-02:00 South Georgia", "Atlantic/South_Georgia"),
|
|
||||||
MyTimeZone(27, "GMT-01:00 Azores", "Atlantic/Azores"),
|
|
||||||
MyTimeZone(28, "GMT-01:00 Cape Verde", "Atlantic/Cape_Verde"),
|
|
||||||
MyTimeZone(29, "GMT+00:00 Casablanca", "Africa/Casablanca"),
|
|
||||||
MyTimeZone(30, "GMT+00:00 Greenwich Mean Time", "Etc/Greenwich"),
|
|
||||||
MyTimeZone(31, "GMT+01:00 Amsterdam", "Europe/Amsterdam"),
|
|
||||||
MyTimeZone(32, "GMT+01:00 Belgrade", "Europe/Belgrade"),
|
|
||||||
MyTimeZone(33, "GMT+01:00 Brussels", "Europe/Brussels"),
|
|
||||||
MyTimeZone(34, "GMT+01:00 Madrid", "Europe/Madrid"),
|
|
||||||
MyTimeZone(35, "GMT+01:00 Sarajevo", "Europe/Sarajevo"),
|
|
||||||
MyTimeZone(36, "GMT+01:00 Brazzaville", "Africa/Brazzaville"),
|
|
||||||
MyTimeZone(37, "GMT+02:00 Windhoek", "Africa/Windhoek"),
|
|
||||||
MyTimeZone(38, "GMT+02:00 Amman", "Asia/Amman"),
|
|
||||||
MyTimeZone(39, "GMT+02:00 Athens", "Europe/Athens"),
|
|
||||||
MyTimeZone(40, "GMT+02:00 Istanbul", "Europe/Istanbul"),
|
|
||||||
MyTimeZone(41, "GMT+02:00 Beirut", "Asia/Beirut"),
|
|
||||||
MyTimeZone(42, "GMT+02:00 Cairo", "Africa/Cairo"),
|
|
||||||
MyTimeZone(43, "GMT+02:00 Helsinki", "Europe/Helsinki"),
|
|
||||||
MyTimeZone(44, "GMT+02:00 Jerusalem", "Asia/Jerusalem"),
|
|
||||||
MyTimeZone(45, "GMT+02:00 Harare", "Africa/Harare"),
|
|
||||||
MyTimeZone(46, "GMT+03:00 Minsk", "Europe/Minsk"),
|
|
||||||
MyTimeZone(47, "GMT+03:00 Baghdad", "Asia/Baghdad"),
|
|
||||||
MyTimeZone(48, "GMT+03:00 Moscow", "Europe/Moscow"),
|
|
||||||
MyTimeZone(49, "GMT+03:00 Kuwait", "Asia/Kuwait"),
|
|
||||||
MyTimeZone(50, "GMT+03:00 Nairobi", "Africa/Nairobi"),
|
|
||||||
MyTimeZone(51, "GMT+03:30 Tehran", "Asia/Tehran"),
|
|
||||||
MyTimeZone(52, "GMT+04:00 Baku", "Asia/Baku"),
|
|
||||||
MyTimeZone(53, "GMT+04:00 Tbilisi", "Asia/Tbilisi"),
|
|
||||||
MyTimeZone(54, "GMT+04:00 Yerevan", "Asia/Yerevan"),
|
|
||||||
MyTimeZone(55, "GMT+04:00 Dubai", "Asia/Dubai"),
|
|
||||||
MyTimeZone(56, "GMT+04:30 Kabul", "Asia/Kabul"),
|
|
||||||
MyTimeZone(57, "GMT+05:00 Karachi", "Asia/Karachi"),
|
|
||||||
MyTimeZone(58, "GMT+05:00 Oral", "Asia/Oral"),
|
|
||||||
MyTimeZone(59, "GMT+05:00 Yekaterinburg", "Asia/Yekaterinburg"),
|
|
||||||
MyTimeZone(60, "GMT+05:30 Kolkata", "Asia/Kolkata"),
|
|
||||||
MyTimeZone(61, "GMT+05:30 Colombo", "Asia/Colombo"),
|
|
||||||
MyTimeZone(62, "GMT+05:45 Kathmandu", "Asia/Kathmandu"),
|
|
||||||
MyTimeZone(63, "GMT+06:00 Almaty", "Asia/Almaty"),
|
|
||||||
MyTimeZone(64, "GMT+06:30 Rangoon", "Asia/Rangoon"),
|
|
||||||
MyTimeZone(65, "GMT+07:00 Krasnoyarsk", "Asia/Krasnoyarsk"),
|
|
||||||
MyTimeZone(66, "GMT+07:00 Bangkok", "Asia/Bangkok"),
|
|
||||||
MyTimeZone(67, "GMT+07:00 Jakarta", "Asia/Jakarta"),
|
|
||||||
MyTimeZone(68, "GMT+08:00 Shanghai", "Asia/Shanghai"),
|
|
||||||
MyTimeZone(69, "GMT+08:00 Hong Kong", "Asia/Hong_Kong"),
|
|
||||||
MyTimeZone(70, "GMT+08:00 Irkutsk", "Asia/Irkutsk"),
|
|
||||||
MyTimeZone(71, "GMT+08:00 Kuala Lumpur", "Asia/Kuala_Lumpur"),
|
|
||||||
MyTimeZone(72, "GMT+08:00 Perth", "Australia/Perth"),
|
|
||||||
MyTimeZone(73, "GMT+08:00 Taipei", "Asia/Taipei"),
|
|
||||||
MyTimeZone(74, "GMT+09:00 Seoul", "Asia/Seoul"),
|
|
||||||
MyTimeZone(75, "GMT+09:00 Tokyo", "Asia/Tokyo"),
|
|
||||||
MyTimeZone(76, "GMT+09:00 Yakutsk", "Asia/Yakutsk"),
|
|
||||||
MyTimeZone(77, "GMT+09:30 Darwin", "Australia/Darwin"),
|
|
||||||
MyTimeZone(78, "GMT+10:00 Brisbane", "Australia/Brisbane"),
|
|
||||||
MyTimeZone(79, "GMT+10:00 Vladivostok", "Asia/Vladivostok"),
|
|
||||||
MyTimeZone(80, "GMT+10:00 Guam", "Pacific/Guam"),
|
|
||||||
MyTimeZone(81, "GMT+10:00 Magadan", "Asia/Magadan"),
|
|
||||||
MyTimeZone(82, "GMT+10:30 Adelaide", "Australia/Adelaide"),
|
|
||||||
MyTimeZone(83, "GMT+11:00 Hobart", "Australia/Hobart"),
|
|
||||||
MyTimeZone(84, "GMT+11:00 Sydney", "Australia/Sydney"),
|
|
||||||
MyTimeZone(85, "GMT+11:00 Noumea", "Pacific/Noumea"),
|
|
||||||
MyTimeZone(86, "GMT+12:00 Majuro", "Pacific/Majuro"),
|
|
||||||
MyTimeZone(87, "GMT+12:00 Fiji", "Pacific/Fiji"),
|
|
||||||
MyTimeZone(88, "GMT+13:00 Auckland", "Pacific/Auckland"),
|
|
||||||
MyTimeZone(89, "GMT+13:00 Tongatapu", "Pacific/Tongatapu")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package com.simplemobiletools.clock.fragments
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.support.design.widget.CoordinatorLayout
|
|
||||||
import android.util.AttributeSet
|
|
||||||
|
|
||||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) {
|
|
||||||
abstract fun onActivityResume()
|
|
||||||
}
|
|
@ -1,16 +1,17 @@
|
|||||||
package com.simplemobiletools.clock.fragments
|
package com.simplemobiletools.clock.fragments
|
||||||
|
|
||||||
import android.content.Context
|
import android.os.Bundle
|
||||||
import android.util.AttributeSet
|
import android.support.v4.app.Fragment
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import android.view.LayoutInflater
|
||||||
import kotlinx.android.synthetic.main.fragment_stopwatch.view.*
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.simplemobiletools.clock.R
|
||||||
|
|
||||||
class StopwatchFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class StopwatchFragment : Fragment() {
|
||||||
override fun onFinishInflate() {
|
lateinit var view: ViewGroup
|
||||||
super.onFinishInflate()
|
|
||||||
context.updateTextColors(stopwatch_fragment)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResume() {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
view = inflater.inflate(R.layout.fragment_stopwatch, container, false) as ViewGroup
|
||||||
|
return view
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,101 @@
|
|||||||
package com.simplemobiletools.clock.helpers
|
package com.simplemobiletools.clock.helpers
|
||||||
|
|
||||||
|
import com.simplemobiletools.clock.models.MyTimeZone
|
||||||
|
|
||||||
// shared preferences
|
// shared preferences
|
||||||
const val SHOW_SECONDS = "show_seconds"
|
const val SHOW_SECONDS = "show_seconds"
|
||||||
const val DISPLAY_OTHER_TIME_ZONES = "display_other_time_zones"
|
const val DISPLAY_OTHER_TIME_ZONES = "display_other_time_zones"
|
||||||
|
|
||||||
const val TABS_COUNT = 3
|
const val TABS_COUNT = 3
|
||||||
|
|
||||||
|
val timezones = arrayListOf(
|
||||||
|
MyTimeZone(1, "GMT-11:00 Midway", "Pacific/Midway"),
|
||||||
|
MyTimeZone(2, "GMT-10:00 Honolulu", "Pacific/Honolulu"),
|
||||||
|
MyTimeZone(3, "GMT-09:00 Anchorage", "America/Anchorage"),
|
||||||
|
MyTimeZone(4, "GMT-08:00 Los Angeles", "America/Los_Angeles"),
|
||||||
|
MyTimeZone(5, "GMT-08:00 Tijuana", "America/Tijuana"),
|
||||||
|
MyTimeZone(6, "GMT-07:00 Phoenix", "America/Phoenix"),
|
||||||
|
MyTimeZone(7, "GMT-07:00 Chihuahua", "America/Chihuahua"),
|
||||||
|
MyTimeZone(8, "GMT-07:00 Denver", "America/Denver"),
|
||||||
|
MyTimeZone(9, "GMT-06:00 Costa Rica", "America/Costa_Rica"),
|
||||||
|
MyTimeZone(10, "GMT-06:00 Chicago", "America/Chicago"),
|
||||||
|
MyTimeZone(11, "GMT-06:00 Mexico City", "America/Mexico_City"),
|
||||||
|
MyTimeZone(12, "GMT-06:00 Regina", "America/Regina"),
|
||||||
|
MyTimeZone(13, "GMT-05:00 Bogota", "America/Bogota"),
|
||||||
|
MyTimeZone(14, "GMT-05:00 New York", "America/New_York"),
|
||||||
|
MyTimeZone(15, "GMT-04:30 Caracas", "America/Caracas"),
|
||||||
|
MyTimeZone(16, "GMT-04:00 Barbados", "America/Barbados"),
|
||||||
|
MyTimeZone(17, "GMT-04:00 Halifax", "America/Halifax"),
|
||||||
|
MyTimeZone(18, "GMT-04:00 Manaus", "America/Manaus"),
|
||||||
|
MyTimeZone(19, "GMT-03:30 St. John's", "America/St_Johns"),
|
||||||
|
MyTimeZone(20, "GMT-03:00 Santiago", "America/Santiago"),
|
||||||
|
MyTimeZone(21, "GMT-03:00 Recife", "America/Recife"),
|
||||||
|
MyTimeZone(22, "GMT-03:00 Sao Paulo", "America/Sao_Paulo"),
|
||||||
|
MyTimeZone(23, "GMT-03:00 Buenos Aires", "America/Buenos_Aires"),
|
||||||
|
MyTimeZone(24, "GMT-03:00 Nuuk", "America/Godthab"),
|
||||||
|
MyTimeZone(25, "GMT-03:00 Montevideo", "America/Montevideo"),
|
||||||
|
MyTimeZone(26, "GMT-02:00 South Georgia", "Atlantic/South_Georgia"),
|
||||||
|
MyTimeZone(27, "GMT-01:00 Azores", "Atlantic/Azores"),
|
||||||
|
MyTimeZone(28, "GMT-01:00 Cape Verde", "Atlantic/Cape_Verde"),
|
||||||
|
MyTimeZone(29, "GMT+00:00 Casablanca", "Africa/Casablanca"),
|
||||||
|
MyTimeZone(30, "GMT+00:00 Greenwich Mean Time", "Etc/Greenwich"),
|
||||||
|
MyTimeZone(31, "GMT+01:00 Amsterdam", "Europe/Amsterdam"),
|
||||||
|
MyTimeZone(32, "GMT+01:00 Belgrade", "Europe/Belgrade"),
|
||||||
|
MyTimeZone(33, "GMT+01:00 Brussels", "Europe/Brussels"),
|
||||||
|
MyTimeZone(34, "GMT+01:00 Madrid", "Europe/Madrid"),
|
||||||
|
MyTimeZone(35, "GMT+01:00 Sarajevo", "Europe/Sarajevo"),
|
||||||
|
MyTimeZone(36, "GMT+01:00 Brazzaville", "Africa/Brazzaville"),
|
||||||
|
MyTimeZone(37, "GMT+02:00 Windhoek", "Africa/Windhoek"),
|
||||||
|
MyTimeZone(38, "GMT+02:00 Amman", "Asia/Amman"),
|
||||||
|
MyTimeZone(39, "GMT+02:00 Athens", "Europe/Athens"),
|
||||||
|
MyTimeZone(40, "GMT+02:00 Istanbul", "Europe/Istanbul"),
|
||||||
|
MyTimeZone(41, "GMT+02:00 Beirut", "Asia/Beirut"),
|
||||||
|
MyTimeZone(42, "GMT+02:00 Cairo", "Africa/Cairo"),
|
||||||
|
MyTimeZone(43, "GMT+02:00 Helsinki", "Europe/Helsinki"),
|
||||||
|
MyTimeZone(44, "GMT+02:00 Jerusalem", "Asia/Jerusalem"),
|
||||||
|
MyTimeZone(45, "GMT+02:00 Harare", "Africa/Harare"),
|
||||||
|
MyTimeZone(46, "GMT+03:00 Minsk", "Europe/Minsk"),
|
||||||
|
MyTimeZone(47, "GMT+03:00 Baghdad", "Asia/Baghdad"),
|
||||||
|
MyTimeZone(48, "GMT+03:00 Moscow", "Europe/Moscow"),
|
||||||
|
MyTimeZone(49, "GMT+03:00 Kuwait", "Asia/Kuwait"),
|
||||||
|
MyTimeZone(50, "GMT+03:00 Nairobi", "Africa/Nairobi"),
|
||||||
|
MyTimeZone(51, "GMT+03:30 Tehran", "Asia/Tehran"),
|
||||||
|
MyTimeZone(52, "GMT+04:00 Baku", "Asia/Baku"),
|
||||||
|
MyTimeZone(53, "GMT+04:00 Tbilisi", "Asia/Tbilisi"),
|
||||||
|
MyTimeZone(54, "GMT+04:00 Yerevan", "Asia/Yerevan"),
|
||||||
|
MyTimeZone(55, "GMT+04:00 Dubai", "Asia/Dubai"),
|
||||||
|
MyTimeZone(56, "GMT+04:30 Kabul", "Asia/Kabul"),
|
||||||
|
MyTimeZone(57, "GMT+05:00 Karachi", "Asia/Karachi"),
|
||||||
|
MyTimeZone(58, "GMT+05:00 Oral", "Asia/Oral"),
|
||||||
|
MyTimeZone(59, "GMT+05:00 Yekaterinburg", "Asia/Yekaterinburg"),
|
||||||
|
MyTimeZone(60, "GMT+05:30 Kolkata", "Asia/Kolkata"),
|
||||||
|
MyTimeZone(61, "GMT+05:30 Colombo", "Asia/Colombo"),
|
||||||
|
MyTimeZone(62, "GMT+05:45 Kathmandu", "Asia/Kathmandu"),
|
||||||
|
MyTimeZone(63, "GMT+06:00 Almaty", "Asia/Almaty"),
|
||||||
|
MyTimeZone(64, "GMT+06:30 Rangoon", "Asia/Rangoon"),
|
||||||
|
MyTimeZone(65, "GMT+07:00 Krasnoyarsk", "Asia/Krasnoyarsk"),
|
||||||
|
MyTimeZone(66, "GMT+07:00 Bangkok", "Asia/Bangkok"),
|
||||||
|
MyTimeZone(67, "GMT+07:00 Jakarta", "Asia/Jakarta"),
|
||||||
|
MyTimeZone(68, "GMT+08:00 Shanghai", "Asia/Shanghai"),
|
||||||
|
MyTimeZone(69, "GMT+08:00 Hong Kong", "Asia/Hong_Kong"),
|
||||||
|
MyTimeZone(70, "GMT+08:00 Irkutsk", "Asia/Irkutsk"),
|
||||||
|
MyTimeZone(71, "GMT+08:00 Kuala Lumpur", "Asia/Kuala_Lumpur"),
|
||||||
|
MyTimeZone(72, "GMT+08:00 Perth", "Australia/Perth"),
|
||||||
|
MyTimeZone(73, "GMT+08:00 Taipei", "Asia/Taipei"),
|
||||||
|
MyTimeZone(74, "GMT+09:00 Seoul", "Asia/Seoul"),
|
||||||
|
MyTimeZone(75, "GMT+09:00 Tokyo", "Asia/Tokyo"),
|
||||||
|
MyTimeZone(76, "GMT+09:00 Yakutsk", "Asia/Yakutsk"),
|
||||||
|
MyTimeZone(77, "GMT+09:30 Darwin", "Australia/Darwin"),
|
||||||
|
MyTimeZone(78, "GMT+10:00 Brisbane", "Australia/Brisbane"),
|
||||||
|
MyTimeZone(79, "GMT+10:00 Vladivostok", "Asia/Vladivostok"),
|
||||||
|
MyTimeZone(80, "GMT+10:00 Guam", "Pacific/Guam"),
|
||||||
|
MyTimeZone(81, "GMT+10:00 Magadan", "Asia/Magadan"),
|
||||||
|
MyTimeZone(82, "GMT+10:30 Adelaide", "Australia/Adelaide"),
|
||||||
|
MyTimeZone(83, "GMT+11:00 Hobart", "Australia/Hobart"),
|
||||||
|
MyTimeZone(84, "GMT+11:00 Sydney", "Australia/Sydney"),
|
||||||
|
MyTimeZone(85, "GMT+11:00 Noumea", "Pacific/Noumea"),
|
||||||
|
MyTimeZone(86, "GMT+12:00 Majuro", "Pacific/Majuro"),
|
||||||
|
MyTimeZone(87, "GMT+12:00 Fiji", "Pacific/Fiji"),
|
||||||
|
MyTimeZone(88, "GMT+13:00 Auckland", "Pacific/Auckland"),
|
||||||
|
MyTimeZone(89, "GMT+13:00 Tongatapu", "Pacific/Tongatapu")
|
||||||
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.simplemobiletools.clock.fragments.AlarmFragment
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/alarm_fragment"
|
android:id="@+id/alarm_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
</com.simplemobiletools.clock.fragments.AlarmFragment>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.simplemobiletools.clock.fragments.ClockFragment
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
@ -51,4 +51,4 @@
|
|||||||
android:layout_margin="@dimen/activity_margin"
|
android:layout_margin="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_plus"/>
|
android:src="@drawable/ic_plus"/>
|
||||||
|
|
||||||
</com.simplemobiletools.clock.fragments.ClockFragment>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.simplemobiletools.clock.fragments.StopwatchFragment
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/stopwatch_fragment"
|
android:id="@+id/stopwatch_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
</com.simplemobiletools.clock.fragments.StopwatchFragment>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user