SHOW:
|
|
- or go back to the newest paste.
1 | - | @Override |
1 | + | public class OrderAdapter extends ArrayAdapter<PostData> implements View.OnClickListener { |
2 | public ArrayList<PostData> items; | |
3 | Activity a; | |
4 | ViewHolder holder; | |
5 | ||
6 | private int progress = 0; | |
7 | private Runnable res; | |
8 | public ImageLoader imageLoader; | |
9 | DisplayImageOptions options; | |
10 | private ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener(); | |
11 | ||
12 | ||
13 | ||
14 | public OrderAdapter(Context context, int textViewResourceId,ArrayList<PostData> items) { | |
15 | super(context, textViewResourceId, items); | |
16 | this.items = items; | |
17 | //=================================== | |
18 | File cacheDir = StorageUtils.getOwnCacheDirectory(context, "MyFolderCache"); | |
19 | ||
20 | // Get singletone instance of ImageLoader | |
21 | imageLoader = ImageLoader.getInstance(); | |
22 | // Create configuration for ImageLoader (all options are optional) | |
23 | ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) | |
24 | // You can pass your own memory cache implementation | |
25 | .discCacheExtraOptions(1024, 1024, CompressFormat.PNG, 100) | |
26 | .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation | |
27 | .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) | |
28 | .enableLogging() | |
29 | .build(); | |
30 | // Initialize ImageLoader with created configuration. Do it once. | |
31 | imageLoader.init(config); | |
32 | imageLoader.init(ImageLoaderConfiguration.createDefault(context)); | |
33 | // imageLoader=new ImageLoader(context.getApplicationContext()); | |
34 | options = new DisplayImageOptions.Builder() | |
35 | .showStubImage(R.drawable.ic_launcher) | |
36 | .cacheInMemory() | |
37 | .cacheOnDisc() | |
38 | .displayer(new RoundedBitmapDisplayer(60)) | |
39 | .build(); | |
40 | } | |
41 | ||
42 | ||
43 | ||
44 | @Override | |
45 | public View getView(final int position, View convertView,ViewGroup parent) { | |
46 | ||
47 | View v = convertView; | |
48 | if (v == null) { | |
49 | LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
50 | //imageLoader = new ImageLoader(TodaysDeals.this); | |
51 | v = vi.inflate(R.layout.post_list_row, null); | |
52 | holder = new ViewHolder(); | |
53 | //imageLoader = new ImageLoader(getContext()); | |
54 | //-------------- | |
55 | ||
56 | //--------------------------------------------------------------------- | |
57 | // for head to head | |
58 | holder.userName = (TextView) v.findViewById(R.id.username); | |
59 | holder.seekBar = (ProgressWheel) v.findViewById(R.id.progressBarTwo); | |
60 | holder.playButton = (ImageView) v.findViewById(R.id.playBtn); | |
61 | holder.profilePic = (ImageView) v.findViewById(R.id.userProfilePic); | |
62 | //holder.soundTimeMeter = (Chronometer) v.findViewById(R.id.soundTimeMeter); | |
63 | - | holder.playButton.setOnClickListener(new View.OnClickListener() { |
63 | + | |
64 | //holder.dealDescription = (TextView) v.findViewById(R.id.txtDescription); | |
65 | //holder.dealRatingBar = (RatingBar) v.findViewById(R.id.dealRattingBar); | |
66 | /*holder.DealsState = (TextView) v.findViewById(R.id.txtstate); | |
67 | holder.DealsCountry = (TextView) v.findViewById(R.id.txtContry);*/ | |
68 | //--------------------------------------------------------------------- | |
69 | holder.playButton.setOnClickListener(this); | |
70 | holder.seekBar.setTag(position); | |
71 | - | }); |
71 | + | |
72 | ||
73 | v.setTag(holder); | |
74 | }else{ | |
75 | ||
76 | - | } |
76 | + | |
77 | holder=(ViewHolder)v.getTag(); | |
78 | } | |
79 | ||
80 | ||
81 | //holder=(ViewHolder)v.getTag(); | |
82 | ||
83 | final PostData o = items.get(position); | |
84 | ||
85 | holder = (ViewHolder) v.getTag(); | |
86 | ||
87 | /*res = new Runnable() { | |
88 | public void run() { | |
89 | if(progress<=100){ | |
90 | holder.seekBar.setProgress(progress); | |
91 | holder.seekBar.invalidate(); | |
92 | progress++; | |
93 | new Handler().postDelayed(res, 1000); | |
94 | } | |
95 | ||
96 | } | |
97 | };*/ | |
98 | ||
99 | if (o != null) { | |
100 | holder.userName.setText(o.getDealName()); | |
101 | ||
102 | ||
103 | holder.seekBar.setProgress((progress+20)); | |
104 | ||
105 | ||
106 | //postlv.getPositionForView(holder.playButton); | |
107 | /*holder.playButton.setOnClickListener(new View.OnClickListener() { | |
108 | @Override | |
109 | public void onClick(View v) { | |
110 | //Toast.makeText(getActivity(), "PLay:: "+position, Toast.LENGTH_SHORT).show(); | |
111 | progress=progress+10; | |
112 | holder.seekBar.getTag(position); | |
113 | holder.seekBar.setProgress(progress); | |
114 | } | |
115 | });*/ | |
116 | ||
117 | imageLoader.displayImage("https://graph.facebook.com/100005093370152/picture", holder.profilePic,options,animateFirstListener); | |
118 | } | |
119 | return v; | |
120 | } | |
121 | ||
122 | ||
123 | ||
124 | @Override | |
125 | public void onClick(View v) { | |
126 | switch(v.getId()){ | |
127 | case R.id.playBtn: | |
128 | ||
129 | progress=progress+10; | |
130 | holder.seekBar.getTag(); | |
131 | holder.seekBar.setProgress(progress); | |
132 | break; | |
133 | } | |
134 | } | |
135 | } | |
136 | class ViewHolder { | |
137 | ||
138 | // | |
139 | TextView userName ; | |
140 | ProgressWheel seekBar; | |
141 | ImageView playButton; | |
142 | ImageView profilePic; | |
143 | //Chronometer soundTimeMeter; | |
144 | //WaveformView soundPath; | |
145 | /*TextView dealTotalStamp; | |
146 | TextView DealsCountry;*/ | |
147 | //ImageView dealPic ; | |
148 | //RatingBar dealRatingBar; | |
149 | ||
150 | } | |
151 | ||
152 | ||
153 | ||
154 | } |