mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Use jvmOverloads to make multiple function declarations
This commit is contained in:
parent
0d8ca9f8b8
commit
d4b4f3fecd
@ -1549,7 +1549,7 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
}
|
||||
|
||||
private void updateNightMode() {
|
||||
painter.update(getCurrentWebView(), kiwixWebView -> !(kiwixWebView.getUrl() != null && kiwixWebView.getUrl().equals(HOME_URL)), videoView, getCurrentWebView());
|
||||
painter.update(getCurrentWebView(), kiwixWebView -> !(kiwixWebView.getUrl() != null && kiwixWebView.getUrl().equals(HOME_URL)), videoView);
|
||||
}
|
||||
|
||||
private void loadPrefs() {
|
||||
@ -1722,8 +1722,7 @@ public abstract class CoreMainActivity extends BaseActivity
|
||||
|
||||
@Override
|
||||
public void setHomePage(View view) {
|
||||
painter.deactivateNightMode(getCurrentWebView());
|
||||
painter.deactivateNightMode(videoView);
|
||||
painter.deactivateNightMode(getCurrentWebView(), videoView);
|
||||
RecyclerView homeRecyclerView = view.findViewById(R.id.recycler_view);
|
||||
presenter.loadBooks();
|
||||
homeRecyclerView.setAdapter(booksAdapter);
|
||||
|
@ -36,29 +36,32 @@ class NightModeViewPainter @Inject constructor(
|
||||
private val invertedPaint =
|
||||
Paint().apply { colorFilter = ColorMatrixColorFilter(KiwixWebView.NIGHT_MODE_COLORS) }
|
||||
|
||||
@JvmOverloads
|
||||
fun <T : View> update(
|
||||
view: T,
|
||||
shouldActivateCriteria: ((T) -> Boolean) = { true },
|
||||
vararg additionalViews: View
|
||||
vararg additionalViews: View = emptyArray()
|
||||
) {
|
||||
if (nightModeConfig.isNightModeActive()) {
|
||||
if (shouldActivateCriteria(view)) {
|
||||
for (view in additionalViews) {
|
||||
activateNightMode(view)
|
||||
}
|
||||
activateNightMode(view, *additionalViews)
|
||||
}
|
||||
} else {
|
||||
for (view in additionalViews) {
|
||||
deactivateNightMode(view)
|
||||
}
|
||||
deactivateNightMode(view, *additionalViews)
|
||||
}
|
||||
}
|
||||
|
||||
fun deactivateNightMode(view: View) {
|
||||
fun deactivateNightMode(view: View, vararg additionalViews: View) {
|
||||
view.setLayerType(View.LAYER_TYPE_NONE, null)
|
||||
for (v in additionalViews) {
|
||||
v.setLayerType(View.LAYER_TYPE_NONE, null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun activateNightMode(view: View) {
|
||||
private fun activateNightMode(view: View, vararg additionalViews: View) {
|
||||
view.setLayerType(View.LAYER_TYPE_HARDWARE, invertedPaint)
|
||||
for (v in additionalViews) {
|
||||
v.setLayerType(View.LAYER_TYPE_HARDWARE, invertedPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class TabsAdapter extends RecyclerView.Adapter<TabsAdapter.ViewHolder> {
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
if (!webViewTitle.equals(activity.getString(R.string.menu_home))) {
|
||||
painter.update(holder.content, imageView -> true, holder.content);
|
||||
painter.update(holder.content);//, imageView -> true, holder.content);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user