|
|
* @author Administrator
|
|
53
|
|
*
|
|
54
|
|
*/
|
|
55
|
|
public class SelectPhotoActivity extends Activity {
|
|
56
|
|
|
|
57
|
|
private GridView photoGrid;//图片列表
|
|
58
|
|
|
|
59
|
|
private Button photoBtn;//底部下一步按钮
|
|
60
|
|
|
|
61
|
|
private TextView titleName;//头部的标题
|
|
62
|
|
|
|
63
|
|
private ImageView titleIcon;//头部的三角图标
|
|
64
|
|
|
|
65
|
|
private ProgressDialog mProgressDialog;
|
|
66
|
|
|
|
67
|
|
private HashSet<String> mDirPaths = new HashSet<String>();// 临时的辅助类,用于防止同一个文件夹的多次扫描
|
|
68
|
|
|
|
69
|
|
private List<ImageFloder> mImageFloders = new ArrayList<ImageFloder>();// 扫描拿到所有的图片文件夹
|
|
70
|
|
|
|
71
|
|
int totalCount = 0;
|
|
72
|
|
|
|
73
|
|
private File mImgDir=new File("");// 图片数量最多的文件夹
|
|
74
|
|
|
|
75
|
|
private int mPicsSize;//存储文件夹中的图片数量
|
|
76
|
|
|
|
77
|
|
private List<String> mImgs=new ArrayList<String>();//所有的图片
|
|
78
|
|
|
|
79
|
|
private int mScreenHeight;
|
|
80
|
|
|
|
81
|
|
private LinearLayout dirLayout;
|
|
82
|
|
|
|
83
|
|
private TextView quxiaoBtn;
|
|
84
|
|
|
|
85
|
|
private ListView dirListView;
|
|
86
|
|
|
|
87
|
|
private RelativeLayout headLayout;
|
|
88
|
|
|
|
89
|
|
private int mScreenWidth;
|
|
90
|
|
|
|
91
|
|
private ImageFloderAdapter floderAdapter;
|
|
92
|
|
|
|
93
|
|
private GirdItemAdapter girdItemAdapter;
|
|
94
|
|
|
|
95
|
|
private PopupWindow popupWindow;
|
|
96
|
|
|
|
97
|
|
private View dirview;
|
|
98
|
|
|
|
99
|
|
private static final int TAKE_CAMERA_PICTURE = 1000;//拍照
|
|
100
|
|
|
|
101
|
|
private String path;
|
|
102
|
|
|
|
103
|
|
private File dir;
|
|
104
|
|
|
|
105
|
|
private String imagename;
|
|
106
|
|
@Override
|
|
107
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
108
|
|
super.onCreate(savedInstanceState);
|
|
109
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
110
|
|
setContentView(R.layout.photo_select_view);
|
|
111
|
|
GirdItemAdapter.mSelectedImage.clear();
|
|
112
|
|
DisplayMetrics outMetrics = new DisplayMetrics();
|
|
113
|
|
getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
|
114
|
|
mScreenHeight = outMetrics.heightPixels;
|
|
115
|
|
mScreenWidth = outMetrics.widthPixels;
|
|
116
|
|
setView();
|
|
117
|
|
getImages();
|
|
118
|
|
initEvent();
|
|
119
|
|
}
|
|
120
|
|
/**
|
|
121
|
|
* 获取控件
|
|
122
|
|
*/
|
|
123
|
|
private void setView() {
|
|
124
|
|
photoGrid=(GridView)findViewById(R.id.gird_photo_list);
|
|
125
|
|
photoBtn=(Button)findViewById(R.id.selected_photo_btn);
|
|
126
|
|
titleName=(TextView)this.findViewById(R.id.selected_photo_name_text);
|
|
127
|
|
quxiaoBtn=(TextView)findViewById(R.id.quxiao_btn);
|
|
128
|
|
titleIcon=(ImageView)findViewById(R.id.selected_photo_icon);
|
|
129
|
|
headLayout=(RelativeLayout)findViewById(R.id.selected_photo_header_layout);
|
|
130
|
|
titleIcon.setBackgroundResource(R.drawable.navigationbar_arrow_down);
|
|
131
|
|
}
|
|
132
|
|
/**
|
|
133
|
|
* 利用ContentProvider扫描手机中的图片,此方法在运行在子线程中 完成图片的扫描,最终获得jpg最多的那个文件夹
|
|
134
|
|
*/
|
|
135
|
|
private void getImages(){
|
|
136
|
|
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
|
|
137
|
|
Toast.makeText(this, "暂无外部存储", Toast.LENGTH_SHORT).show();
|
|
138
|
|
return;
|
|
139
|
|
}
|
|
140
|
|
// 显示进度条
|
|
141
|
|
mProgressDialog = ProgressDialog.show(this, null, "正在加载...");
|
|
142
|
|
new Thread(new Runnable(){
|
|
143
|
|
@Override
|
|
144
|
|
public void run(){
|
|
145
|
|
String firstImage = null;
|
|
146
|
|
Uri mImageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
|
147
|
|
ContentResolver mContentResolver = SelectPhotoActivity.this.getContentResolver();
|
|
148
|
|
// 只查询jpeg和png的图片
|
|
149
|
|
Cursor mCursor = mContentResolver.query(mImageUri, null,
|
|
150
|
|
MediaStore.Images.Media.MIME_TYPE + "=? or "
|
|
151
|
|
+ MediaStore.Images.Media.MIME_TYPE + "=?",
|
|
152
|
|
new String[] { "image/jpeg", "image/png" },
|
|
153
|
|
MediaStore.Images.Media.DATE_MODIFIED);
|
|
154
|
|
Log.e("TAG", mCursor.getCount() + "");
|
|
155
|
|
while (mCursor.moveToNext()){
|
|
156
|
|
// 获取图片的路径
|
|
157
|
|
String path = mCursor.getString(mCursor.getColumnIndex(MediaStore.Images.Media.DATA));
|
|
158
|
|
Log.e("TAG", path);
|
|
159
|
|
// 拿到第一张图片的路径
|
|
160
|
|
if (firstImage == null)
|
|
161
|
|
firstImage = path;
|
|
162
|
|
// 获取该图片的父路径名
|
|
163
|
|
File parentFile = new File(path).getParentFile();
|
|
164
|
|
if (parentFile == null)
|
|
165
|
|
continue;
|
|
166
|
|
String dirPath = parentFile.getAbsolutePath();
|
|
167
|
|
ImageFloder imageFloder = null;
|
|
168
|
|
// 利用一个HashSet防止多次扫描同一个文件夹(不加这个判断,图片多起来还是相当恐怖的~~)
|
|
169
|
|
if (mDirPaths.contains(dirPath)){
|
|
170
|
|
continue;
|
|
171
|
|
} else{
|
|
172
|
|
mDirPaths.add(dirPath);
|
|
173
|
|
// 初始化imageFloder
|
|
174
|
|
imageFloder = new ImageFloder();
|
|
175
|
|
imageFloder.setDir(dirPath);
|
|
176
|
|
imageFloder.setFirstImagePath(path);
|
|
177
|
|
}
|
|
178
|
|
if(parentFile.list()==null)continue ;
|
|
179
|
|
int picSize = parentFile.list(new FilenameFilter(){
|
|
180
|
|
@Override
|
|
181
|
|
public boolean accept(File dir, String filename){
|
|
182
|
|
if (filename.endsWith(".jpg")
|
|
183
|
|
|| filename.endsWith(".png")
|
|
184
|
|
|| filename.endsWith(".jpeg"))
|
|
185
|
|
return true;
|
|
186
|
|
return false;
|
|
187
|
|
}
|
|
188
|
|
}).length;
|
|
189
|
|
totalCount += picSize;
|
|
190
|
|
imageFloder.setCount(picSize);
|
|
191
|
|
mImageFloders.add(imageFloder);
|
|
192
|
|
|
|
193
|
|
if (picSize > mPicsSize){
|
|
194
|
|
mPicsSize = picSize;
|
|
195
|
|
mImgDir = parentFile;
|
|
196
|
|
}
|
|
197
|
|
}
|
|
198
|
|
mCursor.close();
|
|
199
|
|
|
|
200
|
|
// 扫描完成,辅助的HashSet也就可以释放内存了
|
|
201
|
|
mDirPaths = null;
|
|
202
|
|
|
|
203
|
|
// 通知Handler扫描图片完成
|
|
204
|
|
mHandler.sendEmptyMessage(0x110);
|
|
205
|
|
|
|
206
|
|
}
|
|
207
|
|
}).start();
|
|
208
|
|
|
|
209
|
|
}
|
|
210
|
|
private Handler mHandler = new Handler(){
|
|
211
|
|
public void handleMessage(android.os.Message msg){
|
|
212
|
|
mProgressDialog.dismiss();
|
|
213
|
|
setDataView();// 为View绑定数据
|
|
214
|
|
}
|
|
215
|
|
};
|
|
216
|
|
|
|
217
|
|
|
|
218
|
|
/**
|
|
219
|
|
* 为View绑定数据
|
|
220
|
|
*/
|
|
221
|
|
public void setDataView(){
|
|
222
|
|
path=Environment.getExternalStorageDirectory() + "/"+"test/photo/";
|
|
223
|
|
dir=new File(path);
|
|
224
|
|
if(!dir.exists())dir.mkdirs();
|
|
225
|
|
if (mImgDir == null){
|
|
226
|
|
Toast.makeText(getApplicationContext(), "一张图片没扫描到",Toast.LENGTH_SHORT).show();
|
|
227
|
|
return;
|
|
228
|
|
}
|
|
229
|
|
|
|
230
|
|
if(mImgDir.exists()){
|
|
231
|
|
mImgs = Arrays.asList(mImgDir.list());
|
|
232
|
|
}
|
|
233
|
|
|
|
234
|
|
//可以在此设置最大选择照片的数量
|
|
235
|
|
girdItemAdapter=new GirdItemAdapter(this, mImgs, mImgDir.getAbsolutePath(),10);
|
|
236
|
|
photoGrid.setAdapter(girdItemAdapter);
|
|
237
|
|
girdItemAdapter.setOnPhotoSelectedListener(new OnPhotoSelectedListener() {
|
|
238
|
|
@Override
|
|
239
|
|
public void takePhoto() {
|
|
240
|
|
imagename=getTimeName(System.currentTimeMillis())+".jpg";
|
|
241
|
|
String state = Environment.getExternalStorageState();
|
|
242
|
|
if (state.equals(Environment.MEDIA_MOUNTED)) {
|
|
243
|
|
Intent intent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
|
|
244
|
|
File f=new File(dir, imagename);//localTempImgDir和localTempImageFileName是自己定义的名字
|
|
245
|
|
Uri u=Uri.fromFile(f);
|
|
246
|
|
intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
|
|
247
|
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, u);
|
|
248
|
|
startActivityForResult(intent, TAKE_CAMERA_PICTURE);
|
|
249
|
|
} else {
|
|
250
|
|
Toast.makeText(SelectPhotoActivity.this, "请插入SD卡",Toast.LENGTH_SHORT).show();
|
|
251
|
|
}
|
|
252
|
|
}
|
|
253
|
|
@Override
|
|
254
|
|
public void photoClick(List<String> number) {
|
|
255
|
|
photoBtn.setText("下一步("+number.size() + "张)");
|
|
256
|
|
}
|
|
257
|
|
});
|
|
258
|
|
}
|
|
259
|
|
/**
|
|
260
|
|
* 初始化展示文件夹的popupWindw
|
|
261
|
|
*/
|
|
262
|
|
private void initListDirPopupWindw(){
|
|
263
|
|
if(popupWindow==null){
|
|
264
|
|
dirview=LayoutInflater.from(SelectPhotoActivity.this).inflate(R.layout.image_select_dirlist, null);
|
|
265
|
|
dirListView=(ListView)dirview.findViewById(R.id.id_list_dirs);
|
|
266
|
|
popupWindow =new PopupWindow(dirview, LayoutParams.MATCH_PARENT, mScreenHeight*3/5);
|
|
267
|
|
floderAdapter=new ImageFloderAdapter(SelectPhotoActivity.this, mImageFloders);
|
|
268
|
|
dirListView.setAdapter(floderAdapter);
|
|
269
|
|
}
|
|
270
|
|
popupWindow.setFocusable(true);
|
|
271
|
|
popupWindow.setOutsideTouchable(true);
|
|
272
|
|
// 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
|
|
273
|
|
popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
274
|
|
// 显示的位置为:屏幕的宽度的一半-PopupWindow的高度的一半
|
|
275
|
|
titleIcon.setBackgroundResource(R.drawable.navigationbar_arrow_up);
|
|
276
|
|
popupWindow.showAsDropDown(headLayout,0,0);
|
|
277
|
|
popupWindow.setOnDismissListener(new OnDismissListener() {
|
|
278
|
|
@Override
|
|
279
|
|
public void onDismiss() {
|
|
280
|
|
titleIcon.setBackgroundResource(R.drawable.navigationbar_arrow_down);
|
|
281
|
|
}
|
|
282
|
|
});
|
|
283
|
|
dirListView.setOnItemClickListener(new OnItemClickListener() {
|
|
284
|
|
@Override
|
|
285
|
|
public void onItemClick(AdapterView<?> parent, View view,
|
|
286
|
|
int position, long id) {
|
|
287
|
|
titleName.setText(mImageFloders.get(position).getName());
|
|
288
|
|
mImgDir = new File(mImageFloders.get(position).getDir());
|
|
289
|
|
mImgs = Arrays.asList(mImgDir.list(new FilenameFilter(){
|
|
290
|
|
@Override
|
|
291
|
|
public boolean accept(File dir, String filename)
|
|
292
|
|
{
|
|
293
|
|
if (filename.endsWith(".jpg") || filename.endsWith(".png")
|
|
294
|
|
|| filename.endsWith(".jpeg"))
|
|
295
|
|
return true;
|
|
296
|
|
return false;
|
|
297
|
|
}
|
|
298
|
|
}));
|
|
299
|
|
for (int i = 0; i < mImageFloders.size(); i++) {
|
|
300
|
|
mImageFloders.get(i).setSelected(false);
|
|
301
|
|
}
|
|
302
|
|
mImageFloders.get(position).setSelected(true);
|
|
303
|
|
floderAdapter.changeData(mImageFloders);
|
|
304
|
|
girdItemAdapter.changeData(mImgs, mImageFloders.get(position).getDir());
|
|
305
|
|
if(popupWindow!=null){
|
|
306
|
|
popupWindow.dismiss();
|
|
307
|
|
}
|
|
308
|
|
}
|
|
309
|
|
});
|
|
310
|
|
|
|
311
|
|
}
|
|
312
|
|
|
|
313
|
|
/**
|
|
314
|
|
* 监听事件
|
|
315
|
|
*/
|
|
316
|
|
private void initEvent(){
|
|
317
|
|
quxiaoBtn.setOnClickListener(new OnClickListener() {
|
|
318
|
|
@Override
|
|
319
|
|
public void onClick(View v) {
|
|
320
|
|
// TODO Auto-generated method stub
|
|
321
|
|
finish();
|
|
322
|
|
}
|
|
323
|
|
});
|
|
324
|
|
/**
|
|
325
|
|
* 为底部的布局设置点击事件,弹出popupWindow
|
|
326
|
|
*/
|
|
327
|
|
titleName.setOnClickListener(new OnClickListener(){
|
|
328
|
|
@Override
|
|
329
|
|
public void onClick(View v){
|
|
330
|
|
// 初始化展示文件夹的popupWindw
|
|
331
|
|
initListDirPopupWindw();
|
|
332
|
|
}
|
|
333
|
|
});
|
|
334
|
|
photoBtn.setOnClickListener(new OnClickListener() {
|
|
335
|
|
@Override
|
|
336
|
|
public void onClick(View v) {
|
|
337
|
|
Toast.makeText(SelectPhotoActivity.this, GirdItemAdapter.mSelectedImage.toString(), Toast.LENGTH_SHORT).show();
|
|
338
|
|
}
|
|
339
|
|
});
|
|
340
|
|
}
|
|
341
|
|
public static String getTimeName(long time){
|
|
342
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
343
|
|
Date date = new Date(time);
|
|
344
|
|
return formatter.format(date);
|
|
345
|
|
}
|
|
346
|
|
|
|
347
|
|
@Override
|
|
348
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
349
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
350
|
|
switch (requestCode) {
|
|
351
|
|
case TAKE_CAMERA_PICTURE:
|
|
352
|
|
Toast.makeText(this, path+imagename, Toast.LENGTH_SHORT).show();
|
|
353
|
|
break;
|
|
354
|
|
}
|
|
355
|
|
}
|
|
356
|
|
}
|
|
|
@ -1,98 +0,0 @@
|
|
1
|
|
package com.example.imageselected.photo.adapter;
|
|
2
|
|
|
|
3
|
|
import java.util.ArrayList;
|
|
4
|
|
import java.util.LinkedList;
|
|
5
|
|
import java.util.List;
|
|
6
|
|
|
|
7
|
|
import android.content.Context;
|
|
8
|
|
import android.util.Log;
|
|
9
|
|
import android.view.LayoutInflater;
|
|
10
|
|
import android.view.View;
|
|
11
|
|
import android.view.ViewGroup;
|
|
12
|
|
import android.widget.BaseAdapter;
|
|
13
|
|
|
|
14
|
|
import com.example.imageselected.R;
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
public abstract class CommonAdapter<T> extends BaseAdapter
|
|
18
|
|
{
|
|
19
|
|
final int VIEW_TYPE = 2;
|
|
20
|
|
final int TYPE_1 = 0;
|
|
21
|
|
final int TYPE_2 = 1;
|
|
22
|
|
protected LayoutInflater mInflater;
|
|
23
|
|
protected Context mContext;
|
|
24
|
|
protected List<T> mDatas;
|
|
25
|
|
private String mDirPath;
|
|
26
|
|
public CommonAdapter(Context context, List<T> mDatas)
|
|
27
|
|
{
|
|
28
|
|
this.mContext = context;
|
|
29
|
|
this.mInflater = LayoutInflater.from(mContext);
|
|
30
|
|
this.mDatas = mDatas;
|
|
31
|
|
this.mDirPath=mDirPath;
|
|
32
|
|
}
|
|
33
|
|
@Override
|
|
34
|
|
public int getCount()
|
|
35
|
|
{
|
|
36
|
|
return mDatas.size()+1;
|
|
37
|
|
}
|
|
38
|
|
|
|
39
|
|
@Override
|
|
40
|
|
public T getItem(int position)
|
|
41
|
|
{
|
|
42
|
|
return mDatas.get(position);
|
|
43
|
|
}
|
|
44
|
|
|
|
45
|
|
@Override
|
|
46
|
|
public long getItemId(int position)
|
|
47
|
|
{
|
|
48
|
|
return position;
|
|
49
|
|
}
|
|
50
|
|
|
|
51
|
|
@Override
|
|
52
|
|
public View getView(int position, View convertView, ViewGroup parent)
|
|
53
|
|
{
|
|
54
|
|
int type = getItemViewType(position);
|
|
55
|
|
final ViewHolder viewHolder = getViewHolder(position, convertView,
|
|
56
|
|
parent,type);
|
|
57
|
|
switch (type){
|
|
58
|
|
case TYPE_1:
|
|
59
|
|
convert(viewHolder, getItem(0),type);
|
|
60
|
|
break;
|
|
61
|
|
case TYPE_2:
|
|
62
|
|
convert(viewHolder, getItem(position-1),type);
|
|
63
|
|
break;
|
|
64
|
|
}
|
|
65
|
|
return viewHolder.getConvertView();
|
|
66
|
|
|
|
67
|
|
}
|
|
68
|
|
public int getItemViewType(int position) {
|
|
69
|
|
if(position==0){
|
|
70
|
|
return TYPE_1;
|
|
71
|
|
}else{
|
|
72
|
|
return TYPE_2;
|
|
73
|
|
}
|
|
74
|
|
}
|
|
75
|
|
|
|
76
|
|
@Override
|
|
77
|
|
public int getViewTypeCount() {
|
|
78
|
|
return VIEW_TYPE;
|
|
79
|
|
}
|
|
80
|
|
|
|
81
|
|
public abstract void convert(ViewHolder helper, T item,int type);
|
|
82
|
|
|
|
83
|
|
private ViewHolder getViewHolder(int position, View convertView,
|
|
84
|
|
ViewGroup parent,int type)
|
|
85
|
|
{ int mItemLayoutId= R.layout.grid_item;
|
|
86
|
|
switch (type){
|
|
87
|
|
case TYPE_1:
|
|
88
|
|
mItemLayoutId= R.layout.grid_item2;
|
|
89
|
|
break;
|
|
90
|
|
case TYPE_2:
|
|
91
|
|
mItemLayoutId=R.layout.grid_item;
|
|
92
|
|
break;
|
|
93
|
|
}
|
|
94
|
|
return ViewHolder.get(mContext, convertView, parent,mItemLayoutId ,
|
|
95
|
|
position);
|
|
96
|
|
}
|
|
97
|
|
|
|
98
|
|
}
|
|
|
@ -1,116 +0,0 @@
|
|
1
|
|
package com.example.imageselected.photo.adapter;
|
|
2
|
|
|
|
3
|
|
import java.util.ArrayList;
|
|
4
|
|
import java.util.LinkedList;
|
|
5
|
|
import java.util.List;
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
import android.annotation.SuppressLint;
|
|
9
|
|
import android.content.Context;
|
|
10
|
|
import android.graphics.Color;
|
|
11
|
|
import android.util.Log;
|
|
12
|
|
import android.view.LayoutInflater;
|
|
13
|
|
import android.view.View;
|
|
14
|
|
import android.view.ViewGroup;
|
|
15
|
|
import android.view.View.OnClickListener;
|
|
16
|
|
import android.widget.BaseAdapter;
|
|
17
|
|
import android.widget.ImageButton;
|
|
18
|
|
import android.widget.ImageView;
|
|
19
|
|
import android.widget.LinearLayout;
|
|
20
|
|
import android.widget.Toast;
|
|
21
|
|
|
|
22
|
|
import com.example.imageselected.R;
|
|
23
|
|
|
|
24
|
|
|
|
25
|
|
public class GirdItemAdapter extends CommonAdapter<String>{
|
|
26
|
|
private String mDirPath;
|
|
27
|
|
private Context context;
|
|
28
|
|
public static List<String> mSelectedImage = new LinkedList<String>();
|
|
29
|
|
private int maxSize=5;
|
|
30
|
|
public GirdItemAdapter(Context context, List<String> mDatas,String mDirPath,int maxSize) {
|
|
31
|
|
super(context,mDatas);
|
|
32
|
|
this.maxSize=maxSize;
|
|
33
|
|
this.mDirPath=mDirPath;
|
|
34
|
|
this.context=context;
|
|
35
|
|
}
|
|
36
|
|
public void changeData(List<String> mDatas,String mDirPath){
|
|
37
|
|
this.mDatas = mDatas;
|
|
38
|
|
this.mDirPath=mDirPath;
|
|
39
|
|
notifyDataSetChanged();
|
|
40
|
|
}
|
|
41
|
|
|
|
42
|
|
@Override
|
|
43
|
|
public void convert(ViewHolder helper, String item,int type) {
|
|
44
|
|
switch (type) {
|
|
45
|
|
case TYPE_1:
|
|
46
|
|
final LinearLayout mImageView = helper.getView(R.id.id_item_image2);
|
|
47
|
|
mImageView.setOnClickListener(new OnClickListener() {
|
|
48
|
|
@Override
|
|
49
|
|
public void onClick(View v) {
|
|
50
|
|
onPhotoSelectedListener.takePhoto();
|
|
51
|
|
}
|
|
52
|
|
});
|
|
53
|
|
break;
|
|
54
|
|
case TYPE_2:
|
|
55
|
|
final ImageView myImageView = helper.getView(R.id.id_item_image);
|
|
56
|
|
final ImageButton myImageSelected = helper.getView(R.id.id_item_select);
|
|
57
|
|
myImageSelected.setImageResource(R.drawable.picture_unselected);
|
|
58
|
|
myImageView.setImageResource(R.drawable.pictures_no);
|
|
59
|
|
myImageView.setBackgroundResource(R.drawable.pictures_no);
|
|
60
|
|
helper.setImageByUrl(R.id.id_item_image,mDirPath + "/"+item);
|
|
61
|
|
myImageView.setColorFilter(null);
|
|
62
|
|
myImageView.setOnClickListener(new MyOnClickListener(helper,item));
|
|
63
|
|
if (mSelectedImage.contains(mDirPath + "/" + item)){
|
|
64
|
|
myImageSelected.setImageResource(R.drawable.pictures_selected);
|
|
65
|
|
myImageView.setColorFilter(Color.parseColor("#77000000"));
|
|
66
|
|
} else{
|
|
67
|
|
myImageSelected.setImageResource(R.drawable.picture_unselected);
|
|
68
|
|
myImageView.setColorFilter(Color.parseColor("#00000000"));
|
|
69
|
|
}
|
|
70
|
|
break;
|
|
71
|
|
|
|
72
|
|
default:
|
|
73
|
|
break;
|
|
74
|
|
}
|
|
75
|
|
}
|
|
76
|
|
|
|
77
|
|
class MyOnClickListener implements OnClickListener{
|
|
78
|
|
String item;
|
|
79
|
|
ViewHolder helper;
|
|
80
|
|
ImageView myitemImageView ;
|
|
81
|
|
ImageButton myitemImageSelected;
|
|
82
|
|
MyOnClickListener(ViewHolder helper,String item){
|
|
83
|
|
this.item=item;
|
|
84
|
|
this.helper=helper;
|
|
85
|
|
myitemImageSelected=helper.getView(R.id.id_item_select);
|
|
86
|
|
myitemImageView= helper.getView(R.id.id_item_image);
|
|
87
|
|
}
|
|
88
|
|
@Override
|
|
89
|
|
public void onClick(View v) {
|
|
90
|
|
if (mSelectedImage.contains(mDirPath + "/" + item)){
|
|
91
|
|
mSelectedImage.remove(mDirPath + "/" + item);
|
|
92
|
|
myitemImageSelected.setImageResource( R.drawable.picture_unselected);
|
|
93
|
|
myitemImageView.setColorFilter(null);
|
|
94
|
|
} else{
|
|
95
|
|
if(mSelectedImage.size()>=maxSize){
|
|
96
|
|
Toast.makeText(context, "最多上传"+maxSize+"张", Toast.LENGTH_SHORT).show();
|
|
97
|
|
return ;
|
|
98
|
|
}
|
|
99
|
|
mSelectedImage.add(mDirPath + "/" + item);
|
|
100
|
|
myitemImageSelected.setImageResource( R.drawable.pictures_selected);
|
|
101
|
|
myitemImageView.setColorFilter(Color.parseColor("#77000000"));
|
|
102
|
|
}
|
|
103
|
|
onPhotoSelectedListener.photoClick(mSelectedImage);
|
|
104
|
|
}
|
|
105
|
|
|
|
106
|
|
}
|
|
107
|
|
public OnPhotoSelectedListener onPhotoSelectedListener;
|
|
108
|
|
public void setOnPhotoSelectedListener(OnPhotoSelectedListener onPhotoSelectedListener){
|
|
109
|
|
this.onPhotoSelectedListener=onPhotoSelectedListener;
|
|
110
|
|
}
|
|
111
|
|
public interface OnPhotoSelectedListener{
|
|
112
|
|
public void photoClick(List<String> number);
|
|
113
|
|
public void takePhoto();
|
|
114
|
|
}
|
|
115
|
|
|
|
116
|
|
}
|
|
|
@ -1,89 +0,0 @@
|
|
1
|
|
package com.example.imageselected.photo.adapter;
|
|
2
|
|
|
|
3
|
|
import java.util.List;
|
|
4
|
|
|
|
5
|
|
import com.example.imageselected.R;
|
|
6
|
|
import com.example.imageselected.photo.ImageFloder;
|
|
7
|
|
import com.example.imageselected.photo.ImageLoader;
|
|
8
|
|
import com.example.imageselected.photo.ImageLoader.Type;
|
|
9
|
|
|
|
10
|
|
import android.content.Context;
|
|
11
|
|
import android.view.LayoutInflater;
|
|
12
|
|
import android.view.View;
|
|
13
|
|
import android.view.ViewGroup;
|
|
14
|
|
import android.widget.BaseAdapter;
|
|
15
|
|
import android.widget.ImageView;
|
|
16
|
|
import android.widget.RelativeLayout;
|
|
17
|
|
import android.widget.TextView;
|
|
18
|
|
/**
|
|
19
|
|
* Ïà²áÁбíÀà
|
|
20
|
|
* @author Administrator
|
|
21
|
|
*
|
|
22
|
|
*/
|
|
23
|
|
public class ImageFloderAdapter extends BaseAdapter{
|
|
24
|
|
private Context context;
|
|
25
|
|
private List<ImageFloder> list;
|
|
26
|
|
|
|
27
|
|
public ImageFloderAdapter(Context context, List<ImageFloder> list) {
|
|
28
|
|
super();
|
|
29
|
|
this.context = context;
|
|
30
|
|
this.list = list;
|
|
31
|
|
}
|
|
32
|
|
|
|
33
|
|
public void changeData(List<ImageFloder> list){
|
|
34
|
|
this.list=list;
|
|
35
|
|
notifyDataSetChanged();
|
|
36
|
|
}
|
|
37
|
|
@Override
|
|
38
|
|
public int getCount() {
|
|
39
|
|
// TODO Auto-generated method stub
|
|
40
|
|
return list.size();
|
|
41
|
|
}
|
|
42
|
|
|
|
43
|
|
@Override
|
|
44
|
|
public ImageFloder getItem(int position) {
|
|
45
|
|
// TODO Auto-generated method stub
|
|
46
|
|
return list.get(position);
|
|
47
|
|
}
|
|
48
|
|
|
|
49
|
|
@Override
|
|
50
|
|
public long getItemId(int position) {
|
|
51
|
|
// TODO Auto-generated method stub
|
|
52
|
|
return position;
|
|
53
|
|
}
|
|
54
|
|
|
|
55
|
|
@Override
|
|
56
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
57
|
|
ViewHolder holder=null;
|
|
58
|
|
if(convertView==null){
|
|
59
|
|
convertView=LayoutInflater.from(context).inflate(R.layout.list_dir_item, null);
|
|
60
|
|
holder=new ViewHolder();
|
|
61
|
|
holder.dirItemIcon=(ImageView)convertView.findViewById(R.id.id_dir_choose);
|
|
62
|
|
holder.dirItemImage=(ImageView)convertView.findViewById(R.id.id_dir_item_image);
|
|
63
|
|
holder.dirItemName=(TextView)convertView.findViewById(R.id.id_dir_item_name);
|
|
64
|
|
holder.dirItemNum=(TextView)convertView.findViewById(R.id.id_dir_item_count);
|
|
65
|
|
convertView.setTag(holder);
|
|
66
|
|
}else{
|
|
67
|
|
holder=(ViewHolder) convertView.getTag();
|
|
68
|
|
}
|
|
69
|
|
ImageLoader.getInstance(3,Type.LIFO).loadImage(list.get(position).getFirstImagePath(), holder.dirItemImage);
|
|
70
|
|
holder.dirItemName.setText(list.get(position).getName());
|
|
71
|
|
holder.dirItemNum.setText(list.get(position).getCount()+"ÕÅ");
|
|
72
|
|
if(list.get(position).isSelected())
|
|
73
|
|
holder.dirItemIcon.setVisibility(View.VISIBLE);
|
|
74
|
|
else
|
|
75
|
|
holder.dirItemIcon.setVisibility(View.INVISIBLE);
|
|
76
|
|
return convertView;
|
|
77
|
|
}
|
|
78
|
|
|
|
79
|
|
class ViewHolder{
|
|
80
|
|
ImageView dirItemImage;
|
|
81
|
|
TextView dirItemName;
|
|
82
|
|
TextView dirItemNum;
|
|
83
|
|
ImageView dirItemIcon;
|
|
84
|
|
RelativeLayout listdirLayout;
|
|
85
|
|
}
|
|
86
|
|
|
|
87
|
|
|
|
88
|
|
|
|
89
|
|
}
|
|
|
@ -1,126 +0,0 @@
|
|
1
|
|
package com.example.imageselected.photo.adapter;
|
|
2
|
|
|
|
3
|
|
import android.content.Context;
|
|
4
|
|
import android.graphics.Bitmap;
|
|
5
|
|
import android.util.SparseArray;
|
|
6
|
|
import android.view.LayoutInflater;
|
|
7
|
|
import android.view.View;
|
|
8
|
|
import android.view.ViewGroup;
|
|
9
|
|
import android.widget.ImageView;
|
|
10
|
|
import android.widget.TextView;
|
|
11
|
|
|
|
12
|
|
import com.example.imageselected.photo.ImageLoader;
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
public class ViewHolder
|
|
16
|
|
{
|
|
17
|
|
private final SparseArray<View> mViews;
|
|
18
|
|
private int mPosition;
|
|
19
|
|
private View mConvertView;
|
|
20
|
|
|
|
21
|
|
private ViewHolder(Context context, ViewGroup parent, int layoutId,
|
|
22
|
|
int position)
|
|
23
|
|
{
|
|
24
|
|
this.mPosition = position;
|
|
25
|
|
this.mViews = new SparseArray<View>();
|
|
26
|
|
mConvertView = LayoutInflater.from(context).inflate(layoutId, parent,
|
|
27
|
|
false);
|
|
28
|
|
// setTag
|
|
29
|
|
mConvertView.setTag(this);
|
|
30
|
|
}
|
|
31
|
|
|
|
32
|
|
/**
|
|
33
|
|
* 拿到一个ViewHolder对象
|
|
34
|
|
*
|
|
35
|
|
* @param context
|
|
36
|
|
* @param convertView
|
|
37
|
|
* @param parent
|
|
38
|
|
* @param layoutId
|
|
39
|
|
* @param position
|
|
40
|
|
* @return
|
|
41
|
|
*/
|
|
42
|
|
public static ViewHolder get(Context context, View convertView,
|
|
43
|
|
ViewGroup parent, int layoutId, int position)
|
|
44
|
|
{
|
|
45
|
|
ViewHolder holder = null;
|
|
46
|
|
if (convertView == null)
|
|
47
|
|
{
|
|
48
|
|
holder = new ViewHolder(context, parent, layoutId, position);
|
|
49
|
|
} else
|
|
50
|
|
{
|
|
51
|
|
holder = (ViewHolder) convertView.getTag();
|
|
52
|
|
holder.mPosition = position;
|
|
53
|
|
}
|
|
54
|
|
return holder;
|
|
55
|
|
}
|
|
56
|
|
|
|
57
|
|
public View getConvertView()
|
|
58
|
|
{
|
|
59
|
|
return mConvertView;
|
|
60
|
|
}
|
|
61
|
|
|
|
62
|
|
/**
|
|
63
|
|
* 通过控件的Id获取对于的控件,如果没有则加入views
|
|
64
|
|
*
|
|
65
|
|
* @param viewId
|
|
66
|
|
* @return
|
|
67
|
|
*/
|
|
68
|
|
public <T extends View> T getView(int viewId)
|
|
69
|
|
{
|
|
70
|
|
View view = mViews.get(viewId);
|
|
71
|
|
if (view == null)
|
|
72
|
|
{
|
|
73
|
|
view = mConvertView.findViewById(viewId);
|
|
74
|
|
mViews.put(viewId, view);
|
|
75
|
|
}
|
|
76
|
|
return (T) view;
|
|
77
|
|
}
|
|
78
|
|
|
|
79
|
|
|
|
80
|
|
|
|
81
|
|
/**
|
|
82
|
|
* 为ImageView设置图片
|
|
83
|
|
*
|
|
84
|
|
* @param viewId
|
|
85
|
|
* @param drawableId
|
|
86
|
|
* @return
|
|
87
|
|
*/
|
|
88
|
|
public ViewHolder setImageResource(int viewId, int drawableId)
|
|
89
|
|
{
|
|
90
|
|
ImageView view = getView(viewId);
|
|
91
|
|
view.setImageResource(drawableId);
|
|
92
|
|
|
|
93
|
|
return this;
|
|
94
|
|
}
|
|
95
|
|
|
|
96
|
|
/**
|
|
97
|
|
* 为ImageView设置图片
|
|
98
|
|
*
|
|
99
|
|
* @param viewId
|
|
100
|
|
* @return
|
|
101
|
|
*/
|
|
102
|
|
public ViewHolder setImageBitmap(int viewId, Bitmap bm)
|
|
103
|
|
{
|
|
104
|
|
ImageView view = getView(viewId);
|
|
105
|
|
view.setImageBitmap(bm);
|
|
106
|
|
return this;
|
|
107
|
|
}
|
|
108
|
|
|
|
109
|
|
/**
|
|
110
|
|
* 为ImageView设置图片
|
|
111
|
|
*
|
|
112
|
|
* @param viewId
|
|
113
|
|
* @return
|
|
114
|
|
*/
|
|
115
|
|
public ViewHolder setImageByUrl(int viewId, String url)
|
|
116
|
|
{
|
|
117
|
|
ImageLoader.getInstance(3, ImageLoader.Type.LIFO).loadImage(url, (ImageView) getView(viewId));
|
|
118
|
|
return this;
|
|
119
|
|
}
|
|
120
|
|
|
|
121
|
|
public int getPosition()
|
|
122
|
|
{
|
|
123
|
|
return mPosition;
|
|
124
|
|
}
|
|
125
|
|
|
|
126
|
|
}
|
|
|
@ -1,8 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
|
|
|
4
|
|
<item android:state_pressed="true" android:drawable="@drawable/compose_photo_photograph_highlighted"></item>
|
|
5
|
|
<item android:state_pressed="false" android:drawable="@drawable/compose_photo_photograph"></item>
|
|
6
|
|
<item android:drawable="@drawable/compose_photo_photograph"></item>
|
|
7
|
|
|
|
8
|
|
</selector>
|
|
|
@ -1,30 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
|
|
|
4
|
|
<item android:state_pressed="true" android:state_enabled="true"><shape>
|
|
5
|
|
<corners android:radius="6dip" />
|
|
6
|
|
|
|
7
|
|
<solid android:color="#E56311" />
|
|
8
|
|
</shape></item>
|
|
9
|
|
<item android:state_pressed="false" android:state_enabled="true"><shape>
|
|
10
|
|
<corners android:radius="6dip" />
|
|
11
|
|
|
|
12
|
|
<solid android:color="#F78A00" />
|
|
13
|
|
</shape></item>
|
|
14
|
|
<item><shape>
|
|
15
|
|
<corners android:radius="6dip" />
|
|
16
|
|
|
|
17
|
|
<solid android:color="#F78A00" />
|
|
18
|
|
</shape></item>
|
|
19
|
|
<item android:state_enabled="false"><shape>
|
|
20
|
|
<corners android:radius="6dip" />
|
|
21
|
|
|
|
22
|
|
<solid android:color="#FFFFFF" />
|
|
23
|
|
</shape></item>
|
|
24
|
|
<item android:state_enabled="true"><shape>
|
|
25
|
|
<corners android:radius="6dip" />
|
|
26
|
|
|
|
27
|
|
<solid android:color="#F78A00" />
|
|
28
|
|
</shape></item>
|
|
29
|
|
|
|
30
|
|
</selector>
|
|
|
@ -1,16 +0,0 @@
|
|
1
|
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
|
xmlns:tools="http://schemas.android.com/tools"
|
|
3
|
|
android:layout_width="match_parent"
|
|
4
|
|
android:layout_height="match_parent"
|
|
5
|
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
|
6
|
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
7
|
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
8
|
|
android:paddingTop="@dimen/activity_vertical_margin"
|
|
9
|
|
tools:context="com.example.imageselected.MainActivity" >
|
|
10
|
|
|
|
11
|
|
<TextView
|
|
12
|
|
android:layout_width="wrap_content"
|
|
13
|
|
android:layout_height="wrap_content"
|
|
14
|
|
android:text="@string/hello_world" />
|
|
15
|
|
|
|
16
|
|
</RelativeLayout>
|
|
|
@ -1,25 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
|
android:layout_width="fill_parent"
|
|
4
|
|
android:layout_height="fill_parent" >
|
|
5
|
|
|
|
6
|
|
<ImageView
|
|
7
|
|
android:id="@+id/id_item_image"
|
|
8
|
|
android:layout_width="fill_parent"
|
|
9
|
|
android:layout_height="120dp"
|
|
10
|
|
android:background="@drawable/pictures_no"
|
|
11
|
|
android:scaleType="centerCrop" />
|
|
12
|
|
|
|
13
|
|
<ImageButton
|
|
14
|
|
android:id="@+id/id_item_select"
|
|
15
|
|
android:clickable="false"
|
|
16
|
|
android:layout_width="wrap_content"
|
|
17
|
|
android:layout_height="wrap_content"
|
|
18
|
|
android:layout_alignParentRight="true"
|
|
19
|
|
android:layout_alignParentTop="true"
|
|
20
|
|
android:layout_marginRight="3dp"
|
|
21
|
|
android:layout_marginTop="3dp"
|
|
22
|
|
android:background="@null"
|
|
23
|
|
android:src="@drawable/pictures_selected" />
|
|
24
|
|
|
|
25
|
|
</RelativeLayout>
|
|
|
@ -1,22 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
|
android:layout_width="fill_parent"
|
|
4
|
|
android:layout_height="fill_parent" >
|
|
5
|
|
|
|
6
|
|
<LinearLayout
|
|
7
|
|
android:orientation="horizontal"
|
|
8
|
|
android:gravity="center"
|
|
9
|
|
android:id="@+id/id_item_image2"
|
|
10
|
|
android:layout_width="match_parent"
|
|
11
|
|
android:layout_height="120dp" >
|
|
12
|
|
|
|
13
|
|
<ImageView
|
|
14
|
|
android:layout_width="wrap_content"
|
|
15
|
|
android:layout_gravity="center"
|
|
16
|
|
android:layout_height="wrap_content"
|
|
17
|
|
android:background="@drawable/photo_btn_selector"
|
|
18
|
|
android:scaleType="centerCrop" />
|
|
19
|
|
|
|
20
|
|
</LinearLayout>
|
|
21
|
|
|
|
22
|
|
</RelativeLayout>
|
|
|
@ -1,17 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
|
android:layout_width="match_parent"
|
|
4
|
|
android:layout_height="wrap_content"
|
|
5
|
|
android:visibility="visible"
|
|
6
|
|
android:background="#a0ffffff" >
|
|
7
|
|
|
|
8
|
|
<ListView
|
|
9
|
|
android:id="@+id/id_list_dirs"
|
|
10
|
|
android:layout_width="fill_parent"
|
|
11
|
|
android:layout_height="match_parent"
|
|
12
|
|
android:divider="#EEE3D9"
|
|
13
|
|
android:background="#a0ffffff"
|
|
14
|
|
android:dividerHeight="1px" >
|
|
15
|
|
</ListView>
|
|
16
|
|
|
|
17
|
|
</LinearLayout>
|
|
|
@ -1,56 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
|
android:layout_width="fill_parent"
|
|
4
|
|
android:layout_height="wrap_content"
|
|
5
|
|
android:id="@+id/list_dir_layout"
|
|
6
|
|
android:padding="5dp" >
|
|
7
|
|
|
|
8
|
|
<ImageView
|
|
9
|
|
android:id="@+id/id_dir_item_image"
|
|
10
|
|
android:layout_width="100dp"
|
|
11
|
|
android:layout_height="100dp"
|
|
12
|
|
android:layout_alignParentLeft="true"
|
|
13
|
|
android:layout_centerVertical="true"
|
|
14
|
|
android:background="@drawable/pic_dir"
|
|
15
|
|
android:paddingBottom="17dp"
|
|
16
|
|
android:paddingLeft="12dp"
|
|
17
|
|
android:paddingRight="12dp"
|
|
18
|
|
android:paddingTop="9dp"
|
|
19
|
|
android:scaleType="fitXY"
|
|
20
|
|
android:src="@drawable/ic_launcher" />
|
|
21
|
|
|
|
22
|
|
<LinearLayout
|
|
23
|
|
android:layout_width="wrap_content"
|
|
24
|
|
android:layout_height="wrap_content"
|
|
25
|
|
android:layout_centerVertical="true"
|
|
26
|
|
android:layout_marginLeft="10dp"
|
|
27
|
|
android:layout_toRightOf="@id/id_dir_item_image"
|
|
28
|
|
android:orientation="vertical" >
|
|
29
|
|
|
|
30
|
|
<TextView
|
|
31
|
|
android:id="@+id/id_dir_item_name"
|
|
32
|
|
android:layout_width="wrap_content"
|
|
33
|
|
android:layout_height="wrap_content"
|
|
34
|
|
android:text="所有图片"
|
|
35
|
|
android:textSize="10sp" />
|
|
36
|
|
|
|
37
|
|
<TextView
|
|
38
|
|
android:id="@+id/id_dir_item_count"
|
|
39
|
|
android:layout_width="wrap_content"
|
|
40
|
|
android:layout_height="wrap_content"
|
|
41
|
|
android:layout_gravity="center"
|
|
42
|
|
android:text="4723张"
|
|
43
|
|
android:textColor="#444"
|
|
44
|
|
android:textSize="8sp" />
|
|
45
|
|
</LinearLayout>
|
|
46
|
|
|
|
47
|
|
<ImageView
|
|
48
|
|
android:id="@+id/id_dir_choose"
|
|
49
|
|
android:layout_width="wrap_content"
|
|
50
|
|
android:layout_height="wrap_content"
|
|
51
|
|
android:layout_alignParentRight="true"
|
|
52
|
|
android:layout_centerVertical="true"
|
|
53
|
|
android:layout_marginRight="20dp"
|
|
54
|
|
android:src="@drawable/dir_choose" />
|
|
55
|
|
|
|
56
|
|
</RelativeLayout>
|
|
|
@ -1,52 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
|
android:layout_width="match_parent"
|
|
4
|
|
android:layout_height="match_parent"
|
|
5
|
|
android:orientation="vertical" >
|
|
6
|
|
|
|
7
|
|
<include layout="@layout/select_photo_header" />
|
|
8
|
|
|
|
9
|
|
<LinearLayout
|
|
10
|
|
android:layout_width="match_parent"
|
|
11
|
|
android:layout_height="wrap_content"
|
|
12
|
|
android:layout_weight="1"
|
|
13
|
|
android:orientation="vertical" >
|
|
14
|
|
|
|
15
|
|
<GridView
|
|
16
|
|
android:id="@+id/gird_photo_list"
|
|
17
|
|
android:layout_width="match_parent"
|
|
18
|
|
android:layout_height="wrap_content"
|
|
19
|
|
android:horizontalSpacing="5dp"
|
|
20
|
|
android:verticalSpacing="5dp"
|
|
21
|
|
android:numColumns="3" >
|
|
22
|
|
</GridView>
|
|
23
|
|
</LinearLayout>
|
|
24
|
|
|
|
25
|
|
<TextView
|
|
26
|
|
android:id="@+id/textView4"
|
|
27
|
|
android:layout_width="match_parent"
|
|
28
|
|
android:layout_height="0.5dip"
|
|
29
|
|
android:background="@color/gray"
|
|
30
|
|
android:text="TextView" />
|
|
31
|
|
|
|
32
|
|
<LinearLayout
|
|
33
|
|
android:layout_width="match_parent"
|
|
34
|
|
android:layout_gravity="center_vertical"
|
|
35
|
|
android:gravity="right"
|
|
36
|
|
android:layout_height="50dp" >
|
|
37
|
|
|
|
38
|
|
<Button
|
|
39
|
|
android:id="@+id/selected_photo_btn"
|
|
40
|
|
android:layout_width="wrap_content"
|
|
41
|
|
android:layout_height="35dp"
|
|
42
|
|
android:paddingLeft="10dp"
|
|
43
|
|
android:paddingRight="10dp"
|
|
44
|
|
android:textSize="12sp"
|
|
45
|
|
android:layout_gravity="center_vertical"
|
|
46
|
|
android:layout_marginRight="10dp"
|
|
47
|
|
android:textColor="@color/white"
|
|
48
|
|
android:background="@drawable/photo_select_btn_selector"
|
|
49
|
|
android:text="下一步" />
|
|
50
|
|
</LinearLayout>
|
|
51
|
|
|
|
52
|
|
</LinearLayout>
|
|
|
@ -1,76 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
|
android:id="@+id/selected_photo_header_layout"
|
|
4
|
|
android:layout_width="match_parent"
|
|
5
|
|
android:layout_height="wrap_content"
|
|
6
|
|
android:orientation="vertical"
|
|
7
|
|
android:visibility="visible" >
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
<LinearLayout
|
|
11
|
|
android:id="@+id/header_layout"
|
|
12
|
|
android:layout_width="match_parent"
|
|
13
|
|
android:layout_height="wrap_content"
|
|
14
|
|
android:background="@color/white"
|
|
15
|
|
android:orientation="vertical" >
|
|
16
|
|
|
|
17
|
|
<LinearLayout
|
|
18
|
|
android:layout_width="match_parent"
|
|
19
|
|
android:layout_height="45dp" >
|
|
20
|
|
|
|
21
|
|
<TextView
|
|
22
|
|
android:id="@+id/quxiao_btn"
|
|
23
|
|
android:layout_width="wrap_content"
|
|
24
|
|
android:layout_height="wrap_content"
|
|
25
|
|
android:layout_gravity="center"
|
|
26
|
|
android:layout_marginLeft="5dp"
|
|
27
|
|
android:gravity="center"
|
|
28
|
|
android:text=""
|
|
29
|
|
android:textColor="@color/orange_text" />
|
|
30
|
|
|
|
31
|
|
<LinearLayout
|
|
32
|
|
android:layout_width="0dp"
|
|
33
|
|
android:layout_height="match_parent"
|
|
34
|
|
android:layout_gravity="center"
|
|
35
|
|
android:layout_weight="1"
|
|
36
|
|
android:gravity="center" >
|
|
37
|
|
|
|
38
|
|
<TextView
|
|
39
|
|
android:id="@+id/selected_photo_name_text"
|
|
40
|
|
android:layout_width="wrap_content"
|
|
41
|
|
android:layout_height="match_parent"
|
|
42
|
|
android:layout_marginRight="5dp"
|
|
43
|
|
android:ellipsize="end"
|
|
44
|
|
android:gravity="center"
|
|
45
|
|
android:singleLine="true"
|
|
46
|
|
android:text="相机胶卷"
|
|
47
|
|
android:textSize="16sp" />
|
|
48
|
|
|
|
49
|
|
<ImageView
|
|
50
|
|
android:id="@+id/selected_photo_icon"
|
|
51
|
|
android:layout_width="wrap_content"
|
|
52
|
|
android:layout_height="wrap_content"
|
|
53
|
|
android:layout_gravity="center"
|
|
54
|
|
android:gravity="center" />
|
|
55
|
|
</LinearLayout>
|
|
56
|
|
|
|
57
|
|
<TextView
|
|
58
|
|
android:id="@+id/textView3"
|
|
59
|
|
android:layout_width="wrap_content"
|
|
60
|
|
android:layout_height="wrap_content"
|
|
61
|
|
android:layout_gravity="center"
|
|
62
|
|
android:layout_marginRight="5dp"
|
|
63
|
|
android:gravity="center"
|
|
64
|
|
android:text="确定"
|
|
65
|
|
android:visibility="invisible" />
|
|
66
|
|
</LinearLayout>
|
|
67
|
|
|
|
68
|
|
<TextView
|
|
69
|
|
android:id="@+id/textView4"
|
|
70
|
|
android:layout_width="match_parent"
|
|
71
|
|
android:layout_height="0.5dip"
|
|
72
|
|
android:background="@color/gray"
|
|
73
|
|
android:text="TextView" />
|
|
74
|
|
</LinearLayout>
|
|
75
|
|
|
|
76
|
|
</RelativeLayout>
|
|
|
@ -1,12 +0,0 @@
|
|
1
|
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
3
|
|
xmlns:tools="http://schemas.android.com/tools"
|
|
4
|
|
tools:context="com.example.imageselected.MainActivity" >
|
|
5
|
|
|
|
6
|
|
<item
|
|
7
|
|
android:id="@+id/action_settings"
|
|
8
|
|
android:orderInCategory="100"
|
|
9
|
|
android:title="@string/action_settings"
|
|
10
|
|
app:showAsAction="never"/>
|
|
11
|
|
|
|
12
|
|
</menu>
|
|
|
@ -1,11 +0,0 @@
|
|
1
|
|
<resources>
|
|
2
|
|
|
|
3
|
|
<!--
|
|
4
|
|
Base application theme for API 11+. This theme completely replaces
|
|
5
|
|
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
|
6
|
|
-->
|
|
7
|
|
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
|
|
8
|
|
<!-- API 11 theme customizations can go here. -->
|
|
9
|
|
</style>
|
|
10
|
|
|
|
11
|
|
</resources>
|
|
|
@ -1,12 +0,0 @@
|
|
1
|
|
<resources>
|
|
2
|
|
|
|
3
|
|
<!--
|
|
4
|
|
Base application theme for API 14+. This theme completely replaces
|
|
5
|
|
AppBaseTheme from BOTH res/values/styles.xml and
|
|
6
|
|
res/values-v11/styles.xml on API 14+ devices.
|
|
7
|
|
-->
|
|
8
|
|
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
|
9
|
|
<!-- API 14 theme customizations can go here. -->
|
|
10
|
|
</style>
|
|
11
|
|
|
|
12
|
|
</resources>
|
|
|
@ -1,10 +0,0 @@
|
|
1
|
|
<resources>
|
|
2
|
|
|
|
3
|
|
<!--
|
|
4
|
|
Example customization of dimensions originally defined in res/values/dimens.xml
|
|
5
|
|
(such as screen margins) for screens with more than 820dp of available width. This
|
|
6
|
|
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
|
|
7
|
|
-->
|
|
8
|
|
<dimen name="activity_horizontal_margin">64dp</dimen>
|
|
9
|
|
|
|
10
|
|
</resources>
|
|
|
@ -1,27 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<resources>
|
|
3
|
|
<color name="gray">#AFAFAF</color>
|
|
4
|
|
<color name="orange">#CC6600</color>
|
|
5
|
|
<color name="pink">#FFE6E6</color>
|
|
6
|
|
<color name="yellow">#F99503</color>
|
|
7
|
|
<color name="blue">#00AED6</color>
|
|
8
|
|
<color name="white">#FFFFFF</color>
|
|
9
|
|
<color name="red">#D80000</color>
|
|
10
|
|
<color name="black">#000000</color>
|
|
11
|
|
|
|
12
|
|
|
|
13
|
|
<color name="common_orange_color">#ff601e</color>
|
|
14
|
|
<color name="common_orange_pressed_color">#ea4500</color>
|
|
15
|
|
<color name="common_white_color">#ffffff</color>
|
|
16
|
|
|
|
17
|
|
<color name="common_dark_grey_text_color">#7c7c7c</color>
|
|
18
|
|
<color name="common_light_grey_text_color">#969696</color>
|
|
19
|
|
<color name="btn_gray_normal">#c0c0c0</color>
|
|
20
|
|
<color name="orange_text">#F78A00</color>
|
|
21
|
|
|
|
22
|
|
|
|
23
|
|
<!-- actiondialog-->
|
|
24
|
|
<color name="ui_action_dialog_gray">#e0e6e6e6</color>
|
|
25
|
|
<color name="ui_action_dialog_color">#e0ffffff</color>
|
|
26
|
|
<color name="ui_action_dialog_textviewcolor">#0048fc</color>
|
|
27
|
|
</resources>
|
|
|
@ -1,7 +0,0 @@
|
|
1
|
|
<resources>
|
|
2
|
|
|
|
3
|
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
|
4
|
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
|
5
|
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
|
6
|
|
|
|
7
|
|
</resources>
|
|
|
@ -1,8 +0,0 @@
|
|
1
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
|
<resources>
|
|
3
|
|
|
|
4
|
|
<string name="app_name">ImageSelected</string>
|
|
5
|
|
<string name="hello_world">Hello world!</string>
|
|
6
|
|
<string name="action_settings">Settings</string>
|
|
7
|
|
|
|
8
|
|
</resources>
|
|
|
@ -1,8 +0,0 @@
|
|
1
|
|
<resources>
|
|
2
|
|
|
|
3
|
|
<!-- Base application theme. -->
|
|
4
|
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
|
5
|
|
<!-- Customize your theme here. -->
|
|
6
|
|
</style>
|
|
7
|
|
|
|
8
|
|
</resources>
|