using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace Autocomplete
{
public class RightBorderTask
{
public static int GetRightBorderIndex(IReadOnlyList<string> phrases, string prefix, int left, int right)
{
if (phrases.Count == 0)
return 0;
while (left < right)
{
if (left == right - 2)
return left + 1;
var middle = (left + right) / 2;
if (phrases[middle].StartsWith(prefix) || phrases[middle].CompareTo(prefix) < 0)
left = middle;
else
right = middle + 1;
}
return left;
}
}
}
Value="{Binding Source={x:Static sys:WindowState.Minimized}}"
xmlns:sys="clr-namespace:System.Windows;assembly=PresentationFramework"
<style name="DarkAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorGreen</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorPrimaryDark</item>
<item name="android:windowFullscreen">true</item>
</style>
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (state) {
state = false;
fab.setBackgroundResource(R.drawable.ic_wb_sunny_black_24dp);
setTheme(R.style.DarkAppTheme);
} else {
state = true;
fab.setBackgroundResource(R.drawable.ic_wb_sunny_black_24dp);
setTheme(R.style.LightAppTheme);
}
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getTheme();
theme.resolveAttribute(
android.R.attr.windowBackground, typedValue,
true
);
getWindow().getDecorView().setBackgroundColor(typedValue.data);
}
});
}
theme.resolveAttribute(
android.R.attr.windowBackground, typedValue,
true
);