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>
|
||||
</entry>
|
||||
</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" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -15,7 +15,7 @@ android {
|
||||
applicationId "com.tommasoberlose.anotherwidget"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
versionCode 18
|
||||
versionCode 20
|
||||
versionName "1.2"
|
||||
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)
|
||||
endDate = instanceCursor.getLong(2)
|
||||
|
||||
title = eventCursor.getString(0)
|
||||
title = eventCursor.getString(0)?: ""
|
||||
allDay = !eventCursor.getString(1).equals("0")
|
||||
calendarID = eventCursor.getInt(2)
|
||||
address = eventCursor.getString(3)
|
||||
address = eventCursor.getString(3)?: ""
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
|
@ -51,7 +51,7 @@ class ChooseApplicationActivity : AppCompatActivity() {
|
||||
location.addTextChangedListener(object: TextWatcher {
|
||||
override fun afterTextChanged(text: Editable?) {
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
@ -70,14 +70,18 @@ class CustomLocationActivity : AppCompatActivity() {
|
||||
|
||||
location.addTextChangedListener(object: TextWatcher {
|
||||
override fun afterTextChanged(text: Editable?) {
|
||||
Thread().run {
|
||||
val coder = Geocoder(this@CustomLocationActivity)
|
||||
try {
|
||||
val addresses = coder.getFromLocationName(text.toString(), 10) as ArrayList<Address>
|
||||
EventBus.getDefault().post(CustomLocationEvent(addresses))
|
||||
} catch (ignored: Exception) {
|
||||
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
|
||||
if (text != null && !text.equals("")) {
|
||||
Thread().run {
|
||||
val coder = Geocoder(this@CustomLocationActivity)
|
||||
try {
|
||||
val addresses = coder.getFromLocationName(text.toString(), 10) as ArrayList<Address>
|
||||
EventBus.getDefault().post(CustomLocationEvent(addresses))
|
||||
} catch (ignored: Exception) {
|
||||
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EventBus.getDefault().post(CustomLocationEvent(ArrayList<Address>()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ object CalendarUtil {
|
||||
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),
|
||||
CalendarContract.Events._ID + " is ?",
|
||||
CalendarContract.Events._ID + " = ?",
|
||||
arrayOf(Integer.toString(ID)), null)
|
||||
|
||||
if (eventCursor != null && eventCursor.count > 0) {
|
||||
@ -70,15 +70,15 @@ object CalendarUtil {
|
||||
}
|
||||
eventCursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
eventCursor.close()
|
||||
eventCursor.close()
|
||||
}
|
||||
|
||||
instanceCursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
instanceCursor.close()
|
||||
instanceCursor.close()
|
||||
}
|
||||
|
||||
if (eventList.isEmpty()) {
|
||||
resetNextEventData(context)
|
||||
@ -125,11 +125,11 @@ object CalendarUtil {
|
||||
calendarList.add(CalendarSelector(id, name, account))
|
||||
calendarCursor.moveToNext()
|
||||
}
|
||||
|
||||
calendarCursor.close()
|
||||
} else {
|
||||
Toast.makeText(context, R.string.error_no_calendar, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
calendarCursor.close()
|
||||
} catch (ignored: Exception) {
|
||||
ignored.printStackTrace()
|
||||
try {
|
||||
@ -147,9 +147,9 @@ object CalendarUtil {
|
||||
calendarList.add(CalendarSelector(calendarCursor.getInt(0), calendarCursor.getString(1), calendarCursor.getString(2)))
|
||||
calendarCursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
calendarCursor.close()
|
||||
calendarCursor.close()
|
||||
}
|
||||
} catch (ignore: Exception) {
|
||||
ignore.printStackTrace()
|
||||
} finally {
|
||||
|
@ -86,7 +86,7 @@ object WeatherUtil {
|
||||
}
|
||||
Awareness.getSnapshotClient(context).weather
|
||||
.addOnSuccessListener { weatherResponse ->
|
||||
val weather = weatherResponse.weather
|
||||
val weather: Weather = weatherResponse.weather
|
||||
val SP: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user