Skip to content

Commit

Permalink
Optimize sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyge committed Nov 19, 2016
1 parent 04d2567 commit 3af071b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,19 @@ public void onCheckedChanged(boolean checked) {
}
}, menuClickListener));

menuList.add(new CheckMenu(this, "列表滑动时不加载新图片", Settings.PREFERENCE_SCROLLING_PAUSE_LOAD, null, menuClickListener));
menuList.add(new CheckMenu(this, "移动网络时不下载新图片", Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD, null, menuClickListener));
menuList.add(new CheckMenu(this, "列表滑动时不加载新图片", Settings.PREFERENCE_SCROLLING_PAUSE_LOAD, new CheckMenu.OnCheckedChangedListener() {
@Override
public void onCheckedChanged(boolean checked) {
EventBus.getDefault().post(Settings.PREFERENCE_SCROLLING_PAUSE_LOAD);
}
}, menuClickListener));

menuList.add(new CheckMenu(this, "移动网络时不下载新图片", Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD, new CheckMenu.OnCheckedChangedListener() {
@Override
public void onCheckedChanged(boolean checked) {
EventBus.getDefault().post(Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD);
}
}, menuClickListener));

AssemblyRecyclerAdapter adapter = new AssemblyRecyclerAdapter(menuList);
adapter.addItemFactory(new MenuTitleItemFactory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ void onGlobalAttrChanged(String key){
|| Settings.PREFERENCE_GLOBAL_IN_PREFER_QUALITY_OVER_SPEED.equals(key)
|| Settings.PREFERENCE_GLOBAL_LOW_QUALITY_IMAGE.equals(key)
|| Settings.PREFERENCE_THUMBNAIL_MODE.equals(key)
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)) {
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)
|| Settings.PREFERENCE_SCROLLING_PAUSE_LOAD.equals(key)
|| Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD.equals(key)) {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ void onGlobalAttrChanged(String key){
|| Settings.PREFERENCE_GLOBAL_IN_PREFER_QUALITY_OVER_SPEED.equals(key)
|| Settings.PREFERENCE_GLOBAL_LOW_QUALITY_IMAGE.equals(key)
|| Settings.PREFERENCE_THUMBNAIL_MODE.equals(key)
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)) {
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)
|| Settings.PREFERENCE_SCROLLING_PAUSE_LOAD.equals(key)
|| Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD.equals(key)) {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.os.Handler;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.StaggeredGridLayoutManager;
Expand Down Expand Up @@ -101,10 +101,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}

private void setTitle(String subtitle) {
if (getActivity() != null && getActivity() instanceof ActionBarActivity) {
ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
if (getActivity() != null && getActivity() instanceof AppCompatActivity) {
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(subtitle);
actionBar.setSubtitle(subtitle);
}
}
}
Expand Down Expand Up @@ -173,6 +173,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
@Override
public void onDestroyView() {
EventBus.getDefault().unregister(this);
setTitle("");
super.onDestroyView();
}

Expand Down Expand Up @@ -309,7 +310,9 @@ void onGlobalAttrChanged(String key){
|| Settings.PREFERENCE_GLOBAL_IN_PREFER_QUALITY_OVER_SPEED.equals(key)
|| Settings.PREFERENCE_GLOBAL_LOW_QUALITY_IMAGE.equals(key)
|| Settings.PREFERENCE_THUMBNAIL_MODE.equals(key)
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)) {
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)
|| Settings.PREFERENCE_SCROLLING_PAUSE_LOAD.equals(key)
|| Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD.equals(key)) {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ void onGlobalAttrChanged(String key) {
|| Settings.PREFERENCE_GLOBAL_IN_PREFER_QUALITY_OVER_SPEED.equals(key)
|| Settings.PREFERENCE_GLOBAL_LOW_QUALITY_IMAGE.equals(key)
|| Settings.PREFERENCE_THUMBNAIL_MODE.equals(key)
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)) {
|| Settings.PREFERENCE_CACHE_PROCESSED_IMAGE.equals(key)
|| Settings.PREFERENCE_SCROLLING_PAUSE_LOAD.equals(key)
|| Settings.PREFERENCE_MOBILE_NETWORK_PAUSE_DOWNLOAD.equals(key)) {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
Expand Down

0 comments on commit 3af071b

Please sign in to comment.