Added player fragment to main activity
This commit is contained in:
parent
e106dc8c1b
commit
2e9bd1f07e
|
@ -1,55 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/fragmentLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/ics_gray" >
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butPlay"
|
||||
android:background="@drawable/borderless_button"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="#AAAAAA" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutInfo"
|
||||
android:layout_width="0dp"
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#D2D2D2" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toLeftOf="@id/butPlay"
|
||||
android:background="@drawable/borderless_button" >
|
||||
android:background="@color/actionbar_gray" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvCover"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_margin="8dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:cropToPadding="true"
|
||||
android:scaleType="fitXY" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="wrap_content"
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutInfo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_toRightOf="@id/imgvCover"
|
||||
android:textStyle="bold" />
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/borderless_button" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPosition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_toRightOf="@id/imgvCover" />
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:id="@+id/imgvCover"
|
||||
android:layout_width="@dimen/external_player_height"
|
||||
android:layout_height="@dimen/external_player_height"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:cropToPadding="true"
|
||||
android:scaleType="fitXY" />
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_toRightOf="@id/imgvCover"
|
||||
android:maxLines="1"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPosition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_toRightOf="@id/imgvCover"
|
||||
android:textSize="14dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butPlay"
|
||||
android:layout_width="@dimen/external_player_height"
|
||||
android:layout_height="@dimen/external_player_height"
|
||||
android:background="@drawable/borderless_button" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,21 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<com.viewpagerindicator.TabPageIndicator
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1">
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</LinearLayout>
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playerFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true" />
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_above="@id/playerFragment"
|
||||
android:layout_below="@id/tabs" >
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</RelativeLayout>
|
|
@ -2,5 +2,6 @@
|
|||
<resources>
|
||||
<dimen name="widget_margin">8dp</dimen>
|
||||
<dimen name="thumbnail_length">55dp</dimen>
|
||||
<dimen name="external_player_height">55dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -7,6 +7,7 @@ import android.content.IntentFilter;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
|
@ -20,6 +21,7 @@ import com.viewpagerindicator.TabPageIndicator;
|
|||
|
||||
import de.danoeh.antennapod.asynctask.OpmlExportWorker;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
|
||||
import de.danoeh.antennapod.fragment.FeedlistFragment;
|
||||
import de.danoeh.antennapod.fragment.QueueFragment;
|
||||
import de.danoeh.antennapod.fragment.UnreadItemlistFragment;
|
||||
|
@ -38,6 +40,7 @@ public class MainActivity extends SherlockFragmentActivity {
|
|||
private ViewPager viewpager;
|
||||
private MainPagerAdapter pagerAdapter;
|
||||
private TabPageIndicator tabs;
|
||||
private ExternalPlayerFragment externalPlayerFragment;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -53,6 +56,12 @@ public class MainActivity extends SherlockFragmentActivity {
|
|||
|
||||
viewpager.setAdapter(pagerAdapter);
|
||||
tabs.setViewPager(viewpager);
|
||||
|
||||
FragmentTransaction transaction = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
externalPlayerFragment = new ExternalPlayerFragment();
|
||||
transaction.replace(R.id.playerFragment, externalPlayerFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.actionbarsherlock.app.SherlockFragment;
|
|||
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.AudioplayerActivity;
|
||||
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
||||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.receiver.PlayerWidget;
|
||||
|
@ -48,6 +47,10 @@ public class ExternalPlayerFragment extends SherlockFragment {
|
|||
|
||||
private boolean mediaInfoLoaded = false;
|
||||
|
||||
public ExternalPlayerFragment() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -85,7 +88,7 @@ public class ExternalPlayerFragment extends SherlockFragment {
|
|||
PlayerStatus status = playbackService.getStatus();
|
||||
if (status == PlayerStatus.PLAYING) {
|
||||
playbackService.pause(true);
|
||||
} else if (status == PlayerStatus.PAUSED){
|
||||
} else if (status == PlayerStatus.PAUSED) {
|
||||
playbackService.play();
|
||||
}
|
||||
}
|
||||
|
@ -217,9 +220,12 @@ public class ExternalPlayerFragment extends SherlockFragment {
|
|||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Refreshing fragment state");
|
||||
if (playbackService == null) {
|
||||
getActivity().bindService(
|
||||
new Intent(getActivity(), PlaybackService.class),
|
||||
mConnection, 0);
|
||||
fragmentLayout.setVisibility(View.GONE);
|
||||
if (PlaybackService.isRunning) {
|
||||
getActivity().bindService(
|
||||
new Intent(getActivity(), PlaybackService.class),
|
||||
mConnection, 0);
|
||||
}
|
||||
} else {
|
||||
PlayerStatus status = playbackService.getStatus();
|
||||
if ((status == PlayerStatus.PAUSED || status == PlayerStatus.PLAYING)) {
|
||||
|
|
Loading…
Reference in New Issue