Commit 0ff2ad496e55acf609a42ce8faafdcf06052728f

Authored by xiongwei
1 parent dcad913bbd
Exists in master

学校,年级,意见反馈整理和调试

Showing 25 changed files with 1673 additions and 21 deletions   Show diff stats
PersonalCenter/app/build.gradle
... ... @@ -40,5 +40,6 @@ dependencies {
40 40 compile files('libs/android-async-http-1.4.8.jar')
41 41 compile 'com.google.code.gson:gson:2.7'
42 42 compile 'com.zaaach:toprightmenu:1.0'
  43 + compile 'com.facebook.fresco:fresco:1.1.0'
43 44  
44 45 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.java
1 1 package com.hjx.personalcenter.activity;
2 2  
3   -import android.app.Activity;
  3 +import android.content.Intent;
  4 +import android.content.pm.PackageManager;
  5 +import android.graphics.Color;
  6 +import android.net.Uri;
  7 +import android.os.Build;
4 8 import android.os.Bundle;
  9 +import android.provider.MediaStore;
  10 +import android.support.annotation.NonNull;
  11 +import android.support.v4.content.FileProvider;
  12 +import android.support.v7.app.AppCompatActivity;
  13 +import android.view.Gravity;
  14 +import android.view.View;
  15 +import android.widget.AdapterView;
  16 +import android.widget.EditText;
  17 +import android.widget.ImageView;
  18 +import android.widget.TextView;
  19 +import android.widget.Toast;
5 20  
  21 +import com.facebook.drawee.backends.pipeline.Fresco;
  22 +import com.facebook.drawee.generic.GenericDraweeHierarchy;
  23 +import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
  24 +import com.facebook.drawee.generic.RoundingParams;
  25 +import com.facebook.drawee.interfaces.DraweeController;
  26 +import com.facebook.drawee.view.SimpleDraweeView;
6 27 import com.hjx.personalcenter.R;
  28 +import com.hjx.personalcenter.util.CropUtils;
  29 +import com.hjx.personalcenter.util.DialogPermission;
  30 +import com.hjx.personalcenter.util.FileUtil;
  31 +import com.hjx.personalcenter.util.PermissionUtil;
  32 +import com.hjx.personalcenter.util.SharedPreferenceMark;
  33 +import com.mylhyl.circledialog.CircleDialog;
  34 +import com.mylhyl.circledialog.callback.ConfigButton;
  35 +import com.mylhyl.circledialog.callback.ConfigDialog;
  36 +import com.mylhyl.circledialog.params.ButtonParams;
  37 +import com.mylhyl.circledialog.params.DialogParams;
  38 +
  39 +import java.io.File;
7 40  
8 41 /**
9 42 * Created by h on 2017/8/11.
10 43 */
11 44  
12   -public class FeedBackActivity extends Activity{
  45 +public class FeedBackActivity extends AppCompatActivity implements View.OnClickListener {
  46 + private ImageView iv_cance,iv_show,iv_take;
  47 + private EditText content, phone;
  48 + private TextView tv_sub;
  49 + private static final int REQUEST_CODE_TAKE_PHOTO = 1;
  50 + private static final int REQUEST_CODE_ALBUM = 2;
  51 + private static final int REQUEST_CODE_CROUP_PHOTO = 3;
  52 + SimpleDraweeView mSimpleDraweeView;
  53 + private File file;
  54 + private Uri uri;
13 55 @Override
14 56 protected void onCreate(Bundle savedInstanceState) {
15 57 super.onCreate(savedInstanceState);
  58 + Fresco.initialize(this);
16 59 setContentView(R.layout.activity_feedback);
  60 + initView();
  61 + initData();
  62 + initLister();
  63 + }
  64 +
  65 + private void initView() {
  66 + iv_cance = (ImageView) findViewById(R.id.cancel);
  67 + mSimpleDraweeView = (SimpleDraweeView) findViewById(R.id.show_iv);
  68 + iv_take = (ImageView) findViewById(R.id.iv_take);
  69 + content = (EditText) findViewById(R.id.feedback_content);
  70 + phone = (EditText) findViewById(R.id.feedback_phone);
  71 + tv_sub = (TextView) findViewById(R.id.feedback_sub);
  72 +
  73 + }
  74 +
  75 + private void initData() {
  76 + file = new File(FileUtil.getCachePath(this), "user-avatar.jpg");
  77 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
  78 + uri = Uri.fromFile(file);
  79 + } else {
  80 + //通过FileProvider创建一个content类型的Uri(android 7.0需要这样的方法跨应用访问)
  81 + uri = FileProvider.getUriForFile(MyApplication.getContext(), "com.hjx.personalcenter", file);
  82 + }
  83 +
  84 + }
  85 +
  86 + private void initLister() {
  87 + iv_cance.setOnClickListener(this);
  88 + iv_take.setOnClickListener(this);
  89 + tv_sub.setOnClickListener(this);
  90 +
  91 + }
  92 +
  93 + @Override
  94 + public void onClick(View v) {
  95 + switch (v.getId()){
  96 + case R.id.cancel:
  97 + finish();
  98 + break;
  99 + case R.id.iv_take:
  100 + choiceAvatar();
  101 + break;
  102 + case R.id.feedback_sub:
  103 + break;
  104 + }
  105 + }
  106 +
  107 + //拍摄头像
  108 + private void choiceAvatar() {
  109 + final String[] items = {"拍照", "从相册选择"};
  110 + new CircleDialog.Builder(this)
  111 + .configDialog(new ConfigDialog() {
  112 + @Override
  113 + public void onConfig(DialogParams params) {
  114 + //增加弹出动画
  115 + params.gravity = Gravity.CENTER;
  116 + }
  117 + })
  118 + .setTitle("请选择图片来源")
  119 + .setWidth(0.5f)
  120 + .setItems(items, new AdapterView.OnItemClickListener() {
  121 + @Override
  122 + public void onItemClick(AdapterView<?> parent, View view, int
  123 + position, long id) {
  124 + switch (position){
  125 + case 0:
  126 + if (PermissionUtil.hasCameraPermission(FeedBackActivity.this)) {
  127 + uploadAvatarFromPhotoRequest();
  128 + }
  129 + break;
  130 + case 1:
  131 + uploadAvatarFromAlbumRequest();
  132 + break;
  133 + }
  134 +
  135 + }
  136 + })
  137 + .setNegative("取消", null)
  138 + .configNegative(new ConfigButton() {
  139 + @Override
  140 + public void onConfig(ButtonParams params) {
  141 + //取消按钮字体颜色
  142 + params.textColor = Color.RED;
  143 + }
  144 + })
  145 + .show();
  146 +
  147 +
  148 + }
  149 + //照相
  150 + private void uploadAvatarFromPhotoRequest() {
  151 + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  152 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  153 + intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
  154 + intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
  155 + startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO);
  156 + }
  157 +
  158 + //选择图库
  159 + private void uploadAvatarFromAlbumRequest() {
  160 + Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
  161 + photoPickerIntent.setType("image/*");
  162 + startActivityForResult(photoPickerIntent, REQUEST_CODE_ALBUM);
  163 + }
  164 + //回掉
  165 + @Override
  166 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  167 + super.onActivityResult(requestCode, resultCode, data);
  168 + if (resultCode != -1) {
  169 + return;
  170 + }
  171 + if (requestCode == REQUEST_CODE_ALBUM && data != null) {
  172 + Uri newUri;
  173 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
  174 + newUri = Uri.parse("file:///" + CropUtils.getPath(this, data.getData()));
  175 + } else {
  176 + newUri = data.getData();
  177 + }
  178 + if (newUri != null) {
  179 + startPhotoZoom(newUri);
  180 + } else {
  181 + Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show();
  182 + }
  183 + } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) {
  184 + startPhotoZoom(uri);
  185 + } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) {
  186 + uploadAvatarFromPhoto();
  187 + }
  188 + }
  189 +
  190 + private void uploadAvatarFromPhoto() {
  191 + compressAndUploadAvatar(file.getPath());
  192 +
  193 + }
  194 + private void compressAndUploadAvatar(String fileSrc) {
  195 +
  196 +
  197 + //上传到服务器
  198 +
  199 + final File cover = FileUtil.getSmallBitmap(this, fileSrc);
  200 + String mimeType = "image/*";
  201 + //requestBody = RequestBody.create(MediaType.parse(mimeType), file);
  202 + //String fileName = cover.getName();
  203 + //HttpManager.getInstance().header(this, fileSrc);
  204 + //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody);
  205 + //Fresco设置圆形头像
  206 + GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
  207 + GenericDraweeHierarchy hierarchy = builder
  208 + .setDesiredAspectRatio(1f)
  209 + .setFailureImage(R.mipmap.blank)
  210 + //圆形头像
  211 + .setRoundingParams(RoundingParams.asCircle())
  212 + .build();
  213 +
  214 + //加载本地图片
  215 + Uri uri = Uri.fromFile(cover);
  216 + DraweeController controller = Fresco.newDraweeControllerBuilder()
  217 + .setOldController(mSimpleDraweeView.getController())
  218 + .setUri(uri)
  219 + .build();
  220 + mSimpleDraweeView.setHierarchy(hierarchy);
  221 + mSimpleDraweeView.setController(controller);
  222 +
  223 + }
  224 +
  225 + public void startPhotoZoom(Uri uri) {
  226 + Intent intent = new Intent("com.android.camera.action.CROP");
  227 + intent.setDataAndType(uri, "image/*");
  228 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  229 + intent.putExtra("crop", "true");// crop=true 有这句才能出来最后的裁剪页面.
  230 + intent.putExtra("aspectX", 1);// 这两项为裁剪框的比例.
  231 + intent.putExtra("aspectY", 1);// x:y=1:1
  232 +// intent.putExtra("outputX", 400);//图片输出大小
  233 +// intent.putExtra("outputY", 400);
  234 + intent.putExtra("output", Uri.fromFile(file));
  235 + intent.putExtra("outputFormat", "JPEG");// 返回格式
  236 + startActivityForResult(intent, REQUEST_CODE_CROUP_PHOTO);
  237 + }
  238 +
  239 + @Override
  240 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  241 + switch (requestCode) {
  242 +
  243 + case PermissionUtil.REQUEST_SHOWCAMERA:
  244 + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  245 + // Permission Granted
  246 + uploadAvatarFromPhotoRequest();
  247 +
  248 + } else {
  249 + if (!SharedPreferenceMark.getHasShowCamera()) {
  250 + SharedPreferenceMark.setHasShowCamera(true);
  251 + new DialogPermission(this, "关闭摄像头权限影响扫描功能");
  252 +
  253 + } else {
  254 + Toast.makeText(this, "未获取摄像头权限", Toast.LENGTH_SHORT)
  255 + .show();
  256 + }
  257 + }
  258 + break;
  259 + default:
  260 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  261 + }
17 262 }
18 263 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MyApplication.java
... ... @@ -0,0 +1,39 @@
  1 +package com.hjx.personalcenter.activity;
  2 +
  3 +import android.app.Application;
  4 +import android.content.Context;
  5 +
  6 +import com.facebook.drawee.backends.pipeline.Fresco;
  7 +import com.hjx.personalcenter.util.ImageCache;
  8 +import com.tencent.bugly.crashreport.CrashReport;
  9 +
  10 +/**
  11 + * Created by ${yf} on 2017/2/16.
  12 + */
  13 +
  14 +public class MyApplication extends Application {
  15 +
  16 + private ImageCache mImageCache;
  17 + private static Context context;
  18 + private static MyApplication instance;
  19 + @Override
  20 + public void onCreate() {
  21 + super.onCreate();
  22 + context = getApplicationContext();
  23 + //初始化Fresco
  24 + Fresco.initialize(this);
  25 + mImageCache = new ImageCache();
  26 + instance = this;
  27 + CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false);
  28 + }
  29 + public ImageCache getImageCache() {
  30 + return mImageCache;
  31 + }
  32 +
  33 + public static Context getContext() {
  34 + return context;
  35 + }
  36 + public static MyApplication getInstance() {
  37 + return instance;
  38 + }
  39 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
... ... @@ -3,6 +3,8 @@ package com.hjx.personalcenter.activity;
3 3 import android.content.Intent;
4 4 import android.os.Bundle;
5 5 import android.support.v7.app.AppCompatActivity;
  6 +import android.text.TextUtils;
  7 +import android.view.KeyEvent;
6 8 import android.view.View;
7 9 import android.widget.AdapterView;
8 10 import android.widget.Button;
... ... @@ -12,8 +14,10 @@ import android.widget.TextView;
12 14 import com.hjx.personalcenter.R;
13 15 import com.hjx.personalcenter.customdialog.GradeListDialog;
14 16 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
  17 +import com.hjx.personalcenter.customdialog.SchoolListDialog;
15 18 import com.hjx.personalcenter.http.HttpManager;
16 19 import com.hjx.personalcenter.interfaces.DialogCallBack;
  20 +import com.hjx.personalcenter.util.AlertUtils;
17 21  
18 22 /**填写注册信息 熊巍
19 23 * Created by h on 2017/8/9.
... ... @@ -23,7 +27,6 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
23 27 private EditText et_username;
24 28 private TextView et_region,et_grade,et_school;
25 29 private Button btn_ok;
26   - String[] items;
27 30  
28 31 @Override
29 32 protected void onCreate(Bundle savedInstanceState) {
... ... @@ -45,7 +48,6 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
45 48 }
46 49  
47 50 private void initData() {
48   - items = new String[] { "魏", "蜀", "吴" };
49 51  
50 52 }
51 53  
... ... @@ -60,6 +62,10 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
60 62  
61 63 @Override
62 64 public void onClick(View v) {
  65 + String register1 = et_username.getText().toString().trim();
  66 + String register2 = et_region.getText().toString().trim();
  67 + String register3 = et_grade.getText().toString().trim();
  68 + String register4 = et_school.getText().toString().trim();
63 69 switch (v.getId()){
64 70 case R.id.et_region:
65 71 choiseregion();
... ... @@ -68,17 +74,32 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
68 74 choisegrade();
69 75 break;
70 76 case R.id.et_school:
  77 + if (TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){
  78 + AlertUtils.showToast(RegisterInfoActivity.this, "请选择年级和地址");
  79 + return;
  80 + }else {
  81 + choiseschool();
  82 + }
  83 +
71 84 break;
72 85 case R.id.btn_ok:
73   - Intent intent = new Intent();
74   - intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class);
75   - startActivity(intent);
76   - overridePendingTransition(R.anim.rightin, R.anim.rightout);
  86 + if (TextUtils.isEmpty(register1)||TextUtils.isEmpty(register4) ||
  87 + TextUtils.isEmpty(register2) || TextUtils.isEmpty(register3)){
  88 + AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整");
  89 + return;
  90 + }else{
  91 + Intent intent = new Intent();
  92 + intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class);
  93 + startActivity(intent);
  94 + overridePendingTransition(R.anim.rightin, R.anim.rightout);
  95 + }
  96 +
77 97 break;
78 98 }
79 99  
80 100 }
81   -//选择地区
  101 +
  102 + //选择地区
82 103 private void choiseregion() {
83 104 HttpManager.getInstance().provices(RegisterInfoActivity.this);
84 105 ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog");
... ... @@ -88,9 +109,17 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
88 109 }
89 110 //选择年级
90 111 private void choisegrade() {
  112 + HttpManager.getInstance().getgrade(RegisterInfoActivity.this);
91 113 GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog");
92 114  
93 115 }
  116 + //选择学校
  117 + private void choiseschool() {
  118 + HttpManager.getInstance().getschool(RegisterInfoActivity.this,130102,14);
  119 + SchoolListDialog.getInstance().show(getSupportFragmentManager(), "SchoolListDialog");
  120 +
  121 + }
  122 +
94 123  
95 124 @Override
96 125 public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id) {
... ... @@ -101,4 +130,12 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
101 130  
102 131  
103 132 }
  133 + @Override
  134 + public boolean onKeyUp(int keyCode, KeyEvent event) {
  135 + if (keyCode == KeyEvent.KEYCODE_BACK) {
  136 + finish();
  137 +
  138 + }
  139 + return super.onKeyUp(keyCode, event);
  140 + }
104 141 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GrandeAdapter.java
... ... @@ -0,0 +1,65 @@
  1 +package com.hjx.personalcenter.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.View;
  5 +import android.view.ViewGroup;
  6 +import android.widget.BaseAdapter;
  7 +import android.widget.TextView;
  8 +
  9 +import com.hjx.personalcenter.R;
  10 +import com.hjx.personalcenter.model.GradeInfo;
  11 +
  12 +import java.util.ArrayList;
  13 +
  14 +/**
  15 + * Created by h on 2017/8/21.
  16 + */
  17 +
  18 +public class GrandeAdapter extends BaseAdapter{
  19 + ArrayList<GradeInfo.DataBean> objects;
  20 + private Context context;
  21 +
  22 + public GrandeAdapter(ArrayList<GradeInfo.DataBean> objects, Context context) {
  23 + this.objects = objects;
  24 + this.context = context;
  25 + }
  26 +
  27 + @Override
  28 + public int getCount() {
  29 + return objects.size();
  30 + }
  31 +
  32 + @Override
  33 + public Object getItem(int position) {
  34 + return position;
  35 + }
  36 +
  37 + @Override
  38 + public long getItemId(int position) {
  39 + return position;
  40 + }
  41 +
  42 + @Override
  43 + public View getView(final int position, View convertView, ViewGroup parent) {
  44 +
  45 + ProvincesAdapter.ViewHolder holder = null;
  46 +
  47 + if (convertView == null) {
  48 + convertView = View.inflate(context, R.layout.custom_adilog_list_item, null);
  49 + holder = new ProvincesAdapter.ViewHolder();
  50 + holder.nameText = (TextView) convertView.findViewById(R.id.list_items);
  51 + convertView.setTag(holder);
  52 + } else {
  53 + holder = (ProvincesAdapter.ViewHolder) convertView.getTag();
  54 + }
  55 +
  56 + holder.nameText.setText(objects.get(position).getName());
  57 +
  58 + return convertView;
  59 + }
  60 +
  61 +
  62 + static class ViewHolder {
  63 + TextView nameText;
  64 + }
  65 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/SchoolAdapter.java
... ... @@ -0,0 +1,151 @@
  1 +package com.hjx.personalcenter.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.View;
  5 +import android.view.ViewGroup;
  6 +import android.widget.BaseAdapter;
  7 +import android.widget.Filter;
  8 +import android.widget.Filterable;
  9 +import android.widget.TextView;
  10 +
  11 +import com.hjx.personalcenter.R;
  12 +import com.hjx.personalcenter.model.SchoolInfo;
  13 +
  14 +import java.util.ArrayList;
  15 +import java.util.List;
  16 +
  17 +/**
  18 + * Created by h on 2017/8/21.
  19 + */
  20 +
  21 +public class SchoolAdapter extends BaseAdapter implements Filterable {
  22 + private List<SchoolInfo.DataBean> mDatas;
  23 + ArrayList<SchoolInfo.DataBean> objects;
  24 + private Context context;
  25 + private final Object mLock = new Object();
  26 + private ArrayFilter mFilter;
  27 +
  28 + public SchoolAdapter(ArrayList<SchoolInfo.DataBean> objects, Context context) {
  29 + this.objects = objects;
  30 + this.context = context;
  31 + }
  32 +
  33 + @Override
  34 + public int getCount() {
  35 + return objects.size();
  36 + }
  37 +
  38 + @Override
  39 + public Object getItem(int position) {
  40 + return position;
  41 + }
  42 +
  43 + @Override
  44 + public long getItemId(int position) {
  45 + return position;
  46 + }
  47 +
  48 + @Override
  49 + public View getView(final int position, View convertView, ViewGroup parent) {
  50 +
  51 + ProvincesAdapter.ViewHolder holder = null;
  52 +
  53 + if (convertView == null) {
  54 + convertView = View.inflate(context, R.layout.custom_adilog_school_list_items, null);
  55 + holder = new ProvincesAdapter.ViewHolder();
  56 + holder.nameText = (TextView) convertView.findViewById(R.id.list_school_items);
  57 + convertView.setTag(holder);
  58 + } else {
  59 + holder = (ProvincesAdapter.ViewHolder) convertView.getTag();
  60 + }
  61 +
  62 + holder.nameText.setText(objects.get(position).getSchoolName());
  63 +
  64 + return convertView;
  65 + }
  66 +
  67 + @Override
  68 + public Filter getFilter() {
  69 + if (mFilter == null) {
  70 + mFilter = new ArrayFilter();
  71 + }
  72 + return mFilter;
  73 + }
  74 +
  75 +
  76 + static class ViewHolder {
  77 + TextView nameText;
  78 + }
  79 + private class ArrayFilter extends Filter {
  80 + //执行刷选
  81 + @Override
  82 + protected FilterResults performFiltering(CharSequence prefix) {
  83 + FilterResults results = new FilterResults();//过滤的结果
  84 + //原始数据备份为空时,上锁,同步复制原始数据
  85 + if (objects == null) {
  86 + synchronized (mLock) {
  87 + objects = new ArrayList<>(mDatas);
  88 + }
  89 + }
  90 + //当首字母为空时
  91 + if (prefix == null || prefix.length() == 0) {
  92 + ArrayList<SchoolInfo.DataBean> list;
  93 + synchronized (mLock) {//同步复制一个原始备份数据
  94 + list = new ArrayList<>(objects);
  95 + }
  96 + results.values = list;
  97 + results.count = list.size();//此时返回的results就是原始的数据,不进行过滤
  98 + } else {
  99 + String prefixString = prefix.toString().toLowerCase();//转化为小写
  100 +
  101 + ArrayList<SchoolInfo.DataBean> values;
  102 + synchronized (mLock) {//同步复制一个原始备份数据
  103 + values = new ArrayList<>(objects);
  104 + }
  105 + final int count = values.size();
  106 + final ArrayList<SchoolInfo.DataBean> newValues = new ArrayList<>();
  107 +
  108 + for (int i = 0; i < count; i++) {
  109 + final SchoolInfo.DataBean value = values.get(i);//从List<User>中拿到User对象
  110 +// final String valueText = value.toString().toLowerCase();
  111 + final String valueText = value.getSchoolName().toString().toLowerCase();//User对象的name属性作为过滤的参数
  112 + // First match against the whole, non-splitted value
  113 + if (valueText.startsWith(prefixString) || valueText.indexOf(prefixString.toString()) != -1) {//第一个字符是否匹配
  114 + newValues.add(value);//将这个item加入到数组对象中
  115 + } else {//处理首字符是空格
  116 + final String[] words = valueText.split(" ");
  117 + final int wordCount = words.length;
  118 +
  119 + // Start at index 0, in case valueText starts with space(s)
  120 + for (int k = 0; k < wordCount; k++) {
  121 + if (words[k].startsWith(prefixString)) {//一旦找到匹配的就break,跳出for循环
  122 + newValues.add(value);
  123 + break;
  124 + }
  125 + }
  126 + }
  127 + }
  128 + results.values = newValues;//此时的results就是过滤后的List<User>数组
  129 + results.count = newValues.size();
  130 + }
  131 + return results;
  132 + }
  133 +
  134 + //刷选结果
  135 + @Override
  136 + protected void publishResults(CharSequence prefix, FilterResults results) {
  137 + //noinspection unchecked
  138 + mDatas = (List<SchoolInfo.DataBean>) results.values;//此时,Adapter数据源就是过滤后的Results
  139 + if (results.count > 0) {
  140 + notifyDataSetChanged();//这个相当于从mDatas中删除了一些数据,只是数据的变化,故使用notifyDataSetChanged()
  141 + } else {
  142 + /**
  143 + * 数据容器变化 ----> notifyDataSetInValidated
  144 +
  145 + 容器中的数据变化 ----> notifyDataSetChanged
  146 + */
  147 + notifyDataSetInvalidated();//当results.count<=0时,此时数据源就是重新new出来的,说明原始的数据源已经失效了
  148 + }
  149 + }
  150 + }
  151 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
... ... @@ -8,11 +8,14 @@ import android.view.LayoutInflater;
8 8 import android.view.View;
9 9 import android.view.ViewGroup;
10 10 import android.widget.AdapterView;
11   -import android.widget.ArrayAdapter;
12 11 import android.widget.ListView;
13 12 import android.widget.Toast;
14 13  
15 14 import com.hjx.personalcenter.R;
  15 +import com.hjx.personalcenter.adapter.GrandeAdapter;
  16 +import com.hjx.personalcenter.db.SaveParam;
  17 +import com.hjx.personalcenter.http.HttpManager;
  18 +import com.hjx.personalcenter.model.GradeInfo;
16 19 import com.mylhyl.circledialog.BaseCircleDialog;
17 20 import com.mylhyl.circledialog.res.values.CircleDimen;
18 21  
... ... @@ -23,9 +26,9 @@ import java.util.ArrayList;
23 26 */
24 27  
25 28 public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener {
26   - ArrayAdapter listadapter;
27   - ListView listView;
28   - ArrayList<String> data = new ArrayList<>();
  29 + private GrandeAdapter listadapter;
  30 + private ListView listView;
  31 + ArrayList<GradeInfo.DataBean> data = new ArrayList<>();
29 32 public static GradeListDialog getInstance() {
30 33 GradeListDialog dialogFragment = new GradeListDialog();
31 34 dialogFragment.setCanceledBack(true);
... ... @@ -45,11 +48,18 @@ public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnI
45 48 public void onActivityCreated(Bundle savedInstanceState) {
46 49 super.onActivityCreated(savedInstanceState);
47 50 listView = (ListView) getView().findViewById(R.id.listadapter);
48   - for (int i=0;i<=50;i++){
49   - data.add("sss"+i);
50   - }
  51 + String gradens = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.GRADENS);
  52 + if (gradens != null) {
51 53  
52   - listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data);
  54 + for (int i = 0; i < gradens.split(",").length; i++) {
  55 + GradeInfo.DataBean dataBean = new GradeInfo.DataBean();
  56 + dataBean.setName(gradens.split(",")[i]);
  57 + data.add(dataBean);
  58 + }
  59 + } else {
  60 + HttpManager.getInstance().getgrade(getActivity());
  61 + }
  62 + listadapter = new GrandeAdapter(data,getActivity());
53 63 listView.setAdapter(listadapter);
54 64 listView.setOnItemClickListener(this);
55 65  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/SchoolListDialog.java
... ... @@ -0,0 +1,119 @@
  1 +package com.hjx.personalcenter.customdialog;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Color;
  5 +import android.os.Bundle;
  6 +import android.text.Editable;
  7 +import android.text.TextWatcher;
  8 +import android.view.Gravity;
  9 +import android.view.LayoutInflater;
  10 +import android.view.View;
  11 +import android.view.ViewGroup;
  12 +import android.widget.AdapterView;
  13 +import android.widget.EditText;
  14 +import android.widget.ListView;
  15 +
  16 +import com.hjx.personalcenter.R;
  17 +import com.hjx.personalcenter.adapter.SchoolAdapter;
  18 +import com.hjx.personalcenter.db.SaveParam;
  19 +import com.hjx.personalcenter.http.HttpManager;
  20 +import com.hjx.personalcenter.interfaces.DialogCallBack;
  21 +import com.hjx.personalcenter.model.SchoolInfo;
  22 +import com.mylhyl.circledialog.BaseCircleDialog;
  23 +import com.mylhyl.circledialog.res.values.CircleDimen;
  24 +
  25 +import java.util.ArrayList;
  26 +
  27 +/**
  28 + * Created by h on 2017/8/21.
  29 + */
  30 +
  31 +public class SchoolListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener, View.OnClickListener {
  32 + private ListView school_list;
  33 + private EditText school_sech;
  34 + private SchoolAdapter listadapter;
  35 + private View mView;
  36 + boolean isFilter;
  37 + private DialogCallBack.CallBackView mCallBack;
  38 + ArrayList<SchoolInfo.DataBean> data = new ArrayList<>();
  39 +
  40 +// public SchoolListDialog(DialogCallBack.CallBackView callBack) {
  41 +// this.mCallBack = callBack;
  42 +// }
  43 +
  44 + public static SchoolListDialog getInstance() {
  45 + SchoolListDialog dialogFragment = new SchoolListDialog();
  46 + dialogFragment.setCanceledBack(true);
  47 + dialogFragment.setCanceledOnTouchOutside(true);
  48 + dialogFragment.setRadius(CircleDimen.RADIUS);
  49 + dialogFragment.setWidth(0.5f);
  50 + dialogFragment.setGravity(Gravity.CENTER);
  51 + dialogFragment.setBackgroundColor(Color.WHITE);
  52 + return dialogFragment;
  53 + }
  54 +
  55 + @Override
  56 + public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
  57 +
  58 + if (mView == null) {
  59 + mView = inflater.inflate(R.layout.custom_adilog_school_list, container, false);
  60 + //mCallBack.provinceOnItemClick(context, inflater, container);
  61 + }
  62 + return mView;
  63 + }
  64 +
  65 + @Override
  66 + public void onActivityCreated(Bundle savedInstanceState) {
  67 + super.onActivityCreated(savedInstanceState);
  68 + school_list = (ListView) getView().findViewById(R.id.listschooladapter);
  69 + school_sech = (EditText) getView().findViewById(R.id.et_school_sech);
  70 + String gradens = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.SCHOOL);
  71 + if (gradens != null) {
  72 +
  73 + for (int i = 0; i < gradens.split(",").length; i++) {
  74 + SchoolInfo.DataBean dataBean = new SchoolInfo.DataBean();
  75 + dataBean.setSchoolName(gradens.split(",")[i]);
  76 + data.add(dataBean);
  77 + }
  78 + } else {
  79 + HttpManager.getInstance().getschool(getActivity(),130102,14);
  80 + }
  81 + listadapter = new SchoolAdapter(data, getActivity());
  82 + school_list.setAdapter(listadapter);
  83 + school_list.setOnItemClickListener(this);
  84 + school_sech.setOnClickListener(this);
  85 + intiEditView();
  86 +
  87 +
  88 + }
  89 + private void intiEditView() {
  90 + school_sech.addTextChangedListener(new TextWatcher() {
  91 + @Override
  92 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  93 +
  94 + }
  95 +
  96 + @Override
  97 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  98 +// mAdapter.getFilter().filter(s);
  99 +
  100 + listadapter.getFilter().filter(s);
  101 + }
  102 +
  103 + @Override
  104 + public void afterTextChanged(Editable s) {
  105 +
  106 + }
  107 + });
  108 + }
  109 +
  110 + @Override
  111 + public void onClick(View v) {
  112 +
  113 + }
  114 +
  115 + @Override
  116 + public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  117 +
  118 + }
  119 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
... ... @@ -14,6 +14,9 @@ public class SaveParam {
14 14 return instance;
15 15 }
16 16 //个人信息
  17 + public static String GRADENS = "gradens";//年级
  18 + public static String SCHOOL = "school";//学校
  19 +
17 20 //电子保卡信息
18 21 public static String CARDPHONE = "cardphone";//保卡手机号
19 22 public static String CUNSTEMNAME = "cunstemname";//客户姓名
... ... @@ -22,9 +25,10 @@ public class SaveParam {
22 25 public static String SHOPADRESS = "shopadress";//购买地址
23 26 public static String SHOPTLEPHONE = "shoptlephone";//售后电话
24 27  
25   - //省市区参数
  28 + //省市区参数
26 29 public static String PROVINCES = "provinces";//省
27   - public static String CITYS = "citys";
  30 + public static String CITYS = "citys";//市
  31 + public static String COUNTRY = "country";//区
28 32  
29 33  
30 34 public void saveLoginParam(Context context,String spname, String spstr) {
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
... ... @@ -22,7 +22,9 @@ import com.hjx.personalcenter.db.SaveParam;
22 22 import com.hjx.personalcenter.gson.GsonTool;
23 23 import com.hjx.personalcenter.model.CityInfo;
24 24 import com.hjx.personalcenter.model.CountyInfo;
  25 +import com.hjx.personalcenter.model.GradeInfo;
25 26 import com.hjx.personalcenter.model.ProvinceInfo;
  27 +import com.hjx.personalcenter.model.SchoolInfo;
26 28 import com.hjx.personalcenter.util.DialogPermission;
27 29 import com.loopj.android.http.AsyncHttpResponseHandler;
28 30 import com.loopj.android.http.JsonHttpResponseHandler;
... ... @@ -632,7 +634,7 @@ public class HttpManager {
632 634 HttpClient.getInstance().get(HttpUrl.cardcheck+ "?userId=" + userId, new AsyncHttpResponseHandler() {
633 635 @Override
634 636 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
635   - Log.e("test", "" + new String(arg2));
  637 + Log.e("test", "---" + new String(arg2));
636 638 Message msg = Message.obtain();
637 639 msg.what = HttpCode.CHECKCARD;
638 640 msg.obj = new String(arg2);
... ... @@ -669,6 +671,98 @@ public class HttpManager {
669 671 });
670 672 }
671 673  
  674 + ///获取年级
  675 + public void getgrade(final Context mContext) {
  676 + HttpClient.getInstance().addHeader("Accept", "application/json");
  677 + HttpClient.getInstance().get(HttpUrl.gradesUrl, new AsyncHttpResponseHandler() {
  678 + @Override
  679 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  680 + Log.e("test", "年级" + new String(arg2));
  681 + GradeInfo gradensInfo = GsonTool.getPerson(new String(arg2), GradeInfo.class);//解析json数据
  682 + StringBuffer sb = new StringBuffer();
  683 + for (int i = 0; i < gradensInfo.getData().size(); i++) {
  684 + sb.append(gradensInfo.getData().get(i).getName() + ",");
  685 +
  686 + }
  687 + Log.e("test", "年级" + sb.toString());
  688 + SaveParam.getInstance().saveLoginParam(mContext, SaveParam.GRADENS, "" + sb.toString());
  689 +
  690 +
  691 + }
  692 +
  693 + @Override
  694 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  695 + new CircleDialog.Builder((FragmentActivity) mContext)
  696 + .setCanceledOnTouchOutside(false)
  697 + .setCancelable(false)
  698 + .setWidth(0.5f)
  699 + .configText(new ConfigText() {
  700 + @Override
  701 + public void onConfig(TextParams params) {
  702 + params.gravity = Gravity.CENTER;
  703 + params.padding = new int[]{50, 50, 50, 50};
  704 + }
  705 + })
  706 + .setText("当前无网络,请检查网络设置")
  707 + .setNegative("继续使用", null)
  708 + .setPositive("设置网络", new View.OnClickListener() {
  709 + @Override
  710 + public void onClick(View v) {
  711 + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面
  712 + mContext.startActivity(intent);
  713 + }
  714 + })
  715 + .show();
  716 + }
  717 + });
  718 + }
  719 + ///获取学校
  720 + public void getschool(final Context mContext,int regionId,int gradeId) {
  721 + HttpClient.getInstance().addHeader("Accept", "application/json");
  722 + HttpClient.getInstance().get(HttpUrl.schoolUrl+ "?regionId=" + regionId+ "&gradeId=" + gradeId, new AsyncHttpResponseHandler() {
  723 + @Override
  724 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  725 + Log.e("test", "学校" + new String(arg2));
  726 + SchoolInfo schoolInfo = GsonTool.getPerson(new String(arg2), SchoolInfo.class);//解析json数据
  727 + StringBuffer sb = new StringBuffer();
  728 + for (int i = 0; i < schoolInfo.getData().size(); i++) {
  729 + sb.append(schoolInfo.getData().get(i).getSchoolName() + ",");
  730 +
  731 + }
  732 + Log.e("test", "学校" + sb.toString());
  733 + SaveParam.getInstance().saveLoginParam(mContext, SaveParam.SCHOOL, "" + sb.toString());
  734 +
  735 +
  736 + }
  737 +
  738 + @Override
  739 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  740 + new CircleDialog.Builder((FragmentActivity) mContext)
  741 + .setCanceledOnTouchOutside(false)
  742 + .setCancelable(false)
  743 + .setWidth(0.5f)
  744 + .configText(new ConfigText() {
  745 + @Override
  746 + public void onConfig(TextParams params) {
  747 + params.gravity = Gravity.CENTER;
  748 + params.padding = new int[]{50, 50, 50, 50};
  749 + }
  750 + })
  751 + .setText("当前无网络,请检查网络设置")
  752 + .setNegative("继续使用", null)
  753 + .setPositive("设置网络", new View.OnClickListener() {
  754 + @Override
  755 + public void onClick(View v) {
  756 + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面
  757 + mContext.startActivity(intent);
  758 + }
  759 + })
  760 + .show();
  761 + }
  762 + });
  763 + }
  764 +
  765 +
672 766  
673 767  
674 768  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
... ... @@ -12,6 +12,8 @@ public class HttpUrl {
12 12 }
13 13  
14 14 public static String loginUrl = GetDomain()+"/user/access_token";//登录
  15 + public static String schoolUrl = GetDomain()+"/school/get";//学校
  16 + public static String gradesUrl = GetDomain()+"/grades";//年级
15 17 public static String provinceUrl = GetDomain()+"/ozing/provinces";//省
16 18 public static String cityUrl = GetDomain()+"/ozing/cities";//市
17 19 public static String countyUrl = GetDomain()+"/ozing/counties";//区县
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/GradeInfo.java
... ... @@ -0,0 +1,78 @@
  1 +package com.hjx.personalcenter.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class GradeInfo {
  6 +
  7 + private List<DataBean> data;
  8 +
  9 + public List<DataBean> getData() {
  10 + return data;
  11 + }
  12 +
  13 + public void setData(List<DataBean> data) {
  14 + this.data = data;
  15 + }
  16 +
  17 + public static class DataBean {
  18 + /**
  19 + * name : 小学
  20 + * id : 1
  21 + * children : [{"name":"一年级","id":2},{"name":"二年级","id":3},{"name":"三年级","id":4},{"name":"四年级","id":5},{"name":"五年级","id":6},{"name":"小学六年级","id":7}]
  22 + */
  23 +
  24 + private String name;
  25 + private int id;
  26 + private List<ChildrenBean> children;
  27 +
  28 + public String getName() {
  29 + return name;
  30 + }
  31 +
  32 + public void setName(String name) {
  33 + this.name = name;
  34 + }
  35 +
  36 + public int getId() {
  37 + return id;
  38 + }
  39 +
  40 + public void setId(int id) {
  41 + this.id = id;
  42 + }
  43 +
  44 + public List<ChildrenBean> getChildren() {
  45 + return children;
  46 + }
  47 +
  48 + public void setChildren(List<ChildrenBean> children) {
  49 + this.children = children;
  50 + }
  51 +
  52 + public static class ChildrenBean {
  53 + /**
  54 + * name : 一年级
  55 + * id : 2
  56 + */
  57 +
  58 + private String name;
  59 + private int id;
  60 +
  61 + public String getName() {
  62 + return name;
  63 + }
  64 +
  65 + public void setName(String name) {
  66 + this.name = name;
  67 + }
  68 +
  69 + public int getId() {
  70 + return id;
  71 + }
  72 +
  73 + public void setId(int id) {
  74 + this.id = id;
  75 + }
  76 + }
  77 + }
  78 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/SchoolInfo.java
... ... @@ -0,0 +1,90 @@
  1 +package com.hjx.personalcenter.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * Created by h on 2017/8/21.
  7 + */
  8 +
  9 +public class SchoolInfo {
  10 +
  11 + /**
  12 + * status : 1
  13 + * pageSize : 0
  14 + * data : [{"schoolName":"自强学校","schoolId":554606},{"schoolName":"石家庄十三中","schoolId":560171},{"schoolName":"石家庄五十中","schoolId":560172},{"schoolName":"石家庄二十二中","schoolId":561412},{"schoolName":"石家庄二十四中","schoolId":561413},{"schoolName":"石家庄四十五中","schoolId":561414},{"schoolName":"石家庄五十二中","schoolId":561415},{"schoolName":"石家庄五十三中","schoolId":561416},{"schoolName":"石家庄五十一中","schoolId":561417},{"schoolName":"国化工十二建公学校","schoolId":562347},{"schoolName":"建一局六公司子弟学校","schoolId":562540},{"schoolName":"石家庄八十二中(化肥厂学校)","schoolId":562966},{"schoolName":"固安一中","schoolId":605836},{"schoolName":"石家庄市二十一中","schoolId":647584}]
  15 + * msg : success
  16 + * pageNum : 0
  17 + */
  18 +
  19 + private int status;
  20 + private int pageSize;
  21 + private String msg;
  22 + private int pageNum;
  23 + private List<DataBean> data;
  24 +
  25 + public int getStatus() {
  26 + return status;
  27 + }
  28 +
  29 + public void setStatus(int status) {
  30 + this.status = status;
  31 + }
  32 +
  33 + public int getPageSize() {
  34 + return pageSize;
  35 + }
  36 +
  37 + public void setPageSize(int pageSize) {
  38 + this.pageSize = pageSize;
  39 + }
  40 +
  41 + public String getMsg() {
  42 + return msg;
  43 + }
  44 +
  45 + public void setMsg(String msg) {
  46 + this.msg = msg;
  47 + }
  48 +
  49 + public int getPageNum() {
  50 + return pageNum;
  51 + }
  52 +
  53 + public void setPageNum(int pageNum) {
  54 + this.pageNum = pageNum;
  55 + }
  56 +
  57 + public List<DataBean> getData() {
  58 + return data;
  59 + }
  60 +
  61 + public void setData(List<DataBean> data) {
  62 + this.data = data;
  63 + }
  64 +
  65 + public static class DataBean {
  66 + /**
  67 + * schoolName : 自强学校
  68 + * schoolId : 554606
  69 + */
  70 +
  71 + private String schoolName;
  72 + private int schoolId;
  73 +
  74 + public String getSchoolName() {
  75 + return schoolName;
  76 + }
  77 +
  78 + public void setSchoolName(String schoolName) {
  79 + this.schoolName = schoolName;
  80 + }
  81 +
  82 + public int getSchoolId() {
  83 + return schoolId;
  84 + }
  85 +
  86 + public void setSchoolId(int schoolId) {
  87 + this.schoolId = schoolId;
  88 + }
  89 + }
  90 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/CropUtils.java
... ... @@ -0,0 +1,148 @@
  1 +package com.hjx.personalcenter.util;
  2 +
  3 +import android.annotation.SuppressLint;
  4 +import android.content.ContentUris;
  5 +import android.content.Context;
  6 +import android.database.Cursor;
  7 +import android.net.Uri;
  8 +import android.os.Build;
  9 +import android.os.Environment;
  10 +import android.provider.DocumentsContract;
  11 +import android.provider.MediaStore;
  12 +import android.util.Log;
  13 +
  14 +import static android.content.ContentValues.TAG;
  15 +
  16 +/**
  17 + * Created by yf on 2016/2/23.
  18 + */
  19 +public class CropUtils {
  20 + @SuppressLint("NewApi")
  21 + public static String getPath(final Context context, final Uri uri) {
  22 +
  23 + final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
  24 +
  25 +// DocumentProvider
  26 + if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
  27 + // ExternalStorageProvider
  28 + if (isExternalStorageDocument(uri)) {
  29 + final String docId = DocumentsContract.getDocumentId(uri);
  30 + final String[] split = docId.split(":");
  31 + final String type = split[0];
  32 +
  33 + if ("primary".equalsIgnoreCase(type)) {
  34 + return Environment.getExternalStorageDirectory() + "/" + split[1];
  35 + }
  36 +
  37 + }
  38 + // DownloadsProvider
  39 + else if (isDownloadsDocument(uri)) {
  40 +
  41 + final String id = DocumentsContract.getDocumentId(uri);
  42 + final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
  43 +
  44 + return getDataColumn(context, contentUri, null, null);
  45 + }
  46 + // MediaProvider
  47 + else if (isMediaDocument(uri)) {
  48 + final String docId = DocumentsContract.getDocumentId(uri);
  49 + final String[] split = docId.split(":");
  50 + final String type = split[0];
  51 +
  52 + Uri contentUri = null;
  53 + if ("image".equals(type)) {
  54 + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
  55 + } else if ("video".equals(type)) {
  56 + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
  57 + } else if ("audio".equals(type)) {
  58 + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
  59 + }
  60 +
  61 + final String selection = "_id=?";
  62 + final String[] selectionArgs = new String[]{split[1]};
  63 +
  64 + return getDataColumn(context, contentUri, selection, selectionArgs);
  65 + }
  66 + }
  67 + // MediaStore (and general)
  68 + else if ("content".equalsIgnoreCase(uri.getScheme())) {
  69 + return getDataColumn(context, uri, null, null);
  70 + }
  71 + // File
  72 + else if ("file".equalsIgnoreCase(uri.getScheme())) {
  73 + return uri.getPath();
  74 + } else {
  75 + String uriStr = uri.toString();
  76 + String path = uriStr.substring(10, uriStr.length());
  77 + if (path.startsWith("com.sec.android.gallery3d")) {
  78 + Log.e(TAG, "It's auto backup pic path:" + uri.toString());
  79 + return null;
  80 + }
  81 + String[] filePathColumn = {MediaStore.Images.Media.DATA};
  82 + Cursor cursor = context.getContentResolver().query(uri, filePathColumn, null, null, null);
  83 + if (cursor != null) {
  84 + cursor.moveToFirst();
  85 + }
  86 + int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
  87 + String picturePath = cursor.getString(columnIndex);
  88 + cursor.close();
  89 + return picturePath;
  90 + }
  91 +
  92 + return null;
  93 + }
  94 +
  95 + /**
  96 + * Get the value of the data column for this Uri. This is useful for
  97 + * MediaStore Uris, and other file-based ContentProviders.
  98 + *
  99 + * @param context The context.
  100 + * @param uri The Uri to query.
  101 + * @param selection (Optional) Filter used in the query.
  102 + * @param selectionArgs (Optional) Selection arguments used in the query.
  103 + * @return The value of the _data column, which is typically a file path.
  104 + */
  105 + private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
  106 +
  107 + Cursor cursor = null;
  108 + final String column = "_data";
  109 + final String[] projection = {column};
  110 +
  111 + try {
  112 + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
  113 + if (cursor != null && cursor.moveToFirst()) {
  114 + final int column_index = cursor.getColumnIndexOrThrow(column);
  115 + return cursor.getString(column_index);
  116 + }
  117 + } finally {
  118 + if (cursor != null)
  119 + cursor.close();
  120 + }
  121 + return null;
  122 + }
  123 +
  124 + /**
  125 + * @param uri The Uri to check.
  126 + * @return Whether the Uri authority is ExternalStorageProvider.
  127 + */
  128 + private static boolean isExternalStorageDocument(Uri uri) {
  129 + return "com.android.externalstorage.documents".equals(uri.getAuthority());
  130 + }
  131 +
  132 + /**
  133 + * @param uri The Uri to check.
  134 + * @return Whether the Uri authority is DownloadsProvider.
  135 + */
  136 + private static boolean isDownloadsDocument(Uri uri) {
  137 + return "com.android.providers.downloads.documents".equals(uri.getAuthority());
  138 + }
  139 +
  140 + /**
  141 + * @param uri The Uri to check.
  142 + * @return Whether the Uri authority is MediaProvider.
  143 + */
  144 + private static boolean isMediaDocument(Uri uri) {
  145 + return "com.android.providers.media.documents".equals(uri.getAuthority());
  146 + }
  147 +
  148 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/FileUtil.java
... ... @@ -0,0 +1,142 @@
  1 +package com.hjx.personalcenter.util;
  2 +
  3 +
  4 +import android.content.Context;
  5 +import android.graphics.Bitmap;
  6 +import android.graphics.BitmapFactory;
  7 +import android.os.Environment;
  8 +import android.util.Log;
  9 +
  10 +import java.io.File;
  11 +import java.io.FileNotFoundException;
  12 +import java.io.FileOutputStream;
  13 +import java.io.OutputStream;
  14 +
  15 +/**
  16 + * Created by yf on 2016/7/22 0022.
  17 + * 文件的缓存与读取
  18 + */
  19 +public class FileUtil {
  20 + private static final String TAG = "FileUtil";
  21 +
  22 + /**
  23 + * 获取缓存路径
  24 + *
  25 + * @param context
  26 + * @return
  27 + */
  28 + public static String getCachePath(Context context) {
  29 + String cachePath = null;
  30 +
  31 + if (Environment.MEDIA_MOUNTED.equals(Environment
  32 + .getExternalStorageState())
  33 + || !Environment.isExternalStorageRemovable()) {
  34 +
  35 + cachePath = context.getExternalCacheDir().getPath();
  36 +
  37 + } else {
  38 + cachePath = context.getCacheDir().getPath();
  39 + }
  40 + return cachePath;
  41 + }
  42 +
  43 + /**
  44 + * 删除指定文件
  45 + *
  46 + * @param file
  47 + * @return
  48 + */
  49 + public static boolean deleteFile(File file) {
  50 + if (file.exists() && file.isFile()) {
  51 + return file.delete();
  52 + }
  53 + return false;
  54 + }
  55 +
  56 + /**
  57 + * 递归删除文件和文件夹
  58 + *
  59 + * @param file 要删除的根目录
  60 + */
  61 + public static void recursionDeleteFile(File file) {
  62 + if (file.isFile()) {
  63 + file.delete();
  64 + return;
  65 + }
  66 + if (file.isDirectory()) {
  67 + File[] childFile = file.listFiles();
  68 + if (childFile == null || childFile.length == 0) {
  69 + file.delete();
  70 + return;
  71 + }
  72 + for (File f : childFile) {
  73 + recursionDeleteFile(f);
  74 + }
  75 + file.delete();
  76 + }
  77 + }
  78 +
  79 +
  80 + /**
  81 + * 压缩图片方法,为了上传到服务器,保证图片大小在100k一下
  82 + *
  83 + * @param context
  84 + * @param fileSrc
  85 + * @return
  86 + */
  87 + public static File getSmallBitmap(Context context, String fileSrc) {
  88 + BitmapFactory.Options options = new BitmapFactory.Options();
  89 + options.inJustDecodeBounds = true;
  90 + BitmapFactory.decodeFile(fileSrc, options);
  91 + options.inSampleSize = calculateInSampleSize(options, 480, 800);
  92 + Log.i(TAG, "options.inSampleSize-->" + options.inSampleSize);
  93 + options.inJustDecodeBounds = false;
  94 + Bitmap img = BitmapFactory.decodeFile(fileSrc, options);
  95 + Log.i(TAG, "file size after compress-->" + img.getByteCount() / 256);
  96 + String filename = context.getFilesDir() + File.separator + "video-" + img.hashCode() + ".jpg";
  97 + saveBitmap2File(img, filename);
  98 + return new File(filename);
  99 + }
  100 +
  101 + /**
  102 + * 设置压缩的图片的大小设置的参数
  103 + *
  104 + * @param options
  105 + * @param reqWidth
  106 + * @param reqHeight
  107 + * @return
  108 + */
  109 + public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
  110 + int height = options.outHeight;
  111 + int width = options.outWidth;
  112 + int inSampleSize = 1;
  113 + if (height > reqHeight || width > reqWidth) {
  114 + int heightRatio = Math.round(height) / reqHeight;
  115 + int widthRatio = Math.round(width) / reqWidth;
  116 + inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
  117 + }
  118 + return inSampleSize;
  119 + }
  120 +
  121 +
  122 + /**
  123 + * 保存bitmap到文件
  124 + *
  125 + * @param bmp
  126 + * @param filename
  127 + * @return
  128 + */
  129 + public static boolean saveBitmap2File(Bitmap bmp, String filename) {
  130 + Bitmap.CompressFormat format = Bitmap.CompressFormat.JPEG;
  131 + int quality = 50;//压缩50% 100表示不压缩
  132 + OutputStream stream = null;
  133 + try {
  134 + stream = new FileOutputStream(filename);
  135 + } catch (FileNotFoundException e) {
  136 + // TODO Auto-generated catch block
  137 + e.printStackTrace();
  138 + }
  139 +
  140 + return bmp.compress(format, quality, stream);
  141 + }
  142 +}
0 143 \ No newline at end of file
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/ImageCache.java
... ... @@ -0,0 +1,17 @@
  1 +
  2 +
  3 +package com.hjx.personalcenter.util;
  4 +
  5 +import android.graphics.Bitmap;
  6 +
  7 +import java.util.WeakHashMap;
  8 +
  9 +public class ImageCache extends WeakHashMap<String, Bitmap> {
  10 +
  11 + private static final long serialVersionUID = 1L;
  12 +
  13 + public boolean isCached(String url){
  14 + return containsKey(url) && get(url) != null;
  15 + }
  16 +
  17 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/PermissionUtil.java
... ... @@ -0,0 +1,116 @@
  1 +package com.hjx.personalcenter.util;
  2 +
  3 +import android.Manifest;
  4 +import android.app.Activity;
  5 +import android.content.pm.PackageManager;
  6 +import android.os.Build;
  7 +import android.support.v4.app.ActivityCompat;
  8 +import android.support.v4.content.ContextCompat;
  9 +import android.support.v4.util.SimpleArrayMap;
  10 +import android.util.Log;
  11 +
  12 +/**
  13 + * Created by yf on 2016/7/22 0022.
  14 + */
  15 +public class PermissionUtil {
  16 + public static final int REQUEST_SHOWCAMERA = 0;
  17 + public static final int REQUEST_READ_EXTERNAL_STORAGE = 1;
  18 + public static final int REQUEST_RECORD_AUDIO = 2;
  19 + public static final int REQUEST_CONTACTS = 3;
  20 + public static final int REQUEST_LOCATION = 4;
  21 +
  22 +
  23 + private static final SimpleArrayMap<String, Integer> MIN_SDK_PERMISSIONS;
  24 + static {
  25 + MIN_SDK_PERMISSIONS = new SimpleArrayMap<>(8);
  26 + MIN_SDK_PERMISSIONS.put("com.android.voicemail.permission.ADD_VOICEMAIL", 14);
  27 + MIN_SDK_PERMISSIONS.put("android.permission.BODY_SENSORS", 20);
  28 + MIN_SDK_PERMISSIONS.put("android.permission.READ_CALL_LOG", 16);
  29 + MIN_SDK_PERMISSIONS.put("android.permission.READ_EXTERNAL_STORAGE", 16);
  30 + MIN_SDK_PERMISSIONS.put("android.permission.USE_SIP", 9);
  31 + MIN_SDK_PERMISSIONS.put("android.permission.WRITE_CALL_LOG", 16);
  32 + MIN_SDK_PERMISSIONS.put("android.permission.SYSTEM_ALERT_WINDOW", 23);
  33 + MIN_SDK_PERMISSIONS.put("android.permission.WRITE_SETTINGS", 23);
  34 + }
  35 + private static boolean permissionExists(String permission) {
  36 + Integer minVersion = MIN_SDK_PERMISSIONS.get(permission);
  37 + return minVersion == null || Build.VERSION.SDK_INT >= minVersion;
  38 + }
  39 +
  40 + public static boolean hasCameraPermission(Activity activity){
  41 + int hasPermission = ContextCompat.checkSelfPermission(activity,
  42 + Manifest.permission.CAMERA);
  43 + if(!permissionExists(Manifest.permission.CAMERA)){
  44 + Log.e("permission","your system does not suppport"+ Manifest.permission.CAMERA+" permission");
  45 + return false;
  46 + }
  47 + if (hasPermission != PackageManager.PERMISSION_GRANTED) {
  48 + ActivityCompat.requestPermissions(activity,
  49 + new String[]{Manifest.permission.CAMERA},
  50 + PermissionUtil.REQUEST_SHOWCAMERA);
  51 + return false;
  52 + }
  53 + return true;
  54 + }
  55 +
  56 + public static boolean hasReadExternalStoragePermission(Activity activity){
  57 + int hasPermission = ContextCompat.checkSelfPermission(activity,
  58 + Manifest.permission.READ_EXTERNAL_STORAGE);
  59 + if(!permissionExists(Manifest.permission.READ_EXTERNAL_STORAGE)){
  60 + Log.e("permission","your system does not suppport "+ Manifest.permission.READ_EXTERNAL_STORAGE+" permission");
  61 + return false;
  62 + }
  63 + if (hasPermission != PackageManager.PERMISSION_GRANTED) {
  64 + ActivityCompat.requestPermissions(activity,
  65 + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
  66 + PermissionUtil.REQUEST_READ_EXTERNAL_STORAGE);
  67 + return false;
  68 + }
  69 + return true;
  70 + }
  71 + public static boolean hasRecordAudioPermission(Activity activity){
  72 + int hasPermission = ContextCompat.checkSelfPermission(activity,
  73 + Manifest.permission.RECORD_AUDIO);
  74 + if(!permissionExists(Manifest.permission.RECORD_AUDIO)){
  75 + Log.e("permission","your system does not suppport"+ Manifest.permission.RECORD_AUDIO+" permission");
  76 + return false;
  77 + }
  78 + if (hasPermission != PackageManager.PERMISSION_GRANTED) {
  79 + ActivityCompat.requestPermissions(activity,
  80 + new String[]{Manifest.permission.RECORD_AUDIO},
  81 + PermissionUtil.REQUEST_RECORD_AUDIO);
  82 + return false;
  83 + }
  84 + return true;
  85 + }
  86 +
  87 + public static boolean hasContactsPermission(Activity activity){
  88 + int hasWPermission = ContextCompat.checkSelfPermission(activity,
  89 + Manifest.permission.WRITE_CONTACTS);
  90 + int hasRPermission = ContextCompat.checkSelfPermission(activity,
  91 + Manifest.permission.READ_CONTACTS);
  92 +
  93 + if(hasRPermission== PackageManager.PERMISSION_GRANTED && hasWPermission== PackageManager.PERMISSION_GRANTED){
  94 + return true;
  95 + }
  96 + ActivityCompat.requestPermissions(activity,
  97 + new String[]{Manifest.permission.WRITE_CONTACTS, Manifest.permission.READ_CONTACTS},
  98 + PermissionUtil.REQUEST_CONTACTS);
  99 + return false;
  100 + }
  101 + public static boolean hasLocationPermission(Activity activity){
  102 + int hasFPermission = ContextCompat.checkSelfPermission(activity,
  103 + Manifest.permission.ACCESS_FINE_LOCATION);
  104 + int hasCPermission = ContextCompat.checkSelfPermission(activity,
  105 + Manifest.permission.ACCESS_COARSE_LOCATION);
  106 +
  107 + if(hasFPermission== PackageManager.PERMISSION_GRANTED&&hasCPermission== PackageManager.PERMISSION_GRANTED){
  108 + return true;
  109 + }
  110 + ActivityCompat.requestPermissions(activity,
  111 + new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
  112 + PermissionUtil.REQUEST_LOCATION);
  113 + return false;
  114 + }
  115 +
  116 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/util/SharedPreferenceMark.java
... ... @@ -0,0 +1,56 @@
  1 +package com.hjx.personalcenter.util;
  2 +
  3 +/**
  4 + * SharedPreference存储 记录只出现一次的组件是否已经出现过
  5 + * Created by yf on 2016/7/25.
  6 + */
  7 +public final class SharedPreferenceMark {
  8 +
  9 +
  10 + public static Boolean hasShowCamera=false;//是否已经提示过摄像头权限
  11 + public static Boolean hasShowLocation=false;//是否已经提示过摄像头权限
  12 + public static Boolean hasShowRecordAudio=false;//是否已经提示过摄像头权限
  13 + public static Boolean hasShowExtralStoreage=false;//是否已经提示过摄像头权限
  14 + public static Boolean hasShowContact=false;//是否已经提示过摄像头权限
  15 +
  16 +
  17 + public static Boolean getHasShowCamera() {
  18 + return hasShowCamera;
  19 + }
  20 +
  21 + public static void setHasShowCamera(Boolean hasShowCamera) {
  22 + SharedPreferenceMark.hasShowCamera = hasShowCamera;
  23 + }
  24 +
  25 + public static Boolean getHasShowLocation() {
  26 + return hasShowLocation;
  27 + }
  28 +
  29 + public static void setHasShowLocation(Boolean hasShowLocation) {
  30 + SharedPreferenceMark.hasShowLocation = hasShowLocation;
  31 + }
  32 +
  33 + public static Boolean getHasShowRecordAudio() {
  34 + return hasShowRecordAudio;
  35 + }
  36 +
  37 + public static void setHasShowRecordAudio(Boolean hasShowRecordAudio) {
  38 + SharedPreferenceMark.hasShowRecordAudio = hasShowRecordAudio;
  39 + }
  40 +
  41 + public static Boolean getHasShowExtralStoreage() {
  42 + return hasShowExtralStoreage;
  43 + }
  44 +
  45 + public static void setHasShowExtralStoreage(Boolean hasShowExtralStoreage) {
  46 + SharedPreferenceMark.hasShowExtralStoreage = hasShowExtralStoreage;
  47 + }
  48 +
  49 + public static Boolean getHasShowContact() {
  50 + return hasShowContact;
  51 + }
  52 +
  53 + public static void setHasShowContact(Boolean hasShowContact) {
  54 + SharedPreferenceMark.hasShowContact = hasShowContact;
  55 + }
  56 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/widget/ClearEditText.java
... ... @@ -0,0 +1,158 @@
  1 +package com.hjx.personalcenter.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Rect;
  5 +import android.graphics.drawable.Drawable;
  6 +import android.text.Editable;
  7 +import android.text.TextWatcher;
  8 +import android.util.AttributeSet;
  9 +import android.view.MotionEvent;
  10 +import android.view.View;
  11 +import android.view.animation.Animation;
  12 +import android.view.animation.CycleInterpolator;
  13 +import android.view.animation.TranslateAnimation;
  14 +import android.widget.EditText;
  15 +
  16 +import com.hjx.personalcenter.R;
  17 +
  18 +/**
  19 + * 项目名称:EditSearch
  20 + * 类描述:
  21 + * 创建人:tonycheng
  22 + * 创建时间:2016/4/26 14:39
  23 + * 邮箱:tonycheng93@outlook.com
  24 + * 修改人:
  25 + * 修改时间:
  26 + * 修改备注:
  27 + */
  28 +public class ClearEditText extends EditText implements View.OnFocusChangeListener,TextWatcher {
  29 + /**
  30 + * 删除按钮的引用
  31 + */
  32 + private Drawable mClearDrawable;
  33 + private Context context;
  34 +
  35 + /**
  36 + * 控件是否有焦点
  37 + */
  38 + private boolean hasFocus;
  39 +
  40 + public ClearEditText(Context context) {
  41 + this(context,null);
  42 +// super(context);
  43 +// this.context = context;
  44 +// init();
  45 + }
  46 + public ClearEditText(Context context, AttributeSet attrs){
  47 + //这里构造方法也很重要,不加这个很多属性不能再XML里面定义
  48 + this(context, attrs, android.R.attr.editTextStyle);
  49 + }
  50 +
  51 + public ClearEditText(Context context, AttributeSet attrs, int defStyle) {
  52 + super(context, attrs, defStyle);
  53 + init();
  54 + }
  55 + private void init() {
  56 + //获取EditText的DrawableRight,假如没有设置我们就使用默认的图片
  57 + mClearDrawable = getCompoundDrawables()[2];
  58 + if (mClearDrawable == null) {
  59 + mClearDrawable = getResources().getDrawable(R.drawable.delete_selector);
  60 + }
  61 + mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight());
  62 + //默认设置隐藏图标
  63 + setClearIconVisible(false);
  64 + //设置焦点改变的监听
  65 + setOnFocusChangeListener(this);
  66 + //设置输入框里面内容发生改变的监听
  67 + addTextChangedListener(this);
  68 + }
  69 +
  70 + @Override
  71 + public boolean onTouchEvent(MotionEvent event) {
  72 +
  73 + if (mClearDrawable != null && event.getAction() == MotionEvent.ACTION_UP) {
  74 + int x = (int) event.getX();
  75 + //判断触摸点是否在水平范围内
  76 + boolean isInnerWidth = (x > (getWidth() - getTotalPaddingRight())) &&
  77 + (x < (getWidth() - getPaddingRight()));
  78 + //获取删除图标的边界,返回一个Rect对象
  79 + Rect rect = mClearDrawable.getBounds();
  80 + //获取删除图标的高度
  81 + int height = rect.height();
  82 + int y = (int) event.getY();
  83 + //计算图标底部到控件底部的距离
  84 + int distance = (getHeight() - height) / 2;
  85 + //判断触摸点是否在竖直范围内(可能会有点误差)
  86 + //触摸点的纵坐标在distance到(distance+图标自身的高度)之内,则视为点中删除图标
  87 + boolean isInnerHeight = (y > distance) && (y < (distance + height));
  88 + if (isInnerHeight && isInnerWidth) {
  89 + this.setText("");
  90 + }
  91 + }
  92 + return super.onTouchEvent(event);
  93 + }
  94 +
  95 + /**
  96 + * 设置清除图标的显示与隐藏,调用setCompoundDrawables为EditText绘制上去
  97 + *
  98 + * @param visible
  99 + */
  100 + private void setClearIconVisible(boolean visible) {
  101 + Drawable right = visible ? mClearDrawable : null;
  102 + setCompoundDrawables(getCompoundDrawables()[0], getCompoundDrawables()[1],
  103 + right, getCompoundDrawables()[3]);
  104 + }
  105 +
  106 + /**
  107 + * 当ClearEditText焦点发生变化的时候,判断里面字符串长度设置清除图标的显示与隐藏
  108 + */
  109 + @Override
  110 + public void onFocusChange(View v, boolean hasFocus) {
  111 + this.hasFocus = hasFocus;
  112 + if (hasFocus) {
  113 + setClearIconVisible(getText().length() > 0);
  114 + } else {
  115 + setClearIconVisible(false);
  116 + }
  117 + }
  118 +
  119 + /**
  120 + * 当输入框里面内容发生变化的时候回调的方法
  121 + */
  122 + @Override
  123 + public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
  124 + if (hasFocus) {
  125 + setClearIconVisible(text.length() > 0);
  126 + }
  127 + }
  128 +
  129 + @Override
  130 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  131 +
  132 + }
  133 +
  134 + @Override
  135 + public void afterTextChanged(Editable s) {
  136 +
  137 + }
  138 +
  139 + /**
  140 + * 设置晃动动画
  141 + */
  142 + public void setShakeAnimation() {
  143 + this.setAnimation(shakeAnimation(5));
  144 + }
  145 +
  146 + /**
  147 + * 晃动动画
  148 + *
  149 + * @param counts 1秒钟晃动多少下
  150 + * @return
  151 + */
  152 + public static Animation shakeAnimation(int counts) {
  153 + Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
  154 + translateAnimation.setInterpolator(new CycleInterpolator(counts));
  155 + translateAnimation.setDuration(1000);
  156 + return translateAnimation;
  157 + }
  158 +}
... ...
PersonalCenter/app/src/main/res/drawable/delete_selector.xml
... ... @@ -0,0 +1,5 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<selector xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <item android:drawable="@drawable/search_clear_pressed" android:state_pressed="true"/>
  4 + <item android:drawable="@drawable/search_clear_normal"/>
  5 +</selector>
0 6 \ No newline at end of file
... ...
PersonalCenter/app/src/main/res/drawable/search_clear_normal.png

453 Bytes

PersonalCenter/app/src/main/res/drawable/search_clear_pressed.png

436 Bytes

PersonalCenter/app/src/main/res/layout/activity_feedback.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3   - android:orientation="vertical" android:layout_width="match_parent"
  3 + xmlns:fresco="http://schemas.android.com/tools"
  4 + android:orientation="vertical"
  5 + android:layout_width="match_parent"
4 6 android:layout_height="match_parent"
5 7 android:background="@color/backgerangde_laout">
6 8 <RelativeLayout
... ... @@ -57,13 +59,24 @@
57 59 android:layout_height="wrap_content"
58 60 android:background="@color/white">
59 61 <ImageView
  62 + android:id="@+id/iv_take"
60 63 android:layout_margin="20dp"
61 64 android:layout_width="wrap_content"
62 65 android:layout_height="wrap_content"
63 66 android:src="@mipmap/feedback_take_phone"/>
64 67  
  68 + <com.facebook.drawee.view.SimpleDraweeView
  69 + android:id="@+id/show_iv"
  70 + android:layout_width="54dp"
  71 + android:layout_height="54dp"
  72 + android:layout_gravity="center"
  73 + fresco:placeholderImage="@mipmap/title_back"
  74 + fresco:roundAsCircle="true"
  75 + fresco:placeholderImageScaleType="fitCenter" />
  76 +
65 77 </LinearLayout>
66 78 <EditText
  79 + android:id="@+id/feedback_phone"
67 80 android:layout_width="match_parent"
68 81 android:layout_marginTop="20dp"
69 82 android:background="@color/white"
... ...
PersonalCenter/app/src/main/res/layout/custom_adilog_school_list.xml
... ... @@ -0,0 +1,50 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical" android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 + <RelativeLayout
  6 + android:id="@+id/title"
  7 + android:layout_width="match_parent"
  8 + android:layout_height="wrap_content"
  9 + android:minHeight="70dp" >
  10 +
  11 + <ImageView
  12 + android:id="@+id/cancel"
  13 + android:layout_width="wrap_content"
  14 + android:layout_height="wrap_content"
  15 + android:layout_centerVertical="true"
  16 + android:layout_alignParentRight="true"
  17 + android:padding="20dp"
  18 + android:src="@mipmap/cancel_fork" />
  19 +
  20 + <TextView
  21 + android:id="@+id/menu_title"
  22 + android:layout_width="wrap_content"
  23 + android:layout_height="wrap_content"
  24 + android:layout_centerInParent="true"
  25 + android:padding="20dp"
  26 + android:text="选学校"
  27 + android:textColor="@android:color/black"
  28 + android:textSize="22sp" />
  29 + </RelativeLayout>
  30 + <com.hjx.personalcenter.widget.ClearEditText
  31 + android:id="@+id/et_school_sech"
  32 + android:layout_marginLeft="20dp"
  33 + android:layout_marginRight="20dp"
  34 + android:layout_marginTop="10dp"
  35 + android:paddingLeft="20dp"
  36 + android:layout_marginBottom="10dp"
  37 + android:hint="请输入学校名称"
  38 + android:layout_width="match_parent"
  39 + android:background="@drawable/corcle_black_bg"
  40 + android:layout_height="50dp"/>
  41 + <ListView
  42 + android:layout_marginLeft="20dp"
  43 + android:layout_marginRight="20dp"
  44 + android:id="@+id/listschooladapter"
  45 + android:layout_width="match_parent"
  46 + android:layout_height="400dp">
  47 +
  48 + </ListView>
  49 +
  50 +</LinearLayout>
0 51 \ No newline at end of file
... ...
PersonalCenter/app/src/main/res/layout/custom_adilog_school_list_items.xml
... ... @@ -0,0 +1,12 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical" android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 + <TextView
  6 + android:id="@+id/list_school_items"
  7 + android:textSize="18sp"
  8 + android:layout_width="match_parent"
  9 + android:layout_height="50dp"
  10 + android:textColor="@color/btn_text_color"/>
  11 +
  12 +</LinearLayout>
0 13 \ No newline at end of file
... ...