Merge pull request #658 from mfietz/issue-126
Queue view: Swipe to dismiss, undo bar, status information
This commit is contained in:
commit
006f793fae
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
@ -16,6 +17,7 @@ import de.danoeh.antennapod.R;
|
|||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
|
||||
/**
|
||||
* List adapter for the queue.
|
||||
|
@ -64,12 +66,16 @@ public class QueueListAdapter extends BaseAdapter {
|
|||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.queue_listitem,
|
||||
parent, false);
|
||||
holder.imageView = (ImageView) convertView.findViewById(R.id.imgvImage);
|
||||
holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
|
||||
holder.pubDate = (TextView) convertView.findViewById(R.id.txtvPubDate);
|
||||
holder.progressLeft = (TextView) convertView.findViewById(R.id.txtvProgressLeft);
|
||||
holder.progressRight = (TextView) convertView
|
||||
.findViewById(R.id.txtvProgressRight);
|
||||
holder.butSecondary = (ImageButton) convertView
|
||||
.findViewById(R.id.butSecondaryAction);
|
||||
holder.position = (TextView) convertView.findViewById(R.id.txtvPosition);
|
||||
holder.progress = (ProgressBar) convertView
|
||||
.findViewById(R.id.pbar_download_progress);
|
||||
.findViewById(R.id.progressBar);
|
||||
holder.imageView = (ImageView) convertView.findViewById(R.id.imgvImage);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
|
@ -77,19 +83,39 @@ public class QueueListAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
holder.title.setText(item.getTitle());
|
||||
|
||||
AdapterUtils.updateEpisodePlaybackProgress(item, context.getResources(), holder.position, holder.progress);
|
||||
|
||||
FeedMedia media = item.getMedia();
|
||||
|
||||
|
||||
holder.title.setText(item.getTitle());
|
||||
String pubDate = DateUtils.formatDateTime(context, item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL);
|
||||
holder.pubDate.setText(pubDate.replace(" ", "\n"));
|
||||
|
||||
if (media != null) {
|
||||
final boolean isDownloadingMedia = DownloadRequester.getInstance().isDownloadingFile(media);
|
||||
|
||||
if (!media.isDownloaded()) {
|
||||
if (isDownloadingMedia) {
|
||||
// item is being downloaded
|
||||
holder.progress.setVisibility(View.VISIBLE);
|
||||
holder.progress.setProgress(itemAccess.getItemDownloadProgressPercent(item));
|
||||
FeedItem.State state = item.getState();
|
||||
if (isDownloadingMedia) {
|
||||
holder.progressLeft.setText(Converter.byteToString(itemAccess.getItemDownloadedBytes(item)));
|
||||
if(itemAccess.getItemDownloadSize(item) > 0) {
|
||||
holder.progressRight.setText(Converter.byteToString(itemAccess.getItemDownloadSize(item)));
|
||||
} else {
|
||||
holder.progressRight.setText(Converter.byteToString(media.getSize()));
|
||||
}
|
||||
holder.progress.setProgress(itemAccess.getItemDownloadProgressPercent(item));
|
||||
holder.progress.setVisibility(View.VISIBLE);
|
||||
} else if (state == FeedItem.State.PLAYING
|
||||
|| state == FeedItem.State.IN_PROGRESS) {
|
||||
if (media.getDuration() > 0) {
|
||||
int progress = (int) (100.0 * media.getPosition() / media.getDuration());
|
||||
holder.progress.setProgress(progress);
|
||||
holder.progress.setVisibility(View.VISIBLE);
|
||||
holder.progressLeft.setText(Converter
|
||||
.getDurationStringLong(media.getPosition()));
|
||||
holder.progressRight.setText(Converter.getDurationStringLong(media.getDuration()));
|
||||
}
|
||||
} else {
|
||||
holder.progressLeft.setText(Converter.byteToString(media.getSize()));
|
||||
holder.progressRight.setText(Converter.getDurationStringLong(media.getDuration()));
|
||||
holder.progress.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,18 +142,20 @@ public class QueueListAdapter extends BaseAdapter {
|
|||
|
||||
|
||||
static class Holder {
|
||||
TextView title;
|
||||
ImageView imageView;
|
||||
TextView position;
|
||||
TextView title;
|
||||
TextView pubDate;
|
||||
TextView progressLeft;
|
||||
TextView progressRight;
|
||||
ProgressBar progress;
|
||||
ImageButton butSecondary;
|
||||
}
|
||||
|
||||
public interface ItemAccess {
|
||||
int getCount();
|
||||
|
||||
FeedItem getItem(int position);
|
||||
|
||||
int getCount();
|
||||
long getItemDownloadedBytes(FeedItem item);
|
||||
long getItemDownloadSize(FeedItem item);
|
||||
int getItemDownloadProgressPercent(FeedItem item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.support.v4.util.Pair;
|
|||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -49,6 +50,7 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.QueueAccess;
|
||||
import de.danoeh.antennapod.core.util.playback.Timeline;
|
||||
import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
|
||||
|
@ -91,6 +93,8 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba
|
|||
private View header;
|
||||
private WebView webvDescription;
|
||||
private TextView txtvTitle;
|
||||
private TextView txtvDuration;
|
||||
private TextView txtvPublished;
|
||||
private ImageView imgvCover;
|
||||
private ProgressBar progbarDownload;
|
||||
private ProgressBar progbarLoading;
|
||||
|
@ -166,6 +170,8 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba
|
|||
header = inflater.inflate(R.layout.feeditem_fragment_header, toolbar, false);
|
||||
root = (ViewGroup) layout.findViewById(R.id.content_root);
|
||||
txtvTitle = (TextView) header.findViewById(R.id.txtvTitle);
|
||||
txtvDuration = (TextView) header.findViewById(R.id.txtvDuration);
|
||||
txtvPublished = (TextView) header.findViewById(R.id.txtvPublished);
|
||||
if (Build.VERSION.SDK_INT >= 14) { // ellipsize is causing problems on old versions, see #448
|
||||
txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
|
@ -313,6 +319,8 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba
|
|||
|
||||
private void updateAppearance() {
|
||||
txtvTitle.setText(item.getTitle());
|
||||
txtvPublished.setText(DateUtils.formatDateTime(getActivity(), item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL));
|
||||
|
||||
Picasso.with(getActivity()).load(item.getImageUri())
|
||||
.fit()
|
||||
.into(imgvCover);
|
||||
|
@ -348,7 +356,10 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba
|
|||
}
|
||||
|
||||
drawables.recycle();
|
||||
} else {
|
||||
} else {if(media.getDuration() > 0) {
|
||||
txtvDuration.setText(Converter.getDurationStringLong(media.getDuration()));
|
||||
}
|
||||
|
||||
boolean isDownloading = DownloadRequester.getInstance().isDownloadingFile(media);
|
||||
TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.av_play,
|
||||
R.attr.av_download, R.attr.action_stream, R.attr.content_discard, R.attr.navigation_cancel});
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
|
@ -43,6 +44,8 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.QueueSorter;
|
||||
import de.danoeh.antennapod.core.util.gui.FeedItemUndoToken;
|
||||
import de.danoeh.antennapod.core.util.gui.UndoBarController;
|
||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
|
||||
|
||||
|
@ -60,6 +63,8 @@ public class QueueFragment extends Fragment {
|
|||
private TextView txtvEmpty;
|
||||
private ProgressBar progLoading;
|
||||
|
||||
private UndoBarController undoBarController;
|
||||
|
||||
private List<FeedItem> queue;
|
||||
private List<Downloader> downloaderList;
|
||||
|
||||
|
@ -137,6 +142,7 @@ public class QueueFragment extends Fragment {
|
|||
unregisterForContextMenu(listView);
|
||||
listAdapter = null;
|
||||
activity.set(null);
|
||||
undoBarController = null;
|
||||
viewsCreated = false;
|
||||
blockDownloadObserverUpdate = false;
|
||||
if (downloadObserver != null) {
|
||||
|
@ -318,9 +324,31 @@ public class QueueFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void remove(int which) {
|
||||
Log.d(TAG, "remove("+which+")");
|
||||
stopItemLoader();
|
||||
FeedItem item = (FeedItem) listView.getAdapter().getItem(which);
|
||||
DBWriter.removeQueueItem(getActivity(), item.getId(), true);
|
||||
undoBarController.showUndoBar(false,
|
||||
getString(R.string.removed_from_queue), new FeedItemUndoToken(item,
|
||||
which)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
undoBarController = new UndoBarController(root.findViewById(R.id.undobar), new UndoBarController.UndoListener() {
|
||||
@Override
|
||||
public void onUndo(Parcelable token) {
|
||||
// Perform the undo
|
||||
FeedItemUndoToken undoToken = (FeedItemUndoToken) token;
|
||||
if (token != null) {
|
||||
long itemId = undoToken.getFeedItemId();
|
||||
int position = undoToken.getPosition();
|
||||
DBWriter.addQueueItemAt(getActivity(), itemId, position, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
registerForContextMenu(listView);
|
||||
|
||||
if (!itemsLoaded) {
|
||||
|
@ -384,6 +412,33 @@ public class QueueFragment extends Fragment {
|
|||
return (itemsLoaded) ? queue.get(position) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemDownloadedBytes(FeedItem item) {
|
||||
if (downloaderList != null) {
|
||||
for (Downloader downloader : downloaderList) {
|
||||
if (downloader.getDownloadRequest().getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA
|
||||
&& downloader.getDownloadRequest().getFeedfileId() == item.getMedia().getId()) {
|
||||
Log.d(TAG, "downloaded bytes: " + downloader.getDownloadRequest().getSoFar());
|
||||
return downloader.getDownloadRequest().getSoFar();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemDownloadSize(FeedItem item) {
|
||||
if (downloaderList != null) {
|
||||
for (Downloader downloader : downloaderList) {
|
||||
if (downloader.getDownloadRequest().getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA
|
||||
&& downloader.getDownloadRequest().getFeedfileId() == item.getMedia().getId()) {
|
||||
Log.d(TAG, "downloaded size: " + downloader.getDownloadRequest().getSize());
|
||||
return downloader.getDownloadRequest().getSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getItemDownloadProgressPercent(FeedItem item) {
|
||||
if (downloaderList != null) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="8dp">
|
||||
android:paddingBottom="0dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvCover"
|
||||
|
@ -59,6 +59,29 @@
|
|||
android:maxLines="5"
|
||||
tools:text="Podcast title"
|
||||
tools:background="@android:color/holo_green_dark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvDuration"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/imgvCover"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:layout_marginLeft="16dp"
|
||||
tools:text="00:42:23"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPublished"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/butMoreActions"
|
||||
android:layout_marginRight="8dp"
|
||||
tools:text="Jan 23"
|
||||
tools:background="@android:color/holo_green_dark"
|
||||
android:layout_below="@+id/txtvTitle"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ProgressBar
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
dslv:float_alpha="0.6"
|
||||
dslv:float_background_color="?attr/dragview_float_background"
|
||||
dslv:max_drag_scroll_speed="0.5"
|
||||
dslv:remove_enabled="false"
|
||||
dslv:remove_enabled="true"
|
||||
dslv:remove_mode="flingRemove"
|
||||
dslv:slide_shuffle_speed="0.3"
|
||||
dslv:sort_enabled="true"
|
||||
dslv:track_drag_sort="true"
|
||||
|
@ -42,4 +43,18 @@
|
|||
android:indeterminateOnly="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
<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>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
|
||||
android:layout_marginLeft="@dimen/listitem_threeline_textleftpadding"
|
||||
android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
|
||||
|
@ -40,46 +40,72 @@
|
|||
android:layout_weight="1"
|
||||
tools:background="@android:color/holo_red_dark">
|
||||
|
||||
<!-- order is important, pubDate first! -->
|
||||
<TextView
|
||||
android:id="@+id/txtvPubDate"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="2"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:gravity="right|bottom"
|
||||
android:text="Feb\n12"
|
||||
tools:background="@android:color/holo_blue_light" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/txtvPubDate"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Queue item title"
|
||||
android:ellipsize="end"
|
||||
tools:background="@android:color/holo_blue_light" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottom_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="16dp">
|
||||
android:layout_alignParentRight="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPosition"
|
||||
android:id="@+id/txtvProgressLeft"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:text="00:42:23"
|
||||
tools:background="@android:color/holo_blue_light" />
|
||||
tools:background="@android:color/holo_blue_light"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pbar_download_progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:id="@+id/txtvProgressRight"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_toRightOf="@id/txtvPosition"
|
||||
android:layout_marginBottom="0dp"
|
||||
tools:text="Jan 23"
|
||||
tools:background="@android:color/holo_green_dark" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/txtvProgressLeft"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:max="100"
|
||||
tools:background="@android:color/holo_blue_light" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -44,4 +44,5 @@ dependencies {
|
|||
compile 'com.squareup.okhttp:okhttp:2.2.0'
|
||||
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
|
||||
compile 'com.squareup.okio:okio:1.2.0'
|
||||
}
|
||||
compile 'com.nineoldandroids:library:2.4.0'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package de.danoeh.antennapod.core.util.gui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
import com.nineoldandroids.animation.AnimatorListenerAdapter;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
import com.nineoldandroids.view.ViewPropertyAnimator;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
|
||||
import static com.nineoldandroids.view.ViewPropertyAnimator.animate;
|
||||
|
||||
public class UndoBarController {
|
||||
private View mBarView;
|
||||
private TextView mMessageView;
|
||||
private ViewPropertyAnimator mBarAnimator;
|
||||
private Handler mHideHandler = new Handler();
|
||||
|
||||
private UndoListener mUndoListener;
|
||||
|
||||
// State objects
|
||||
private Parcelable mUndoToken;
|
||||
private CharSequence mUndoMessage;
|
||||
|
||||
public interface UndoListener {
|
||||
void onUndo(Parcelable token);
|
||||
}
|
||||
|
||||
public UndoBarController(View undoBarView, UndoListener undoListener) {
|
||||
mBarView = undoBarView;
|
||||
mBarAnimator = animate(mBarView);
|
||||
mUndoListener = undoListener;
|
||||
|
||||
mMessageView = (TextView) mBarView.findViewById(R.id.undobar_message);
|
||||
mBarView.findViewById(R.id.undobar_button)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
hideUndoBar(false);
|
||||
mUndoListener.onUndo(mUndoToken);
|
||||
}
|
||||
});
|
||||
|
||||
hideUndoBar(true);
|
||||
}
|
||||
|
||||
public void showUndoBar(boolean immediate, CharSequence message, Parcelable undoToken) {
|
||||
mUndoToken = undoToken;
|
||||
mUndoMessage = message;
|
||||
mMessageView.setText(mUndoMessage);
|
||||
|
||||
mHideHandler.removeCallbacks(mHideRunnable);
|
||||
mHideHandler.postDelayed(mHideRunnable,
|
||||
mBarView.getResources().getInteger(R.integer.undobar_hide_delay));
|
||||
|
||||
mBarView.setVisibility(View.VISIBLE);
|
||||
if (immediate) {
|
||||
ViewHelper.setAlpha(mBarView, 1);
|
||||
} else {
|
||||
mBarAnimator.cancel();
|
||||
mBarAnimator
|
||||
.alpha(1)
|
||||
.setDuration(
|
||||
mBarView.getResources()
|
||||
.getInteger(android.R.integer.config_shortAnimTime))
|
||||
.setListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideUndoBar(boolean immediate) {
|
||||
mHideHandler.removeCallbacks(mHideRunnable);
|
||||
if (immediate) {
|
||||
mBarView.setVisibility(View.GONE);
|
||||
ViewHelper.setAlpha(mBarView, 0);
|
||||
mUndoMessage = null;
|
||||
} else {
|
||||
mBarAnimator.cancel();
|
||||
mBarAnimator
|
||||
.alpha(0)
|
||||
.setDuration(mBarView.getResources()
|
||||
.getInteger(android.R.integer.config_shortAnimTime))
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mBarView.setVisibility(View.GONE);
|
||||
mUndoMessage = null;
|
||||
mUndoToken = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putCharSequence("undo_message", mUndoMessage);
|
||||
outState.putParcelable("undo_token", mUndoToken);
|
||||
}
|
||||
|
||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
if (savedInstanceState != null) {
|
||||
mUndoMessage = savedInstanceState.getCharSequence("undo_message");
|
||||
mUndoToken = savedInstanceState.getParcelable("undo_token");
|
||||
|
||||
if (mUndoToken != null || !TextUtils.isEmpty(mUndoMessage)) {
|
||||
showUndoBar(true, mUndoMessage, mUndoToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable mHideRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideUndoBar(false);
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue