Removed unused resources, reduced number of lint warnings
This commit is contained in:
parent
fe7af4265d
commit
1ee50e81ae
@ -154,6 +154,10 @@
|
||||
<action android:name="de.danoeh.antennapod.NOTIFY_BUTTON_RECEIVER"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity android:name=".activity.FeedInfoActivity">
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".service.playback.PlayerWidgetService"
|
||||
android:enabled="true"
|
||||
|
@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#D2D2D2" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="10dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#ECECEC" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="20dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#D2D2D2" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="30dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#ECECEC" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="40dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#D2D2D2" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="50dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#ECECEC" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="60dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#D2D2D2" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#BEBEBE" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="10dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#242A30" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="20dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#BEBEBE" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="30dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#242A30" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="40dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#BEBEBE" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="50dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#242A30" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="60dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="3dp" />
|
||||
|
||||
<solid android:color="#BEBEBE" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<GridView
|
||||
android:id="@+id/grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:stretchMode="columnWidth"
|
||||
android:numColumns="auto_fit"
|
||||
android:verticalSpacing="4dp"
|
||||
android:horizontalSpacing="4dp"
|
||||
android:gravity="center"
|
||||
android:columnWidth="@dimen/thumbnail_length"
|
||||
tools:listitem="@layout/feedlist_item_grid" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:paddingLeft="4dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvItemname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPublished"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/txtvItemname"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="@dimen/text_size_micro" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvType"
|
||||
android:layout_width="@dimen/enc_icons_size"
|
||||
android:layout_height="@dimen/enc_icons_size"
|
||||
android:layout_below="@id/txtvPublished"
|
||||
android:padding="2dp"
|
||||
tools:ignore="ContentDescription"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvLenSize"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/txtvPublished"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="@dimen/text_size_micro" />
|
||||
|
||||
</RelativeLayout>
|
@ -4,7 +4,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
</ExpandableListView>
|
||||
|
||||
</LinearLayout>
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
android:id="@id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:drawSelectorOnTop="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/feeditemlistFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playerFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="?attr/non_transparent_background" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvItemname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPublished"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="@color/ics_gray" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/description_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
android:id="@id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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.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.PagerTabStrip
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top" />
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</LinearLayout>
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/searchListFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/taglistFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvLoading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="8dp"
|
||||
android:text="@string/loading_label" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_toLeftOf="@+id/txtvLoading" />
|
||||
|
||||
</RelativeLayout>
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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.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.PagerTabStrip
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top" />
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</LinearLayout>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
android:id="@id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center" />
|
||||
|
||||
</LinearLayout>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:layout_margin="8dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progLoading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminateOnly="true" />
|
||||
|
||||
<RelativeLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/layout_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="8dp"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
android:id="@+id/title_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:background="@color/ics_gray" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/title_divider"
|
||||
android:layout_margin="8dp"
|
||||
android:maxLines="8"
|
||||
android:textSize="@dimen/text_size_small" />
|
||||
|
||||
<View
|
||||
android:id="@+id/description_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_below="@id/txtvDescription"
|
||||
android:background="@color/ics_gray" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/itemlist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/description_divider"
|
||||
tools:listitem="@android:layout/simple_list_item_1" >
|
||||
</ListView>
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:textSize="@dimen/text_size_medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvDate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
</LinearLayout>
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/channellistFragment"
|
||||
android:name=".fragment.MiroChannellistFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:padding="12dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAllCaps="true"
|
||||
style="@style/AntennaPod.TextView.Heading"
|
||||
android:text="@string/recently_published_episodes_label"/>
|
||||
|
||||
</LinearLayout>
|
@ -1,45 +0,0 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:dslv="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<com.mobeta.android.dslv.DragSortListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
dslv:collapsed_height="2dp"
|
||||
dslv:drag_enabled="true"
|
||||
dslv:drag_handle_id="@id/drag_handle"
|
||||
dslv:drag_scroll_start="0.33"
|
||||
dslv:drag_start_mode="onDown"
|
||||
dslv:float_alpha="0.6"
|
||||
dslv:max_drag_scroll_speed="0.5"
|
||||
dslv:remove_enabled="true"
|
||||
dslv:remove_mode="flingRemove"
|
||||
dslv:slide_shuffle_speed="0.3"
|
||||
dslv:sort_enabled="true"
|
||||
dslv:track_drag_sort="false"
|
||||
dslv:float_background_color="?attr/dragview_float_background"
|
||||
dslv:use_default_controller="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_items_label" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progLoading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminateOnly="true" />
|
||||
|
||||
<LinearLayout android:id="@+id/undobar" style="@style/UndoBar">
|
||||
<TextView android:id="@+id/undobar_message" style="@style/UndoBarMessage" />
|
||||
<Button android:id="@+id/undobar_button" style="@style/UndoBarButton" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvFeedimage"
|
||||
android:contentDescription="@string/cover_label"
|
||||
android:layout_width="@dimen/thumbnail_length_itemlist"
|
||||
android:layout_height="@dimen/thumbnail_length_itemlist"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<View
|
||||
android:id="@id/drag_handle"
|
||||
android:layout_width="@dimen/dragview_length"
|
||||
android:layout_height="@dimen/dragview_length"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?attr/dragview_background"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_toLeftOf="@id/drag_handle"
|
||||
android:layout_toRightOf="@id/imgvFeedimage"
|
||||
android:ellipsize="end"
|
||||
android:lines="2"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/text_size_small" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvFeedname"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_toLeftOf="@id/drag_handle"
|
||||
android:layout_toRightOf="@id/imgvFeedimage"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/text_size_micro" />
|
||||
|
||||
</RelativeLayout>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/playbackhistory_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
|
||||
</FrameLayout>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
android:id="@id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center" />
|
||||
|
||||
</LinearLayout>
|
@ -13,7 +13,6 @@
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/add_feed"
|
||||
android:icon="?attr/content_new"
|
||||
android:title="@string/add_new_feed_label"
|
||||
custom:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/visit_website_item"
|
||||
android:title="@string/visit_website_label"
|
||||
custom:showAsAction="ifRoom"
|
||||
android:icon="?attr/location_web_site"/>
|
||||
|
||||
|
||||
</menu>
|
@ -2,23 +2,9 @@
|
||||
<resources>
|
||||
|
||||
<color name="white">#FFFFFF</color>
|
||||
<color name="yellow">#FFFF00</color>
|
||||
<color name="fuchsia">#FF00FF</color>
|
||||
<color name="red">#FF0000</color>
|
||||
<color name="silver">#C0C0C0</color>
|
||||
<color name="gray">#808080</color>
|
||||
<color name="olive">#808000</color>
|
||||
<color name="purple">#800080</color>
|
||||
<color name="maroon">#800000</color>
|
||||
<color name="aqua">#00FFFF</color>
|
||||
<color name="lime">#00FF00</color>
|
||||
<color name="teal">#008080</color>
|
||||
<color name="green">#008000</color>
|
||||
<color name="blue">#0000FF</color>
|
||||
<color name="navy">#000080</color>
|
||||
<color name="black">#000000</color>
|
||||
<color name="bright_blue">#33B5E5</color>
|
||||
<color name="dark_blue">#3899C9</color>
|
||||
<color name="ics_gray">#858585</color>
|
||||
<color name="actionbar_gray">#DDDDDD</color>
|
||||
<color name="download_success_green">#669900</color>
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
<dimen name="widget_margin">8dp</dimen>
|
||||
<dimen name="thumbnail_length">70dp</dimen>
|
||||
<dimen name="dragview_length">54dp</dimen>
|
||||
<dimen name="external_player_height">70dp</dimen>
|
||||
<dimen name="enc_icons_size">20dp</dimen>
|
||||
<dimen name="text_size_micro">12sp</dimen>
|
||||
|
@ -20,7 +20,6 @@
|
||||
<string name="downloads_completed_label">Completed</string>
|
||||
<string name="downloads_log_label">Log</string>
|
||||
<string name="cancel_download_label">Cancel Download</string>
|
||||
<string name="download_log_label">Download log</string>
|
||||
<string name="playback_history_label">Playback history</string>
|
||||
<string name="gpodnet_main_label">gpodder.net</string>
|
||||
<string name="gpodnet_auth_label">gpodder.net login</string>
|
||||
@ -58,12 +57,10 @@
|
||||
<string name="description_label">Description</string>
|
||||
<string name="most_recent_prefix">Most Recent Episode:\u0020</string>
|
||||
<string name="episodes_suffix">\u0020episodes</string>
|
||||
<string name="published_prefix">Published:\u0020</string>
|
||||
<string name="length_prefix">Length:\u0020</string>
|
||||
<string name="size_prefix">Size:\u0020</string>
|
||||
<string name="processing_label">Processing</string>
|
||||
<string name="loading_label">Loading...</string>
|
||||
<string name="image_of_prefix">Image of:\u0020</string>
|
||||
<string name="save_username_password_label">Save username and password</string>
|
||||
<string name="close_label">Close</string>
|
||||
<string name="retry_label">Retry</string>
|
||||
@ -149,14 +146,9 @@
|
||||
<string name="position_default_label">00:00:00</string>
|
||||
<string name="player_buffering_msg">Buffering</string>
|
||||
<string name="playbackservice_notification_title">Playing podcast</string>
|
||||
<string name="playbackservice_notification_content">Tap here for more info</string>
|
||||
<!-- Navigation -->
|
||||
<string name="show_download_log">Show Log</string>
|
||||
<string name="show_player_label">Show player</string>
|
||||
|
||||
<!-- Queue operations -->
|
||||
<string name="clear_queue_label">Clear queue</string>
|
||||
<string name="organize_queue_label">Organize queue</string>
|
||||
<string name="undo">Undo</string>
|
||||
<string name="removed_from_queue">Item removed</string>
|
||||
<string name="move_to_top_label">Move to top</string>
|
||||
@ -227,8 +219,6 @@
|
||||
<string name="pref_revokeAccess_sum">Revoke the access permission to your flattr account for this app.</string>
|
||||
<string name="pref_auto_flattr_title">Automatic Flattr</string>
|
||||
<string name="pref_auto_flattr_sum">Flattr episodes of which 80% have been played.</string>
|
||||
<string name="pref_display_only_episodes_title">Display only episodes</string>
|
||||
<string name="pref_display_only_episodes_sum">Display only items which also have an episode.</string>
|
||||
<string name="user_interface_label">User Interface</string>
|
||||
<string name="pref_set_theme_title">Select theme</string>
|
||||
<string name="pref_set_theme_sum">Change the appearance of AntennaPod.</string>
|
||||
@ -259,10 +249,7 @@
|
||||
<string name="search_hint">Search for Feeds or Episodes</string>
|
||||
<string name="found_in_shownotes_label">Found in shownotes</string>
|
||||
<string name="found_in_chapters_label">Found in chapters</string>
|
||||
<string name="search_status_searching">Searching...</string>
|
||||
<string name="search_status_no_results">No results were found</string>
|
||||
<string name="search_results_label">Search results</string>
|
||||
<string name="search_term_label">You searched:\u0020</string>
|
||||
<string name="search_label">Search</string>
|
||||
<string name="found_in_title_label">Found in title</string>
|
||||
|
||||
@ -295,17 +282,6 @@
|
||||
<string name="time_unit_minutes">minutes</string>
|
||||
<string name="time_unit_hours">hours</string>
|
||||
|
||||
<!-- Miro Guide -->
|
||||
<string name="loading_categories_label">Loading categories...</string>
|
||||
<string name="browse_miroguide_label">Browse Miro Guide</string>
|
||||
<string name="txtv_browse_miroguide_label">Or browse the Miro Guide:</string>
|
||||
<string name="miro_guide_label">Miro Guide</string>
|
||||
<string name="miro_search_hint">Search Miro Guide</string>
|
||||
<string name="popular_label">Popular</string>
|
||||
<string name="best_rating_label">Best rating</string>
|
||||
<string name="add_feed_label">Add podcast</string>
|
||||
<string name="miro_feed_added">Feed is being added</string>
|
||||
|
||||
<!-- gpodder.net -->
|
||||
<string name="gpodnet_taglist_header">CATEGORIES</string>
|
||||
<string name="gpodnet_toplist_header">TOP PODCASTS</string>
|
||||
@ -370,7 +346,6 @@
|
||||
<string name="status_playing_label">Episode is being played</string>
|
||||
<string name="status_downloading_label">Episode is being downloaded</string>
|
||||
<string name="status_downloaded_label">Episode is downloaded</string>
|
||||
<string name="status_not_downloaded_label">Episode has not been downloaded yet</string>
|
||||
<string name="status_unread_label">Item is new</string>
|
||||
<string name="in_queue_label">Episode is in the queue</string>
|
||||
<string name="new_episodes_count_label">Number of new episodes</string>
|
||||
@ -381,9 +356,6 @@
|
||||
<string name="authentication_label">Authentication</string>
|
||||
<string name="authentication_descr">Change your username and password for this podcast and its episodes.</string>
|
||||
|
||||
<!-- OPML backup -->
|
||||
<string name="backup_restored">"Restored feed subscriptions from backup"</string>
|
||||
|
||||
<!-- AntennaPodSP -->
|
||||
|
||||
<string name="sp_apps_importing_feeds_msg">Importing subscriptions from single-purpose apps…</string>
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<searchable xmlns:android="http://schemas.android.com/apk/res/android" android:hint="@string/gpodnet_search_hint" android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
|
||||
|
||||
</searchable>
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<searchable xmlns:android="http://schemas.android.com/apk/res/android" android:hint="@string/miro_search_hint" android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
|
||||
|
||||
</searchable>
|
@ -1,143 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.gpoddernet.GpodnetMainActivity;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.util.StorageUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Activity for adding a Feed
|
||||
*/
|
||||
public class AddFeedActivity extends ActionBarActivity {
|
||||
private static final String TAG = "AddFeedActivity";
|
||||
|
||||
private EditText etxtFeedurl;
|
||||
private Button butBrowseMiroGuide;
|
||||
private Button butBrowserGpoddernet;
|
||||
private Button butOpmlImport;
|
||||
private Button butConfirm;
|
||||
|
||||
private ProgressDialog progDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Was started with Intent " + getIntent().getAction()
|
||||
+ " and Data " + getIntent().getDataString());
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
setContentView(R.layout.addfeed);
|
||||
|
||||
progDialog = new ProgressDialog(this);
|
||||
|
||||
etxtFeedurl = (EditText) findViewById(R.id.etxtFeedurl);
|
||||
if (StringUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
|
||||
etxtFeedurl.setText(getIntent().getDataString());
|
||||
}
|
||||
|
||||
butBrowserGpoddernet = (Button) findViewById(R.id.butBrowseGpoddernet);
|
||||
butOpmlImport = (Button) findViewById(R.id.butOpmlImport);
|
||||
butConfirm = (Button) findViewById(R.id.butConfirm);
|
||||
|
||||
butBrowseMiroGuide.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(AddFeedActivity.this,
|
||||
MiroGuideMainActivity.class));
|
||||
}
|
||||
});
|
||||
butBrowserGpoddernet.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(AddFeedActivity.this,
|
||||
GpodnetMainActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
butOpmlImport.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(AddFeedActivity.this,
|
||||
OpmlImportFromPathActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
butConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(AddFeedActivity.this, DefaultOnlineFeedViewActivity.class);
|
||||
intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, etxtFeedurl.getText().toString());
|
||||
intent.putExtra(OnlineFeedViewActivity.ARG_TITLE, getSupportActionBar().getTitle());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
Intent intent = getIntent();
|
||||
if (intent.getAction() != null
|
||||
&& intent.getAction().equals(Intent.ACTION_SEND)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Resuming with ACTION_SEND intent");
|
||||
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (text != null) {
|
||||
etxtFeedurl.setText(text);
|
||||
} else {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "No text was sent");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Stopping Activity");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,190 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ListView;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.DownloadlistAdapter;
|
||||
import de.danoeh.antennapod.asynctask.DownloadObserver;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.service.download.Downloader;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Shows all running downloads in a list. The list objects are DownloadStatus
|
||||
* objects created by a DownloadObserver.
|
||||
*/
|
||||
public class DownloadActivity extends ActionBarActivity implements
|
||||
ActionMode.Callback {
|
||||
|
||||
private static final String TAG = "DownloadActivity";
|
||||
private static final int MENU_SHOW_LOG = 0;
|
||||
private static final int MENU_CANCEL_ALL_DOWNLOADS = 1;
|
||||
private DownloadlistAdapter dla;
|
||||
private DownloadRequester requester;
|
||||
|
||||
private ActionMode mActionMode;
|
||||
private DownloadRequest selectedDownload;
|
||||
|
||||
private ListView listview;
|
||||
|
||||
private DownloadObserver downloadObserver;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.listview_activity);
|
||||
|
||||
listview = (ListView) findViewById(R.id.listview);
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Creating Activity");
|
||||
requester = DownloadRequester.getInstance();
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
downloadObserver = new DownloadObserver(this, new Handler(), observerCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
downloadObserver.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
downloadObserver.onResume();
|
||||
if (dla != null) {
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Stopping Activity");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
listview.setOnItemLongClickListener(new OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View view,
|
||||
int position, long id) {
|
||||
DownloadRequest selection = dla.getItem(position)
|
||||
.getDownloadRequest();
|
||||
if (selection != null && mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
dla.setSelectedItemIndex(position);
|
||||
selectedDownload = selection;
|
||||
mActionMode = startSupportActionMode(DownloadActivity.this);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, MENU_SHOW_LOG, Menu.NONE,
|
||||
R.string.show_download_log),
|
||||
MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, MENU_CANCEL_ALL_DOWNLOADS, Menu.NONE,
|
||||
R.string.cancel_all_downloads_label),
|
||||
MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
case MENU_SHOW_LOG:
|
||||
startActivity(new Intent(this, DownloadLogActivity.class));
|
||||
break;
|
||||
case MENU_CANCEL_ALL_DOWNLOADS:
|
||||
requester.cancelAllDownloads(this);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
if (selectedDownload != null) {
|
||||
TypedArray drawables = obtainStyledAttributes(new int[]{R.attr.navigation_cancel});
|
||||
menu.add(Menu.NONE, R.id.cancel_download_item, Menu.NONE,
|
||||
R.string.cancel_download_label).setIcon(
|
||||
drawables.getDrawable(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
boolean handled = false;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.cancel_download_item:
|
||||
requester.cancelDownload(this, selectedDownload.getSource());
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
mActionMode.finish();
|
||||
return handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mActionMode = null;
|
||||
selectedDownload = null;
|
||||
dla.setSelectedItemIndex(DownloadlistAdapter.SELECTION_NONE);
|
||||
}
|
||||
|
||||
|
||||
private DownloadObserver.Callback observerCallback = new DownloadObserver.Callback() {
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
if (dla != null) {
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadDataAvailable(List<Downloader> downloaderList) {
|
||||
//dla = new DownloadlistAdapter(DownloadActivity.this, 0,
|
||||
// downloaderList);
|
||||
listview.setAdapter(dla);
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ListView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.DownloadLogAdapter;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays completed and failed downloads in a list.
|
||||
*/
|
||||
public class DownloadLogActivity extends ActionBarActivity {
|
||||
private static final String TAG = "DownloadLogActivity";
|
||||
|
||||
private List<DownloadStatus> downloadLog;
|
||||
private DownloadLogAdapter dla;
|
||||
|
||||
private ListView listview;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.listview_activity);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
listview = (ListView) findViewById(R.id.listview);
|
||||
|
||||
dla = new DownloadLogAdapter(this, itemAccess);
|
||||
listview.setAdapter(dla);
|
||||
loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
AsyncTask<Void, Void, List<DownloadStatus>> loadTask = new AsyncTask<Void, Void, List<DownloadStatus>>() {
|
||||
@Override
|
||||
protected List<DownloadStatus> doInBackground(Void... voids) {
|
||||
return DBReader.getDownloadLog(DownloadLogActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<DownloadStatus> downloadStatuses) {
|
||||
super.onPostExecute(downloadStatuses);
|
||||
if (downloadStatuses != null) {
|
||||
downloadLog = downloadStatuses;
|
||||
if (dla != null) {
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Could not load download log");
|
||||
}
|
||||
}
|
||||
};
|
||||
loadTask.execute();
|
||||
}
|
||||
|
||||
private DownloadLogAdapter.ItemAccess itemAccess = new DownloadLogAdapter.ItemAccess() {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return (downloadLog != null) ? downloadLog.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadStatus getItem(int position) {
|
||||
return (downloadLog != null) ? downloadLog.get(position) : null;
|
||||
}
|
||||
};
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((arg & EventDistributor.DOWNLOADLOG_UPDATE) != 0) {
|
||||
loadData();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.media.AudioManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.asynctask.FeedRemover;
|
||||
import de.danoeh.antennapod.dialog.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
|
||||
import de.danoeh.antennapod.fragment.FeedlistFragment;
|
||||
import de.danoeh.antennapod.fragment.ItemlistFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.util.StorageUtils;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
||||
|
||||
/**
|
||||
* Displays a List of FeedItems
|
||||
*/
|
||||
public class FeedItemlistActivity extends ActionBarActivity {
|
||||
private static final String TAG = "FeedItemlistActivity";
|
||||
|
||||
/**
|
||||
* The feed which the activity displays
|
||||
*/
|
||||
private Feed feed;
|
||||
private ItemlistFragment filf;
|
||||
private ExternalPlayerFragment externalPlayerFragment;
|
||||
|
||||
private AsyncTask<?, ?, ?> currentLoadTask;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.feeditemlist_activity);
|
||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
|
||||
long feedId = getIntent().getLongExtra(
|
||||
FeedlistFragment.EXTRA_SELECTED_FEED, -1);
|
||||
if (feedId == -1) {
|
||||
Log.e(TAG, "Received invalid feed selection.");
|
||||
} else {
|
||||
loadData(feedId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private synchronized void loadData(long id) {
|
||||
if (currentLoadTask != null) {
|
||||
currentLoadTask.cancel(true);
|
||||
}
|
||||
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
||||
|
||||
@Override
|
||||
protected Feed doInBackground(Long... longs) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Loading feed data in background");
|
||||
return DBReader.getFeed(FeedItemlistActivity.this, longs[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled(Feed feed) {
|
||||
super.onCancelled(feed);
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "load task was cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Feed result) {
|
||||
super.onPostExecute(result);
|
||||
if (result != null) {
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Finished loading feed data");
|
||||
feed = result;
|
||||
setTitle(feed.getTitle());
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
FragmentTransaction fT = fragmentManager.beginTransaction();
|
||||
|
||||
filf = ItemlistFragment.newInstance(feed.getId());
|
||||
fT.replace(R.id.feeditemlistFragment, filf);
|
||||
|
||||
externalPlayerFragment = new ExternalPlayerFragment();
|
||||
fT.replace(R.id.playerFragment, externalPlayerFragment);
|
||||
fT.commit();
|
||||
supportInvalidateOptionsMenu();
|
||||
} else {
|
||||
Log.e(TAG, "Error: Feed was null");
|
||||
}
|
||||
}
|
||||
};
|
||||
currentLoadTask = loadTask;
|
||||
loadTask.execute(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (currentLoadTask != null) {
|
||||
currentLoadTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
if (feed != null) {
|
||||
TypedArray drawables = obtainStyledAttributes(new int[]{R.attr.action_search});
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
|
||||
.setIcon(drawables.getDrawable(0)),
|
||||
MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
MenuItemCompat.setActionView(menu.findItem(R.id.search_item), new SearchView(this));
|
||||
|
||||
SearchManager searchManager =
|
||||
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_item));
|
||||
|
||||
|
||||
searchView.setIconifiedByDefault(true);
|
||||
|
||||
searchView.setSearchableInfo(
|
||||
searchManager.getSearchableInfo(getComponentName()));
|
||||
FeedMenuHandler
|
||||
.onCreateOptionsMenu(getMenuInflater(), menu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
return FeedMenuHandler.onPrepareOptionsMenu(menu, feed);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
try {
|
||||
if (FeedMenuHandler.onOptionsItemClicked(this, item, feed)) {
|
||||
// filf.getListAdapter().notifyDataSetChanged();
|
||||
} else {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.remove_item:
|
||||
final FeedRemover remover = new FeedRemover(
|
||||
FeedItemlistActivity.this, feed) {
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
super.onPostExecute(result);
|
||||
finish();
|
||||
}
|
||||
};
|
||||
ConfirmationDialog conDialog = new ConfirmationDialog(this,
|
||||
R.string.remove_feed_label,
|
||||
R.string.feed_delete_confirmation_msg) {
|
||||
|
||||
@Override
|
||||
public void onConfirmButtonPressed(
|
||||
DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
remover.executeAsync();
|
||||
}
|
||||
};
|
||||
conDialog.createNewDialog().show();
|
||||
break;
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
|
||||
e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
if (feed != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(SearchActivity.EXTRA_FEED_ID, feed.getId());
|
||||
startSearch(null, false, bundle, false);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
if (intent.getAction() != null &&
|
||||
intent.getAction().equals(Intent.ACTION_SEARCH)) {
|
||||
addSearchInformation(intent);
|
||||
}
|
||||
super.startActivity(intent);
|
||||
}
|
||||
|
||||
private void addSearchInformation(Intent startIntent) {
|
||||
startIntent.putExtra(SearchActivity.EXTRA_FEED_ID, feed.getId());
|
||||
}
|
||||
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.media.AudioManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
|
||||
import de.danoeh.antennapod.fragment.ItemlistFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.util.QueueAccess;
|
||||
import de.danoeh.antennapod.util.StorageUtils;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
/**
|
||||
* Displays a single FeedItem and provides various actions
|
||||
*/
|
||||
public class ItemviewActivity extends ActionBarActivity {
|
||||
private static final String TAG = "ItemviewActivity";
|
||||
|
||||
private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED | EventDistributor.DOWNLOAD_QUEUED;
|
||||
|
||||
private FeedItem item;
|
||||
private boolean guiInitialized;
|
||||
private AsyncTask<?, ?, ?> currentLoadTask;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
|
||||
guiInitialized = false;
|
||||
|
||||
long itemId = getIntent().getLongExtra(
|
||||
ItemlistFragment.EXTRA_SELECTED_FEEDITEM, -1);
|
||||
if (itemId == -1) {
|
||||
Log.e(TAG, "Received invalid selection of either feeditem or feed.");
|
||||
} else {
|
||||
loadData(itemId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
if (currentLoadTask != null) {
|
||||
currentLoadTask.cancel(true);
|
||||
}
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Stopping Activity");
|
||||
}
|
||||
|
||||
private synchronized void loadData(long itemId) {
|
||||
if (currentLoadTask != null) {
|
||||
currentLoadTask.cancel(true);
|
||||
}
|
||||
AsyncTask<Long, Void, FeedItem> loadTask = new AsyncTask<Long, Void, FeedItem>() {
|
||||
|
||||
@Override
|
||||
protected FeedItem doInBackground(Long... longs) {
|
||||
return DBReader.getFeedItem(ItemviewActivity.this, longs[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled(FeedItem feedItem) {
|
||||
super.onCancelled(feedItem);
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "loadTask was cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(FeedItem feedItem) {
|
||||
super.onPostExecute(feedItem);
|
||||
if (feedItem != null && feedItem.getFeed() != null) {
|
||||
item = feedItem;
|
||||
populateUI();
|
||||
supportInvalidateOptionsMenu();
|
||||
} else {
|
||||
if (feedItem == null) {
|
||||
Log.e(TAG, "Error: FeedItem was null");
|
||||
} else if (feedItem.getFeed() == null) {
|
||||
Log.e(TAG, "Error: Feed was null");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
loadTask.execute(itemId);
|
||||
currentLoadTask = loadTask;
|
||||
}
|
||||
|
||||
private synchronized void populateUI() {
|
||||
if (!guiInitialized) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.feeditemview);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
FragmentTransaction fragmentTransaction = fragmentManager
|
||||
.beginTransaction();
|
||||
ItemDescriptionFragment fragment = ItemDescriptionFragment
|
||||
.newInstance(item, false);
|
||||
fragmentTransaction.replace(R.id.description_fragment, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
TextView txtvTitle = (TextView) findViewById(R.id.txtvItemname);
|
||||
TextView txtvPublished = (TextView) findViewById(R.id.txtvPublished);
|
||||
setTitle(item.getFeed().getTitle());
|
||||
|
||||
txtvPublished.setText(DateUtils.formatSameDayTime(item.getPubDate()
|
||||
.getTime(), System.currentTimeMillis(), DateFormat.MEDIUM,
|
||||
DateFormat.SHORT));
|
||||
txtvTitle.setText(item.getTitle());
|
||||
|
||||
guiInitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
if (item != null) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.feeditem, menu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (!FeedItemMenuHandler.onMenuItemClicked(this,
|
||||
menuItem.getItemId(), item)) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
|
||||
e.getMessage());
|
||||
}
|
||||
supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
FeedItemMenuHandler.onPrepareMenu(
|
||||
new FeedItemMenuHandler.MenuInterface() {
|
||||
|
||||
@Override
|
||||
public void setItemVisibility(int id, boolean visible) {
|
||||
menu.findItem(id).setVisible(visible);
|
||||
}
|
||||
}, item, true, QueueAccess.NotInQueueAccess());
|
||||
return true;
|
||||
}
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
if (item != null) {
|
||||
loadData(item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.fragment.MiroGuideChannellistFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
/**
|
||||
* Shows channels of a category sorted by different criteria in lists. The
|
||||
* activity uses MiroGuideChannelListFragments for these lists. If the user
|
||||
* selects a channel, the MiroGuideChannelViewActivity is started.
|
||||
*/
|
||||
public class MiroGuideCategoryActivity extends ActionBarActivity {
|
||||
private static final String TAG = "MiroGuideCategoryActivity";
|
||||
|
||||
public static final String EXTRA_CATEGORY = "category";
|
||||
|
||||
private ViewPager viewpager;
|
||||
private CategoryPagerAdapter pagerAdapter;
|
||||
|
||||
private String category;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle arg0) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(arg0);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.miroguide_category);
|
||||
|
||||
viewpager = (ViewPager) findViewById(R.id.viewpager);
|
||||
|
||||
category = getIntent().getStringExtra(EXTRA_CATEGORY);
|
||||
if (category != null) {
|
||||
getSupportActionBar().setTitle(category);
|
||||
pagerAdapter = new CategoryPagerAdapter(getSupportFragmentManager());
|
||||
viewpager.setAdapter(pagerAdapter);
|
||||
} else {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class CategoryPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public CategoryPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
private static final int NUM_ITEMS = 2;
|
||||
private static final int POS_RATING = 0;
|
||||
private static final int POS_POPULAR = 1;
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
case POS_RATING:
|
||||
return MiroGuideChannellistFragment.newInstance("category",
|
||||
category, "rating");
|
||||
case POS_POPULAR:
|
||||
return MiroGuideChannellistFragment.newInstance("category",
|
||||
category, "popular");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case POS_RATING:
|
||||
return getString(R.string.best_rating_label);
|
||||
case POS_POPULAR:
|
||||
return getString(R.string.popular_label);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return NUM_ITEMS;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.*;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.MiroGuideItemlistAdapter;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.miroguide.conn.MiroGuideException;
|
||||
import de.danoeh.antennapod.miroguide.conn.MiroGuideService;
|
||||
import de.danoeh.antennapod.miroguide.model.MiroGuideChannel;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays information about one channel and lets the user add this channel to
|
||||
* his library.
|
||||
*/
|
||||
public class MiroGuideChannelViewActivity extends ActionBarActivity {
|
||||
private static final String TAG = "MiroGuideChannelViewActivity";
|
||||
|
||||
public static final String EXTRA_CHANNEL_ID = "id";
|
||||
public static final String EXTRA_CHANNEL_URL = "url";
|
||||
|
||||
private RelativeLayout layoutContent;
|
||||
private ProgressBar progLoading;
|
||||
private TextView txtvTitle;
|
||||
private TextView txtVDescription;
|
||||
private ListView listEntries;
|
||||
|
||||
private long channelId;
|
||||
private String channelUrl;
|
||||
private MiroGuideChannel channel;
|
||||
private volatile List<Feed> feeds;
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
channelLoader.cancel(true);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.miroguide_channelview);
|
||||
|
||||
layoutContent = (RelativeLayout) findViewById(R.id.layout_content);
|
||||
progLoading = (ProgressBar) findViewById(R.id.progLoading);
|
||||
txtvTitle = (TextView) findViewById(R.id.txtvTitle);
|
||||
txtVDescription = (TextView) findViewById(R.id.txtvDescription);
|
||||
listEntries = (ListView) findViewById(R.id.itemlist);
|
||||
|
||||
channelId = getIntent().getLongExtra(EXTRA_CHANNEL_ID, -1);
|
||||
channelUrl = getIntent().getStringExtra(EXTRA_CHANNEL_URL);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||
channelLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
channelLoader.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is used to load channel information asynchronously.
|
||||
*/
|
||||
private AsyncTask<Void, Void, Void> channelLoader = new AsyncTask<Void, Void, Void>() {
|
||||
private static final String TAG = "ChannelLoader";
|
||||
private Exception exception;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Starting background task");
|
||||
feeds = DBReader.getFeedList(MiroGuideChannelViewActivity.this);
|
||||
MiroGuideService service = new MiroGuideService();
|
||||
try {
|
||||
channel = service.getChannel(channelId);
|
||||
} catch (MiroGuideException e) {
|
||||
e.printStackTrace();
|
||||
exception = e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Loading finished");
|
||||
if (exception == null) {
|
||||
txtvTitle.setText(channel.getName());
|
||||
txtVDescription.setText(channel.getDescription());
|
||||
|
||||
MiroGuideItemlistAdapter listAdapter = new MiroGuideItemlistAdapter(
|
||||
MiroGuideChannelViewActivity.this, 0,
|
||||
channel.getItems());
|
||||
listEntries.setAdapter(listAdapter);
|
||||
progLoading.setVisibility(View.GONE);
|
||||
layoutContent.setVisibility(View.VISIBLE);
|
||||
supportInvalidateOptionsMenu();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.channelview, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
boolean channelLoaded = channel != null;
|
||||
boolean beingDownloaded = channelLoaded
|
||||
&& DownloadRequester.getInstance().isDownloadingFile(
|
||||
channel.getDownloadUrl());
|
||||
boolean notAdded = channelLoaded
|
||||
&& !((feedExists(
|
||||
channel.getDownloadUrl()) || beingDownloaded));
|
||||
menu.findItem(R.id.add_feed).setVisible(notAdded);
|
||||
menu.findItem(R.id.visit_website_item).setVisible(
|
||||
channelLoaded && channel.getWebsiteUrl() != null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
case R.id.visit_website_item:
|
||||
Uri uri = Uri.parse(channel.getWebsiteUrl());
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
||||
return true;
|
||||
case R.id.add_feed:
|
||||
try {
|
||||
DownloadRequester.getInstance().downloadFeed(
|
||||
this,
|
||||
new Feed(channel.getDownloadUrl(), new Date(), channel
|
||||
.getName()));
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
|
||||
e.getMessage());
|
||||
}
|
||||
Toast toast = Toast.makeText(this, R.string.miro_feed_added,
|
||||
Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean feedExists(String downloadUrl) {
|
||||
if (feeds == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Feed feed : feeds) {
|
||||
if (feed.getDownload_url().equals(downloadUrl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.miroguide.conn.MiroGuideException;
|
||||
import de.danoeh.antennapod.miroguide.conn.MiroGuideService;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
/**
|
||||
* Shows a list of available categories and offers a search button. If the user
|
||||
* selects a category, the MiroGuideCategoryActivity is started.
|
||||
*/
|
||||
public class MiroGuideMainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
|
||||
private static final String TAG = "MiroGuideMainActivity";
|
||||
|
||||
private static String[] categories;
|
||||
private ArrayAdapter<String> listAdapter;
|
||||
|
||||
private TextView txtvStatus;
|
||||
private ListView listView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.miroguide_categorylist);
|
||||
|
||||
txtvStatus = (TextView) findViewById(android.R.id.empty);
|
||||
listView = (ListView) findViewById(android.R.id.list);
|
||||
listView.setOnItemClickListener(this);
|
||||
listView.setEmptyView(txtvStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (categories != null) {
|
||||
createAdapter();
|
||||
} else {
|
||||
loadCategories();
|
||||
}
|
||||
}
|
||||
|
||||
private void createAdapter() {
|
||||
if (categories != null) {
|
||||
listAdapter = new ArrayAdapter<String>(this,
|
||||
android.R.layout.simple_list_item_1, categories);
|
||||
txtvStatus.setText(R.string.no_items_label);
|
||||
listView.setAdapter(listAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches an AsyncTask to load the available categories in the background.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
private void loadCategories() {
|
||||
AsyncTask<Void, Void, Void> listLoader = new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
private String[] c;
|
||||
private MiroGuideException exception;
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (exception == null) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Successfully loaded categories");
|
||||
categories = c;
|
||||
createAdapter();
|
||||
} else {
|
||||
Log.e(TAG, "Error happened while trying to load categories");
|
||||
txtvStatus.setText(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
txtvStatus.setText(R.string.loading_categories_label);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
MiroGuideService service = new MiroGuideService();
|
||||
try {
|
||||
c = service.getCategories();
|
||||
} catch (MiroGuideException e) {
|
||||
e.printStackTrace();
|
||||
exception = e;
|
||||
} finally {
|
||||
service.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||
listLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
listLoader.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
|
||||
.setIcon(
|
||||
obtainStyledAttributes(
|
||||
new int[]{R.attr.action_search})
|
||||
.getDrawable(0)),
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
MenuItemCompat.setActionView(menu.findItem(R.id.search_item), new SearchView(this));
|
||||
|
||||
SearchManager searchManager =
|
||||
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_item));
|
||||
searchView.setIconifiedByDefault(true);
|
||||
searchView.setSearchableInfo(
|
||||
searchManager.getSearchableInfo(getComponentName()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
String selection = listAdapter.getItem(position);
|
||||
Intent launchIntent = new Intent(this, MiroGuideCategoryActivity.class);
|
||||
launchIntent.putExtra(MiroGuideCategoryActivity.EXTRA_CATEGORY,
|
||||
selection);
|
||||
startActivity(launchIntent);
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.fragment.MiroGuideChannellistFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
/**
|
||||
* Displays results when a search for miroguide channels has been performed. It
|
||||
* uses a MiroGuideChannelListFragment to display the results.
|
||||
*/
|
||||
public class MiroGuideSearchActivity extends ActionBarActivity {
|
||||
private static final String TAG = "MiroGuideSearchActivity";
|
||||
|
||||
private MiroGuideChannellistFragment listFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle arg0) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(arg0);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.miroguidesearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent intent = getIntent();
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
getSupportActionBar()
|
||||
.setSubtitle(
|
||||
getString(R.string.search_term_label) + "\""
|
||||
+ query + "\"");
|
||||
handleSearchRequest(query);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSearchRequest(String query) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Performing search");
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
listFragment = MiroGuideChannellistFragment.newInstance("name", query,
|
||||
"name");
|
||||
ft.replace(R.id.channellistFragment, listFragment);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
setIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
|
||||
.setIcon(
|
||||
obtainStyledAttributes(
|
||||
new int[]{R.attr.action_search})
|
||||
.getDrawable(0)),
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
case R.id.search_item:
|
||||
onSearchRequested();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,307 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import com.mobeta.android.dslv.DragSortListView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.asynctask.ImageLoader;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DBTasks;
|
||||
import de.danoeh.antennapod.storage.DBWriter;
|
||||
import de.danoeh.antennapod.util.UndoBarController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OrganizeQueueActivity extends ActionBarActivity implements
|
||||
UndoBarController.UndoListener {
|
||||
private static final String TAG = "OrganizeQueueActivity";
|
||||
|
||||
private static final int MENU_ID_ACCEPT = 2;
|
||||
|
||||
private List<FeedItem> queue;
|
||||
|
||||
private OrganizeAdapter adapter;
|
||||
private UndoBarController undoBarController;
|
||||
|
||||
private DragSortListView listView;
|
||||
private TextView emptyView;
|
||||
private ProgressBar progLoading;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.organize_queue);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
listView = (DragSortListView) findViewById(android.R.id.list);
|
||||
emptyView = (TextView) findViewById(android.R.id.empty);
|
||||
progLoading = (ProgressBar) findViewById(R.id.progLoading);
|
||||
|
||||
listView.setDropListener(dropListener);
|
||||
listView.setRemoveListener(removeListener);
|
||||
listView.setEmptyView(findViewById(android.R.id.empty));
|
||||
|
||||
loadData();
|
||||
undoBarController = new UndoBarController(findViewById(R.id.undobar),
|
||||
this);
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
AsyncTask<Void, Void, List<FeedItem>> loadTask = new AsyncTask<Void, Void, List<FeedItem>>() {
|
||||
|
||||
@Override
|
||||
protected List<FeedItem> doInBackground(Void... voids) {
|
||||
return DBReader.getQueue(OrganizeQueueActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
// do not show loading animation if queue is already loaded
|
||||
if (queue == null) {
|
||||
progLoading.setVisibility(View.VISIBLE);
|
||||
listView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<FeedItem> feedItems) {
|
||||
super.onPostExecute(feedItems);
|
||||
if (feedItems != null) {
|
||||
queue = feedItems;
|
||||
if (adapter == null) {
|
||||
adapter = new OrganizeAdapter(OrganizeQueueActivity.this);
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
} else {
|
||||
Log.e(TAG, "Queue was null");
|
||||
}
|
||||
progLoading.setVisibility(View.GONE);
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
};
|
||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||
loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
loadTask.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
DBTasks.autodownloadUndownloadedItems(getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
}
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if (((EventDistributor.QUEUE_UPDATE | EventDistributor.FEED_LIST_UPDATE) & arg) != 0) {
|
||||
loadData();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private DragSortListView.DropListener dropListener = new DragSortListView.DropListener() {
|
||||
|
||||
@Override
|
||||
public void drop(int from, int to) {
|
||||
final FeedItem item = queue.remove(from);
|
||||
queue.add(to, item);
|
||||
adapter.notifyDataSetChanged();
|
||||
DBWriter.moveQueueItem(OrganizeQueueActivity.this, from, to, true);
|
||||
}
|
||||
};
|
||||
|
||||
private DragSortListView.RemoveListener removeListener = new DragSortListView.RemoveListener() {
|
||||
|
||||
@Override
|
||||
public void remove(int which) {
|
||||
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
|
||||
DBWriter.removeQueueItem(OrganizeQueueActivity.this, item.getId(), true);
|
||||
undoBarController.showUndoBar(false,
|
||||
getString(R.string.removed_from_queue), new UndoToken(item,
|
||||
which));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUndo(Parcelable token) {
|
||||
// Perform the undo
|
||||
UndoToken undoToken = (UndoToken) token;
|
||||
if (token != null) {
|
||||
long itemId = undoToken.getFeedItemId();
|
||||
int position = undoToken.getPosition();
|
||||
DBWriter.addQueueItemAt(OrganizeQueueActivity.this, itemId, position, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static class OrganizeAdapter extends BaseAdapter {
|
||||
|
||||
private OrganizeQueueActivity organizeQueueActivity;
|
||||
|
||||
public OrganizeAdapter(OrganizeQueueActivity organizeQueueActivity) {
|
||||
super();
|
||||
this.organizeQueueActivity = organizeQueueActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
final FeedItem item = getItem(position);
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
LayoutInflater inflater = (LayoutInflater) organizeQueueActivity
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(
|
||||
R.layout.organize_queue_listitem, null);
|
||||
holder.title = (TextView) convertView
|
||||
.findViewById(R.id.txtvTitle);
|
||||
holder.feedTitle = (TextView) convertView
|
||||
.findViewById(R.id.txtvFeedname);
|
||||
|
||||
holder.feedImage = (ImageView) convertView
|
||||
.findViewById(R.id.imgvFeedimage);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.title.setText(item.getTitle());
|
||||
holder.feedTitle.setText(item.getFeed().getTitle());
|
||||
|
||||
holder.feedImage.setTag(item.getImageLoaderCacheKey());
|
||||
ImageLoader.getInstance().loadThumbnailBitmap(
|
||||
item,
|
||||
holder.feedImage,
|
||||
(int) convertView.getResources().getDimension(
|
||||
R.dimen.thumbnail_length));
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
static class Holder {
|
||||
TextView title;
|
||||
TextView feedTitle;
|
||||
ImageView feedImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (organizeQueueActivity.queue != null) {
|
||||
return organizeQueueActivity.queue.size();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedItem getItem(int position) {
|
||||
if (organizeQueueActivity.queue != null) {
|
||||
return organizeQueueActivity.queue.get(position);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class UndoToken implements Parcelable {
|
||||
private long itemId;
|
||||
private long feedId;
|
||||
private int position;
|
||||
|
||||
public UndoToken(FeedItem item, int position) {
|
||||
this.itemId = item.getId();
|
||||
this.feedId = item.getFeed().getId();
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
private UndoToken(Parcel in) {
|
||||
itemId = in.readLong();
|
||||
feedId = in.readLong();
|
||||
position = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<UndoToken> CREATOR = new Parcelable.Creator<UndoToken>() {
|
||||
public UndoToken createFromParcel(Parcel in) {
|
||||
return new UndoToken(in);
|
||||
}
|
||||
|
||||
public UndoToken[] newArray(int size) {
|
||||
return new UndoToken[size];
|
||||
}
|
||||
};
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeLong(itemId);
|
||||
out.writeLong(feedId);
|
||||
out.writeInt(position);
|
||||
}
|
||||
|
||||
public long getFeedItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.DBWriter;
|
||||
|
||||
public class PlaybackHistoryActivity extends ActionBarActivity {
|
||||
private static final String TAG = "PlaybackHistoryActivity";
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.clear_history_item, Menu.NONE,
|
||||
R.string.clear_history_label),
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
case R.id.clear_history_item:
|
||||
DBWriter.clearPlaybackHistory(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle arg0) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(arg0);
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Activity created");
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.playbackhistory_activity);
|
||||
|
||||
FragmentTransaction fT = getSupportFragmentManager().beginTransaction();
|
||||
fT.replace(R.id.playbackhistory_fragment, new PlaybackHistoryFragment());
|
||||
fT.commit();
|
||||
}
|
||||
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.SearchlistAdapter;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.SearchResult;
|
||||
import de.danoeh.antennapod.fragment.FeedlistFragment;
|
||||
import de.danoeh.antennapod.fragment.ItemlistFragment;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.FeedSearcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays the results when the user searches for FeedItems or Feeds.
|
||||
*/
|
||||
public class SearchActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
|
||||
private static final String TAG = "SearchActivity";
|
||||
|
||||
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.searchactivity.extra.feedId";
|
||||
|
||||
private SearchlistAdapter searchAdapter;
|
||||
|
||||
/**
|
||||
* ID of the feed that is being searched or null if the search is global.
|
||||
*/
|
||||
private long feedID;
|
||||
|
||||
private ListView listView;
|
||||
private TextView txtvStatus;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.searchlist);
|
||||
listView = (ListView) findViewById(android.R.id.list);
|
||||
txtvStatus = (TextView) findViewById(android.R.id.empty);
|
||||
|
||||
listView.setOnItemClickListener(this);
|
||||
//searchAdapter = new SearchlistAdapter(this, 0, new ArrayList<SearchResult>());
|
||||
listView.setAdapter(searchAdapter);
|
||||
listView.setEmptyView(txtvStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
setIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent intent = getIntent();
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
if (intent.hasExtra(SearchActivity.EXTRA_FEED_ID)) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Found bundle extra");
|
||||
feedID = intent.getLongExtra(SearchActivity.EXTRA_FEED_ID, 0);
|
||||
}
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Starting search");
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
getSupportActionBar()
|
||||
.setSubtitle(
|
||||
getString(R.string.search_term_label) + "\""
|
||||
+ query + "\"");
|
||||
handleSearchRequest(query);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
|
||||
.setIcon(
|
||||
obtainStyledAttributes(
|
||||
new int[]{R.attr.action_search})
|
||||
.getDrawable(0)),
|
||||
(MenuItem.SHOW_AS_ACTION_IF_ROOM));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
case R.id.search_item:
|
||||
onSearchRequested();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
Bundle extra = null;
|
||||
if (feedID != 0) {
|
||||
extra = new Bundle();
|
||||
extra.putLong(EXTRA_FEED_ID, feedID);
|
||||
}
|
||||
startSearch(null, false, extra, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint({"NewApi", "NewApi"})
|
||||
private void handleSearchRequest(final String query) {
|
||||
if (searchAdapter != null) {
|
||||
// searchAdapter.clear();
|
||||
searchAdapter.notifyDataSetChanged();
|
||||
}
|
||||
txtvStatus.setText(R.string.search_status_searching);
|
||||
|
||||
Thread thread = new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "Starting background work");
|
||||
final Activity activity = SearchActivity.this;
|
||||
final List<SearchResult> result = FeedSearcher
|
||||
.performSearch(activity, query, feedID);
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Background work finished");
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Found " + result.size()
|
||||
+ " results");
|
||||
|
||||
// searchAdapter.clear();
|
||||
for (SearchResult s : result) {
|
||||
// searchAdapter.add(s);
|
||||
}
|
||||
searchAdapter.notifyDataSetChanged();
|
||||
txtvStatus
|
||||
.setText(R.string.search_status_no_results);
|
||||
if (!searchAdapter.isEmpty()) {
|
||||
txtvStatus.setVisibility(View.GONE);
|
||||
} else {
|
||||
txtvStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
SearchResult selection = searchAdapter.getItem(position);
|
||||
if (selection.getComponent().getClass() == Feed.class) {
|
||||
Feed feed = (Feed) selection.getComponent();
|
||||
Intent launchIntent = new Intent(this, FeedItemlistActivity.class);
|
||||
launchIntent.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED,
|
||||
feed.getId());
|
||||
startActivity(launchIntent);
|
||||
|
||||
} else if (selection.getComponent().getClass() == FeedItem.class) {
|
||||
FeedItem item = (FeedItem) selection.getComponent();
|
||||
Intent launchIntent = new Intent(this, ItemviewActivity.class);
|
||||
launchIntent.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED, item
|
||||
.getFeed().getId());
|
||||
launchIntent.putExtra(ItemlistFragment.EXTRA_SELECTED_FEEDITEM,
|
||||
item.getId());
|
||||
startActivity(launchIntent);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package de.danoeh.antennapod.activity.gpoddernet;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
/**
|
||||
* Created by daniel on 23.08.13.
|
||||
*/
|
||||
public class GpodnetActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
|
||||
.setIcon(
|
||||
obtainStyledAttributes(
|
||||
new int[]{R.attr.action_search})
|
||||
.getDrawable(0)),
|
||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
MenuItemCompat.setActionView(menu.findItem(R.id.search_item), new SearchView(this));
|
||||
|
||||
SearchManager searchManager =
|
||||
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_item));
|
||||
searchView.setIconifiedByDefault(true);
|
||||
searchView.setSearchableInfo(
|
||||
searchManager.getSearchableInfo(getComponentName()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package de.danoeh.antennapod.activity.gpoddernet;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.fragment.gpodnet.PodcastTopListFragment;
|
||||
import de.danoeh.antennapod.fragment.gpodnet.SuggestionListFragment;
|
||||
import de.danoeh.antennapod.fragment.gpodnet.TagListFragment;
|
||||
|
||||
/**
|
||||
* Created by daniel on 22.08.13.
|
||||
*/
|
||||
public class GpodnetMainActivity extends GpodnetActivity {
|
||||
private static final String TAG = "GPodnetMainActivity";
|
||||
|
||||
private static final int POS_TAGS = 0;
|
||||
private static final int POS_TOPLIST = 1;
|
||||
private static final int POS_SUGGESTIONS = 2;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.gpodnet_main);
|
||||
ViewPager viewpager = (ViewPager) findViewById(R.id.viewpager);
|
||||
viewpager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private class PagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private static final int NUM_PAGES_LOGGED_OUT = 2;
|
||||
private static final int NUM_PAGES_LOGGED_IN = 3;
|
||||
private final int NUM_PAGES;
|
||||
|
||||
public PagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
NUM_PAGES = NUM_PAGES_LOGGED_OUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int i) {
|
||||
switch (i) {
|
||||
case POS_TAGS:
|
||||
return new TagListFragment();
|
||||
case POS_TOPLIST:
|
||||
return new PodcastTopListFragment();
|
||||
case POS_SUGGESTIONS:
|
||||
return new SuggestionListFragment();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case POS_TAGS:
|
||||
return getString(R.string.gpodnet_taglist_header);
|
||||
case POS_TOPLIST:
|
||||
return getString(R.string.gpodnet_toplist_header);
|
||||
case POS_SUGGESTIONS:
|
||||
return getString(R.string.gpodnet_suggestions_header);
|
||||
default:
|
||||
return super.getPageTitle(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return NUM_PAGES;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package de.danoeh.antennapod.activity.gpoddernet;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.fragment.gpodnet.SearchListFragment;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Created by daniel on 23.08.13.
|
||||
*/
|
||||
public class GpodnetSearchActivity extends GpodnetActivity {
|
||||
|
||||
private SearchListFragment searchFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.gpodnet_search);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent intent = getIntent();
|
||||
if (StringUtils.equals(intent.getAction(), Intent.ACTION_SEARCH)) {
|
||||
handleSearchRequest(intent.getStringExtra(SearchManager.QUERY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
setIntent(intent);
|
||||
}
|
||||
|
||||
private void handleSearchRequest(String query) {
|
||||
getSupportActionBar().setSubtitle(getString(R.string.search_term_label) + query);
|
||||
if (searchFragment == null) {
|
||||
FragmentTransaction transaction = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
searchFragment = SearchListFragment.newInstance(query);
|
||||
transaction.replace(R.id.searchListFragment, searchFragment);
|
||||
transaction.commit();
|
||||
} else {
|
||||
searchFragment.changeQuery(query);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package de.danoeh.antennapod.activity.gpoddernet;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.MenuItem;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.fragment.gpodnet.PodcastListFragment;
|
||||
import de.danoeh.antennapod.gpoddernet.GpodnetService;
|
||||
import de.danoeh.antennapod.gpoddernet.GpodnetServiceException;
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetPodcast;
|
||||
import de.danoeh.antennapod.gpoddernet.model.GpodnetTag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by daniel on 23.08.13.
|
||||
*/
|
||||
public class GpodnetTagActivity extends GpodnetActivity{
|
||||
|
||||
private static final int PODCAST_COUNT = 50;
|
||||
public static final String ARG_TAGNAME = "tagname";
|
||||
|
||||
private GpodnetTag tag;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.gpodnet_tag_activity);
|
||||
|
||||
if (!getIntent().hasExtra(ARG_TAGNAME)) {
|
||||
throw new IllegalArgumentException("No tagname argument");
|
||||
}
|
||||
tag = new GpodnetTag(getIntent().getStringExtra(ARG_TAGNAME));
|
||||
getSupportActionBar().setTitle(tag.getName());
|
||||
|
||||
FragmentTransaction transaction = getSupportFragmentManager()
|
||||
.beginTransaction();
|
||||
Fragment taglistFragment = new TaglistFragment();
|
||||
transaction.replace(R.id.taglistFragment, taglistFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
private class TaglistFragment extends PodcastListFragment {
|
||||
|
||||
@Override
|
||||
protected List<GpodnetPodcast> loadPodcastData(GpodnetService service) throws GpodnetServiceException {
|
||||
return service.getPodcastsForTag(tag, PODCAST_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package de.danoeh.antennapod.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.miroguide.model.MiroGuideChannel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MiroGuideChannelListAdapter extends ArrayAdapter<MiroGuideChannel> {
|
||||
|
||||
public MiroGuideChannelListAdapter(Context context, int textViewResourceId,
|
||||
List<MiroGuideChannel> objects) {
|
||||
super(context, textViewResourceId, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
MiroGuideChannel channel = getItem(position);
|
||||
|
||||
// Inflate Layout
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
LayoutInflater inflater = (LayoutInflater) getContext()
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
convertView = inflater.inflate(R.layout.miroguide_channellist_item, null);
|
||||
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.title.setText(channel.getName());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
static class Holder {
|
||||
TextView title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package de.danoeh.antennapod.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.miroguide.model.MiroGuideItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MiroGuideItemlistAdapter extends ArrayAdapter<MiroGuideItem> {
|
||||
|
||||
public MiroGuideItemlistAdapter(Context context, int textViewResourceId,
|
||||
List<MiroGuideItem> objects) {
|
||||
super(context, textViewResourceId, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
MiroGuideItem item = getItem(position);
|
||||
|
||||
// Inflate Layout
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
LayoutInflater inflater = (LayoutInflater) getContext()
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
convertView = inflater.inflate(R.layout.miroguide_itemlist_item,
|
||||
null);
|
||||
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
|
||||
holder.date = (TextView) convertView.findViewById(R.id.txtvDate);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.title.setText(item.getName());
|
||||
if (item.getDate() != null) {
|
||||
holder.date.setText(DateUtils.getRelativeTimeSpanString(
|
||||
item.getDate().getTime(), System.currentTimeMillis(), 0, 0));
|
||||
holder.date.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.date.setVisibility(View.GONE);
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
static class Holder {
|
||||
TextView title;
|
||||
TextView date;
|
||||
}
|
||||
|
||||
}
|
@ -1,327 +0,0 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.OnChildClickListener;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.ItemviewActivity;
|
||||
import de.danoeh.antennapod.activity.OrganizeQueueActivity;
|
||||
import de.danoeh.antennapod.adapter.ActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.ExternalEpisodesListAdapter;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DBTasks;
|
||||
import de.danoeh.antennapod.storage.DBWriter;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.util.QueueAccess;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EpisodesFragment extends Fragment {
|
||||
private static final String TAG = "EpisodesFragment";
|
||||
|
||||
private static final int EVENTS = EventDistributor.QUEUE_UPDATE
|
||||
| EventDistributor.UNREAD_ITEMS_UPDATE
|
||||
| EventDistributor.FEED_LIST_UPDATE
|
||||
| EventDistributor.DOWNLOAD_HANDLED
|
||||
| EventDistributor.DOWNLOAD_QUEUED;
|
||||
|
||||
private ExpandableListView listView;
|
||||
private ExternalEpisodesListAdapter adapter;
|
||||
|
||||
private List<FeedItem> queue;
|
||||
private List<FeedItem> unreadItems;
|
||||
|
||||
protected FeedItem selectedItem = null;
|
||||
protected long selectedGroupId = -1;
|
||||
protected boolean contextMenuClosed = true;
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.episodes_fragment, null);
|
||||
listView = (ExpandableListView) v.findViewById(android.R.id.list);
|
||||
return v;
|
||||
}
|
||||
|
||||
protected ActionButtonCallback adapterCallback = new ActionButtonCallback() {
|
||||
|
||||
@Override
|
||||
public void onActionButtonPressed(FeedItem item) {
|
||||
resetContextMenuSelection();
|
||||
selectedItem = item;
|
||||
listView.showContextMenu();
|
||||
}
|
||||
};
|
||||
|
||||
protected ExternalEpisodesListAdapter.OnGroupActionClicked groupActionCallback = new ExternalEpisodesListAdapter.OnGroupActionClicked() {
|
||||
|
||||
@Override
|
||||
public void onClick(long groupId) {
|
||||
resetContextMenuSelection();
|
||||
selectedGroupId = groupId;
|
||||
listView.showContextMenu();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
adapter = new ExternalEpisodesListAdapter(getActivity(),
|
||||
adapterCallback, groupActionCallback, itemAccess);
|
||||
listView.setAdapter(adapter);
|
||||
listView.expandGroup(ExternalEpisodesListAdapter.GROUP_POS_QUEUE);
|
||||
listView.expandGroup(ExternalEpisodesListAdapter.GROUP_POS_UNREAD);
|
||||
listView.setOnChildClickListener(new OnChildClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v,
|
||||
int groupPosition, int childPosition, long id) {
|
||||
FeedItem selection = adapter.getChild(groupPosition,
|
||||
childPosition);
|
||||
if (selection != null) {
|
||||
Intent showItem = new Intent(getActivity(),
|
||||
ItemviewActivity.class);
|
||||
showItem.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED,
|
||||
selection.getFeed().getId());
|
||||
showItem.putExtra(ItemlistFragment.EXTRA_SELECTED_FEEDITEM,
|
||||
selection.getId());
|
||||
|
||||
startActivity(showItem);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
loadData();
|
||||
registerForContextMenu(listView);
|
||||
|
||||
}
|
||||
|
||||
ExternalEpisodesListAdapter.ItemAccess itemAccess = new ExternalEpisodesListAdapter.ItemAccess() {
|
||||
|
||||
@Override
|
||||
public int getQueueSize() {
|
||||
return (queue != null) ? queue.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnreadItemsSize() {
|
||||
return (unreadItems != null) ? unreadItems.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedItem getQueueItemAt(int position) {
|
||||
return (queue != null) ? queue.get(position) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedItem getUnreadItemAt(int position) {
|
||||
return (unreadItems != null) ? unreadItems.get(position) : null;
|
||||
}
|
||||
};
|
||||
|
||||
private void loadData() {
|
||||
AsyncTask<Void, Void, Void> loadTask = new AsyncTask<Void, Void, Void>() {
|
||||
private volatile List<FeedItem> queueRef;
|
||||
private volatile List<FeedItem> unreadItemsRef;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Starting to load list data");
|
||||
Context context = EpisodesFragment.this.getActivity();
|
||||
if (context != null) {
|
||||
queueRef = DBReader.getQueue(context);
|
||||
unreadItemsRef = DBReader.getUnreadItemsList(context);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
if (queueRef != null && unreadItemsRef != null) {
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Done loading list data");
|
||||
queue = queueRef;
|
||||
unreadItems = unreadItemsRef;
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
if (queueRef == null) {
|
||||
Log.e(TAG, "Could not load queue");
|
||||
}
|
||||
if (unreadItemsRef == null) {
|
||||
Log.e(TAG, "Could not load unread items");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
loadTask.execute();
|
||||
}
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
loadData();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(final ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
if (!contextMenuClosed) { // true if context menu was cancelled before
|
||||
resetContextMenuSelection();
|
||||
}
|
||||
contextMenuClosed = false;
|
||||
listView.setOnItemLongClickListener(null);
|
||||
if (selectedItem != null) {
|
||||
new MenuInflater(getActivity()).inflate(R.menu.feeditem, menu);
|
||||
|
||||
menu.setHeaderTitle(selectedItem.getTitle());
|
||||
FeedItemMenuHandler.onPrepareMenu(
|
||||
new FeedItemMenuHandler.MenuInterface() {
|
||||
|
||||
@Override
|
||||
public void setItemVisibility(int id, boolean visible) {
|
||||
menu.findItem(id).setVisible(visible);
|
||||
}
|
||||
}, selectedItem, false, QueueAccess.ItemListAccess(queue));
|
||||
|
||||
// check to see if the item is in the queue, if so add queue menu items
|
||||
int itemIndex = queue.indexOf(selectedItem);
|
||||
if (itemIndex != -1) {
|
||||
addQueueOnlyMenus(menu, itemIndex);
|
||||
}
|
||||
|
||||
} else if (selectedGroupId == ExternalEpisodesListAdapter.GROUP_POS_QUEUE) {
|
||||
menu.add(Menu.NONE, R.id.organize_queue_item, Menu.NONE,
|
||||
R.string.organize_queue_label);
|
||||
menu.add(Menu.NONE, R.id.clear_queue_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.clear_queue_label));
|
||||
menu.add(Menu.NONE, R.id.download_all_item, Menu.NONE,
|
||||
getActivity().getString(R.string.download_all));
|
||||
} else if (selectedGroupId == ExternalEpisodesListAdapter.GROUP_POS_UNREAD) {
|
||||
menu.add(Menu.NONE, R.id.mark_all_read_item, Menu.NONE,
|
||||
getActivity().getString(R.string.mark_all_read_label));
|
||||
menu.add(Menu.NONE, R.id.enqueue_all_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.enqueue_all_new));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds submenus to the ContextMenu if the item selected is in the queue.
|
||||
* @param menu the ContextMenu to add the submenus to
|
||||
* @param itemIndex the index of the selected item within the queue.
|
||||
*/
|
||||
private void addQueueOnlyMenus(ContextMenu menu, int itemIndex) {
|
||||
if (itemIndex != 0) {
|
||||
// don't add move to top if this item is already on the top
|
||||
menu.add(Menu.NONE, R.id.move_to_top_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.move_to_top_label));
|
||||
}
|
||||
if (itemIndex != queue.size() - 1) {
|
||||
// don't add move to bottom if this item is already on the bottom
|
||||
menu.add(Menu.NONE, R.id.move_to_bottom_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.move_to_bottom_label));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(android.view.MenuItem item) {
|
||||
boolean handled = false;
|
||||
if (selectedItem != null) {
|
||||
try {
|
||||
handled = FeedItemMenuHandler.onMenuItemClicked(
|
||||
getActivity(), item.getItemId(), selectedItem);
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(
|
||||
getActivity(), e.getMessage());
|
||||
}
|
||||
if (!handled) {
|
||||
// if it wasn't handled by the FeedItemMenuHandler it might be one of ours
|
||||
switch (item.getItemId()) {
|
||||
case R.id.move_to_top_item:
|
||||
DBWriter.moveQueueItemToTop(getActivity(), selectedItem.getId(), true);
|
||||
handled = true;
|
||||
break;
|
||||
case R.id.move_to_bottom_item:
|
||||
DBWriter.moveQueueItemToBottom(getActivity(), selectedItem.getId(), true);
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (selectedGroupId == ExternalEpisodesListAdapter.GROUP_POS_QUEUE) {
|
||||
handled = true;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.organize_queue_item:
|
||||
startActivity(new Intent(getActivity(),
|
||||
OrganizeQueueActivity.class));
|
||||
break;
|
||||
case R.id.clear_queue_item:
|
||||
DBWriter.clearQueue(getActivity());
|
||||
break;
|
||||
case R.id.download_all_item:
|
||||
DBTasks.downloadAllItemsInQueue(getActivity());
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
}
|
||||
} else if (selectedGroupId == ExternalEpisodesListAdapter.GROUP_POS_UNREAD) {
|
||||
handled = true;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.mark_all_read_item:
|
||||
DBWriter.markAllItemsRead(getActivity());
|
||||
break;
|
||||
case R.id.enqueue_all_item:
|
||||
DBTasks.enqueueAllNewItems(getActivity());
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
}
|
||||
}
|
||||
|
||||
resetContextMenuSelection();
|
||||
return handled;
|
||||
}
|
||||
|
||||
private void resetContextMenuSelection() {
|
||||
selectedItem = null;
|
||||
selectedGroupId = -1;
|
||||
contextMenuClosed = true;
|
||||
}
|
||||
}
|
@ -1,292 +0,0 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.FeedItemlistActivity;
|
||||
import de.danoeh.antennapod.adapter.FeedlistAdapter;
|
||||
import de.danoeh.antennapod.asynctask.FeedRemover;
|
||||
import de.danoeh.antennapod.dialog.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.storage.DBReader;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.storage.FeedItemStatistics;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FeedlistFragment extends Fragment implements
|
||||
ActionMode.Callback, AdapterView.OnItemClickListener,
|
||||
AdapterView.OnItemLongClickListener {
|
||||
private static final String TAG = "FeedlistFragment";
|
||||
|
||||
private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED
|
||||
| EventDistributor.DOWNLOAD_QUEUED
|
||||
| EventDistributor.FEED_LIST_UPDATE
|
||||
| EventDistributor.UNREAD_ITEMS_UPDATE;
|
||||
|
||||
public static final String EXTRA_SELECTED_FEED = "extra.de.danoeh.antennapod.activity.selected_feed";
|
||||
|
||||
private FeedlistAdapter fla;
|
||||
private List<Feed> feeds;
|
||||
private List<FeedItemStatistics> feedItemStatistics;
|
||||
|
||||
private Feed selectedFeed;
|
||||
private ActionMode mActionMode;
|
||||
|
||||
private GridView gridView;
|
||||
private ListView listView;
|
||||
private TextView emptyView;
|
||||
|
||||
private FeedlistAdapter.ItemAccess itemAccess = new FeedlistAdapter.ItemAccess() {
|
||||
|
||||
@Override
|
||||
public Feed getItem(int position) {
|
||||
if (feeds != null) {
|
||||
return feeds.get(position);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedItemStatistics getFeedItemStatistics(int position) {
|
||||
if (feedItemStatistics != null && position < feedItemStatistics.size()) {
|
||||
return feedItemStatistics.get(position);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (feeds != null) {
|
||||
return feeds.size();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Creating");
|
||||
fla = new FeedlistAdapter(getActivity(), itemAccess);
|
||||
loadFeeds();
|
||||
}
|
||||
|
||||
private void loadFeeds() {
|
||||
AsyncTask<Void, Void, List[]> loadTask = new AsyncTask<Void, Void, List[]>() {
|
||||
@Override
|
||||
protected List[] doInBackground(Void... params) {
|
||||
Context context = getActivity();
|
||||
if (context != null) {
|
||||
return new List[]{DBReader.getFeedList(context),
|
||||
DBReader.getFeedStatisticsList(context)};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List[] result) {
|
||||
super.onPostExecute(result);
|
||||
if (result != null) {
|
||||
feeds = result[0];
|
||||
feedItemStatistics = result[1];
|
||||
setEmptyViewIfListIsEmpty();
|
||||
if (fla != null) {
|
||||
fla.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Failed to load feeds");
|
||||
}
|
||||
}
|
||||
};
|
||||
loadTask.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View result = inflater.inflate(R.layout.feedlist, container, false);
|
||||
listView = (ListView) result.findViewById(android.R.id.list);
|
||||
gridView = (GridView) result.findViewById(R.id.grid);
|
||||
emptyView = (TextView) result.findViewById(android.R.id.empty);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (listView != null) {
|
||||
listView.setOnItemClickListener(this);
|
||||
listView.setOnItemLongClickListener(this);
|
||||
listView.setAdapter(fla);
|
||||
listView.setEmptyView(emptyView);
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Using ListView");
|
||||
} else {
|
||||
gridView.setOnItemClickListener(this);
|
||||
gridView.setOnItemLongClickListener(this);
|
||||
gridView.setAdapter(fla);
|
||||
gridView.setEmptyView(emptyView);
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Using GridView");
|
||||
}
|
||||
setEmptyViewIfListIsEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Resuming");
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
loadFeeds();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
FeedMenuHandler.onCreateOptionsMenu(mode.getMenuInflater(), menu);
|
||||
mode.setTitle(selectedFeed.getTitle());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
return FeedMenuHandler.onPrepareOptionsMenu(menu, selectedFeed);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
try {
|
||||
if (FeedMenuHandler.onOptionsItemClicked(getActivity(),
|
||||
item, selectedFeed)) {
|
||||
loadFeeds();
|
||||
} else {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.remove_item:
|
||||
final FeedRemover remover = new FeedRemover(
|
||||
getActivity(), selectedFeed) {
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
super.onPostExecute(result);
|
||||
loadFeeds();
|
||||
}
|
||||
};
|
||||
ConfirmationDialog conDialog = new ConfirmationDialog(
|
||||
getActivity(), R.string.remove_feed_label,
|
||||
R.string.feed_delete_confirmation_msg) {
|
||||
|
||||
@Override
|
||||
public void onConfirmButtonPressed(
|
||||
DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
remover.executeAsync();
|
||||
}
|
||||
};
|
||||
conDialog.createNewDialog().show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(
|
||||
getActivity(), e.getMessage());
|
||||
}
|
||||
mode.finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mActionMode = null;
|
||||
selectedFeed = null;
|
||||
fla.setSelectedItemIndex(FeedlistAdapter.SELECTION_NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
|
||||
long id) {
|
||||
Feed selection = fla.getItem(position);
|
||||
Intent showFeed = new Intent(getActivity(), FeedItemlistActivity.class);
|
||||
showFeed.putExtra(EXTRA_SELECTED_FEED, selection.getId());
|
||||
|
||||
getActivity().startActivity(showFeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
Feed selection = fla.getItem(position);
|
||||
if (selection != null) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Selected Feed with title " + selection.getTitle());
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
fla.setSelectedItemIndex(position);
|
||||
selectedFeed = selection;
|
||||
mActionMode = ((ActionBarActivity) getActivity()).startSupportActionMode(FeedlistFragment.this);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private AbsListView getMainView() {
|
||||
return (listView != null) ? listView : gridView;
|
||||
}
|
||||
|
||||
private void setEmptyViewIfListIsEmpty() {
|
||||
if (getMainView() != null && emptyView != null && feeds != null) {
|
||||
if (feeds.isEmpty()) {
|
||||
emptyView.setText(R.string.no_feeds_label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,266 +0,0 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.ListView;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MiroGuideChannelViewActivity;
|
||||
import de.danoeh.antennapod.adapter.MiroGuideChannelListAdapter;
|
||||
import de.danoeh.antennapod.miroguide.conn.MiroGuideException;
|
||||
import de.danoeh.antennapod.miroguide.conn.MiroGuideService;
|
||||
import de.danoeh.antennapod.miroguide.model.MiroGuideChannel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays a list of MiroGuideChannel objects that were results of a certain
|
||||
* MiroGuideService query. If the user reaches the bottom of the list, more
|
||||
* entries will be loaded until all entries have been loaded or the maximum
|
||||
* number of channels has been reached.
|
||||
* */
|
||||
public class MiroGuideChannellistFragment extends ListFragment {
|
||||
private static final String TAG = "MiroGuideChannellistFragment";
|
||||
|
||||
private static final String ARG_FILTER = "filter";
|
||||
private static final String ARG_FILTER_VALUE = "filter_value";
|
||||
private static final String ARG_SORT = "sort";
|
||||
|
||||
private static final int MAX_CHANNELS = 200;
|
||||
private static final int CHANNELS_PER_QUERY = MiroGuideService.DEFAULT_CHANNEL_LIMIT;
|
||||
|
||||
private ArrayList<MiroGuideChannel> channels;
|
||||
private MiroGuideChannelListAdapter listAdapter;
|
||||
private int offset;
|
||||
|
||||
private boolean isLoadingChannels;
|
||||
/**
|
||||
* True if there are no more entries to load or if the maximum number of
|
||||
* channels in the channellist has been reached
|
||||
*/
|
||||
private boolean stopLoading;
|
||||
|
||||
private View footer;
|
||||
|
||||
private String filter;
|
||||
private String filterValue;
|
||||
private String sort;
|
||||
|
||||
private AsyncTask<Void, Void, List<MiroGuideChannel>> channelLoader;
|
||||
|
||||
/**
|
||||
* Creates a new instance of Channellist fragment.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if filter, filterValue or sort is null
|
||||
* */
|
||||
public static MiroGuideChannellistFragment newInstance(String filter,
|
||||
String filterValue, String sort) {
|
||||
if (filter == null) {
|
||||
throw new IllegalArgumentException("filter cannot be null");
|
||||
}
|
||||
if (filterValue == null) {
|
||||
throw new IllegalArgumentException("filter value cannot be null");
|
||||
}
|
||||
if (sort == null) {
|
||||
throw new IllegalArgumentException("sort cannot be null");
|
||||
}
|
||||
MiroGuideChannellistFragment cf = new MiroGuideChannellistFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_FILTER, filter);
|
||||
args.putString(ARG_FILTER_VALUE, filterValue);
|
||||
args.putString(ARG_SORT, sort);
|
||||
cf.setArguments(args);
|
||||
return cf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
offset = 0;
|
||||
channels = new ArrayList<MiroGuideChannel>();
|
||||
|
||||
Bundle args = getArguments();
|
||||
filter = args.getString(ARG_FILTER);
|
||||
filterValue = args.getString(ARG_FILTER_VALUE);
|
||||
sort = args.getString(ARG_SORT);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) getActivity()
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
footer = inflater.inflate(R.layout.loading_footer, null);
|
||||
listAdapter = new MiroGuideChannelListAdapter(getActivity(), 0,
|
||||
channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (channels.isEmpty()) {
|
||||
setListShown(false);
|
||||
loadChannels();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (channelLoader != null) {
|
||||
channelLoader.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
getListView().addFooterView(footer); // footer has to be added before
|
||||
// the adapter has been set
|
||||
getListView().setAdapter(listAdapter);
|
||||
getListView().removeFooterView(footer);
|
||||
|
||||
getListView().setOnScrollListener(new OnScrollListener() {
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem,
|
||||
int visibleItemCount, int totalItemCount) {
|
||||
int lastVisibleItem = firstVisibleItem + visibleItemCount;
|
||||
if (lastVisibleItem == totalItemCount) {
|
||||
if (BuildConfig.DEBUG)
|
||||
loadChannels();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
super.onListItemClick(l, v, position, id);
|
||||
if (listAdapter != null) {
|
||||
MiroGuideChannel selection = listAdapter.getItem(position);
|
||||
Intent launchIntent = new Intent(getActivity(),
|
||||
MiroGuideChannelViewActivity.class);
|
||||
launchIntent.putExtra(
|
||||
MiroGuideChannelViewActivity.EXTRA_CHANNEL_ID,
|
||||
selection.getId());
|
||||
launchIntent.putExtra(
|
||||
MiroGuideChannelViewActivity.EXTRA_CHANNEL_URL,
|
||||
selection.getDownloadUrl());
|
||||
startActivity(launchIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void loadChannels() {
|
||||
if (!isLoadingChannels) {
|
||||
if (!stopLoading) {
|
||||
isLoadingChannels = true;
|
||||
channelLoader = new AsyncTask<Void, Void, List<MiroGuideChannel>>() {
|
||||
private MiroGuideException exception;
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Channel loader was cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<MiroGuideChannel> result) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Channel loading finished");
|
||||
if (exception == null) {
|
||||
getListView().removeFooterView(footer);
|
||||
for (MiroGuideChannel channel : result) {
|
||||
channels.add(channel);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
offset += CHANNELS_PER_QUERY;
|
||||
// check if fragment should not send any more
|
||||
// queries
|
||||
if (result.size() < CHANNELS_PER_QUERY) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG,
|
||||
"Query result was less than requested number of channels. Stopping to send any more queries");
|
||||
stopLoading = true;
|
||||
}
|
||||
if (offset >= MAX_CHANNELS) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG,
|
||||
"Maximum number of feeds has been reached. Stopping to send any more queries");
|
||||
stopLoading = true;
|
||||
}
|
||||
|
||||
setListShown(true);
|
||||
} else {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(
|
||||
getActivity());
|
||||
dialog.setTitle(R.string.error_label);
|
||||
dialog.setMessage(exception.getMessage());
|
||||
dialog.setNeutralButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(
|
||||
DialogInterface dialog,
|
||||
int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.create().show();
|
||||
}
|
||||
isLoadingChannels = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
getListView().addFooterView(footer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<MiroGuideChannel> doInBackground(
|
||||
Void... params) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Background channel loader started");
|
||||
MiroGuideService service = new MiroGuideService();
|
||||
try {
|
||||
return service.getChannelList(filter, filterValue,
|
||||
sort, CHANNELS_PER_QUERY, offset);
|
||||
} catch (MiroGuideException e) {
|
||||
exception = e;
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// service.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||
channelLoader
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
channelLoader.execute();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Channels are already being loaded");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
package de.danoeh.antennapod.miroguide.conn;
|
||||
|
||||
import android.net.Uri;
|
||||
import de.danoeh.antennapod.util.LangUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/** Executes HTTP requests and returns the results. */
|
||||
public class MiroGuideConnector {
|
||||
private HttpClient httpClient;
|
||||
|
||||
private static final String HOST_URL = "http://www.miroguide.com/api/";
|
||||
private static final String PATH_GET_CHANNELS = "get_channels";
|
||||
private static final String PATH_LIST_CATEGORIES = "list_categories";
|
||||
private static final String PATH_GET_CHANNEL = "get_channel";
|
||||
|
||||
public MiroGuideConnector() {
|
||||
httpClient = new DefaultHttpClient();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
}
|
||||
|
||||
private Uri.Builder getBaseURIBuilder(String path) {
|
||||
Uri.Builder builder = Uri.parse(HOST_URL).buildUpon();
|
||||
builder.appendPath(path).appendQueryParameter("datatype", "json");
|
||||
return builder;
|
||||
}
|
||||
|
||||
public JSONArray getArrayResponse(Uri uri) throws MiroGuideException {
|
||||
try {
|
||||
JSONArray result = new JSONArray(executeRequest(uri));
|
||||
return result;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
throw new MiroGuideException();
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject getSingleObjectResponse(Uri uri) throws MiroGuideException {
|
||||
try {
|
||||
JSONObject result = new JSONObject(executeRequest(uri));
|
||||
return result;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
throw new MiroGuideException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a HTTP GET request with the given URI and returns the content of
|
||||
* the return value.
|
||||
*
|
||||
* @throws MiroGuideException
|
||||
*/
|
||||
private String executeRequest(Uri uri) throws MiroGuideException {
|
||||
HttpGet httpGet = new HttpGet(uri.toString());
|
||||
String result = null;
|
||||
try {
|
||||
HttpResponse response = httpClient.execute(httpGet);
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null) {
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(entity.getContent(),
|
||||
LangUtils.UTF_8));
|
||||
try {
|
||||
result = reader.readLine();
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new MiroGuideException(response.getStatusLine()
|
||||
.getReasonPhrase());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new MiroGuideException(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public Uri createGetChannelsUri(String filter, String filterValue,
|
||||
String sort, String limit, String offset) throws MiroGuideException {
|
||||
Uri.Builder resultBuilder = getBaseURIBuilder(PATH_GET_CHANNELS);
|
||||
resultBuilder.appendQueryParameter("filter", filter)
|
||||
.appendQueryParameter("filter_value", filterValue);
|
||||
|
||||
if (sort != null) {
|
||||
resultBuilder.appendQueryParameter("sort", sort);
|
||||
}
|
||||
if (limit != null) {
|
||||
resultBuilder.appendQueryParameter("limit", limit);
|
||||
}
|
||||
if (offset != null) {
|
||||
resultBuilder.appendQueryParameter("offset", offset);
|
||||
}
|
||||
Uri result = resultBuilder.build();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Uri createListCategoriesURI() throws MiroGuideException {
|
||||
Uri.Builder resultBuilder = getBaseURIBuilder(PATH_LIST_CATEGORIES);
|
||||
Uri result = resultBuilder.build();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Uri createGetChannelUri(String id) throws MiroGuideException {
|
||||
Uri.Builder resultBuilder = getBaseURIBuilder(PATH_GET_CHANNEL)
|
||||
.appendQueryParameter("id", id);
|
||||
Uri result = resultBuilder.build();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package de.danoeh.antennapod.miroguide.conn;
|
||||
|
||||
public class MiroGuideException extends Exception {
|
||||
private static final long serialVersionUID = -8834656185748713194L;
|
||||
|
||||
public MiroGuideException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MiroGuideException(String arg0, Throwable arg1) {
|
||||
super(arg0, arg1);
|
||||
}
|
||||
|
||||
public MiroGuideException(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public MiroGuideException(Throwable arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
package de.danoeh.antennapod.miroguide.conn;
|
||||
|
||||
import de.danoeh.antennapod.miroguide.model.MiroGuideChannel;
|
||||
import de.danoeh.antennapod.miroguide.model.MiroGuideItem;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/** Provides methods to communicate with the Miroguide API on an abstract level. */
|
||||
public class MiroGuideService {
|
||||
private static final String TAG = "MiroGuideService";
|
||||
|
||||
public static final int DEFAULT_CHANNEL_LIMIT = 20;
|
||||
|
||||
public static final String FILTER_CATEGORY = "category";
|
||||
public static final String FILTER_NAME = "name";
|
||||
public static final String SORT_NAME = "name";
|
||||
public static final String SORT_POPULAR = "popular";
|
||||
public static final String SORT_RATING = "rating";
|
||||
|
||||
public static final String JSON_DATE_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss";
|
||||
|
||||
private MiroGuideConnector connector;
|
||||
|
||||
private static ThreadLocal<SimpleDateFormat> jSONDateFormat = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat(JSON_DATE_FORMAT_STRING, Locale.US);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public MiroGuideService() {
|
||||
connector = new MiroGuideConnector();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
connector.shutdown();
|
||||
}
|
||||
|
||||
public String[] getCategories() throws MiroGuideException {
|
||||
JSONArray resultArray = connector.getArrayResponse(connector
|
||||
.createListCategoriesURI());
|
||||
String[] result = new String[resultArray.length()];
|
||||
for (int i = 0; i < resultArray.length(); i++) {
|
||||
try {
|
||||
result[i] = resultArray.getJSONObject(i).getString("name");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
throw new MiroGuideException();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Get a list of MiroGuideChannel objects without their items. */
|
||||
public List<MiroGuideChannel> getChannelList(String filter, String filterValue,
|
||||
String sort, int limit, int offset) throws MiroGuideException {
|
||||
JSONArray resultArray = connector.getArrayResponse(connector
|
||||
.createGetChannelsUri(filter, filterValue, sort,
|
||||
Integer.toString(limit), Integer.toString(offset)));
|
||||
int resultLen = resultArray.length();
|
||||
List<MiroGuideChannel> channels = new ArrayList<MiroGuideChannel>(resultLen);
|
||||
for (int i = 0; i < resultLen; i++) {
|
||||
JSONObject content = null;
|
||||
try {
|
||||
content = resultArray.getJSONObject(i);
|
||||
MiroGuideChannel channel = extractMiroChannel(content, false);
|
||||
channels.add(channel);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
throw new MiroGuideException();
|
||||
}
|
||||
}
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single channel with its items.
|
||||
*
|
||||
* @throws MiroGuideException
|
||||
*/
|
||||
public MiroGuideChannel getChannel(long id) throws MiroGuideException {
|
||||
JSONObject resultObject = connector.getSingleObjectResponse(connector
|
||||
.createGetChannelUri(Long.toString(id)));
|
||||
MiroGuideChannel result = null;
|
||||
try {
|
||||
result = extractMiroChannel(resultObject, true);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
throw new MiroGuideException();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a MiroGuideChannel object from it's JSON source. The itemlist of the
|
||||
* channel can be included or excluded
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
private MiroGuideChannel extractMiroChannel(JSONObject content, boolean withItems)
|
||||
throws JSONException {
|
||||
long id = content.getLong("id");
|
||||
String name = content.getString("name");
|
||||
String description = content.getString("description");
|
||||
String thumbnailUrl = content.optString("thumbnail_url");
|
||||
String downloadUrl = content.getString("url");
|
||||
String websiteUrl = content.getString("website_url");
|
||||
if (!withItems) {
|
||||
return new MiroGuideChannel(id, name, thumbnailUrl, downloadUrl,
|
||||
websiteUrl, description);
|
||||
} else {
|
||||
JSONArray itemData = content.getJSONArray("item");
|
||||
int numItems = itemData.length();
|
||||
ArrayList<MiroGuideItem> items = new ArrayList<MiroGuideItem>(numItems);
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
items.add(extractMiroItem(itemData.getJSONObject(i)));
|
||||
}
|
||||
|
||||
return new MiroGuideChannel(id, name, thumbnailUrl, downloadUrl,
|
||||
websiteUrl, description, items);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get a MiroGuideItem from its JSON source. */
|
||||
private MiroGuideItem extractMiroItem(JSONObject content) throws JSONException {
|
||||
Date date = parseMiroItemDate(content.getString("date"));
|
||||
String description = content.getString("description");
|
||||
String name = content.getString("name");
|
||||
String url = content.getString("url");
|
||||
return new MiroGuideItem(name, description, date, url);
|
||||
}
|
||||
|
||||
private Date parseMiroItemDate(String s) {
|
||||
try {
|
||||
return jSONDateFormat.get().parse(s);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package de.danoeh.antennapod.miroguide.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MiroGuideChannel {
|
||||
private long id;
|
||||
private String name;
|
||||
private String thumbnailUrl;
|
||||
private String downloadUrl;
|
||||
private String websiteUrl;
|
||||
private String description;
|
||||
private ArrayList<MiroGuideItem> items;
|
||||
|
||||
public MiroGuideChannel(long id, String name, String thumbnailUrl,
|
||||
String downloadUrl, String websiteUrl, String description) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.thumbnailUrl = thumbnailUrl;
|
||||
this.downloadUrl = downloadUrl;
|
||||
this.websiteUrl = websiteUrl;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public MiroGuideChannel(long id, String name, String thumbnailUrl,
|
||||
String downloadUrl, String websiteUrl, String description,
|
||||
ArrayList<MiroGuideItem> items) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.thumbnailUrl = thumbnailUrl;
|
||||
this.downloadUrl = downloadUrl;
|
||||
this.websiteUrl = websiteUrl;
|
||||
this.description = description;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + " " + name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getThumbnailUrl() {
|
||||
return thumbnailUrl;
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public String getWebsiteUrl() {
|
||||
return websiteUrl;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public ArrayList<MiroGuideItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setThumbnailUrl(String thumbnailUrl) {
|
||||
this.thumbnailUrl = thumbnailUrl;
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package de.danoeh.antennapod.miroguide.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class MiroGuideItem {
|
||||
private String name;
|
||||
private String description;
|
||||
private Date date;
|
||||
private String url;
|
||||
|
||||
public MiroGuideItem(String name, String description, Date date, String url) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.date = (Date) date.clone();
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " " + date.toString();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return (Date) date.clone();
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
@ -21,9 +21,7 @@ import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.DownloadActivity;
|
||||
import de.danoeh.antennapod.activity.DownloadAuthenticationActivity;
|
||||
import de.danoeh.antennapod.activity.DownloadLogActivity;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.adapter.NavListAdapter;
|
||||
import de.danoeh.antennapod.feed.*;
|
||||
|
Loading…
x
Reference in New Issue
Block a user