Upgraded butterknife to 8.8.1 (#524)

Refactored MusicListFragment and PVRListFragment to use AbstractTabsFragment
Fixed scrolling in a nested scroll view using espresso
Fixed issue with setting and checking Kodi major version
This commit is contained in:
Martijn Brekhof 2018-04-05 19:22:20 +02:00 committed by Synced Synapse
parent 2f2791a795
commit 2ed968456a
39 changed files with 558 additions and 337 deletions

View File

@ -119,7 +119,8 @@ dependencies {
compile "com.android.support:design:${supportLibVersion}" compile "com.android.support:design:${supportLibVersion}"
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.2' compile 'com.fasterxml.jackson.core:jackson-databind:2.5.2'
compile 'com.jakewharton:butterknife:6.1.0' compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.squareup.okhttp:okhttp:2.3.0' compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.greenrobot:eventbus:2.4.0' compile 'de.greenrobot:eventbus:2.4.0'

View File

@ -20,8 +20,8 @@
# Butterknife # Butterknife
-dontwarn butterknife.internal.** -dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; } -keep class **$$ViewBinder { *; }
-keepnames class * { @butterknife.InjectView *;} -keepnames class * { @butterknife.BindView *;}
# Jackson # Jackson
-dontskipnonpubliclibraryclassmembers -dontskipnonpubliclibraryclassmembers

View File

@ -0,0 +1,78 @@
/*
* Copyright 2018 Martijn Brekhof. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xbmc.kore.testhelpers.action;
import android.graphics.Rect;
import android.support.test.espresso.PerformException;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.espresso.util.HumanReadables;
import android.support.v4.widget.NestedScrollView;
import android.view.View;
import org.hamcrest.Matcher;
import org.xbmc.kore.utils.LogUtils;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast;
import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;
import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
/**
* Modified version of {@link android.support.test.espresso.action.ScrollToAction} to support
* NestedScrollView.
* TODO Check future versions of {@link android.support.test.espresso.action.ScrollToAction} to see if support for NestedScrollView has been added
*/
public class NestedScrollTo implements ViewAction {
private final static String TAG = LogUtils.makeLogTag(NestedScrollTo.class);
@Override
public Matcher<View> getConstraints() {
return allOf(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE), isDescendantOfA(anyOf(
isAssignableFrom(NestedScrollView.class))));
}
@Override
public String getDescription() {
return "nested scroll to";
}
@Override
public void perform(UiController uiController, View view) {
if (isDisplayingAtLeast(90).matches(view)) {
LogUtils.LOGI(TAG, "View is already displayed. Returning.");
return;
}
Rect rect = new Rect();
view.getDrawingRect(rect);
if (!view.requestRectangleOnScreen(rect, true /* immediate */)) {
LogUtils.LOGW(TAG, "Scrolling to view was requested, but none of the parents scrolled.");
}
uiController.loopMainThreadUntilIdle();
if (!isDisplayingAtLeast(90).matches(view)) {
throw new PerformException.Builder()
.withActionDescription(this.getDescription())
.withViewDescription(HumanReadables.describe(view))
.withCause(new RuntimeException(
"Scrolling to view was attempted, but the view is not displayed"))
.build();
}
}
}

View File

@ -22,6 +22,7 @@ import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction; import android.support.test.espresso.ViewAction;
import android.support.test.espresso.action.MotionEvents; import android.support.test.espresso.action.MotionEvents;
import android.support.test.espresso.action.Press; import android.support.test.espresso.action.Press;
import android.support.test.espresso.action.ScrollToAction;
import android.support.test.espresso.util.HumanReadables; import android.support.test.espresso.util.HumanReadables;
import android.support.test.espresso.util.TreeIterables; import android.support.test.espresso.util.TreeIterables;
import android.view.View; import android.view.View;
@ -50,6 +51,19 @@ public final class ViewActions {
return actionWithAssertions(new ClearFocus()); return actionWithAssertions(new ClearFocus());
} }
/**
* Returns an action that scrolls to the view in a nested scroll view.<br>
* <br>
* View preconditions:
* <ul>
* <li>must be a descendant of NestedScrollView
* <li>must have visibility set to View.VISIBLE
* <ul></ul>
*/
public static ViewAction nestedScrollTo() {
return actionWithAssertions(new NestedScrollTo());
}
public interface CheckStatus { public interface CheckStatus {
boolean check(View v); boolean check(View v);
} }

View File

@ -76,7 +76,7 @@ abstract public class AbstractTestClass<T extends AppCompatActivity> {
private static PlayerHandler playerHandler; private static PlayerHandler playerHandler;
private static ApplicationHandler applicationHandler; private static ApplicationHandler applicationHandler;
private static InputHandler inputHandler; private static InputHandler inputHandler;
private int kodiMajorVersion = HostInfo.DEFAULT_KODI_VERSION_MAJOR;
private HostInfo hostInfo; private HostInfo hostInfo;
@BeforeClass @BeforeClass
@ -120,7 +120,7 @@ abstract public class AbstractTestClass<T extends AppCompatActivity> {
hostInfo = Database.addHost(context, server.getHostName(), hostInfo = Database.addHost(context, server.getHostName(),
HostConnection.PROTOCOL_TCP, HostInfo.DEFAULT_HTTP_PORT, HostConnection.PROTOCOL_TCP, HostInfo.DEFAULT_HTTP_PORT,
server.getPort(), useEventServer); server.getPort(), useEventServer, kodiMajorVersion);
//Allow each test to change the host info //Allow each test to change the host info
configureHostInfo(hostInfo); configureHostInfo(hostInfo);
@ -164,6 +164,17 @@ abstract public class AbstractTestClass<T extends AppCompatActivity> {
return null; return null;
} }
/**
* Use this to set the major version of Kodi.
* <br/>
* NOTE: be sure to call this before {@link #setUp()} is called to have the version correctly
* set in the database.
* @param kodiMajorVersion
*/
protected void setKodiMajorVersion(int kodiMajorVersion) {
this.kodiMajorVersion = kodiMajorVersion;
}
public static PlayerHandler getPlayerHandler() { public static PlayerHandler getPlayerHandler() {
return playerHandler; return playerHandler;
} }

View File

@ -18,6 +18,7 @@ package org.xbmc.kore.tests.ui.music;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.SystemClock;
import android.support.test.espresso.Espresso; import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule; import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4;
@ -180,6 +181,7 @@ public class RestoreSearchQueryViewPagerTest extends AbstractTestClass<MusicActi
clickAlbumsTab(); clickAlbumsTab();
EspressoTestUtils.rotateDevice(activity); EspressoTestUtils.rotateDevice(activity);
EspressoTestUtils.clickMenuItem(activity, activity.getString(R.string.action_search), R.id.action_search); EspressoTestUtils.clickMenuItem(activity, activity.getString(R.string.action_search), R.id.action_search);
Espresso.closeSoftKeyboard();
EspressoTestUtils.checkTextInSearchQuery(""); EspressoTestUtils.checkTextInSearchQuery("");
EspressoTestUtils.checkListMatchesSearchQuery("", ALBUM_COMPLETE_LIST_SIZE, R.id.list); EspressoTestUtils.checkListMatchesSearchQuery("", ALBUM_COMPLETE_LIST_SIZE, R.id.list);

View File

@ -64,7 +64,7 @@ public class ButtonTests extends AbstractTestClass<RemoteActivity> {
@Override @Override
protected void configureHostInfo(HostInfo hostInfo) { protected void configureHostInfo(HostInfo hostInfo) {
hostInfo.setKodiVersionMajor(17);
} }
@BeforeClass @BeforeClass
@ -74,6 +74,12 @@ public class ButtonTests extends AbstractTestClass<RemoteActivity> {
mockEventServer.start(); mockEventServer.start();
} }
@Override
public void setUp() throws Throwable {
setKodiMajorVersion(HostInfo.KODI_V17_KRYPTON);
super.setUp();
}
@After @After
public void resetState() { public void resetState() {
mockEventServer.reset(); mockEventServer.reset();

View File

@ -69,6 +69,12 @@ public class KodiPreV17Tests extends AbstractTestClass<RemoteActivity> {
mockEventServer.start(); mockEventServer.start();
} }
@Override
public void setUp() throws Throwable {
setKodiMajorVersion(HostInfo.KODI_V16_JARVIS);
super.setUp();
}
@After @After
public void resetState() { public void resetState() {
mockEventServer.reset(); mockEventServer.reset();

View File

@ -55,6 +55,12 @@ public class ButtonTests extends AbstractTestClass<RemoteActivity> {
hostInfo.setKodiVersionMajor(17); hostInfo.setKodiVersionMajor(17);
} }
@Override
public void setUp() throws Throwable {
setKodiMajorVersion(HostInfo.KODI_V17_KRYPTON);
super.setUp();
}
@Test @Test
public void leftControlPadButtonTest() throws InterruptedException { public void leftControlPadButtonTest() throws InterruptedException {
onView(withId(R.id.left)).perform(click()); onView(withId(R.id.left)).perform(click());

View File

@ -53,6 +53,12 @@ public class KodiPreV17Tests extends AbstractTestClass<RemoteActivity> {
hostInfo.setKodiVersionMajor(16); hostInfo.setKodiVersionMajor(16);
} }
@Override
public void setUp() throws Throwable {
setKodiMajorVersion(HostInfo.KODI_V16_JARVIS);
super.setUp();
}
@Test @Test
public void infoControlPadButtonLongClickTest() throws InterruptedException { public void infoControlPadButtonLongClickTest() throws InterruptedException {
onView(withId(R.id.info)).perform(longClick()); onView(withId(R.id.info)).perform(longClick());

View File

@ -28,13 +28,13 @@ import org.xbmc.kore.ui.sections.video.TVShowsActivity;
import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.scrollTo;
import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent; import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText; import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.xbmc.kore.testhelpers.action.ViewActions.nestedScrollTo;
public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity> { public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity> {
@ -79,7 +79,7 @@ public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity
@Test @Test
public void setActionBarTitleOnNextEpisode() { public void setActionBarTitleOnNextEpisode() {
EspressoTestUtils.clickAdapterViewItem(1, R.id.list); EspressoTestUtils.clickAdapterViewItem(1, R.id.list);
onView( withId(R.id.next_episode_list)).perform( scrollTo(), click()); onView( withId(R.id.next_episode_list)).perform( nestedScrollTo(), click());
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar)))) onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
.check(matches(withText("3"))); .check(matches(withText("3")));
@ -96,7 +96,7 @@ public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity
@Test @Test
public void setActionBarTitleOnSeasonList() { public void setActionBarTitleOnSeasonList() {
EspressoTestUtils.clickAdapterViewItem(0, R.id.list); EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
onView( withId(R.id.seasons_list)).perform( scrollTo(), click()); onView( withId(R.id.seasons_list)).perform( nestedScrollTo(), click());
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar)))) onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
.check(matches(withText("Season 01"))); .check(matches(withText("Season 01")));
@ -114,7 +114,7 @@ public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity
@Test @Test
public void setActionBarTitleOnSeasonListEpisode() { public void setActionBarTitleOnSeasonListEpisode() {
EspressoTestUtils.clickAdapterViewItem(0, R.id.list); EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
onView( withId(R.id.seasons_list)).perform( scrollTo(), click()); onView( withId(R.id.seasons_list)).perform( nestedScrollTo(), click());
EspressoTestUtils.selectListItemAndCheckActionbarTitle(0, R.id.list, "11.22.63"); EspressoTestUtils.selectListItemAndCheckActionbarTitle(0, R.id.list, "11.22.63");
} }
@ -145,7 +145,7 @@ public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity
@Test @Test
public void restoreActionBarTitleSeasonListOnConfigurationStateChanged() { public void restoreActionBarTitleSeasonListOnConfigurationStateChanged() {
EspressoTestUtils.clickAdapterViewItem(0, R.id.list); EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
onView( withId(R.id.seasons_list)).perform( scrollTo(), click()); onView( withId(R.id.seasons_list)).perform( nestedScrollTo(), click());
EspressoTestUtils.rotateDevice(mActivityRule.getActivity()); EspressoTestUtils.rotateDevice(mActivityRule.getActivity());
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar)))) onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
@ -165,7 +165,7 @@ public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity
@Test @Test
public void restoreActionBarTitleSeasonListEpisodeOnConfigurationStateChanged() { public void restoreActionBarTitleSeasonListEpisodeOnConfigurationStateChanged() {
EspressoTestUtils.clickAdapterViewItem(0, R.id.list); EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
onView( withId(R.id.seasons_list)).perform( scrollTo(), click()); onView( withId(R.id.seasons_list)).perform( nestedScrollTo(), click());
EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list, EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
"11.22.63", "11.22.63",
mActivityRule.getActivity()); mActivityRule.getActivity());
@ -183,7 +183,7 @@ public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity
@Test @Test
public void restoreActionBarTitleNextEpisodeOnConfigurationStateChanged() { public void restoreActionBarTitleNextEpisodeOnConfigurationStateChanged() {
EspressoTestUtils.clickAdapterViewItem(1, R.id.list); EspressoTestUtils.clickAdapterViewItem(1, R.id.list);
onView( withId(R.id.next_episode_list)).perform( scrollTo() ); onView( withId(R.id.next_episode_list)).perform( nestedScrollTo() );
onView( withText("You'll See the Sparkle")).perform( click() ); onView( withText("You'll See the Sparkle")).perform( click() );
EspressoTestUtils.rotateDevice(mActivityRule.getActivity()); EspressoTestUtils.rotateDevice(mActivityRule.getActivity());

View File

@ -300,11 +300,11 @@ public class HostInfo {
} }
public boolean isGothamOrLater() { public boolean isGothamOrLater() {
return kodiVersionMajor > KODI_V13_GOTHAM; return kodiVersionMajor >= KODI_V13_GOTHAM;
} }
public boolean isKryptonOrLater() { public boolean isKryptonOrLater() {
return kodiVersionMajor > KODI_V17_KRYPTON; return kodiVersionMajor >= KODI_V17_KRYPTON;
} }
/** /**

View File

@ -70,7 +70,8 @@ import java.util.Locale;
import at.blogc.android.views.ExpandableTextView; import at.blogc.android.views.ExpandableTextView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
import static android.view.View.GONE; import static android.view.View.GONE;
@ -83,29 +84,29 @@ abstract public class AbstractInfoFragment extends AbstractFragment
private static final String BUNDLE_KEY_APIMETHOD_PENDING = "pending_apimethod"; private static final String BUNDLE_KEY_APIMETHOD_PENDING = "pending_apimethod";
// Detail views // Detail views
@InjectView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout;
@InjectView(R.id.media_panel) NestedScrollView panelScrollView; @BindView(R.id.media_panel) NestedScrollView panelScrollView;
@InjectView(R.id.art) ImageView artImageView; @BindView(R.id.art) ImageView artImageView;
@InjectView(R.id.poster) ImageView posterImageView; @BindView(R.id.poster) ImageView posterImageView;
@InjectView(R.id.media_title) TextView titleTextView; @BindView(R.id.media_title) TextView titleTextView;
@InjectView(R.id.media_undertitle) TextView underTitleTextView; @BindView(R.id.media_undertitle) TextView underTitleTextView;
@InjectView(R.id.rating_container) LinearLayout ratingContainer; @BindView(R.id.rating_container) LinearLayout ratingContainer;
@InjectView(R.id.rating) TextView ratingTextView; @BindView(R.id.rating) TextView ratingTextView;
@InjectView(R.id.rating_votes) TextView ratingVotesTextView; @BindView(R.id.rating_votes) TextView ratingVotesTextView;
@InjectView(R.id.max_rating) TextView maxRatingTextView; @BindView(R.id.max_rating) TextView maxRatingTextView;
@InjectView(R.id.media_details_right) TextView detailsRightTextView; @BindView(R.id.media_details_right) TextView detailsRightTextView;
@InjectView(R.id.media_details) LinearLayout mediaDetailsContainer; @BindView(R.id.media_details) LinearLayout mediaDetailsContainer;
@InjectView(R.id.media_action_download) ImageButton downloadButton; @BindView(R.id.media_action_download) ImageButton downloadButton;
@InjectView(R.id.media_action_pin_unpin) ImageButton pinUnpinButton; @BindView(R.id.media_action_pin_unpin) ImageButton pinUnpinButton;
@InjectView(R.id.media_action_add_to_playlist) ImageButton addToPlaylistButton; @BindView(R.id.media_action_add_to_playlist) ImageButton addToPlaylistButton;
@InjectView(R.id.media_action_seen) ImageButton seenButton; @BindView(R.id.media_action_seen) ImageButton seenButton;
@InjectView(R.id.media_action_go_to_imdb) ImageButton imdbButton; @BindView(R.id.media_action_go_to_imdb) ImageButton imdbButton;
@InjectView(R.id.media_actions_bar) LinearLayout mediaActionsBar; @BindView(R.id.media_actions_bar) LinearLayout mediaActionsBar;
@InjectView(R.id.media_description) ExpandableTextView descriptionExpandableTextView; @BindView(R.id.media_description) ExpandableTextView descriptionExpandableTextView;
@InjectView(R.id.media_description_container) LinearLayout descriptionContainer; @BindView(R.id.media_description_container) LinearLayout descriptionContainer;
@InjectView(R.id.show_all) ImageView expansionImage; @BindView(R.id.show_all) ImageView expansionImage;
@InjectView(R.id.fab) FABSpeedDial fabButton; @BindView(R.id.fab) FABSpeedDial fabButton;
@InjectView(R.id.exit_transition_view) View exitTransitionView; @BindView(R.id.exit_transition_view) View exitTransitionView;
private HostManager hostManager; private HostManager hostManager;
private HostInfo hostInfo; private HostInfo hostInfo;
@ -113,6 +114,7 @@ abstract public class AbstractInfoFragment extends AbstractFragment
private RefreshItem refreshItem; private RefreshItem refreshItem;
private boolean expandDescription; private boolean expandDescription;
private int methodId; private int methodId;
private Unbinder unbinder;
/** /**
* Handler on which to post RPC callbacks * Handler on which to post RPC callbacks
@ -146,7 +148,7 @@ abstract public class AbstractInfoFragment extends AbstractFragment
} }
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_info, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_info, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
Resources resources = getActivity().getResources(); Resources resources = getActivity().getResources();
@ -244,6 +246,12 @@ abstract public class AbstractInfoFragment extends AbstractFragment
SyncUtils.disconnectFromLibrarySyncService(getActivity(), serviceConnection); SyncUtils.disconnectFromLibrarySyncService(getActivity(), serviceConnection);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);

View File

@ -41,7 +41,8 @@ import org.xbmc.kore.utils.LogUtils;
import org.xbmc.kore.utils.Utils; import org.xbmc.kore.utils.Utils;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
public abstract class AbstractListFragment extends Fragment implements public abstract class AbstractListFragment extends Fragment implements
SwipeRefreshLayout.OnRefreshListener { SwipeRefreshLayout.OnRefreshListener {
@ -51,10 +52,11 @@ public abstract class AbstractListFragment extends Fragment implements
private final String BUNDLE_SAVEDINSTANCE_LISTPOSITION = "lposition"; private final String BUNDLE_SAVEDINSTANCE_LISTPOSITION = "lposition";
private boolean gridViewUsesMultipleColumns; private boolean gridViewUsesMultipleColumns;
private Unbinder unbinder;
protected @InjectView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout; protected @BindView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout;
@InjectView(R.id.list) GridView gridView; @BindView(R.id.list) GridView gridView;
@InjectView(android.R.id.empty) TextView emptyView; @BindView(android.R.id.empty) TextView emptyView;
abstract protected AdapterView.OnItemClickListener createOnItemClickListener(); abstract protected AdapterView.OnItemClickListener createOnItemClickListener();
abstract protected BaseAdapter createAdapter(); abstract protected BaseAdapter createAdapter();
@ -70,7 +72,7 @@ public abstract class AbstractListFragment extends Fragment implements
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setOnRefreshListener(this);
@ -113,6 +115,12 @@ public abstract class AbstractListFragment extends Fragment implements
return root; return root;
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);

View File

@ -31,15 +31,18 @@ import org.xbmc.kore.utils.SharedElementTransition;
import org.xbmc.kore.utils.TabsAdapter; import org.xbmc.kore.utils.TabsAdapter;
import org.xbmc.kore.utils.UIUtils; import org.xbmc.kore.utils.UIUtils;
import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.Unbinder;
abstract public class AbstractTabsFragment extends AbstractFragment abstract public class AbstractTabsFragment extends AbstractFragment
implements SharedElementTransition.SharedElement { implements SharedElementTransition.SharedElement {
private static final String TAG = LogUtils.makeLogTag(AbstractTabsFragment.class); private static final String TAG = LogUtils.makeLogTag(AbstractTabsFragment.class);
@InjectView(R.id.pager_tab_strip) PagerSlidingTabStrip pagerTabStrip; @BindView(R.id.pager_tab_strip) PagerSlidingTabStrip pagerTabStrip;
@InjectView(R.id.pager) ViewPager viewPager; @BindView(R.id.pager) ViewPager viewPager;
private Unbinder unbinder;
/** /**
* Use {@link #setDataHolder(AbstractInfoFragment.DataHolder)} to provide the required info * Use {@link #setDataHolder(AbstractInfoFragment.DataHolder)} to provide the required info
@ -58,7 +61,7 @@ abstract public class AbstractTabsFragment extends AbstractFragment
} }
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_default_view_pager, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_default_view_pager, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
viewPager.setAdapter(createTabsAdapter(getDataHolder())); viewPager.setAdapter(createTabsAdapter(getDataHolder()));
pagerTabStrip.setViewPager(viewPager); pagerTabStrip.setViewPager(viewPager);
@ -72,6 +75,12 @@ abstract public class AbstractTabsFragment extends AbstractFragment
setHasOptionsMenu(false); setHasOptionsMenu(false);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override @Override
public boolean isSharedElementVisible() { public boolean isSharedElementVisible() {
View view = getView(); View view = getView();
@ -92,6 +101,10 @@ abstract public class AbstractTabsFragment extends AbstractFragment
return false; return false;
} }
protected ViewPager getViewPager() {
return viewPager;
}
/** /**
* Called to get the TabsAdapter that should be connected to the ViewPager * Called to get the TabsAdapter that should be connected to the ViewPager
* @param dataHolder the data passed to the *DetailsFragment * @param dataHolder the data passed to the *DetailsFragment

View File

@ -59,7 +59,7 @@ import org.xbmc.kore.utils.UIUtils;
import org.xbmc.kore.utils.Utils; import org.xbmc.kore.utils.Utils;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
public abstract class BaseMediaActivity extends BaseActivity public abstract class BaseMediaActivity extends BaseActivity
implements HostConnectionObserver.ApplicationEventsObserver, implements HostConnectionObserver.ApplicationEventsObserver,
@ -71,7 +71,7 @@ public abstract class BaseMediaActivity extends BaseActivity
private static final String NAVICON_ISARROW = "navstate"; private static final String NAVICON_ISARROW = "navstate";
private static final String ACTIONBAR_TITLE = "actionbartitle"; private static final String ACTIONBAR_TITLE = "actionbartitle";
@InjectView(R.id.now_playing_panel) NowPlayingPanel nowPlayingPanel; @BindView(R.id.now_playing_panel) NowPlayingPanel nowPlayingPanel;
private NavigationDrawerFragment navigationDrawerFragment; private NavigationDrawerFragment navigationDrawerFragment;
private SharedElementTransition sharedElementTransition = new SharedElementTransition(); private SharedElementTransition sharedElementTransition = new SharedElementTransition();
@ -111,7 +111,7 @@ public abstract class BaseMediaActivity extends BaseActivity
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_generic_media); setContentView(R.layout.activity_generic_media);
ButterKnife.inject(this); ButterKnife.bind(this);
// Set up the drawer. // Set up the drawer.
navigationDrawerFragment = (NavigationDrawerFragment)getSupportFragmentManager() navigationDrawerFragment = (NavigationDrawerFragment)getSupportFragmentManager()

View File

@ -26,7 +26,8 @@ import org.xbmc.kore.ui.widgets.VolumeLevelIndicator;
import org.xbmc.kore.utils.LogUtils; import org.xbmc.kore.utils.LogUtils;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragment public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragment
implements HostConnectionObserver.ApplicationEventsObserver, implements HostConnectionObserver.ApplicationEventsObserver,
@ -35,13 +36,11 @@ public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragm
private static final String TAG = LogUtils.makeLogTag(VolumeControllerDialogFragmentListener.class); private static final String TAG = LogUtils.makeLogTag(VolumeControllerDialogFragmentListener.class);
private static final int AUTO_DISMISS_DELAY = 2000; private static final int AUTO_DISMISS_DELAY = 2000;
@InjectView(R.id.npp_volume_mute) @BindView(R.id.npp_volume_mute) HighlightButton volumeMuteButton;
HighlightButton volumeMuteButton; @BindView(R.id.npp_volume_muted_indicator) HighlightButton volumeMutedIndicatorButton;
@InjectView(R.id.npp_volume_muted_indicator) @BindView(R.id.npp_volume_level_indicator) VolumeLevelIndicator volumeLevelIndicator;
HighlightButton volumeMutedIndicatorButton;
@InjectView(R.id.npp_volume_level_indicator)
VolumeLevelIndicator volumeLevelIndicator;
private Unbinder unbinder;
private Handler callbackHandler = new Handler(); private Handler callbackHandler = new Handler();
private HostManager hostManager = null; private HostManager hostManager = null;
private ApiCallback<Integer> defaultIntActionCallback = ApiMethod.getDefaultActionCallback(); private ApiCallback<Integer> defaultIntActionCallback = ApiMethod.getDefaultActionCallback();
@ -100,7 +99,7 @@ public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragm
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.volume_controller_dialog, container, false); View rootView = inflater.inflate(R.layout.volume_controller_dialog, container, false);
ButterKnife.inject(this, rootView); unbinder = ButterKnife.bind(this, rootView);
return rootView; return rootView;
} }
@ -123,6 +122,12 @@ public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragm
delayedDismissDialog(); delayedDismissDialog();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
private void registerObserver() { private void registerObserver() {
HostConnectionObserver hostConnectionObserver = hostManager.getHostConnectionObserver(); HostConnectionObserver hostConnectionObserver = hostManager.getHostConnectionObserver();
if (hostConnectionObserver == null) { if (hostConnectionObserver == null) {

View File

@ -26,43 +26,32 @@ import com.astuetz.PagerSlidingTabStrip;
import org.xbmc.kore.R; import org.xbmc.kore.R;
import org.xbmc.kore.ui.AbstractCursorListFragment; import org.xbmc.kore.ui.AbstractCursorListFragment;
import org.xbmc.kore.ui.AbstractFragment;
import org.xbmc.kore.ui.AbstractTabsFragment;
import org.xbmc.kore.utils.LogUtils; import org.xbmc.kore.utils.LogUtils;
import org.xbmc.kore.utils.TabsAdapter; import org.xbmc.kore.utils.TabsAdapter;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
/** /**
* Container for the various music lists * Container for the various music lists
*/ */
public class MusicListFragment extends Fragment { public class MusicListFragment extends AbstractTabsFragment {
private static final String TAG = LogUtils.makeLogTag(MusicListFragment.class); private static final String TAG = LogUtils.makeLogTag(MusicListFragment.class);
private TabsAdapter tabsAdapter;
private int currentItem; private int currentItem;
private TabsAdapter tabsAdapter;
@InjectView(R.id.pager_tab_strip) PagerSlidingTabStrip pagerTabStrip;
@InjectView(R.id.pager) ViewPager viewPager;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_default_view_pager, container, false); View view = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.inject(this, root); if (view == null)
return view;
tabsAdapter = new TabsAdapter(getActivity(), getChildFragmentManager()) currentItem = getViewPager().getCurrentItem();
.addTab(ArtistListFragment.class, getArguments(), R.string.artists, 1)
.addTab(AlbumListFragment.class, getArguments(), R.string.albums, 2)
.addTab(AudioGenresListFragment.class, getArguments(), R.string.genres, 3)
.addTab(SongsListFragment.class, getArguments(), R.string.songs, 4)
.addTab(MusicVideoListFragment.class, getArguments(), R.string.music_videos, 5);
viewPager.setAdapter(tabsAdapter); getViewPager().addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
pagerTabStrip.setViewPager(viewPager);
currentItem = viewPager.getCurrentItem();
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@ -75,14 +64,15 @@ public class MusicListFragment extends Fragment {
if (f != null) { if (f != null) {
f.saveSearchState(); f.saveSearchState();
} }
currentItem = viewPager.getCurrentItem(); currentItem = getViewPager().getCurrentItem();
} }
@Override @Override
public void onPageScrollStateChanged(int state) { public void onPageScrollStateChanged(int state) {
} }
}); });
return root;
return view;
} }
@Override @Override
@ -90,4 +80,15 @@ public class MusicListFragment extends Fragment {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(false); setHasOptionsMenu(false);
} }
@Override
protected TabsAdapter createTabsAdapter(DataHolder dataHolder) {
tabsAdapter = new TabsAdapter(getActivity(), getChildFragmentManager())
.addTab(ArtistListFragment.class, getArguments(), R.string.artists, 1)
.addTab(AlbumListFragment.class, getArguments(), R.string.albums, 2)
.addTab(AudioGenresListFragment.class, getArguments(), R.string.genres, 3)
.addTab(SongsListFragment.class, getArguments(), R.string.songs, 4)
.addTab(MusicVideoListFragment.class, getArguments(), R.string.music_videos, 5);
return tabsAdapter;
}
} }

View File

@ -17,54 +17,31 @@ package org.xbmc.kore.ui.sections.file;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.astuetz.PagerSlidingTabStrip;
import org.xbmc.kore.R; import org.xbmc.kore.R;
import org.xbmc.kore.jsonrpc.method.Files; import org.xbmc.kore.jsonrpc.method.Files;
import org.xbmc.kore.ui.AbstractTabsFragment;
import org.xbmc.kore.ui.OnBackPressedListener; import org.xbmc.kore.ui.OnBackPressedListener;
import org.xbmc.kore.utils.TabsAdapter; import org.xbmc.kore.utils.TabsAdapter;
import butterknife.ButterKnife;
import butterknife.InjectView;
/** /**
* Manages the viewpager of files * Manages the viewpager of files
*/ */
public class FileListFragment extends Fragment public class FileListFragment extends AbstractTabsFragment
implements OnBackPressedListener { implements OnBackPressedListener {
@InjectView(R.id.pager_tab_strip) PagerSlidingTabStrip pagerTabStrip;
@InjectView(R.id.pager) ViewPager viewPager;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { protected TabsAdapter createTabsAdapter(DataHolder dataHolder) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_media_list, container, false);
ButterKnife.inject(this, root);
Bundle videoFileListArgs = new Bundle(); Bundle videoFileListArgs = new Bundle();
videoFileListArgs.putString(MediaFileListFragment.MEDIA_TYPE, Files.Media.VIDEO); videoFileListArgs.putString(MediaFileListFragment.MEDIA_TYPE, Files.Media.VIDEO);
Bundle musicFileListArgs = new Bundle(); Bundle musicFileListArgs = new Bundle();
musicFileListArgs.putString(MediaFileListFragment.MEDIA_TYPE, Files.Media.MUSIC); musicFileListArgs.putString(MediaFileListFragment.MEDIA_TYPE, Files.Media.MUSIC);
Bundle pictureFileListArgs = new Bundle(); Bundle pictureFileListArgs = new Bundle();
pictureFileListArgs.putString(MediaFileListFragment.MEDIA_TYPE, Files.Media.PICTURES); pictureFileListArgs.putString(MediaFileListFragment.MEDIA_TYPE, Files.Media.PICTURES);
TabsAdapter tabsAdapter = new TabsAdapter(getActivity(), getChildFragmentManager()) return new TabsAdapter(getActivity(), getChildFragmentManager())
.addTab(MediaFileListFragment.class, videoFileListArgs, R.string.video, 1) .addTab(MediaFileListFragment.class, videoFileListArgs, R.string.video, 1)
.addTab(MediaFileListFragment.class, musicFileListArgs, R.string.music, 2) .addTab(MediaFileListFragment.class, musicFileListArgs, R.string.music, 2)
.addTab(MediaFileListFragment.class, pictureFileListArgs, R.string.pictures, 3); .addTab(MediaFileListFragment.class, pictureFileListArgs, R.string.pictures, 3);
viewPager.setAdapter(tabsAdapter);
pagerTabStrip.setViewPager(viewPager);
return root;
}
@Override
public void onActivityCreated (Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(false);
} }
@Override @Override
@ -81,8 +58,8 @@ public class FileListFragment extends Fragment
@Override @Override
public boolean onBackPressed() { public boolean onBackPressed() {
// Tell current fragment to move up one directory, if possible // Tell current fragment to move up one directory, if possible
MediaFileListFragment curPage = (MediaFileListFragment)((TabsAdapter)viewPager.getAdapter()) MediaFileListFragment curPage = (MediaFileListFragment)((TabsAdapter)getViewPager().getAdapter())
.getStoredFragment(viewPager.getCurrentItem()); .getStoredFragment(getViewPager().getCurrentItem());
if ((curPage != null) && !curPage.atRootDirectory()) { if ((curPage != null) && !curPage.atRootDirectory()) {
curPage.onBackPressed(); curPage.onBackPressed();
return true; return true;

View File

@ -50,7 +50,8 @@ import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo; import javax.jmdns.ServiceInfo;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* Fragment that searchs foor XBMCs using Zeroconf * Fragment that searchs foor XBMCs using Zeroconf
@ -75,19 +76,20 @@ public class AddHostFragmentZeroconf extends Fragment {
} }
private AddHostZeroconfListener listener; private AddHostZeroconfListener listener;
private Unbinder unbinder;
@InjectView(R.id.search_host_title) TextView titleTextView; @BindView(R.id.search_host_title) TextView titleTextView;
@InjectView(R.id.search_host_message) TextView messageTextView; @BindView(R.id.search_host_message) TextView messageTextView;
@InjectView(R.id.next) Button nextButton; @BindView(R.id.next) Button nextButton;
@InjectView(R.id.previous) Button previousButton; @BindView(R.id.previous) Button previousButton;
@InjectView(R.id.progress_bar) ProgressBar progressBar; @BindView(R.id.progress_bar) ProgressBar progressBar;
@InjectView(R.id.list) GridView hostListGridView; @BindView(R.id.list) GridView hostListGridView;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_add_host_zeroconf, container, false); View root = inflater.inflate(R.layout.fragment_add_host_zeroconf, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
return root; return root;
} }
@ -112,6 +114,12 @@ public class AddHostFragmentZeroconf extends Fragment {
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
// Whether the user cancelled the search // Whether the user cancelled the search
private boolean searchCancelled = false; private boolean searchCancelled = false;
private final Object lock = new Object(); private final Object lock = new Object();

View File

@ -47,7 +47,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* Fragment that presents the welcome message * Fragment that presents the welcome message
@ -84,18 +85,19 @@ public class HostFragmentManualConfiguration extends Fragment {
public static String CANCEL_BUTTON_LABEL_ARG = PREFIX + ".cancel_button_label"; public static String CANCEL_BUTTON_LABEL_ARG = PREFIX + ".cancel_button_label";
private HostManualConfigurationListener listener; private HostManualConfigurationListener listener;
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private Unbinder unbinder;
@InjectView(R.id.xbmc_name) EditText xbmcNameEditText; @BindView(R.id.xbmc_name) EditText xbmcNameEditText;
@InjectView(R.id.xbmc_ip_address) EditText xbmcIpAddressEditText; @BindView(R.id.xbmc_ip_address) EditText xbmcIpAddressEditText;
@InjectView(R.id.xbmc_http_port) EditText xbmcHttpPortEditText; @BindView(R.id.xbmc_http_port) EditText xbmcHttpPortEditText;
@InjectView(R.id.xbmc_tcp_port) EditText xbmcTcpPortEditText; @BindView(R.id.xbmc_tcp_port) EditText xbmcTcpPortEditText;
@InjectView(R.id.xbmc_username) EditText xbmcUsernameEditText; @BindView(R.id.xbmc_username) EditText xbmcUsernameEditText;
@InjectView(R.id.xbmc_password) EditText xbmcPasswordEditText; @BindView(R.id.xbmc_password) EditText xbmcPasswordEditText;
@InjectView(R.id.xbmc_mac_address) EditText xbmcMacAddressEditText; @BindView(R.id.xbmc_mac_address) EditText xbmcMacAddressEditText;
@InjectView(R.id.xbmc_wol_port) EditText xbmcWolPortEditText; @BindView(R.id.xbmc_wol_port) EditText xbmcWolPortEditText;
@InjectView(R.id.xbmc_use_tcp) CheckBox xbmcUseTcpCheckbox; @BindView(R.id.xbmc_use_tcp) CheckBox xbmcUseTcpCheckbox;
@InjectView(R.id.xbmc_use_event_server) CheckBox xbmcUseEventServerCheckbox; @BindView(R.id.xbmc_use_event_server) CheckBox xbmcUseEventServerCheckbox;
@InjectView(R.id.xbmc_event_server_port) EditText xbmcEventServerPortEditText; @BindView(R.id.xbmc_event_server_port) EditText xbmcEventServerPortEditText;
// Handler for callbacks // Handler for callbacks
final Handler handler = new Handler(); final Handler handler = new Handler();
@ -103,7 +105,7 @@ public class HostFragmentManualConfiguration extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_add_host_manual_configuration, container, false); View root = inflater.inflate(R.layout.fragment_add_host_manual_configuration, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
// By default, use TCP // By default, use TCP
xbmcUseTcpCheckbox.setChecked(true); xbmcUseTcpCheckbox.setChecked(true);
@ -215,6 +217,12 @@ public class HostFragmentManualConfiguration extends Fragment {
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
private static boolean isValidPort(int port) { private static boolean isValidPort(int port) {
return port > 0 && port <= 65535; return port > 0 && port <= 65535;
} }

View File

@ -53,8 +53,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.Unbinder;
/** /**
* Fragment to manage the list oof registered hosts. * Fragment to manage the list oof registered hosts.
@ -65,11 +66,11 @@ public class HostListFragment extends Fragment {
private ArrayList<HostInfoRow> hostInfoRows = new ArrayList<HostInfoRow>(); private ArrayList<HostInfoRow> hostInfoRows = new ArrayList<HostInfoRow>();
private HostListAdapter adapter = null; private HostListAdapter adapter = null;
private Context context; private Context context;
private Unbinder unbinder;
private Handler callbackHandler = new Handler(); private Handler callbackHandler = new Handler();
@InjectView(R.id.list) GridView hostGridView; @BindView(R.id.list) GridView hostGridView;
@InjectView(R.id.action_add_host) Button addHostButton; @BindView(R.id.action_add_host) Button addHostButton;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -81,7 +82,7 @@ public class HostListFragment extends Fragment {
context = inflater.getContext(); context = inflater.getContext();
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_host_list, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_host_list, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
// Get the host list // Get the host list
// TODO: This is being done synchronously !!! // TODO: This is being done synchronously !!!
@ -160,6 +161,12 @@ public class HostListFragment extends Fragment {
super.onPause(); super.onPause();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/** /**
* Pings the host to checks it status. * Pings the host to checks it status.
* <br/> * <br/>

View File

@ -66,8 +66,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.Unbinder;
/** /**
* Now playing view * Now playing view
@ -128,39 +129,41 @@ public class NowPlayingFragment extends Fragment
private ApiCallback<Integer> defaultIntActionCallback = ApiMethod.getDefaultActionCallback(); private ApiCallback<Integer> defaultIntActionCallback = ApiMethod.getDefaultActionCallback();
private ApiCallback<Boolean> defaultBooleanActionCallback = ApiMethod.getDefaultActionCallback(); private ApiCallback<Boolean> defaultBooleanActionCallback = ApiMethod.getDefaultActionCallback();
private Unbinder unbinder;
/** /**
* Injectable views * Injectable views
*/ */
@InjectView(R.id.play) ImageButton playButton; @BindView(R.id.play) ImageButton playButton;
@InjectView(R.id.volume_mute) HighlightButton volumeMuteButton; @BindView(R.id.volume_mute) HighlightButton volumeMuteButton;
@InjectView(R.id.shuffle) HighlightButton shuffleButton; @BindView(R.id.shuffle) HighlightButton shuffleButton;
@InjectView(R.id.repeat) RepeatModeButton repeatButton; @BindView(R.id.repeat) RepeatModeButton repeatButton;
@InjectView(R.id.overflow) ImageButton overflowButton; @BindView(R.id.overflow) ImageButton overflowButton;
@InjectView(R.id.info_panel) RelativeLayout infoPanel; @BindView(R.id.info_panel) RelativeLayout infoPanel;
@InjectView(R.id.media_panel) ScrollView mediaPanel; @BindView(R.id.media_panel) ScrollView mediaPanel;
@InjectView(R.id.info_title) TextView infoTitle; @BindView(R.id.info_title) TextView infoTitle;
@InjectView(R.id.info_message) TextView infoMessage; @BindView(R.id.info_message) TextView infoMessage;
@InjectView(R.id.art) ImageView mediaArt; @BindView(R.id.art) ImageView mediaArt;
@InjectView(R.id.poster) ImageView mediaPoster; @BindView(R.id.poster) ImageView mediaPoster;
@InjectView(R.id.media_title) TextView mediaTitle; @BindView(R.id.media_title) TextView mediaTitle;
@InjectView(R.id.media_undertitle) TextView mediaUndertitle; @BindView(R.id.media_undertitle) TextView mediaUndertitle;
@InjectView(R.id.progress_info) MediaProgressIndicator mediaProgressIndicator; @BindView(R.id.progress_info) MediaProgressIndicator mediaProgressIndicator;
@InjectView(R.id.volume_level_indicator) VolumeLevelIndicator volumeLevelIndicator; @BindView(R.id.volume_level_indicator) VolumeLevelIndicator volumeLevelIndicator;
@InjectView(R.id.rating) TextView mediaRating; @BindView(R.id.rating) TextView mediaRating;
@InjectView(R.id.max_rating) TextView mediaMaxRating; @BindView(R.id.max_rating) TextView mediaMaxRating;
@InjectView(R.id.year) TextView mediaYear; @BindView(R.id.year) TextView mediaYear;
@InjectView(R.id.genres) TextView mediaGenreSeason; @BindView(R.id.genres) TextView mediaGenreSeason;
@InjectView(R.id.rating_votes) TextView mediaRatingVotes; @BindView(R.id.rating_votes) TextView mediaRatingVotes;
@InjectView(R.id.media_description) TextView mediaDescription; @BindView(R.id.media_description) TextView mediaDescription;
@InjectView(R.id.cast_list) GridLayout videoCastList; @BindView(R.id.cast_list) GridLayout videoCastList;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
@ -183,7 +186,7 @@ public class NowPlayingFragment extends Fragment
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_now_playing, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_now_playing, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
volumeLevelIndicator.setOnVolumeChangeListener(new VolumeLevelIndicator.OnVolumeChangeListener() { volumeLevelIndicator.setOnVolumeChangeListener(new VolumeLevelIndicator.OnVolumeChangeListener() {
@Override @Override
@ -244,6 +247,12 @@ public class NowPlayingFragment extends Fragment
hostConnectionObserver.unregisterApplicationObserver(this); hostConnectionObserver.unregisterApplicationObserver(this);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/** /**
* Default callback for methods that don't return anything * Default callback for methods that don't return anything
*/ */

View File

@ -57,7 +57,8 @@ import org.xbmc.kore.utils.Utils;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* Playlist view * Playlist view
@ -96,14 +97,16 @@ public class PlaylistFragment extends Fragment
*/ */
private PlayListAdapter playListAdapter; private PlayListAdapter playListAdapter;
private Unbinder unbinder;
/** /**
* Injectable views * Injectable views
*/ */
@InjectView(R.id.info_panel) RelativeLayout infoPanel; @BindView(R.id.info_panel) RelativeLayout infoPanel;
@InjectView(R.id.playlist) DynamicListView playlistListView; @BindView(R.id.playlist) DynamicListView playlistListView;
@InjectView(R.id.info_title) TextView infoTitle; @BindView(R.id.info_title) TextView infoTitle;
@InjectView(R.id.info_message) TextView infoMessage; @BindView(R.id.info_message) TextView infoMessage;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -115,7 +118,7 @@ public class PlaylistFragment extends Fragment
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_playlist, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_playlist, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
playListAdapter = new PlayListAdapter(); playListAdapter = new PlayListAdapter();
playlistListView.setAdapter(playListAdapter); playlistListView.setAdapter(playListAdapter);
@ -157,6 +160,12 @@ public class PlaylistFragment extends Fragment
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {

View File

@ -53,9 +53,9 @@ import org.xbmc.kore.service.ConnectionObserversManagerService;
import org.xbmc.kore.ui.BaseActivity; import org.xbmc.kore.ui.BaseActivity;
import org.xbmc.kore.ui.generic.NavigationDrawerFragment; import org.xbmc.kore.ui.generic.NavigationDrawerFragment;
import org.xbmc.kore.ui.generic.SendTextDialogFragment; import org.xbmc.kore.ui.generic.SendTextDialogFragment;
import org.xbmc.kore.ui.generic.VolumeControllerDialogFragmentListener;
import org.xbmc.kore.ui.sections.hosts.AddHostActivity; import org.xbmc.kore.ui.sections.hosts.AddHostActivity;
import org.xbmc.kore.ui.views.CirclePageIndicator; import org.xbmc.kore.ui.views.CirclePageIndicator;
import org.xbmc.kore.ui.generic.VolumeControllerDialogFragmentListener;
import org.xbmc.kore.utils.LogUtils; import org.xbmc.kore.utils.LogUtils;
import org.xbmc.kore.utils.TabsAdapter; import org.xbmc.kore.utils.TabsAdapter;
import org.xbmc.kore.utils.UIUtils; import org.xbmc.kore.utils.UIUtils;
@ -69,8 +69,8 @@ import java.util.concurrent.Future;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView;
public class RemoteActivity extends BaseActivity public class RemoteActivity extends BaseActivity
@ -100,10 +100,10 @@ public class RemoteActivity extends BaseActivity
private Future<Void> awaitingShare; private Future<Void> awaitingShare;
@InjectView(R.id.background_image) ImageView backgroundImage; @BindView(R.id.background_image) ImageView backgroundImage;
@InjectView(R.id.pager_indicator) CirclePageIndicator pageIndicator; @BindView(R.id.pager_indicator) CirclePageIndicator pageIndicator;
@InjectView(R.id.pager) ViewPager viewPager; @BindView(R.id.pager) ViewPager viewPager;
@InjectView(R.id.default_toolbar) Toolbar toolbar; @BindView(R.id.default_toolbar) Toolbar toolbar;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -113,7 +113,7 @@ public class RemoteActivity extends BaseActivity
PreferenceManager.setDefaultValues(this, R.xml.preferences, false); PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
setContentView(R.layout.activity_remote); setContentView(R.layout.activity_remote);
ButterKnife.inject(this); ButterKnife.bind(this);
hostManager = HostManager.getInstance(this); hostManager = HostManager.getInstance(this);

View File

@ -19,6 +19,7 @@ import android.content.res.TypedArray;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -56,9 +57,10 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.Optional; import butterknife.Optional;
import butterknife.Unbinder;
/** /**
* Remote view * Remote view
@ -119,38 +121,38 @@ public class RemoteFragment extends Fragment
private final ApiMethod<String> contextButtonAction = new Input.ExecuteAction(Input.ExecuteAction.CONTEXTMENU); private final ApiMethod<String> contextButtonAction = new Input.ExecuteAction(Input.ExecuteAction.CONTEXTMENU);
private final ApiMethod<String> osdButtonAction = new Input.ExecuteAction(Input.ExecuteAction.OSD); private final ApiMethod<String> osdButtonAction = new Input.ExecuteAction(Input.ExecuteAction.OSD);
@InjectView(R.id.info_panel) RelativeLayout infoPanel; @BindView(R.id.info_panel) RelativeLayout infoPanel;
@InjectView(R.id.media_panel) RelativeLayout mediaPanel; @BindView(R.id.media_panel) RelativeLayout mediaPanel;
@InjectView(R.id.remote) ControlPad controlPad; @BindView(R.id.remote) ControlPad controlPad;
@InjectView(R.id.info_title) TextView infoTitle; @BindView(R.id.info_title) TextView infoTitle;
@InjectView(R.id.info_message) TextView infoMessage; @BindView(R.id.info_message) TextView infoMessage;
@InjectView(R.id.button_bar) LinearLayout buttonBarPanel; @BindView(R.id.button_bar) LinearLayout buttonBarPanel;
/** /**
* Buttons * Buttons
*/ */
@Optional @InjectView(R.id.home) ImageButton homeButton; @Nullable @BindView(R.id.home) ImageButton homeButton;
@Optional @InjectView(R.id.movies) ImageButton moviesButton; @Nullable @BindView(R.id.movies) ImageButton moviesButton;
@Optional @InjectView(R.id.tv_shows) ImageButton tvShowsButton; @Nullable @BindView(R.id.tv_shows) ImageButton tvShowsButton;
@Optional @InjectView(R.id.music) ImageButton musicButton; @Nullable @BindView(R.id.music) ImageButton musicButton;
@Optional @InjectView(R.id.pvr) ImageButton pvrButton; @Nullable @BindView(R.id.pvr) ImageButton pvrButton;
@Optional @InjectView(R.id.pictures) ImageButton picturesButton; @Nullable @BindView(R.id.pictures) ImageButton picturesButton;
@Optional @InjectView(R.id.videos) ImageButton videosButton; @Nullable @BindView(R.id.videos) ImageButton videosButton;
//@Optional @InjectView(R.id.favourites) ImageButton favouritesButton; //@Nullable @BindView(R.id.favourites) ImageButton favouritesButton;
@Optional @InjectView(R.id.addons) ImageButton addonsButton; @Nullable @BindView(R.id.addons) ImageButton addonsButton;
@Optional @InjectView(R.id.weather) ImageButton weatherButton; @Nullable @BindView(R.id.weather) ImageButton weatherButton;
@Optional @InjectView(R.id.system) ImageButton systemButton; @Nullable @BindView(R.id.system) ImageButton systemButton;
@InjectView(R.id.art) ImageView thumbnail; @BindView(R.id.art) ImageView thumbnail;
@InjectView(R.id.title) TextView nowPlayingTitle; @BindView(R.id.title) TextView nowPlayingTitle;
@InjectView(R.id.details) TextView nowPlayingDetails; @BindView(R.id.details) TextView nowPlayingDetails;
@InjectView(R.id.play) ImageButton playButton; @BindView(R.id.play) ImageButton playButton;
@InjectView(R.id.stop) ImageButton stopButton; @BindView(R.id.stop) ImageButton stopButton;
@InjectView(R.id.rewind) ImageButton rewindButton; @BindView(R.id.rewind) ImageButton rewindButton;
@InjectView(R.id.fast_forward) ImageButton fastForwardButton; @BindView(R.id.fast_forward) ImageButton fastForwardButton;
// EventServer connection // EventServer connection
private EventServerConnection eventServerConnection = null; private EventServerConnection eventServerConnection = null;
@ -158,6 +160,8 @@ public class RemoteFragment extends Fragment
// Icons for fastForward/Rewind or skipPrevious/skipNext // Icons for fastForward/Rewind or skipPrevious/skipNext
int fastForwardIcon, rewindIcon, skipPreviousIcon, skipNextIcon; int fastForwardIcon, rewindIcon, skipPreviousIcon, skipNextIcon;
private Unbinder unbinder;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -171,7 +175,7 @@ public class RemoteFragment extends Fragment
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_remote, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_remote, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
controlPad.setOnPadButtonsListener(this); controlPad.setOnPadButtonsListener(this);
@ -229,6 +233,12 @@ public class RemoteFragment extends Fragment
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/** /**
* Creates a new EventServerConnection if using the event server * Creates a new EventServerConnection if using the event server
* is enabled in the preferences. * is enabled in the preferences.

View File

@ -46,7 +46,7 @@ import org.xbmc.kore.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
/** /**
* Activity that presents all cast of a movie or TV Show * Activity that presents all cast of a movie or TV Show
@ -65,8 +65,8 @@ public class AllCastActivity extends BaseActivity {
NavigationDrawerFragment navigationDrawerFragment; NavigationDrawerFragment navigationDrawerFragment;
@InjectView(R.id.cast_list) GridView castGridView; @BindView(R.id.cast_list) GridView castGridView;
@InjectView(android.R.id.empty) TextView emptyView; @BindView(android.R.id.empty) TextView emptyView;
/** /**
* Returns an intent that can be used to start this activity, with all the correct parameters * Returns an intent that can be used to start this activity, with all the correct parameters
@ -87,7 +87,7 @@ public class AllCastActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_cast); setContentView(R.layout.activity_all_cast);
ButterKnife.inject(this); ButterKnife.bind(this);
// Set up the drawer. // Set up the drawer.
navigationDrawerFragment = (NavigationDrawerFragment)getSupportFragmentManager() navigationDrawerFragment = (NavigationDrawerFragment)getSupportFragmentManager()

View File

@ -43,7 +43,8 @@ import java.util.Date;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* Fragment that presents the Guide for a channel * Fragment that presents the Guide for a channel
@ -55,9 +56,9 @@ public class PVRChannelEPGListFragment extends Fragment
private HostManager hostManager; private HostManager hostManager;
private int channelId; private int channelId;
@InjectView(R.id.list) ListView listView; @BindView(R.id.list) ListView listView;
@InjectView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout;
@InjectView(android.R.id.empty) TextView emptyView; @BindView(android.R.id.empty) TextView emptyView;
/** /**
* Handler on which to post RPC callbacks * Handler on which to post RPC callbacks
@ -68,6 +69,8 @@ public class PVRChannelEPGListFragment extends Fragment
private static final String BUNDLE_KEY_CHANNELID = "bundle_key_channelid"; private static final String BUNDLE_KEY_CHANNELID = "bundle_key_channelid";
private Unbinder unbinder;
/** /**
* Create a new instance of this, initialized to show the current channel * Create a new instance of this, initialized to show the current channel
*/ */
@ -88,7 +91,7 @@ public class PVRChannelEPGListFragment extends Fragment
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_list, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_list, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
Bundle bundle = getArguments(); Bundle bundle = getArguments();
channelId = bundle.getInt(BUNDLE_KEY_CHANNELID, -1); channelId = bundle.getInt(BUNDLE_KEY_CHANNELID, -1);
@ -120,6 +123,12 @@ public class PVRChannelEPGListFragment extends Fragment
browseEPG(); browseEPG();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/** /**
* Swipe refresh layout callback * Swipe refresh layout callback
*/ */

View File

@ -48,7 +48,8 @@ import org.xbmc.kore.utils.UIUtils;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* Fragment that presents the movie list * Fragment that presents the movie list
@ -70,9 +71,9 @@ public class PVRChannelsListFragment extends Fragment
private HostManager hostManager; private HostManager hostManager;
@InjectView(R.id.list) GridView gridView; @BindView(R.id.list) GridView gridView;
@InjectView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout;
@InjectView(android.R.id.empty) TextView emptyView; @BindView(android.R.id.empty) TextView emptyView;
/** /**
* Handler on which to post RPC callbacks * Handler on which to post RPC callbacks
@ -86,6 +87,8 @@ public class PVRChannelsListFragment extends Fragment
private int currentListType; private int currentListType;
private boolean singleChannelGroup = false; private boolean singleChannelGroup = false;
private Unbinder unbinder;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -94,7 +97,7 @@ public class PVRChannelsListFragment extends Fragment
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
if (savedInstanceState != null) { if (savedInstanceState != null) {
selectedChannelGroupId = savedInstanceState.getInt(CHANNELGROUPID); selectedChannelGroupId = savedInstanceState.getInt(CHANNELGROUPID);
@ -165,6 +168,12 @@ public class PVRChannelsListFragment extends Fragment
outState.putBoolean(SINGLECHANNELGROUP, singleChannelGroup); outState.putBoolean(SINGLECHANNELGROUP, singleChannelGroup);
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/** /**
* Swipe refresh layout callback * Swipe refresh layout callback
*/ */

View File

@ -17,44 +17,30 @@ package org.xbmc.kore.ui.sections.video;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.astuetz.PagerSlidingTabStrip;
import org.xbmc.kore.R; import org.xbmc.kore.R;
import org.xbmc.kore.ui.AbstractTabsFragment;
import org.xbmc.kore.ui.OnBackPressedListener; import org.xbmc.kore.ui.OnBackPressedListener;
import org.xbmc.kore.utils.LogUtils; import org.xbmc.kore.utils.LogUtils;
import org.xbmc.kore.utils.TabsAdapter; import org.xbmc.kore.utils.TabsAdapter;
import butterknife.ButterKnife;
import butterknife.InjectView;
/** /**
* Container for the various PVR lists * Container for the various PVR lists
*/ */
public class PVRListFragment extends Fragment public class PVRListFragment extends AbstractTabsFragment
implements OnBackPressedListener { implements OnBackPressedListener {
private static final String TAG = LogUtils.makeLogTag(PVRListFragment.class); private static final String TAG = LogUtils.makeLogTag(PVRListFragment.class);
private TabsAdapter tabsAdapter;
@InjectView(R.id.pager_tab_strip) PagerSlidingTabStrip pagerTabStrip;
@InjectView(R.id.pager) ViewPager viewPager;
public static final String PVR_LIST_TYPE_KEY = "pvr_list_type_key"; public static final String PVR_LIST_TYPE_KEY = "pvr_list_type_key";
public static final int LIST_TV_CHANNELS = 0, public static final int LIST_TV_CHANNELS = 0,
LIST_RADIO_CHANNELS = 1; LIST_RADIO_CHANNELS = 1;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { protected TabsAdapter createTabsAdapter(DataHolder dataHolder) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_default_view_pager, container, false); Bundle tvArgs = new Bundle();
ButterKnife.inject(this, root); Bundle radioArgs = new Bundle();
Bundle tvArgs = new Bundle(), radioArgs = new Bundle();
if (getArguments() != null) { if (getArguments() != null) {
tvArgs.putAll(getArguments()); tvArgs.putAll(getArguments());
radioArgs.putAll(getArguments()); radioArgs.putAll(getArguments());
@ -62,28 +48,17 @@ public class PVRListFragment extends Fragment
tvArgs.putInt(PVR_LIST_TYPE_KEY, LIST_TV_CHANNELS); tvArgs.putInt(PVR_LIST_TYPE_KEY, LIST_TV_CHANNELS);
radioArgs.putInt(PVR_LIST_TYPE_KEY, LIST_RADIO_CHANNELS); radioArgs.putInt(PVR_LIST_TYPE_KEY, LIST_RADIO_CHANNELS);
tabsAdapter = new TabsAdapter(getActivity(), getChildFragmentManager()) return new TabsAdapter(getActivity(), getChildFragmentManager())
.addTab(PVRChannelsListFragment.class, tvArgs, R.string.tv_channels, 1) .addTab(PVRChannelsListFragment.class, tvArgs, R.string.tv_channels, 1)
.addTab(PVRChannelsListFragment.class, radioArgs, R.string.radio_channels, 2) .addTab(PVRChannelsListFragment.class, radioArgs, R.string.radio_channels, 2)
.addTab(PVRRecordingsListFragment.class, getArguments(), R.string.recordings, 3); .addTab(PVRRecordingsListFragment.class, getArguments(), R.string.recordings, 3);
viewPager.setAdapter(tabsAdapter);
pagerTabStrip.setViewPager(viewPager);
return root;
}
@Override
public void onActivityCreated (Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(false);
} }
@Override @Override
public boolean onBackPressed() { public boolean onBackPressed() {
// Tell current fragment to move up one directory, if possible // Tell current fragment to move up one directory, if possible
Fragment visibleFragment = ((TabsAdapter)viewPager.getAdapter()) Fragment visibleFragment = ((TabsAdapter)getViewPager().getAdapter())
.getStoredFragment(viewPager.getCurrentItem()); .getStoredFragment(getViewPager().getCurrentItem());
if (visibleFragment instanceof OnBackPressedListener) { if (visibleFragment instanceof OnBackPressedListener) {
return ((OnBackPressedListener) visibleFragment).onBackPressed(); return ((OnBackPressedListener) visibleFragment).onBackPressed();

View File

@ -43,7 +43,8 @@ import org.xbmc.kore.utils.UIUtils;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* Fragment that presents the PVR recordings list * Fragment that presents the PVR recordings list
@ -54,9 +55,9 @@ public class PVRRecordingsListFragment extends Fragment
private HostManager hostManager; private HostManager hostManager;
@InjectView(R.id.list) GridView gridView; @BindView(R.id.list) GridView gridView;
@InjectView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.swipe_refresh_layout) SwipeRefreshLayout swipeRefreshLayout;
@InjectView(android.R.id.empty) TextView emptyView; @BindView(android.R.id.empty) TextView emptyView;
/** /**
* Handler on which to post RPC callbacks * Handler on which to post RPC callbacks
@ -65,6 +66,8 @@ public class PVRRecordingsListFragment extends Fragment
private RecordingsAdapter recordingsAdapter = null; private RecordingsAdapter recordingsAdapter = null;
private Unbinder unbinder;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -73,7 +76,7 @@ public class PVRRecordingsListFragment extends Fragment
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false);
ButterKnife.inject(this, root); unbinder = ButterKnife.bind(this, root);
hostManager = HostManager.getInstance(getActivity()); hostManager = HostManager.getInstance(getActivity());
@ -97,6 +100,12 @@ public class PVRRecordingsListFragment extends Fragment
browseRecordings(); browseRecordings();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
/** /**
* Swipe refresh layout callback * Swipe refresh layout callback
*/ */

View File

@ -40,7 +40,8 @@ import org.xbmc.kore.utils.RepeatListener;
import org.xbmc.kore.utils.Utils; import org.xbmc.kore.utils.Utils;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
public class ControlPad extends SquareGridLayout public class ControlPad extends SquareGridLayout
implements View.OnClickListener, View.OnLongClickListener { implements View.OnClickListener, View.OnLongClickListener {
@ -63,16 +64,17 @@ public class ControlPad extends SquareGridLayout
} }
private OnPadButtonsListener onPadButtonsListener; private OnPadButtonsListener onPadButtonsListener;
private Unbinder unbinder;
@InjectView(R.id.select) ImageView selectButton; @BindView(R.id.select) ImageView selectButton;
@InjectView(R.id.left) ImageView leftButton; @BindView(R.id.left) ImageView leftButton;
@InjectView(R.id.right) ImageView rightButton; @BindView(R.id.right) ImageView rightButton;
@InjectView(R.id.up) ImageView upButton; @BindView(R.id.up) ImageView upButton;
@InjectView(R.id.down) ImageView downButton; @BindView(R.id.down) ImageView downButton;
@InjectView(R.id.back) ImageView backButton; @BindView(R.id.back) ImageView backButton;
@InjectView(R.id.info) ImageView infoButton; @BindView(R.id.info) ImageView infoButton;
@InjectView(R.id.context) ImageView contextButton; @BindView(R.id.context) ImageView contextButton;
@InjectView(R.id.osd) ImageView osdButton; @BindView(R.id.osd) ImageView osdButton;
public ControlPad(Context context) { public ControlPad(Context context) {
super(context); super(context);
@ -105,13 +107,20 @@ public class ControlPad extends SquareGridLayout
private void initializeView(Context context) { private void initializeView(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.remote_control_pad, this); View view = inflater.inflate(R.layout.remote_control_pad, this);
ButterKnife.inject(this, this); unbinder = ButterKnife.bind(this, view);
setBackgroundImage(); setBackgroundImage();
setupListeners(context); setupListeners(context);
} }
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unbinder.unbind();
onPadButtonsListener = null;
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (onPadButtonsListener == null) if (onPadButtonsListener == null)

View File

@ -31,14 +31,16 @@ import org.xbmc.kore.R;
import org.xbmc.kore.utils.UIUtils; import org.xbmc.kore.utils.UIUtils;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
public class MediaProgressIndicator extends LinearLayout { public class MediaProgressIndicator extends LinearLayout {
@InjectView(R.id.mpi_seek_bar) SeekBar seekBar; @BindView(R.id.mpi_seek_bar) SeekBar seekBar;
@InjectView(R.id.mpi_duration) TextView durationTextView; @BindView(R.id.mpi_duration) TextView durationTextView;
@InjectView(R.id.mpi_progress) TextView progressTextView; @BindView(R.id.mpi_progress) TextView progressTextView;
private Unbinder unbinder;
private int speed = 0; private int speed = 0;
private int maxProgress; private int maxProgress;
private int progress; private int progress;
@ -69,7 +71,8 @@ public class MediaProgressIndicator extends LinearLayout {
private void initializeView(Context context) { private void initializeView(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.media_progress_indicator, this); View view = inflater.inflate(R.layout.media_progress_indicator, this);
ButterKnife.inject(view);
unbinder = ButterKnife.bind(this, view);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
@ -98,6 +101,17 @@ public class MediaProgressIndicator extends LinearLayout {
}); });
} }
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
seekBar.removeCallbacks(seekBarUpdater);
unbinder.unbind();
onProgressChangeListener = null;
}
@Override @Override
protected Parcelable onSaveInstanceState() { protected Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState()); SavedState savedState = new SavedState(super.onSaveInstanceState());
@ -119,6 +133,9 @@ public class MediaProgressIndicator extends LinearLayout {
private Runnable seekBarUpdater = new Runnable() { private Runnable seekBarUpdater = new Runnable() {
@Override @Override
public void run() { public void run() {
if (seekBar == null) // prevent NPE when Butterknife unbinds the view while there was still a runnable pending
return;
if ((maxProgress == 0) || (progress >= maxProgress)) { if ((maxProgress == 0) || (progress >= maxProgress)) {
seekBar.removeCallbacks(this); seekBar.removeCallbacks(this);
return; return;

View File

@ -33,8 +33,9 @@ import org.xbmc.kore.R;
import org.xbmc.kore.jsonrpc.type.GlobalType; import org.xbmc.kore.jsonrpc.type.GlobalType;
import org.xbmc.kore.utils.UIUtils; import org.xbmc.kore.utils.UIUtils;
import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.Unbinder;
public class NowPlayingPanel extends SlidingUpPanelLayout { public class NowPlayingPanel extends SlidingUpPanelLayout {
@ -49,20 +50,21 @@ public class NowPlayingPanel extends SlidingUpPanelLayout {
} }
private OnPanelButtonsClickListener onPanelButtonsClickListener; private OnPanelButtonsClickListener onPanelButtonsClickListener;
private Unbinder unbinder;
@InjectView(R.id.npp_collapsed_view) LinearLayout collapsedView; @BindView(R.id.npp_collapsed_view) LinearLayout collapsedView;
@InjectView(R.id.npp_title) TextView title; @BindView(R.id.npp_title) TextView title;
@InjectView(R.id.npp_details) TextView details; @BindView(R.id.npp_details) TextView details;
@InjectView(R.id.npp_poster) ImageView poster; @BindView(R.id.npp_poster) ImageView poster;
@InjectView(R.id.npp_previous) ImageButton previousButton; @BindView(R.id.npp_previous) ImageButton previousButton;
@InjectView(R.id.npp_next) ImageButton nextButton; @BindView(R.id.npp_next) ImageButton nextButton;
@InjectView(R.id.npp_play) ImageButton playButton; @BindView(R.id.npp_play) ImageButton playButton;
@InjectView(R.id.npp_progress_indicator) MediaProgressIndicator mediaProgressIndicator; @BindView(R.id.npp_progress_indicator) MediaProgressIndicator mediaProgressIndicator;
@InjectView(R.id.npp_volume_level_indicator) VolumeLevelIndicator volumeLevelIndicator; @BindView(R.id.npp_volume_level_indicator) VolumeLevelIndicator volumeLevelIndicator;
@InjectView(R.id.npp_volume_mute) HighlightButton volumeMuteButton; @BindView(R.id.npp_volume_mute) HighlightButton volumeMuteButton;
@InjectView(R.id.npp_volume_muted_indicator) HighlightButton volumeMutedIndicatorButton; @BindView(R.id.npp_volume_muted_indicator) HighlightButton volumeMutedIndicatorButton;
@InjectView(R.id.npp_repeat) RepeatModeButton repeatModeButton; @BindView(R.id.npp_repeat) RepeatModeButton repeatModeButton;
@InjectView(R.id.npp_shuffle) HighlightButton shuffleButton; @BindView(R.id.npp_shuffle) HighlightButton shuffleButton;
public NowPlayingPanel(Context context) { public NowPlayingPanel(Context context) {
super(context); super(context);
@ -81,11 +83,21 @@ public class NowPlayingPanel extends SlidingUpPanelLayout {
private void initializeView(Context context) { private void initializeView(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.now_playing_panel, this); View view = inflater.inflate(R.layout.now_playing_panel, this);
ButterKnife.inject(view); unbinder = ButterKnife.bind(this, view);
setDragView(collapsedView); setDragView(collapsedView);
setupButtonClickListeners(); setupButtonClickListeners();
} }
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unbinder.unbind();
onPanelButtonsClickListener = null;
}
public void setOnPanelButtonsClickListener(OnPanelButtonsClickListener listener) { public void setOnPanelButtonsClickListener(OnPanelButtonsClickListener listener) {
onPanelButtonsClickListener = listener; onPanelButtonsClickListener = listener;
} }

View File

@ -26,14 +26,16 @@ import android.widget.TextView;
import org.xbmc.kore.R; import org.xbmc.kore.R;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
public class VolumeLevelIndicator extends LinearLayout { public class VolumeLevelIndicator extends LinearLayout {
@InjectView(R.id.vli_seek_bar) SeekBar volumeSeekBar; @BindView(R.id.vli_seek_bar) SeekBar volumeSeekBar;
@InjectView(R.id.vli_volume_text) TextView volumeTextView; @BindView(R.id.vli_volume_text) TextView volumeTextView;
private OnVolumeChangeListener onVolumeChangeListener; private OnVolumeChangeListener onVolumeChangeListener;
private VolumeBarTouchTrackerListener volumeBarTouchTrackerListener; private VolumeBarTouchTrackerListener volumeBarTouchTrackerListener;
private Unbinder unbinder;
public interface OnVolumeChangeListener { public interface OnVolumeChangeListener {
void onVolumeChanged(int volume); void onVolumeChanged(int volume);
@ -59,10 +61,18 @@ public class VolumeLevelIndicator extends LinearLayout {
initializeView(context); initializeView(context);
} }
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unbinder.unbind();
onVolumeChangeListener = null;
volumeBarTouchTrackerListener = null;
}
private void initializeView(Context context) { private void initializeView(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.volume_level_indicator, this); View view = inflater.inflate(R.layout.volume_level_indicator, this);
ButterKnife.inject(view); unbinder = ButterKnife.bind(view);
volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override

View File

@ -37,11 +37,11 @@ import org.xbmc.kore.R;
import org.xbmc.kore.utils.Utils; import org.xbmc.kore.utils.Utils;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
public class DialActionButton extends LinearLayout { public class DialActionButton extends LinearLayout {
@InjectView(R.id.dial_label) AppCompatTextView label; @BindView(R.id.dial_label) AppCompatTextView label;
@InjectView(R.id.dial_action_button) FloatingActionButton button; @BindView(R.id.dial_action_button) FloatingActionButton button;
private View anchorView; private View anchorView;
private boolean isHiding; private boolean isHiding;
@ -171,7 +171,7 @@ public class DialActionButton extends LinearLayout {
private void initializeView(Context context, AttributeSet attrs, int defStyleAttr) { private void initializeView(Context context, AttributeSet attrs, int defStyleAttr) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.dial_action_button, this); View view = inflater.inflate(R.layout.dial_action_button, this);
ButterKnife.inject(view); ButterKnife.bind(view);
// Make sure shadow is not clipped // Make sure shadow is not clipped
setClipToPadding(false); setClipToPadding(false);

View File

@ -39,7 +39,8 @@ import org.xbmc.kore.ui.animators.ChangeImageFadeAnimation;
import org.xbmc.kore.ui.animators.PulsateAnimation; import org.xbmc.kore.ui.animators.PulsateAnimation;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.InjectView; import butterknife.BindView;
import butterknife.Unbinder;
/** /**
* The Floating Action Button Speed Dial uses a {@link FloatingActionButton} and can * The Floating Action Button Speed Dial uses a {@link FloatingActionButton} and can
@ -63,9 +64,9 @@ import butterknife.InjectView;
* </p> * </p>
*/ */
public class FABSpeedDial extends LinearLayout { public class FABSpeedDial extends LinearLayout {
@InjectView(R.id.fabspeeddial) FloatingActionButton FABMain; @BindView(R.id.fabspeeddial) FloatingActionButton FABMain;
@InjectView(R.id.play_local) DialActionButton FABPlayLocal; @BindView(R.id.play_local) DialActionButton FABPlayLocal;
@InjectView(R.id.play_remote) DialActionButton FABPlayRemote; @BindView(R.id.play_remote) DialActionButton FABPlayRemote;
private final String BUNDLE_KEY_EXPANDED = "expanded"; private final String BUNDLE_KEY_EXPANDED = "expanded";
private final String BUNDLE_KEY_PARENT = "parent"; private final String BUNDLE_KEY_PARENT = "parent";
@ -82,6 +83,8 @@ public class FABSpeedDial extends LinearLayout {
private OvershootInterpolator showDialsInterpolator = new OvershootInterpolator(); private OvershootInterpolator showDialsInterpolator = new OvershootInterpolator();
private AccelerateInterpolator hideDialsInterpolator = new AccelerateInterpolator(); private AccelerateInterpolator hideDialsInterpolator = new AccelerateInterpolator();
private Unbinder unbinder;
public interface DialListener { public interface DialListener {
void onLocalPlayClicked(); void onLocalPlayClicked();
void onRemotePlayClicked(); void onRemotePlayClicked();
@ -109,6 +112,15 @@ public class FABSpeedDial extends LinearLayout {
initializeView(context); initializeView(context);
} }
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unbinder.unbind();
dialListener = null;
fabListener = null;
}
/** /**
* Enables/disables the speed dials. This means that if enabled, * Enables/disables the speed dials. This means that if enabled,
* the dials will be shown if the user pressed the FAB button. * the dials will be shown if the user pressed the FAB button.
@ -246,7 +258,7 @@ public class FABSpeedDial extends LinearLayout {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.fab_speed_dial, this); View view = inflater.inflate(R.layout.fab_speed_dial, this);
ButterKnife.inject(view); unbinder = ButterKnife.bind(view);
// Makes sure shadow is not clipped // Makes sure shadow is not clipped
setClipToPadding(false); setClipToPadding(false);

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015 Synced Synapse. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/pager_tab_strip"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_strip_height"
style="@style/TabStrip"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View File

@ -66,16 +66,17 @@ public class Database {
public static HostInfo addHost(Context context) { public static HostInfo addHost(Context context) {
return addHost(context, "127.0.0.1", HostConnection.PROTOCOL_TCP, return addHost(context, "127.0.0.1", HostConnection.PROTOCOL_TCP,
HostInfo.DEFAULT_HTTP_PORT, HostInfo.DEFAULT_TCP_PORT, false); HostInfo.DEFAULT_HTTP_PORT, HostInfo.DEFAULT_TCP_PORT, false,
HostInfo.DEFAULT_KODI_VERSION_MAJOR);
} }
public static HostInfo addHost(Context context, String hostname, int protocol, int httpPort, public static HostInfo addHost(Context context, String hostname, int protocol, int httpPort,
int tcpPort, boolean useEventServer) { int tcpPort, boolean useEventServer, int kodiMajorVersion) {
return HostManager.getInstance(context).addHost("TestHost", hostname, protocol, httpPort, return HostManager.getInstance(context).addHost("TestHost", hostname, protocol, httpPort,
tcpPort, null, null, "52:54:00:12:35:02", 9, tcpPort, null, null, "52:54:00:12:35:02", 9,
useEventServer, HostInfo.DEFAULT_EVENT_SERVER_PORT, useEventServer, HostInfo.DEFAULT_EVENT_SERVER_PORT,
HostInfo.DEFAULT_KODI_VERSION_MAJOR, kodiMajorVersion,
HostInfo.DEFAULT_KODI_VERSION_MINOR, HostInfo.DEFAULT_KODI_VERSION_MINOR,
HostInfo.DEFAULT_KODI_VERSION_REVISION, HostInfo.DEFAULT_KODI_VERSION_REVISION,
HostInfo.DEFAULT_KODI_VERSION_TAG, HostInfo.DEFAULT_KODI_VERSION_TAG,