18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/speechkit/speaker/Speaker.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.speechkit.speaker;
17 |
18 | public interface Speaker {
19 |
20 | void speak();
21 |
22 | long getMessageId();
23 |
24 | boolean inProgress();
25 |
26 | void cancel();
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/speechkit/speaker/SpeakerListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.speechkit.speaker;
17 |
18 | public interface SpeakerListener {
19 |
20 | void onSpeakerStarted(final long messageId);
21 |
22 | void onSpeakerFinished(final long messageId);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/doc/ru/yandex/subtitles/analytics/impl/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ru.yandex.subtitles.analytics.impl
7 |
8 |
9 |
10 |
11 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/fragment/OnBackKeyEventListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.fragment;
17 |
18 | /**
19 | * Interface indicates classes responsible for handling back pressed event.
20 | */
21 | public interface OnBackKeyEventListener {
22 |
23 | boolean onBackPressed();
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/context_menu_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_appwidget_phrase.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_zoomed_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/widget/microphonebar/MicrophoneBarListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.widget.microphonebar;
17 |
18 | public interface MicrophoneBarListener {
19 |
20 | void onMicrophoneClicked(final MicrophoneBarController controller,
21 | @MicrophoneBarController.State final int state);
22 |
23 | }
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/widget/NoFadeItemAnimator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.widget;
17 |
18 | import android.support.v7.widget.DefaultItemAnimator;
19 |
20 | public class NoFadeItemAnimator extends DefaultItemAnimator {
21 |
22 | public NoFadeItemAnimator() {
23 | super();
24 | setChangeDuration(0L);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_quick_start.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/messaging/ConversationError.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.messaging;
17 |
18 | public class ConversationError {
19 |
20 | public static final int KIND_UNKNOWN = 0;
21 | public static final int KIND_NETWORK = -1;
22 | public static final int KIND_DATABASE = -2;
23 |
24 | private ConversationError() {
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/Subscribeable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content;
17 |
18 | import android.content.Context;
19 |
20 | /**
21 | * Interface defines subscribeable behavior of concrete implementation.
22 | */
23 | public interface Subscribeable {
24 |
25 | void subscribe(final Context context);
26 |
27 | void unsubscribe(final Context context);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/activity/ActivityResultListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.activity;
17 |
18 | import android.content.Intent;
19 |
20 | /**
21 | * Interface to mark any class available to handle result.
22 | */
23 | public interface ActivityResultListener {
24 |
25 | void onActivityResult(final int requestCode, final int resultCode, final Intent data);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/dao/Identify.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content.dao;
17 |
18 | /**
19 | * Interface to any data entity class that can be inserted, updated or deleted
20 | * by using {@link AbstractIdentifyDAO} implementation.
21 | */
22 | public interface Identify {
23 |
24 | /**
25 | * Returns an entity primary key as is.
26 | */
27 | K getId();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/provider/BaseColumns.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content.provider;
17 |
18 | public interface BaseColumns {
19 |
20 | /**
21 | * The unique ID for a row.
22 | *
Type: TEXT
23 | */
24 | String _ID = "_id";
25 |
26 | /**
27 | * The count of rows in a directory.
28 | *
Type: INTEGER
29 | */
30 | String _COUNT = "_count";
31 |
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/speechkit/recognition/RecognitionListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.speechkit.recognition;
17 |
18 | import android.support.annotation.NonNull;
19 |
20 | /**
21 | * A {@link RecognitionClient} callbacks.
22 | */
23 | public interface RecognitionListener {
24 |
25 | void onPhraseRecognized(final long threadId, @NonNull final String phrase);
26 |
27 | void onRecognitionError();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/utils/LocaleUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.utils;
17 |
18 | import android.content.Context;
19 | import android.support.annotation.NonNull;
20 |
21 | import ru.yandex.subtitles.R;
22 |
23 | public final class LocaleUtils {
24 |
25 | @NonNull
26 | public static String getLanguage(final Context context) {
27 | return context.getString(R.string.locale);
28 | }
29 |
30 | private LocaleUtils() {
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/appwidget/PhrasesAppWidgetRemoteService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.appwidget;
17 |
18 | import android.content.Intent;
19 | import android.widget.RemoteViewsService;
20 |
21 | public class PhrasesAppWidgetRemoteService extends RemoteViewsService {
22 |
23 | @Override
24 | public RemoteViewsFactory onGetViewFactory(final Intent intent) {
25 | return new PhrasesRemoteFactory(getApplicationContext(), intent);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pre_lollipop_list_item_background_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/widget/microphonebar/ColorUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.widget.microphonebar;
17 |
18 | import android.graphics.Color;
19 |
20 | public class ColorUtils {
21 |
22 | public static int setAlpha(final int color, final int alpha) {
23 | final int r = Color.red(color);
24 | final int g = Color.green(color);
25 | final int b = Color.blue(color);
26 | return Color.argb(alpha, r, g, b);
27 | }
28 |
29 | private ColorUtils() {
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_navigation_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/doc/ru/yandex/subtitles/service/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ru.yandex.subtitles.service
7 |
8 |
9 |
10 |
11 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/analytics/MessageAnalytics.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.analytics;
17 |
18 | import ru.yandex.subtitles.content.data.Message;
19 |
20 | public class MessageAnalytics {
21 |
22 | private final Message mMessage;
23 | private final boolean mOpeningPhrase;
24 |
25 | public MessageAnalytics(final Message message, final boolean openingPhrase) {
26 | mMessage = message;
27 | mOpeningPhrase = openingPhrase;
28 | }
29 |
30 | public Message getMessage() {
31 | return mMessage;
32 | }
33 |
34 | public boolean isOpeningPhrase() {
35 | return mOpeningPhrase;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/doc/ru/yandex/subtitles/content/provider/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ru.yandex.subtitles.content.provider
7 |
8 |
9 |
10 |
11 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/loader/QuickResponsesLoader.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content.loader;
17 |
18 | import android.content.Context;
19 |
20 | import java.util.List;
21 |
22 | import ru.yandex.subtitles.content.dao.PhrasesDAO;
23 | import ru.yandex.subtitles.content.data.Phrase;
24 |
25 | public class QuickResponsesLoader extends AbstractContentProviderLoader> {
26 |
27 | private final PhrasesDAO mPhrasesDao;
28 |
29 | public QuickResponsesLoader(final Context context) {
30 | super(context, PhrasesDAO.CONTENT_URI);
31 | mPhrasesDao = new PhrasesDAO(context);
32 | }
33 |
34 | @Override
35 | public List loadInBackground() {
36 | return mPhrasesDao.getQuickResponses();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/loader/StartingPhrasesLoader.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content.loader;
17 |
18 | import android.content.Context;
19 |
20 | import java.util.List;
21 |
22 | import ru.yandex.subtitles.content.dao.PhrasesDAO;
23 | import ru.yandex.subtitles.content.data.Phrase;
24 |
25 | public class StartingPhrasesLoader extends AbstractContentProviderLoader> {
26 |
27 | private final PhrasesDAO mPhrasesDao;
28 |
29 | public StartingPhrasesLoader(final Context context) {
30 | super(context, PhrasesDAO.STARTING_PHRASES_CONTENT_URI);
31 | mPhrasesDao = new PhrasesDAO(context);
32 | }
33 |
34 | @Override
35 | public List loadInBackground() {
36 | return mPhrasesDao.getStartingPhrases();
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/cache/PhrasesUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.cache;
17 |
18 | import android.support.annotation.NonNull;
19 |
20 | public class PhrasesUtils {
21 |
22 | public static final String ASSETS_SAMPLES_DIR = "samples";
23 | public static final String SAMPLES_DIR = "samples";
24 |
25 | private static final String SAMPLE_NAME_FORMAT = "%1$s_%2$s_%3$s.%4$s";
26 |
27 | @NonNull
28 | public static String formatFilename(@NonNull final String sample, @NonNull final String locale,
29 | @NonNull final String voice, @NonNull final String extension) {
30 | return String.format(SAMPLE_NAME_FORMAT, sample, locale, voice, extension);
31 | }
32 |
33 | private PhrasesUtils() {
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/doc/ru/yandex/subtitles/ui/fragment/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ru.yandex.subtitles.ui.fragment
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_speaker.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_conversation.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
27 |
28 |
29 |
30 |
31 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/cache/ConnectivityChangeBroadcastReceiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.cache;
17 |
18 | import android.content.BroadcastReceiver;
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.net.ConnectivityManager;
22 |
23 | import ru.yandex.subtitles.service.PhrasesService;
24 | import ru.yandex.subtitles.utils.NetworkUtils;
25 |
26 | public class ConnectivityChangeBroadcastReceiver extends BroadcastReceiver {
27 |
28 | @Override
29 | public void onReceive(final Context context, final Intent intent) {
30 | final String action = (intent != null ? intent.getAction() : null);
31 | if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
32 | if (NetworkUtils.isNetworkConnected(context)) {
33 | PhrasesService.invalidateSamples(context);
34 | }
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/speechkit/speaker/Voice.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.speechkit.speaker;
17 |
18 | import android.support.annotation.NonNull;
19 |
20 | import ru.yandex.speechkit.Vocalizer;
21 |
22 | /**
23 | * Enumeration contains voices which are supported by Yandex.SpeechKit SDK.
24 | */
25 | public enum Voice {
26 |
27 | /**
28 | * SPEAKERS = {'jane': ['evil', 'good', 'neutral'],
29 | * 'ermil': ['neutral'],
30 | * 'zahar': ['neutral'],
31 | * 'omazh': ['evil', 'good', 'neutral']}
32 | */
33 |
34 | JANE(Vocalizer.Voice.JANE),
35 | ERMIL(Vocalizer.Voice.ERMIL),
36 | ZAHAR(Vocalizer.Voice.ZAHAR),
37 | OMAZH(Vocalizer.Voice.OMAZH);
38 |
39 | private String mVoice;
40 |
41 | /* package */ Voice(@NonNull final String voice) {
42 | mVoice = voice;
43 | }
44 |
45 | @NonNull
46 | public String value() {
47 | return mVoice;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/analytics/EventTracker.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.analytics;
17 |
18 | import android.app.Activity;
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 |
22 | import java.util.Map;
23 |
24 | /**
25 | * Implement interface to provide event reporting to any tracking system, like Yandex.Metrica,
26 | * Google Analytics, Fabric, etc.
27 | */
28 | public interface EventTracker {
29 |
30 | /**
31 | * Activate your event tracker implementation with the application context.
32 | *
33 | * @param context an application context
34 | */
35 | void activate(final Context context);
36 |
37 | void onResumeActivity(final Activity activity);
38 |
39 | void onPauseActivity(final Activity activity);
40 |
41 | void reportEvent(@NonNull final String event);
42 |
43 | void reportEvent(@NonNull final String event, @NonNull final Map attrs);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/SubtitlesApplication.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles;
17 |
18 | import android.app.Application;
19 |
20 | import ru.yandex.subtitles.analytics.Analytics;
21 | import ru.yandex.subtitles.service.MessagingService;
22 | import ru.yandex.subtitles.service.PhrasesService;
23 |
24 | public class SubtitlesApplication extends Application {
25 |
26 | @Override
27 | public void onCreate() {
28 | super.onCreate();
29 |
30 | /*
31 | Uncomment the line below to report analytics events. Please also
32 | modify YandexMetricaEventTracker.java to provide your unique Yandex.Metrica API key.
33 | */
34 | // Analytics.addEventTracker(new YandexMetricaEventTracker());
35 | Analytics.initialize(this);
36 |
37 | Preferences.instantiate(this);
38 |
39 | MessagingService.start(this);
40 |
41 | PhrasesService.prepareSamples(this);
42 | PhrasesService.invalidateSamples(this);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/fragment/navigation/MenuItem.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.fragment.navigation;
17 |
18 | import android.support.annotation.DrawableRes;
19 | import android.support.annotation.StringRes;
20 |
21 | public class MenuItem {
22 |
23 | private int mId;
24 | private int mTitleResId;
25 | private int mDrawableResId;
26 |
27 | public MenuItem(final int id, @StringRes final int titleResId) {
28 | this(id, titleResId, 0);
29 | }
30 |
31 | public MenuItem(final int id, @StringRes final int titleResId, @DrawableRes final int drawableResId) {
32 | mId = id;
33 | mTitleResId = titleResId;
34 | mDrawableResId = drawableResId;
35 | }
36 |
37 | public int getId() {
38 | return mId;
39 | }
40 |
41 | @StringRes
42 | public int getTitleResId() {
43 | return mTitleResId;
44 | }
45 |
46 | @DrawableRes
47 | public int getDrawableResId() {
48 | return mDrawableResId;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/fragment/navigation/YandexAppItem.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.fragment.navigation;
17 |
18 | import android.support.annotation.DrawableRes;
19 | import android.support.annotation.StringRes;
20 |
21 | public class YandexAppItem {
22 |
23 | private int mIconResId;
24 | private int mTitleResId;
25 | private int mPackageNameResId;
26 |
27 | public YandexAppItem(@DrawableRes final int iconResId, @StringRes final int titleResId,
28 | @StringRes final int packageNameResId) {
29 | mIconResId = iconResId;
30 | mTitleResId = titleResId;
31 | mPackageNameResId = packageNameResId;
32 | }
33 |
34 | @DrawableRes
35 | public int getIconResId() {
36 | return mIconResId;
37 | }
38 |
39 | @StringRes
40 | public int getTitleResId() {
41 | return mTitleResId;
42 | }
43 |
44 | @StringRes
45 | public int getPackageNameResId() {
46 | return mPackageNameResId;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/widget/PopupMenuItemClickAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.widget;
17 |
18 | import android.support.annotation.NonNull;
19 | import android.support.v7.widget.PopupMenu;
20 | import android.view.MenuItem;
21 |
22 | public class PopupMenuItemClickAdapter implements PopupMenu.OnMenuItemClickListener {
23 |
24 | public interface OnPopupMenuItemClickListener {
25 |
26 | boolean onPopupMenuItemClick(final MenuItem item, final E entity);
27 |
28 | }
29 |
30 | private final E mEntity;
31 | private final OnPopupMenuItemClickListener mListener;
32 |
33 | public PopupMenuItemClickAdapter(@NonNull final E entity,
34 | @NonNull final OnPopupMenuItemClickListener listener) {
35 | mEntity = entity;
36 | mListener = listener;
37 | }
38 |
39 | @Override
40 | public boolean onMenuItemClick(final MenuItem item) {
41 | return mListener.onPopupMenuItemClick(item, mEntity);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/service/cache/SpeechKitTtsCloudApi.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.service.cache;
17 |
18 | import retrofit.client.Response;
19 | import retrofit.http.GET;
20 | import retrofit.http.Query;
21 | import retrofit.http.Streaming;
22 |
23 | public interface SpeechKitTtsCloudApi {
24 |
25 | String TTS_ENDPOINT = "https://tts.voicetech.yandex.net";
26 |
27 | String FORMAT_MP3 = "mp3";
28 | String FORMAT_WAV = "wav";
29 |
30 | /**
31 | * Replace API_KEY with your unique API key. Please, read official documentation how to obtain one:
32 | * https://tech.yandex.ru/speechkit/cloud/
33 | */
34 | String API_KEY = "API_KEY";
35 |
36 | @GET("/generate")
37 | @Streaming
38 | Response generate(@Query("text") final String text,
39 | @Query("format") final String format,
40 | @Query("lang") final String lang,
41 | @Query("speaker") final String speaker,
42 | @Query("key") final String apiKey);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/doc/ru/yandex/subtitles/service/messaging/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ru.yandex.subtitles.service.messaging
7 |
8 |
9 |
10 |
11 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/dao/QueryUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content.dao;
17 |
18 | import android.support.annotation.NonNull;
19 |
20 | public class QueryUtils {
21 |
22 | @NonNull
23 | public static String in(final String column, final int argsNumber) {
24 | return in(column, argsNumber, true);
25 | }
26 |
27 | @NonNull
28 | public static String notIn(final String column, final int argsNumber) {
29 | return in(column, argsNumber, false);
30 | }
31 |
32 | @NonNull
33 | public static String in(final String column, final int argsNumber, final boolean in) {
34 | final StringBuilder inClause = new StringBuilder();
35 |
36 | if (argsNumber > 0) {
37 | inClause.append(column)
38 | .append(in ? " " : " not ")
39 | .append("in (");
40 | for (int i = 0; i < argsNumber; i++) {
41 | if (i > 0) {
42 | inClause.append(", ");
43 | }
44 | inClause.append("?");
45 | }
46 | inClause.append(")");
47 | }
48 |
49 | return inClause.toString();
50 | }
51 |
52 | private QueryUtils() {
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/adapter/ZoomedMessagesAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.adapter;
17 |
18 | import android.support.annotation.NonNull;
19 | import android.support.v4.app.Fragment;
20 | import android.support.v4.app.FragmentManager;
21 |
22 | import ru.yandex.subtitles.analytics.ZoomedMessage;
23 | import ru.yandex.subtitles.ui.fragment.conversations.ZoomedMessageFragment;
24 | import ru.yandex.subtitles.ui.fragment.conversations.ZoomedMessagesFragment;
25 |
26 | public class ZoomedMessagesAdapter extends AbstractFragmentViewPagerAdapter {
27 |
28 | private Fragment mTargetFragment;
29 |
30 | public ZoomedMessagesAdapter(@NonNull final Fragment targetFragment,
31 | @NonNull final FragmentManager fragmentManager) {
32 | super(targetFragment.getActivity(), fragmentManager);
33 | mTargetFragment = targetFragment;
34 | }
35 |
36 | @NonNull
37 | @Override
38 | public Fragment getItem(final int position) {
39 | final Fragment fragment = ZoomedMessageFragment.newInstance(getData(position));
40 | fragment.setTargetFragment(mTargetFragment, ZoomedMessagesFragment.EXIT_FULLSCREEN_REQUEST_CODE);
41 | return fragment;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/content/loader/MessagesLoader.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.content.loader;
17 |
18 | import android.content.Context;
19 | import android.os.Bundle;
20 | import android.support.annotation.NonNull;
21 |
22 | import java.util.List;
23 |
24 | import ru.yandex.subtitles.content.dao.MessagesDAO;
25 | import ru.yandex.subtitles.content.data.Message;
26 |
27 | public class MessagesLoader extends AbstractContentProviderLoader> {
28 |
29 | private static final String EXTRA_THREAD = "thread_id";
30 |
31 | @NonNull
32 | public static Bundle forThreadId(final long threadId) {
33 | final Bundle args = new Bundle();
34 | args.putLong(EXTRA_THREAD, threadId);
35 | return args;
36 | }
37 |
38 | private final MessagesDAO mMessagesDao;
39 | private final long mThreadId;
40 |
41 | public MessagesLoader(final Context context, @NonNull final Bundle args) {
42 | super(context, MessagesDAO.CONTENT_URI);
43 |
44 | mMessagesDao = new MessagesDAO(context);
45 | mThreadId = args.getLong(EXTRA_THREAD);
46 | }
47 |
48 | @Override
49 | public List loadInBackground() {
50 | return mMessagesDao.getAllByThreadId(mThreadId);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/activity/ConversationsActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.activity;
17 |
18 | import android.content.Context;
19 | import android.content.Intent;
20 | import android.os.Bundle;
21 | import android.support.annotation.Nullable;
22 |
23 | import ru.yandex.subtitles.R;
24 | import ru.yandex.subtitles.ui.fragment.conversations.ConversationsFragment;
25 |
26 | public class ConversationsActivity extends AbstractActivity implements ConversationsFragment.OnConversationClickListener {
27 |
28 | public static void start(final Context context) {
29 | final Intent intent = new Intent(context, ConversationsActivity.class);
30 | context.startActivity(intent);
31 | }
32 |
33 | @Override
34 | protected void onCreate(@Nullable final Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_conversations);
37 |
38 | if (savedInstanceState == null) {
39 | showFragmentNoAnimate(ConversationsFragment.newInstance(), ConversationsFragment.TAG);
40 | }
41 | }
42 |
43 | @Override
44 | public void onConversationClick(final long conversationId) {
45 | ConversationActivity.openConversation(this, conversationId);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/doc/ru/yandex/subtitles/ui/widget/microphonebar/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ru.yandex.subtitles.ui.widget.microphonebar
7 |
8 |
9 |
10 |
11 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/yandex/subtitles/ui/adapter/AbstractFragmentViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 YA LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package ru.yandex.subtitles.ui.adapter;
17 |
18 | import android.content.Context;
19 | import android.support.annotation.NonNull;
20 | import android.support.v4.app.FragmentManager;
21 | import android.support.v4.app.FragmentPagerAdapter;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | /**
27 | * Base adapter class that simplifies working with {@link android.support.v4.view.ViewPager}.
28 | */
29 | public abstract class AbstractFragmentViewPagerAdapter extends FragmentPagerAdapter {
30 |
31 | private final Context mContext;
32 | private final List mData = new ArrayList();
33 |
34 | public AbstractFragmentViewPagerAdapter(@NonNull final Context context,
35 | @NonNull final FragmentManager fragmentManager) {
36 | super(fragmentManager);
37 | mContext = context;
38 | }
39 |
40 | @NonNull
41 | public Context getContext() {
42 | return mContext;
43 | }
44 |
45 | public void setData(@NonNull final List data) {
46 | mData.clear();
47 | mData.addAll(data);
48 | notifyDataSetChanged();
49 | }
50 |
51 | public E getData(final int position) {
52 | return mData.get(position);
53 | }
54 |
55 | @Override
56 | public int getCount() {
57 | return mData.size();
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------