mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 15:27:55 -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() {
|
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() {
|
private void loadPrefs() {
|
||||||
@ -1722,8 +1722,7 @@ public abstract class CoreMainActivity extends BaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHomePage(View view) {
|
public void setHomePage(View view) {
|
||||||
painter.deactivateNightMode(getCurrentWebView());
|
painter.deactivateNightMode(getCurrentWebView(), videoView);
|
||||||
painter.deactivateNightMode(videoView);
|
|
||||||
RecyclerView homeRecyclerView = view.findViewById(R.id.recycler_view);
|
RecyclerView homeRecyclerView = view.findViewById(R.id.recycler_view);
|
||||||
presenter.loadBooks();
|
presenter.loadBooks();
|
||||||
homeRecyclerView.setAdapter(booksAdapter);
|
homeRecyclerView.setAdapter(booksAdapter);
|
||||||
|
@ -36,29 +36,32 @@ class NightModeViewPainter @Inject constructor(
|
|||||||
private val invertedPaint =
|
private val invertedPaint =
|
||||||
Paint().apply { colorFilter = ColorMatrixColorFilter(KiwixWebView.NIGHT_MODE_COLORS) }
|
Paint().apply { colorFilter = ColorMatrixColorFilter(KiwixWebView.NIGHT_MODE_COLORS) }
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
fun <T : View> update(
|
fun <T : View> update(
|
||||||
view: T,
|
view: T,
|
||||||
shouldActivateCriteria: ((T) -> Boolean) = { true },
|
shouldActivateCriteria: ((T) -> Boolean) = { true },
|
||||||
vararg additionalViews: View
|
vararg additionalViews: View = emptyArray()
|
||||||
) {
|
) {
|
||||||
if (nightModeConfig.isNightModeActive()) {
|
if (nightModeConfig.isNightModeActive()) {
|
||||||
if (shouldActivateCriteria(view)) {
|
if (shouldActivateCriteria(view)) {
|
||||||
for (view in additionalViews) {
|
activateNightMode(view, *additionalViews)
|
||||||
activateNightMode(view)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (view in additionalViews) {
|
deactivateNightMode(view, *additionalViews)
|
||||||
deactivateNightMode(view)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deactivateNightMode(view: View) {
|
fun deactivateNightMode(view: View, vararg additionalViews: View) {
|
||||||
view.setLayerType(View.LAYER_TYPE_NONE, null)
|
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)
|
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();
|
notifyDataSetChanged();
|
||||||
});
|
});
|
||||||
if (!webViewTitle.equals(activity.getString(R.string.menu_home))) {
|
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