Skip to content

Commit

Permalink
The MobileLibraryBrowser is now fed from the database.
Browse files Browse the repository at this point in the history
However, only the Artist tab works for now.
Updated Android project with new changes.

Related to issue #406 and issue #409.
  • Loading branch information
ycastonguay committed Feb 14, 2013
1 parent 88d3d3f commit 19d5d7b
Show file tree
Hide file tree
Showing 30 changed files with 1,109 additions and 983 deletions.
29 changes: 15 additions & 14 deletions MPfm/MPfm.Android/Classes/Activities/MainActivity.cs
Expand Up @@ -23,6 +23,8 @@
using Android.Support.V4.View;
using Android.Views;
using Android.OS;
using Android.Views.Animations;
using Android.Widget;
using MPfm.Android.Classes.Adapters;
using MPfm.Android.Classes.Fragments;
using MPfm.Android.Classes.Navigation;
Expand All @@ -41,26 +43,22 @@ public class MainActivity : BaseActivity, IMobileOptionsMenuView
private List<KeyValuePair<MobileNavigationTabType, Fragment>> _fragments;
private SplashFragment _splashFragment;
private AndroidNavigationManager _navigationManager;
private LinearLayout _miniPlayer;

protected override void OnCreate(Bundle bundle)
{
Console.WriteLine("MainActivity - OnCreate");
base.OnCreate(bundle);

// Get application state
ApplicationState state = (ApplicationState)LastNonConfigurationInstance;
if (state != null)
{
// Restore state here
}

// Request features
RequestWindowFeature(WindowFeatures.ActionBar);
SetContentView(Resource.Layout.Main);
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

// Get controls
_viewPager = FindViewById<ViewPager>(Resource.Id.main_pager);
_miniPlayer = FindViewById<LinearLayout>(Resource.Id.main_miniplayer);
_miniPlayer.Visibility = ViewStates.Gone;

// Create view pager adapter
_fragments = new List<KeyValuePair<MobileNavigationTabType, Fragment>>();
Expand Down Expand Up @@ -89,6 +87,10 @@ public void PushTabView(MobileNavigationTabType type, Fragment fragment)
if (fragment is PlayerFragment)
{
// This fragment should completely hide the view pager
//_miniPlayer.Alpha = 1;
_miniPlayer.Visibility = ViewStates.Visible;
Animation anim = AnimationUtils.LoadAnimation(this, Resource.Animation.slide_in_left);
_miniPlayer.StartAnimation(anim);
ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
_viewPager.Visibility = ViewStates.Gone;
var transaction = FragmentManager.BeginTransaction();
Expand All @@ -103,6 +105,12 @@ public override void OnBackPressed()
base.OnBackPressed();
_viewPager.Visibility = ViewStates.Visible;
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
Animation anim = AnimationUtils.LoadAnimation(this, Resource.Animation.slide_out_right);
anim.AnimationEnd += (sender, args) =>
{
_miniPlayer.Visibility = ViewStates.Gone;
};
_miniPlayer.StartAnimation(anim);
}

protected override void OnStart()
Expand Down Expand Up @@ -141,13 +149,6 @@ protected override void OnDestroy()
base.OnDestroy();
}

public override Java.Lang.Object OnRetainNonConfigurationInstance()
{
// Save stuff here
ApplicationState state = new ApplicationState();
return state;
}

public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.main_menu, menu);
Expand Down
104 changes: 53 additions & 51 deletions MPfm/MPfm.Android/Classes/Fragments/AudioPreferencesFragment.cs
@@ -1,51 +1,53 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
using MPfm.Android.Classes.Fragments.Base;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments
{
public class AudioPreferencesFragment : BaseFragment, IAudioPreferencesView, View.IOnClickListener
{
private View _view;
private TextView _lblTitle;

public AudioPreferencesFragment(Action<IBaseView> onViewReady)
: base(onViewReady)
{

}

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
_view = inflater.Inflate(Resource.Layout.Fragment_AudioPreferences, container, false);
_lblTitle = _view.FindViewById<TextView>(Resource.Id.fragment_audioSettings_lblTitle);
return _view;
}

public void OnClick(View v)
{

}
}
}
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
using MPfm.Android.Classes.Fragments.Base;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments
{
public class AudioPreferencesFragment : BaseFragment, IAudioPreferencesView, View.IOnClickListener
{
private View _view;
private TextView _lblTitle;

// Leave an empty constructor or the application will crash at runtime
public AudioPreferencesFragment() : base(null) { }

public AudioPreferencesFragment(Action<IBaseView> onViewReady)
: base(onViewReady)
{
}

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
_view = inflater.Inflate(Resource.Layout.AudioPreferences, container, false);
_lblTitle = _view.FindViewById<TextView>(Resource.Id.fragment_audioSettings_lblTitle);
return _view;
}

public void OnClick(View v)
{

}
}
}
102 changes: 51 additions & 51 deletions MPfm/MPfm.Android/Classes/Fragments/Base/BaseDialogFragment.cs
@@ -1,51 +1,51 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using Android.App;
using Android.OS;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments.Base
{
public class BaseDialogFragment : DialogFragment, IBaseView
{
protected Action<IBaseView> OnViewReady { get; set; }
public Action<IBaseView> OnViewDestroy { get; set; }
public void ShowView(bool shown)
{
// Ignore on Android
}

public BaseDialogFragment(Action<IBaseView> onViewReady)
{
this.OnViewReady = onViewReady;
}

public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
OnViewReady(this);
}

public override void OnDestroy()
{
base.OnDestroy();
OnViewDestroy(this);
}
}
}
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using Android.App;
using Android.OS;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments.Base
{
public class BaseDialogFragment : DialogFragment, IBaseView
{
protected Action<IBaseView> OnViewReady { get; set; }
public Action<IBaseView> OnViewDestroy { get; set; }
public void ShowView(bool shown)
{
// Ignore on Android
}

public BaseDialogFragment(Action<IBaseView> onViewReady)
{
this.OnViewReady = onViewReady;
}

public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (OnViewReady != null) OnViewReady(this);
}

public override void OnDestroy()
{
base.OnDestroy();
if (OnViewReady != null) OnViewDestroy(this);
}
}
}
102 changes: 51 additions & 51 deletions MPfm/MPfm.Android/Classes/Fragments/Base/BaseFragment.cs
@@ -1,51 +1,51 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using Android.App;
using Android.OS;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments.Base
{
public class BaseFragment : Fragment, IBaseView
{
protected Action<IBaseView> OnViewReady { get; set; }
public Action<IBaseView> OnViewDestroy { get; set; }
public void ShowView(bool shown)
{
// Ignore on Android
}

public BaseFragment(Action<IBaseView> onViewReady)
{
this.OnViewReady = onViewReady;
}

public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
OnViewReady(this);
}

public override void OnDestroy()
{
base.OnDestroy();
OnViewDestroy(this);
}
}
}
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using Android.App;
using Android.OS;
using MPfm.MVP.Views;

namespace MPfm.Android.Classes.Fragments.Base
{
public class BaseFragment : Fragment, IBaseView
{
protected Action<IBaseView> OnViewReady { get; set; }
public Action<IBaseView> OnViewDestroy { get; set; }
public void ShowView(bool shown)
{
// Ignore on Android
}

public BaseFragment(Action<IBaseView> onViewReady)
{
this.OnViewReady = onViewReady;
}

public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (OnViewReady != null) OnViewReady(this);
}

public override void OnDestroy()
{
base.OnDestroy();
if (OnViewReady != null) OnViewDestroy(this);
}
}
}

0 comments on commit 19d5d7b

Please sign in to comment.