初步完成收藏

This commit is contained in:
seven332 committed 2014-06-05 19:18:59 +08:00
1 parent 4a1594f982
commit 13cbb7507e
37 files changed
+397 -91

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+3
View File
@@ -24,6 +24,9 @@
<item
android:state_pressed="true"
android:drawable="@drawable/card_bg_selected" />
<item
android:state_activated="true"
android:drawable="@drawable/card_bg_activated" />
<item
android:drawable="@drawable/card_bg" />
</selector>
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 Hippo Seven
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/favorite_menu_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
android:clickable="true"
android:divider="@color/detail_divider"
android:dividerHeight="1.0dp"
android:scrollbarThumbVertical="@drawable/scrollbar_white" />
+10 -7
View File
@@ -13,10 +13,15 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_height="fill_parent" >
<com.hippo.ehviewer.widget.FswView
android:id="@+id/alignment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" />
<ListView
android:id="@+id/favourite"
@@ -24,9 +29,7 @@
android:layout_height="fill_parent"
android:divider="@null"
android:listSelector="@android:color/transparent"
android:cacheColorHint="@color/list_main_bg"
android:fitsSystemWindows="true"
android:clipToPadding="false" >
android:cacheColorHint="@color/list_main_bg" >
</ListView>
</LinearLayout>
</RelativeLayout>
@@ -13,12 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/develop" >
<Preference
android:key="preference_remove_all_noification"
android:title="点击移除所有通知" />
</PreferenceCategory>
</PreferenceScreen>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_list"
android:title="@string/list"
android:icon="@drawable/ic_action_list"
android:showAsAction="always" />
</menu>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 Hippo Seven
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_delete"
android:title="@string/delete"
android:icon="@drawable/ic_action_delete_dark"
android:showAsAction="always" />
<item
android:id="@+id/action_move"
android:title="@string/move"
android:icon="@drawable/ic_action_move_dark"
android:showAsAction="always" />
</menu>
+4
View File
@@ -292,6 +292,7 @@
<string name="rating0">感觉快要窒息了</string>
<!-- Util -->
<string name="local">本地</string>
<string name="tag">标签</string>
<string name="copyed">已复制</string>
<string name="send">发送</string>
@@ -318,6 +319,9 @@
<string name="jump">跳页</string>
<string name="some_page">第 %d 页</string>
<string name="_default">默认</string>
<string name="delete">删除</string>
<string name="move">移动</string>
<string name="list">列表</string>
<string name="homepage">首页</string>
<string name="mode">模式</string>
+11
View File
@@ -47,6 +47,17 @@
<color name="misc_bg">#ffeaccf3</color>
<color name="unknown_bg">@android:color/black</color>
<color name="fav0">#ff616161</color>
<color name="fav1">#ffff3e3e</color>
<color name="fav2">#ffff923e</color>
<color name="fav3">#fffff43e</color>
<color name="fav4">#ff3eff6b</color>
<color name="fav5">#ffb1ff3e</color>
<color name="fav6">#ff3efeff</color>
<color name="fav7">#ff4b3eff</color>
<color name="fav8">#ffa23eff</color>
<color name="fav9">#ffff3ec4</color>
<color name="title_primary">#ff333333</color>
<color name="title_secondary">#ffaaaaaa</color>
+4
View File
@@ -296,6 +296,7 @@
<string name="rating0">DISASTER</string>
<!-- Util -->
<string name="local">Local</string>
<string name="tag">Tag</string>
<string name="copyed">Copyed</string>
<string name="send">Send</string>
@@ -323,6 +324,9 @@
<string name="jump">Jump</string>
<string name="some_page">Page %d</string>
<string name="_default">Default</string>
<string name="delete">Delete</string>
<string name="move">Move</string>
<string name="list">List</string>
<string name="homepage">Homepage</string>
<string name="mode">Mode</string>
+33 -3
View File
@@ -75,6 +75,8 @@ public class EhClient {
private static final String TAG = "EhClient";
public static final int FAVORITE_SLOT_NUM = 10;
public static final int G = 0x0;
public static final int EX = 0x1;
public static final int LOFI_460x = 0x2;
@@ -169,6 +171,19 @@ public class EhClient {
}
}
public static String getFavoriteUrl(int index) {
return getFavoriteUrl(Config.getMode(), index);
}
public static String getFavoriteUrl(int mode, int index) {
switch (mode) {
case EX:
return EX_HEADER + "favorites.php?favcat=" + index;
default:
return G_HEADER + "favorites.php?favcat=" + index;
}
}
public interface OnLogoutListener {
public void onSuccess();
public void onFailure(String eMsg);
@@ -1689,7 +1704,8 @@ public class EhClient {
// modifyFavorite
public interface OnModifyFavoriteListener {
void onSuccess();
void onSuccess(ArrayList<GalleryInfo> gis,
int indexPerPage, int maxPage);
void onFailure(String eMsg);
}
@@ -1706,8 +1722,14 @@ public class EhClient {
}
}
/**
*
* @param gids
* @param cat -1 for delete
* @param listener
*/
public void modifyFavorite(final int[] gids, final int cat,
final OnAddToFavoriteListener listener) {
final OnModifyFavoriteListener listener) {
new Thread(new Runnable() {
@Override
public void run() {
@@ -1717,7 +1739,15 @@ public class EhClient {
hp.setOnRespondListener(new HttpHelper.OnRespondListener() {
@Override
public void onSuccess(String pageContext) {
listener.onSuccess();
ListParser parser = new ListParser();
int re = parser.parser(pageContext);
if (re == ListParser.ALL) {
listener.onSuccess(parser.giList, parser.indexPerPage, parser.maxPage);
} else if (re == ListParser.NOT_FOUND) {
listener.onSuccess(parser.giList, parser.indexPerPage, parser.maxPage);
} else if (re == ListParser.PARSER_ERROR) {
listener.onFailure("parser error"); // TODO
}
}
@Override
public void onFailure(String eMsg) {
@@ -28,7 +28,6 @@ public class ListParser {
public static final int ALL = 0x1;
public static final int NOT_FOUND = 0x2;
public static final int SAD_PANDA = 0x3;
public static final int PARSER_ERROR = -1;
public int indexPerPage = 25;
@@ -45,7 +44,7 @@ public class ListParser {
m = p.matcher(pageContext);
if (m.find()) {
maxPage = Integer.parseInt(m.group(1));
} else if (pageContext.contains("No hits found</p></div>")) {
} else if (pageContext.contains("No hits found</p>")) {
maxPage = 0;
return NOT_FOUND;
} else {
@@ -53,7 +52,7 @@ public class ListParser {
}
giList = new ArrayList<GalleryInfo>(indexPerPage);
p = Pattern.compile("<td class=\"itdc\"><a.+?><img.+?alt=\"(.+?)\".+?/></a></td>" // category
p = Pattern.compile("<td class=\"itdc\">(?:<a.+?>)?<img.+?alt=\"(.+?)\".+?/>(?:</a>)?</td>" // category
+ "<td.+?>(.+?)</td>" // posted
+ "<td.+?><div.+?><div.+?>"
+ "(?:<img.+?src=\"(.+?)\".+?alt=\"(.+?)\" style.+?/>"
@@ -363,6 +363,7 @@ public class HttpHelper {
sb.append(URLEncoder.encode(arg[1], "UTF-8"));
i++;
}
Log.d(TAG, sb.toString());
out.writeBytes(sb.toString());
out.flush();
out.close();
+271 -69
View File
@@ -16,15 +16,25 @@
package com.hippo.ehviewer.ui;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Path;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape;
import android.os.Bundle;
import android.view.ActionMode;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -33,9 +43,8 @@ import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.ImageGeterManager;
@@ -46,64 +55,40 @@ import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.service.DownloadServiceConnection;
import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Log;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.widget.AlertButton;
import com.hippo.ehviewer.widget.DialogBuilder;
import com.hippo.ehviewer.widget.FswView;
import com.hippo.ehviewer.widget.LoadImageView;
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
public class FavouriteActivity extends AbstractActivity {
public class FavouriteActivity extends AbstractSlidingActivity
implements ListView.MultiChoiceModeListener {
@SuppressWarnings("unused")
private static final String TAG = "FavouriteActivity";
private AppContext mAppContext;
private Data mData;
private Resources mResources;
private EhClient mClient;
private FlAdapter flAdapter;
private List<GalleryInfo> mFavouriteLmd;
private int longClickItemIndex;
private SlidingMenu mSlidingMenu;
private ListView mMenuList;
private ListView mListView;
private FlAdapter mAdapter;
private List<GalleryInfo> mGis;
private Set<Integer> mChoiceGids; // Store gid
private int mMenuIndex;
private String[] mFavoriteTitles;
private AlertDialog mMoveDialog;
private ImageGeterManager mImageGeterManager;
private DownloadServiceConnection mServiceConn = new DownloadServiceConnection();
// List item long click dialog
private AlertDialog longClickDialog;
private AlertDialog setLongClickDialog() {
return new DialogBuilder(this).setTitle(R.string.what_to_do)
.setItems(R.array.favourite_item_long_click, new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
switch (position) {
case 0: // Remove favourite item
mData.deleteLocalFavourite(mFavouriteLmd.get(longClickItemIndex).gid);
flAdapter.notifyDataSetChanged();
break;
case 1:
GalleryInfo lmd = mFavouriteLmd.get(longClickItemIndex);
Intent it = new Intent(FavouriteActivity.this, DownloadService.class);
startService(it);
mServiceConn.getService().add(String.valueOf(lmd.gid), lmd.thumb,
EhClient.getDetailUrl(lmd.gid, lmd.token), lmd.title);
Toast.makeText(FavouriteActivity.this,
getString(R.string.toast_add_download),
Toast.LENGTH_SHORT).show();
break;
default:
break;
}
longClickDialog.cancel();
}
}).setNegativeButton(android.R.string.cancel, new View.OnClickListener() {
@Override
public void onClick(View v) {
((AlertButton)v).dialog.dismiss();
}
}).create();
}
private class FlAdapter extends BaseAdapter {
private LayoutInflater mInflater;
@@ -113,12 +98,12 @@ public class FavouriteActivity extends AbstractActivity {
@Override
public int getCount() {
return mFavouriteLmd.size();
return mGis.size();
}
@Override
public Object getItem(int arg0) {
return mFavouriteLmd.get(arg0);
return mGis.get(arg0);
}
@Override
@@ -128,7 +113,7 @@ public class FavouriteActivity extends AbstractActivity {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GalleryInfo lmd= mFavouriteLmd.get(position);
GalleryInfo lmd= mGis.get(position);
if (convertView == null)
convertView = mInflater.inflate(R.layout.list_item, null);
@@ -188,8 +173,8 @@ public class FavouriteActivity extends AbstractActivity {
protected void onResume() {
super.onResume();
if (flAdapter != null)
flAdapter.notifyDataSetChanged();
if (mAdapter != null)
mAdapter.notifyDataSetChanged();
}
@Override
@@ -199,44 +184,157 @@ public class FavouriteActivity extends AbstractActivity {
mAppContext = (AppContext)getApplication();
mData = mAppContext.getData();
mResources =getResources();
mImageGeterManager = mAppContext.getImageGeterManager();
mClient = mAppContext.getEhClient();
Ui.translucent(this);
getActionBar().setDisplayHomeAsUpEnabled(true);
// Download service
Intent it = new Intent(FavouriteActivity.this, DownloadService.class);
bindService(it, mServiceConn, BIND_AUTO_CREATE);
longClickDialog = setLongClickDialog();
setBehindContentView(R.layout.favorite_menu);
setSlidingActionBarEnabled(false);
mSlidingMenu = getSlidingMenu();
mSlidingMenu.setMode(SlidingMenu.RIGHT);
mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
mSlidingMenu.setBehindWidth(
mResources.getDimensionPixelOffset(R.dimen.menu_offset));
mSlidingMenu.setShadowDrawable(R.drawable.shadow_right);
mSlidingMenu.setShadowWidthRes(R.dimen.shadow_width);
getActionBar().setDisplayHomeAsUpEnabled(true);
mFavouriteLmd = mData.getAllLocalFavourites();
ListView listView = (ListView)findViewById(R.id.favourite);
flAdapter = new FlAdapter();
listView.setAdapter(flAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
mFavoriteTitles = new String[EhClient.FAVORITE_SLOT_NUM];
for (int i = 0; i < EhClient.FAVORITE_SLOT_NUM; i++) {
mFavoriteTitles[i] = "收藏 " + i;
}
mMenuIndex = 0;
setTitle("本地收藏"); // TODO
mGis = mData.getAllLocalFavourites();
mChoiceGids = new HashSet<Integer>();
mListView = (ListView)findViewById(R.id.favourite);
mListView.setClipToPadding(false);
mAdapter = new FlAdapter();
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
Intent intent = new Intent(FavouriteActivity.this,
MangaDetailActivity.class);
GalleryInfo gi = mFavouriteLmd.get(position);
GalleryInfo gi = mGis.get(position);
intent.putExtra("url", EhClient.getDetailUrl(gi.gid, gi.token));
intent.putExtra(MangaDetailActivity.KEY_G_INFO, gi);
startActivity(intent);
}
});
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
mListView.setMultiChoiceModeListener(this);
mMenuList = (ListView)findViewById(R.id.favorite_menu_list);
mMenuList.setClipToPadding(false);
mMenuList.setAdapter(new BaseAdapter() {
private ShapeDrawable d;
private ShapeDrawable createDrawable() {
Path path = new Path();
path.moveTo(50, 10);
path.lineTo(10, 50);
path.lineTo(50, 90);
path.lineTo(90, 50);
path.close();
ShapeDrawable d = new ShapeDrawable(new PathShape(path, 100, 100));
d.getPaint().setColor(0xcdffffff);
d.setBounds(0, 0, Ui.dp2pix(36), Ui.dp2pix(36));
return d;
}
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
longClickItemIndex = position;
longClickDialog.show();
return true;
public int getCount() {
return EhClient.FAVORITE_SLOT_NUM + 1;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater li= LayoutInflater.from(FavouriteActivity.this);
TextView tv = (TextView)li.inflate(R.layout.menu_item, null);
if (position == 0) {
Drawable dr = mResources.getDrawable(R.drawable.ic_action_panda);
dr.setBounds(0, 0, Ui.dp2pix(36), Ui.dp2pix(36));
tv.setCompoundDrawables(dr, null, null, null);
tv.setCompoundDrawablePadding(Ui.dp2pix(8));
tv.setText("本地收藏"); // TODO
} else {
if (d == null)
d = createDrawable();
tv.setCompoundDrawables(d, null, null, null);
tv.setCompoundDrawablePadding(Ui.dp2pix(8));
tv.setText(mFavoriteTitles[position - 1]); // TODO
}
return tv;
}
});
mMenuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// If same index, do nothing
if (mMenuIndex == position)
return;
showContent();
mMenuIndex = position;
if (mMenuIndex == 0) {
setTitle("本地收藏"); // TODO
mGis = mData.getAllLocalFavourites();
mAdapter.notifyDataSetChanged();
} else {
setTitle(mFavoriteTitles[mMenuIndex - 1]); // TODO
mClient.getMangaList(EhClient.getFavoriteUrl(mMenuIndex - 1),
null, new EhClient.OnGetMangaListListener() {
@Override
public void onSuccess(Object checkFlag, ArrayList<GalleryInfo> lmdArray,
int indexPerPage, int maxPage) {
mGis = lmdArray;
mAdapter.notifyDataSetChanged();
}
@Override
public void onFailure(Object checkFlag, String eMsg) {
Toast.makeText(FavouriteActivity.this, eMsg, Toast.LENGTH_SHORT).show();
}
});
// TODO
}
}
});
FswView alignment = (FswView)findViewById(R.id.alignment);
alignment.addOnFitSystemWindowsListener(new OnFitSystemWindowsListener() {
@Override
public void onfitSystemWindows(int paddingLeft, int paddingTop,
int paddingRight, int paddingBottom) {
mListView.setPadding(mListView.getPaddingLeft(), paddingTop,
mListView.getPaddingRight(), paddingBottom);
mMenuList.setPadding(mMenuList.getPaddingLeft(), paddingTop,
mMenuList.getPaddingRight(), paddingBottom);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.favorite, menu);
return true;
}
@Override
@@ -246,6 +344,9 @@ public class FavouriteActivity extends AbstractActivity {
case android.R.id.home:
finish();
return true;
case R.id.action_list:
toggle();
return true;
default:
return super.onOptionsItemSelected(item);
}
@@ -257,7 +358,108 @@ public class FavouriteActivity extends AbstractActivity {
unbindService(mServiceConn);
}
public void buttonListItemCancel(View v) {
longClickDialog.cancel();
// ListView.MultiChoiceModeListener
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.favorite_choice, menu);
mode.setTitle("Select Items"); // TODO
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return true;
}
private AlertDialog createMoveDialog(final ActionMode mode) {
return new DialogBuilder(this).setTitle("移动至何处?") //
.setItems(mFavoriteTitles, new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
int[] gids = new int[mChoiceGids.size()];
int i = 0;
for (Integer gid : mChoiceGids)
gids[i++] = gid;
mClient.modifyFavorite(gids, position, new EhClient.OnModifyFavoriteListener() {
@Override
public void onSuccess(ArrayList<GalleryInfo> gis,
int indexPerPage, int maxPage) {
Toast.makeText(FavouriteActivity.this,
"移动成功", Toast.LENGTH_SHORT).show(); // TODO
mGis = gis;
mAdapter.notifyDataSetChanged();
}
@Override
public void onFailure(String eMsg) {
Toast.makeText(FavouriteActivity.this,
"移动失败\n" + eMsg, Toast.LENGTH_SHORT).show(); // TODO
}
});
mMoveDialog.dismiss();
mMoveDialog = null;
mode.finish();
}
}).create();
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.action_delete:
if (mMenuIndex == 0) {
for (Integer gid : mChoiceGids)
mData.deleteLocalFavourite(gid);
mAdapter.notifyDataSetChanged();
} else {
int[] gids = new int[mChoiceGids.size()];
int i = 0;
for (Integer gid : mChoiceGids)
gids[i++] = gid;
mClient.modifyFavorite(gids, -1, new EhClient.OnModifyFavoriteListener() {
@Override
public void onSuccess(ArrayList<GalleryInfo> gis, int indexPerPage,
int maxPage) {
Toast.makeText(FavouriteActivity.this,
"删除成功", Toast.LENGTH_SHORT).show(); // TODO
mGis = gis;
mAdapter.notifyDataSetChanged();
}
@Override
public void onFailure(String eMsg) {
Toast.makeText(FavouriteActivity.this,
"删除失败\n" + eMsg, Toast.LENGTH_SHORT).show(); // TODO
}
});
}
mode.finish();
return true;
case R.id.action_move:
mMoveDialog = createMoveDialog(mode);
mMoveDialog.show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onDestroyActionMode(ActionMode mode) {
mChoiceGids.clear();
}
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position,
long id, boolean checked) {
if (checked)
mChoiceGids.add(mGis.get(position).gid);
else
mChoiceGids.remove(mGis.get(position).gid);
}
}