11package com .yuzhi .fine .fragment ;
22
3- import android .app .Activity ;
43import android .os .Bundle ;
54import android .support .v4 .app .Fragment ;
65import android .view .LayoutInflater ;
1615import com .squareup .okhttp .Request ;
1716import com .squareup .picasso .Picasso ;
1817import com .yuzhi .fine .R ;
18+ import com .yuzhi .fine .activity .MainActivity ;
1919import com .yuzhi .fine .http .HttpClient ;
2020import com .yuzhi .fine .http .HttpResponseHandler ;
2121import com .yuzhi .fine .model .SearchParam ;
3535import in .srain .cube .views .ptr .PtrDefaultHandler ;
3636import in .srain .cube .views .ptr .PtrFrameLayout ;
3737import in .srain .cube .views .ptr .PtrHandler ;
38- import in .srain .cube .views .ptr .PtrUIHandler ;
3938import in .srain .cube .views .ptr .header .StoreHouseHeader ;
40- import in .srain .cube .views .ptr .indicator .PtrIndicator ;
4139
4240/**
4341 * Created by tiansj on 15/9/4.
4442 */
4543public class DemoPtrFragment extends Fragment {
46- private Activity context ;
44+ private MainActivity context ;
4745
4846 private SearchParam param ;
4947 private int pno = 1 ;
@@ -65,7 +63,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6563 @ Override
6664 public void onActivityCreated (Bundle savedInstanceState ) {
6765 super .onActivityCreated (savedInstanceState );
68- context = getActivity ();
66+ context = ( MainActivity ) getActivity ();
6967 initData ();
7068 initView ();
7169 loadData ();
@@ -80,6 +78,7 @@ protected void convert(BaseAdapterHelper helper, SearchShop shop) {
8078 .setImageUrl (R .id .logo , shop .getLogo ()); // 自动异步加载图片
8179 }
8280 };
81+ listView .setDrawingCacheEnabled (true );
8382 listView .setAdapter (adapter );
8483
8584 // header custom begin
@@ -135,10 +134,105 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
135134 @ Override
136135 public void onScroll (AbsListView view , int firstVisibleItem ,
137136 int visibleItemCount , int totalItemCount ) {
137+ // getLastVisibleItemBitmap(firstVisibleItem+visibleItemCount);
138+ // takeScreenShot(context);
138139 }
139140 });
141+
140142 }
141143
144+ // public void takeScreenShot(Activity activity) {
145+ // // View是你需要截图的View
146+ // View view = activity.getWindow().getDecorView();
147+ // view.setDrawingCacheEnabled(true);
148+ // view.buildDrawingCache();
149+ // Bitmap b1 = view.getDrawingCache();
150+ //
151+ // // 获取状态栏高度
152+ // Rect frame = new Rect();
153+ // activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
154+ // int statusBarHeight = frame.top;
155+ // System.out.println(statusBarHeight);
156+ //
157+ // // 获取屏幕长和高
158+ // int width = activity.getWindowManager().getDefaultDisplay().getWidth();
159+ // int height = activity.getWindowManager().getDefaultDisplay().getHeight();
160+ // // 去掉标题栏
161+ //// Bitmap b = Bitmap.createBitmap(b1, 0, height-120, width, 120);
162+ // Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height
163+ // - statusBarHeight);
164+ // view.destroyDrawingCache();
165+ // context.blurFooterBar(b);
166+ //// return b;
167+ // }
168+ //
169+ // private void getLastVisibleItemBitmap(int pos) {
170+ // View childView = adapter.getView(pos, null, listView);
171+ // if(childView == null) {
172+ // return;
173+ // }
174+ // childView.measure(View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.EXACTLY),
175+ // View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
176+ //
177+ // childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
178+ // childView.setDrawingCacheEnabled(true);
179+ // childView.buildDrawingCache();
180+ //// return childView.getDrawingCache();
181+ // context.blurFooterBar(childView.getDrawingCache());
182+ // }
183+ //
184+ // public Bitmap getWholeListViewItemsToBitmap() {
185+ // int itemscount = adapter.getCount();
186+ // int allitemsheight = 0;
187+ // List<Bitmap> bmps = new ArrayList<Bitmap>();
188+ //
189+ // for (int i = 0; i < itemscount; i++) {
190+ //
191+ // View childView = adapter.getView(i, null, listView);
192+ // childView.measure(View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.EXACTLY),
193+ // View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
194+ //
195+ // childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
196+ // childView.setDrawingCacheEnabled(true);
197+ // childView.buildDrawingCache();
198+ // bmps.add(childView.getDrawingCache());
199+ // allitemsheight+=childView.getMeasuredHeight();
200+ // }
201+ //
202+ // Bitmap bigbitmap = Bitmap.createBitmap(listView.getMeasuredWidth(), allitemsheight, Bitmap.Config.ARGB_8888);
203+ // Canvas bigcanvas = new Canvas(bigbitmap);
204+ //
205+ // Paint paint = new Paint();
206+ // int iHeight = 0;
207+ //
208+ // for (int i = 0; i < bmps.size(); i++) {
209+ // Bitmap bmp = bmps.get(i);
210+ // bigcanvas.drawBitmap(bmp, 0, iHeight, paint);
211+ // iHeight+=bmp.getHeight();
212+ //
213+ // bmp.recycle();
214+ // bmp=null;
215+ // }
216+ //
217+ //
218+ // return bigbitmap;
219+ // }
220+ //
221+ //
222+ // private void applyBlur() {
223+ // listView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
224+ // @Override
225+ // public boolean onPreDraw() {
226+ // listView.getViewTreeObserver().removeOnPreDrawListener(this);
227+ // listView.buildDrawingCache();
228+ //
229+ // Bitmap bmp = listView.getDrawingCache();
230+ // context.blurFooterBar(bmp);
231+ // return true;
232+ // }
233+ // });
234+ // }
235+
142236 private void initData () {
143237 param = new SearchParam ();
144238 pno = 1 ;
0 commit comments