当搜索栏失去焦点时隐藏
This commit is contained in:
1 parent
006a8684ff
commit
103cfe1749
2 files changed
+68
-60
No files matched your search
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.service;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
@@ -240,7 +239,6 @@ public class DownloadService extends Service
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onStart(int gid) {
|
||||
if (mCurDownloadInfo == null)
|
||||
return;
|
||||
@@ -253,14 +251,13 @@ public class DownloadService extends Service
|
||||
mBuilder.setContentTitle(getString(R.string.start_download) + " " + gid)
|
||||
.setContentText(null)
|
||||
.setProgress(0, 0, true);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.getNotification());
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.build());
|
||||
mNotifyManager.cancel(gid);
|
||||
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onDownload(int gid, int downloadSize, int totalSize) {
|
||||
if (mCurDownloadInfo == null)
|
||||
return;
|
||||
@@ -273,13 +270,12 @@ public class DownloadService extends Service
|
||||
mBuilder.setContentTitle(getString(R.string.downloading) + " " + gid)
|
||||
.setContentText(mSpeedStr)
|
||||
.setProgress(totalSize, downloadSize, false);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.getNotification());
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.build());
|
||||
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onUpdateSpeed(int gid, int speed) {
|
||||
if (mCurDownloadInfo == null)
|
||||
return;
|
||||
@@ -293,19 +289,18 @@ public class DownloadService extends Service
|
||||
.setContentText(mSpeedStr)
|
||||
.setProgress(mCurDownloadInfo.total, mCurDownloadInfo.download,
|
||||
mCurDownloadInfo.total == -1 ? true :false);
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.getNotification());
|
||||
mNotifyManager.notify(DOWNLOAD_NOTIFY_ID, mBuilder.build());
|
||||
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onDownloadOver(int gid, int legacy) {
|
||||
if (mCurDownloadInfo == null)
|
||||
return;
|
||||
|
||||
mCurDownloadInfo.legacy = legacy;
|
||||
Notification.Builder builder = new Notification.Builder(mContext);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
|
||||
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||
Intent intent = new Intent(DownloadService.this,DownloadActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(DownloadService.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
@@ -314,7 +309,7 @@ public class DownloadService extends Service
|
||||
.setContentText(legacy == 0 ? getString(R.string.done) :
|
||||
String.format(getString(R.string.legacy_pages), legacy))
|
||||
.setOngoing(false).setAutoCancel(true);
|
||||
mNotifyManager.notify(gid, builder.getNotification());
|
||||
mNotifyManager.notify(gid, builder.build());
|
||||
mNotifyManager.cancel(DOWNLOAD_NOTIFY_ID);
|
||||
|
||||
mCurDownloadInfo.legacy = legacy;
|
||||
|
||||
@@ -126,7 +126,9 @@ import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
|
||||
* @author Hippo
|
||||
*/
|
||||
public class GalleryListActivity extends AbsGalleryActivity
|
||||
implements View.OnClickListener {
|
||||
implements View.OnClickListener, SearchView.OnQueryTextListener,
|
||||
SearchView.OnFocusChangeListener, SlidingMenu.OnOpenedListener,
|
||||
SlidingMenu.OnClosedListener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = GalleryListActivity.class.getSimpleName();
|
||||
@@ -152,10 +154,12 @@ public class GalleryListActivity extends AbsGalleryActivity
|
||||
private SlidingMenu mSlidingMenu;
|
||||
private View mMenuLeft;
|
||||
private LinearLayout mUserPanel;
|
||||
private SearchView mSearchView;
|
||||
private ListView itemListMenu;
|
||||
private TagListView tagListMenu;
|
||||
|
||||
private SearchView mSearchView;
|
||||
private MenuItem mSearchItem;
|
||||
|
||||
private ImageView avatar;
|
||||
private TextView userView;
|
||||
private Button loginButton;
|
||||
@@ -912,6 +916,22 @@ public class GalleryListActivity extends AbsGalleryActivity
|
||||
return R.layout.gallery_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpened() {
|
||||
if (mShowDrawer) {
|
||||
setTitle(R.string.app_name);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed() {
|
||||
if (mShowDrawer) {
|
||||
setTitle(mTitle);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -939,24 +959,8 @@ public class GalleryListActivity extends AbsGalleryActivity
|
||||
mSlidingMenu.setShadowWidthRes(R.dimen.shadow_width);
|
||||
mSlidingMenu.setShadowDrawable(R.drawable.shadow);
|
||||
mSlidingMenu.setSecondaryShadowDrawable(R.drawable.shadow_right);
|
||||
mSlidingMenu.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
|
||||
@Override
|
||||
public void onOpened() {
|
||||
if (mShowDrawer) {
|
||||
setTitle(R.string.app_name);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
mSlidingMenu.setOnClosedListener(new SlidingMenu.OnClosedListener() {
|
||||
@Override
|
||||
public void onClosed() {
|
||||
if (mShowDrawer) {
|
||||
setTitle(mTitle);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
mSlidingMenu.setOnOpenedListener(this);
|
||||
mSlidingMenu.setOnClosedListener(this);
|
||||
if (mShowDrawer)
|
||||
mSlidingMenu.setBehindWidth(
|
||||
mResources.getDimensionPixelOffset(R.dimen.menu_width));
|
||||
@@ -1252,6 +1256,41 @@ public class GalleryListActivity extends AbsGalleryActivity
|
||||
mStaggeredGridView.getPaddingRight(), paddingBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
// Store suggestion
|
||||
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
|
||||
GalleryListActivity.this, SimpleSuggestionProvider.AUTHORITY,
|
||||
SimpleSuggestionProvider.MODE);
|
||||
suggestions.saveRecentQuery(query, null);
|
||||
// collapse search view
|
||||
if (mSearchItem != null)
|
||||
mSearchItem.collapseActionView();
|
||||
|
||||
String t = null;
|
||||
if (query == null || query.isEmpty())
|
||||
t = getString(android.R.string.search_go);
|
||||
else
|
||||
t = query;
|
||||
|
||||
lus = new ListUrls(ListUrls.NONE, query);
|
||||
refresh();
|
||||
mTitle = t;
|
||||
setTitle(mTitle);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus && mSearchItem != null)
|
||||
mSearchItem.collapseActionView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Do not show menu when mSlidingMenu is shown
|
||||
@@ -1262,38 +1301,12 @@ public class GalleryListActivity extends AbsGalleryActivity
|
||||
|
||||
SearchManager searchManager =
|
||||
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
final MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
mSearchView = (SearchView) searchItem.getActionView();
|
||||
mSearchItem = menu.findItem(R.id.action_search);
|
||||
mSearchView = (SearchView) mSearchItem.getActionView();
|
||||
mSearchView.setSearchableInfo(
|
||||
searchManager.getSearchableInfo(getComponentName()));
|
||||
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
// Store suggestion
|
||||
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
|
||||
GalleryListActivity.this, SimpleSuggestionProvider.AUTHORITY,
|
||||
SimpleSuggestionProvider.MODE);
|
||||
suggestions.saveRecentQuery(query, null);
|
||||
|
||||
searchItem.collapseActionView();
|
||||
|
||||
String t = null;
|
||||
if (query == null || query.isEmpty())
|
||||
t = getString(android.R.string.search_go);
|
||||
else
|
||||
t = query;
|
||||
|
||||
lus = new ListUrls(ListUrls.NONE, query);
|
||||
refresh();
|
||||
mTitle = t;
|
||||
setTitle(mTitle);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mSearchView.setOnQueryTextListener(this);
|
||||
mSearchView.setOnQueryTextFocusChangeListener(this);
|
||||
|
||||
// Make search view custom look
|
||||
int searchTextID = mResources.getIdentifier("android:id/search_src_text", null, null);
|
||||
|
||||
Reference in new issue
Block a user