Fix Custom Location bug
This commit is contained in:
parent
a97aa24ff7
commit
c8dd8f711e
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -80,7 +80,7 @@
|
|||||||
</profile-state>
|
</profile-state>
|
||||||
</entry>
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -15,7 +15,7 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 18
|
versionCode 20
|
||||||
versionName "1.2"
|
versionName "1.2"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":18},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":20},"path":"app-release.apk","properties":{"packageId":"com.tommasoberlose.anotherwidget","split":"","minSdkVersion":"19"}}]
|
@ -32,10 +32,10 @@ class Event {
|
|||||||
startDate = instanceCursor.getLong(1)
|
startDate = instanceCursor.getLong(1)
|
||||||
endDate = instanceCursor.getLong(2)
|
endDate = instanceCursor.getLong(2)
|
||||||
|
|
||||||
title = eventCursor.getString(0)
|
title = eventCursor.getString(0)?: ""
|
||||||
allDay = !eventCursor.getString(1).equals("0")
|
allDay = !eventCursor.getString(1).equals("0")
|
||||||
calendarID = eventCursor.getInt(2)
|
calendarID = eventCursor.getInt(2)
|
||||||
address = eventCursor.getString(3)
|
address = eventCursor.getString(3)?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
@ -51,7 +51,7 @@ class ChooseApplicationActivity : AppCompatActivity() {
|
|||||||
location.addTextChangedListener(object: TextWatcher {
|
location.addTextChangedListener(object: TextWatcher {
|
||||||
override fun afterTextChanged(text: Editable?) {
|
override fun afterTextChanged(text: Editable?) {
|
||||||
Thread().run {
|
Thread().run {
|
||||||
val appsFiltered = appList.filter { pm.getApplicationLabel(it).toString().contains(text.toString(), true) }
|
val appsFiltered = if (text == null || text.equals("")) appList else appList.filter { pm.getApplicationLabel(it).toString().contains(text.toString(), true) }
|
||||||
EventBus.getDefault().post(ApplicationListEvent(appsFiltered, true))
|
EventBus.getDefault().post(ApplicationListEvent(appsFiltered, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ class CustomLocationActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
location.addTextChangedListener(object: TextWatcher {
|
location.addTextChangedListener(object: TextWatcher {
|
||||||
override fun afterTextChanged(text: Editable?) {
|
override fun afterTextChanged(text: Editable?) {
|
||||||
|
if (text != null && !text.equals("")) {
|
||||||
Thread().run {
|
Thread().run {
|
||||||
val coder = Geocoder(this@CustomLocationActivity)
|
val coder = Geocoder(this@CustomLocationActivity)
|
||||||
try {
|
try {
|
||||||
@ -79,6 +80,9 @@ class CustomLocationActivity : AppCompatActivity() {
|
|||||||
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
|
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||||
|
@ -56,7 +56,7 @@ object CalendarUtil {
|
|||||||
val ID = instanceCursor.getInt(0)
|
val ID = instanceCursor.getInt(0)
|
||||||
|
|
||||||
val eventCursor = context.contentResolver.query(CalendarContract.Events.CONTENT_URI, arrayOf(CalendarContract.Events.TITLE, CalendarContract.Events.ALL_DAY, CalendarContract.Events.CALENDAR_ID, CalendarContract.Events.EVENT_LOCATION),
|
val eventCursor = context.contentResolver.query(CalendarContract.Events.CONTENT_URI, arrayOf(CalendarContract.Events.TITLE, CalendarContract.Events.ALL_DAY, CalendarContract.Events.CALENDAR_ID, CalendarContract.Events.EVENT_LOCATION),
|
||||||
CalendarContract.Events._ID + " is ?",
|
CalendarContract.Events._ID + " = ?",
|
||||||
arrayOf(Integer.toString(ID)), null)
|
arrayOf(Integer.toString(ID)), null)
|
||||||
|
|
||||||
if (eventCursor != null && eventCursor.count > 0) {
|
if (eventCursor != null && eventCursor.count > 0) {
|
||||||
@ -70,15 +70,15 @@ object CalendarUtil {
|
|||||||
}
|
}
|
||||||
eventCursor.moveToNext()
|
eventCursor.moveToNext()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
eventCursor.close()
|
eventCursor.close()
|
||||||
|
}
|
||||||
|
|
||||||
instanceCursor.moveToNext()
|
instanceCursor.moveToNext()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
instanceCursor.close()
|
instanceCursor.close()
|
||||||
|
}
|
||||||
|
|
||||||
if (eventList.isEmpty()) {
|
if (eventList.isEmpty()) {
|
||||||
resetNextEventData(context)
|
resetNextEventData(context)
|
||||||
@ -125,11 +125,11 @@ object CalendarUtil {
|
|||||||
calendarList.add(CalendarSelector(id, name, account))
|
calendarList.add(CalendarSelector(id, name, account))
|
||||||
calendarCursor.moveToNext()
|
calendarCursor.moveToNext()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calendarCursor.close()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, R.string.error_no_calendar, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, R.string.error_no_calendar, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
calendarCursor.close()
|
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
ignored.printStackTrace()
|
ignored.printStackTrace()
|
||||||
try {
|
try {
|
||||||
@ -147,9 +147,9 @@ object CalendarUtil {
|
|||||||
calendarList.add(CalendarSelector(calendarCursor.getInt(0), calendarCursor.getString(1), calendarCursor.getString(2)))
|
calendarList.add(CalendarSelector(calendarCursor.getInt(0), calendarCursor.getString(1), calendarCursor.getString(2)))
|
||||||
calendarCursor.moveToNext()
|
calendarCursor.moveToNext()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
calendarCursor.close()
|
calendarCursor.close()
|
||||||
|
}
|
||||||
} catch (ignore: Exception) {
|
} catch (ignore: Exception) {
|
||||||
ignore.printStackTrace()
|
ignore.printStackTrace()
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -86,7 +86,7 @@ object WeatherUtil {
|
|||||||
}
|
}
|
||||||
Awareness.getSnapshotClient(context).weather
|
Awareness.getSnapshotClient(context).weather
|
||||||
.addOnSuccessListener { weatherResponse ->
|
.addOnSuccessListener { weatherResponse ->
|
||||||
val weather = weatherResponse.weather
|
val weather: Weather = weatherResponse.weather
|
||||||
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
SP.edit()
|
SP.edit()
|
||||||
.putFloat(Constants.PREF_WEATHER_TEMP, weather.getTemperature(if (SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F").equals("F")) Weather.FAHRENHEIT else Weather.CELSIUS))
|
.putFloat(Constants.PREF_WEATHER_TEMP, weather.getTemperature(if (SP.getString(Constants.PREF_WEATHER_TEMP_UNIT, "F").equals("F")) Weather.FAHRENHEIT else Weather.CELSIUS))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user