convert SimpleActivity to kotlin
This commit is contained in:
parent
54eefcd685
commit
dfa8f739e9
|
@ -1,31 +0,0 @@
|
|||
package com.simplemobiletools.calendar.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.simplemobiletools.calendar.Config;
|
||||
import com.simplemobiletools.calendar.R;
|
||||
|
||||
public class SimpleActivity extends AppCompatActivity {
|
||||
protected Config mConfig;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
mConfig = Config.newInstance(getApplicationContext());
|
||||
setTheme(mConfig.getIsDarkTheme() ? R.style.AppTheme_Dark : R.style.AppTheme);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,7 +46,6 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
|
|||
@BindDimen(R.dimen.day_text_size) float mDayTextSize;
|
||||
@BindDimen(R.dimen.today_text_size) float mTodayTextSize;
|
||||
|
||||
private static CalendarImpl mCalendar;
|
||||
private static Resources mRes;
|
||||
private static String mPackageName;
|
||||
private List<Day> mDays;
|
||||
|
@ -99,8 +98,7 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
|
|||
mBgSeekBar.setProgress((int) (mBgAlpha * 100));
|
||||
updateBgColor();
|
||||
|
||||
mCalendar = new CalendarImpl(this, getApplicationContext());
|
||||
mCalendar.updateCalendar(new DateTime());
|
||||
new CalendarImpl(this, getApplicationContext()).updateCalendar(new DateTime());
|
||||
}
|
||||
|
||||
private SharedPreferences initPrefs(Context context) {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.simplemobiletools.calendar.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
|
||||
import com.simplemobiletools.calendar.Config
|
||||
import com.simplemobiletools.calendar.R
|
||||
|
||||
open class SimpleActivity : AppCompatActivity() {
|
||||
lateinit var mConfig: Config
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mConfig = Config.newInstance(applicationContext)
|
||||
setTheme(if (mConfig.isDarkTheme) R.style.AppTheme_Dark else R.style.AppTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue