(
22 | context = context,
23 | fragmentManager = fragmentManager,
24 | tabs = viewControllers,
25 | defaultTabId = defaultTabId,
26 | contentContainerViewId = contentContainerViewId,
27 | contentContainerLayoutId = contentContainerLayoutId,
28 | wrapWithNavigationContainer = wrapWithNavigationContainer
29 | ) {
30 |
31 | override fun onTabReselected() {
32 | onReselectListener?.invoke()
33 | }
34 |
35 | override fun getNavigationContainerClass() = NavigationContainerFragment::class.java
36 |
37 | override fun isTabClass(tab: NavigationTab, fragment: Fragment?): Boolean =
38 | if (wrapWithNavigationContainer) {
39 | super.isTabClass(tab, fragment)
40 | } else {
41 | (fragment as ViewControllerFragment<*, *>).viewControllerClass === tab.cls
42 | }
43 |
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/logging/src/main/java/ru/touchin/roboswag/core/log/ConsoleLogProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 RoboSwag (Gavriil Sitnikov, Vsevolod Ivanov)
3 | *
4 | * This file is part of RoboSwag library.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | */
19 |
20 | package ru.touchin.roboswag.core.log;
21 |
22 | import androidx.annotation.NonNull;
23 | import androidx.annotation.Nullable;
24 | import android.util.Log;
25 |
26 | /**
27 | * Created by Gavriil Sitnikov on 13/11/2015.
28 | * Simple {@link LogProcessor} implementation which is logging messages to console (logcat).
29 | */
30 | public class ConsoleLogProcessor extends LogProcessor {
31 |
32 | public ConsoleLogProcessor(@NonNull final LcLevel lclevel) {
33 | super(lclevel);
34 | }
35 |
36 | @NonNull
37 | private String normalize(@NonNull final String message) {
38 | return message.replace("\r\n", "\n").replace("\0", "");
39 | }
40 |
41 | @Override
42 | @SuppressWarnings({"WrongConstant", "LogConditional"})
43 | //WrongConstant, LogConditional: level.getPriority() is not wrong constant!
44 | public void processLogMessage(@NonNull final LcGroup group, @NonNull final LcLevel level,
45 | @NonNull final String tag, @NonNull final String message, @Nullable final Throwable throwable) {
46 | final String messageToLog = normalize(message + (throwable != null ? '\n' + Log.getStackTraceString(throwable) : ""));
47 |
48 | Log.println(level.getPriority(), tag, messageToLog);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/recyclerview-calendar/src/main/java/ru/touchin/calendar/CalendarHeaderItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016 RoboSwag (Gavriil Sitnikov, Vsevolod Ivanov)
3 | *
4 | * This file is part of RoboSwag library.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | */
19 |
20 | package ru.touchin.calendar;
21 |
22 | /**
23 | * Created by Ilia Kurtov on 17/03/2016.
24 | * Calendar header item for showing headers for months in calendar.
25 | */
26 | public class CalendarHeaderItem implements CalendarItem {
27 |
28 | private final int year;
29 | private final int month;
30 | private final int startRange;
31 | private final int endRange;
32 |
33 | public CalendarHeaderItem(final int year, final int month, final int startRange, final int endRange) {
34 | this.year = year;
35 | this.month = month;
36 | this.startRange = startRange;
37 | this.endRange = endRange;
38 | }
39 |
40 | /**
41 | * Returns year.
42 | *
43 | * @return year.
44 | */
45 | public int getYear() {
46 | return year;
47 | }
48 |
49 | /**
50 | * Returns number of month (where 0 is January and 11 is December).
51 | *
52 | * @return Number of month (where 0 is January and 11 is December).
53 | */
54 | public int getMonth() {
55 | return month;
56 | }
57 |
58 | @Override
59 | public int getStartRange() {
60 | return startRange;
61 | }
62 |
63 | @Override
64 | public int getEndRange() {
65 | return endRange;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/lifecycle-viewcontroller/src/main/java/ru/touchin/lifecycle_viewcontroller/viewmodel/LifecycleViewModelProviders.kt:
--------------------------------------------------------------------------------
1 | package ru.touchin.lifecycle_viewcontroller.viewmodel
2 |
3 | import androidx.lifecycle.LifecycleOwner
4 | import androidx.lifecycle.ViewModelProvider
5 | import androidx.lifecycle.ViewModelProviders
6 | import ru.touchin.lifecycle.viewmodel.BaseLifecycleViewModelProviders
7 | import ru.touchin.roboswag.navigation_viewcontroller.viewcontrollers.ViewController
8 |
9 | object LifecycleViewModelProviders : BaseLifecycleViewModelProviders() {
10 |
11 | /**
12 | * Creates a {@link ViewModelProvider}, which retains ViewModels while a scope of given
13 | * {@code lifecycleOwner} is alive. More detailed explanation is in {@link ViewModel}.
14 | *
15 | * It uses the given {@link Factory} to instantiate new ViewModels.
16 | *
17 | * @param lifecycleOwner a lifecycle owner, in whose scope ViewModels should be retained (ViewController, Fragment, Activity)
18 | * @param factory a {@code Factory} to instantiate new ViewModels
19 | * @return a ViewModelProvider instance
20 | */
21 | override fun of(
22 | lifecycleOwner: LifecycleOwner,
23 | factory: ViewModelProvider.Factory
24 | ): ViewModelProvider =
25 | when (lifecycleOwner) {
26 | is ViewController<*, *> -> ViewModelProviders.of(lifecycleOwner.fragment, factory)
27 | else -> super.of(lifecycleOwner, factory)
28 | }
29 |
30 | /**
31 | * Returns ViewModelProvider.Factory instance from current lifecycleOwner.
32 | * Search #ViewModelFactoryProvider are produced according to priorities:
33 | * 1. View controller;
34 | * 2. Fragment;
35 | * 3. Parent fragment recursively;
36 | * 4. Activity;
37 | * 5. Application.
38 | */
39 | override fun getViewModelFactory(provider: Any): ViewModelProvider.Factory =
40 | when (provider) {
41 | is ViewController<*, *> -> getViewModelFactory(provider.fragment)
42 | else -> super.getViewModelFactory(provider)
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------