-
Notifications
You must be signed in to change notification settings - Fork 4k
ScrollListener to improve performance #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a227cb0
DispatchingQueue
c6822c7
PicasooFlingScrollListner; First UnitTests
94339fc
More unit testing
0419d25
Samples with Scroll Listener
82d9465
Code styling
1a386b9
Sample with ViewPager
60c90e6
Making PicassoExecutorService pausable / resumable
222f7b4
Bugfix: If server returns null for a bitmap than performError will be…
cee103c
Code styling
a0ecfde
Removed newLine
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
picasso-sample/res/layout/sample_gridview_activity_scrolling.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:id="@+id/viewPager" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent"/> | ||
|
|
25 changes: 25 additions & 0 deletions
25
picasso-sample/res/layout/sample_gridview_fragment_scrolling.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?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"> | ||
|
|
||
| <GridView | ||
| android:id="@+id/grid_view" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:numColumns="@integer/column_count" | ||
| android:scrollbarStyle="insideOverlay" | ||
| android:scrollbars="none" | ||
| android:listSelector="@null" | ||
| /> | ||
|
|
||
| <Button | ||
| style="?android:attr/buttonStyleSmall" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="toggle Skip memory cache" | ||
| android:id="@+id/skipMemoryCacheButton" | ||
| android:layout_gravity="right|bottom" | ||
| /> | ||
|
|
||
| </FrameLayout> | ||
23 changes: 23 additions & 0 deletions
23
picasso-sample/res/layout/sample_list_detail_list_scrolling.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?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"> | ||
|
|
||
| <ListView | ||
| android:id="@+id/listView" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:paddingTop="@dimen/faux_action_bar_size" | ||
| android:clipToPadding="false" | ||
| /> | ||
|
|
||
| <Button | ||
| style="?android:attr/buttonStyleSmall" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="toggle Skip memory cache" | ||
| android:id="@+id/skipMemoryCacheButton" | ||
| android:layout_gravity="right|bottom" | ||
| /> | ||
|
|
||
| </FrameLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
picasso-sample/src/main/java/com/example/picasso/SampleGridViewScrollingActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package com.example.picasso; | ||
|
|
||
| import android.os.Bundle; | ||
| import android.support.v4.app.Fragment; | ||
| import android.support.v4.app.FragmentManager; | ||
| import android.support.v4.app.FragmentPagerAdapter; | ||
| import android.support.v4.view.ViewPager; | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.Button; | ||
| import android.widget.GridView; | ||
| import android.widget.Toast; | ||
| import com.squareup.picasso.scrolling.PicassoScrollListener; | ||
|
|
||
| public class SampleGridViewScrollingActivity extends PicassoSampleActivity { | ||
|
|
||
| @Override protected void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| setContentView(R.layout.sample_gridview_activity_scrolling); | ||
|
|
||
| ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); | ||
| viewPager.setAdapter(new GridFragmentAdapter(getSupportFragmentManager())); | ||
| viewPager.setPageMargin(30); | ||
|
|
||
| Toast.makeText(this, | ||
| "ViewPager with GridView\n" | ||
| + "Fades loaded images only if GridView is NOT scrolling and NOT flinging", | ||
| Toast.LENGTH_SHORT).show(); | ||
| } | ||
|
|
||
| public static class GridFragmentAdapter extends FragmentPagerAdapter { | ||
|
|
||
| public GridFragmentAdapter(FragmentManager fm) { | ||
| super(fm); | ||
| } | ||
|
|
||
| @Override public Fragment getItem(int position) { | ||
| return new GridFragment(); | ||
| } | ||
|
|
||
| @Override public int getCount() { | ||
| return 10; | ||
| } | ||
| } | ||
|
|
||
| public static class GridFragment extends Fragment { | ||
|
|
||
| private Button skipMemoryCacheButton; | ||
|
|
||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
| Bundle savedInstanceState) { | ||
| View v = inflater.inflate(R.layout.sample_gridview_fragment_scrolling, container, false); | ||
|
|
||
| boolean skipMemory = true; | ||
|
|
||
| GridView gv = (GridView) v.findViewById(R.id.grid_view); | ||
| final SampleGridViewAdapter adapter = new SampleGridViewAdapter(getActivity(), skipMemory); | ||
| gv.setAdapter(adapter); | ||
| gv.setOnScrollListener(new PicassoScrollListener(getActivity())); | ||
| skipMemoryCacheButton = (Button) v.findViewById(R.id.skipMemoryCacheButton); | ||
| updateButton(skipMemory); | ||
| skipMemoryCacheButton.setOnClickListener(new View.OnClickListener() { | ||
| @Override | ||
| public void onClick(View v) { | ||
| boolean skip = adapter.toggleSkipMemoryCache(); | ||
| updateButton(skip); | ||
| } | ||
| }); | ||
|
|
||
| return v; | ||
| } | ||
|
|
||
| private void updateButton(boolean skip) { | ||
| skipMemoryCacheButton.setText("skip memory cache = " + skip); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line