sdf
This commit is contained in:
44
app/src/main/java/utils/AppStatusManager.java
Normal file
44
app/src/main/java/utils/AppStatusManager.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package utils;
|
||||
|
||||
public class AppStatusManager {
|
||||
|
||||
private static AppStatusManager mInstance = null;
|
||||
|
||||
private int appStatus = AppStatusConstant.APP_FORCE_KILLED;
|
||||
|
||||
private AppStatusManager() {
|
||||
|
||||
}
|
||||
|
||||
public static AppStatusManager getInstance() {
|
||||
if(mInstance==null) {
|
||||
synchronized (AppStatusManager.class) {
|
||||
if(mInstance==null)
|
||||
mInstance = new AppStatusManager();
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public void setAppStatus(int appStatus) {
|
||||
this.appStatus = appStatus;
|
||||
}
|
||||
|
||||
public int getAppStatus() {
|
||||
return appStatus;
|
||||
}
|
||||
|
||||
|
||||
public static class AppStatusConstant {
|
||||
|
||||
/**
|
||||
* App被回收,初始状态
|
||||
*/
|
||||
public static final int APP_FORCE_KILLED = 0;
|
||||
|
||||
/**
|
||||
* 正常运行
|
||||
*/
|
||||
public static final int APP_NORMAL = 1;
|
||||
}
|
||||
}
|
||||
429
app/src/main/java/utils/BitmapTools.java
Normal file
429
app/src/main/java/utils/BitmapTools.java
Normal file
@@ -0,0 +1,429 @@
|
||||
package utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2017/4/24.
|
||||
*/
|
||||
|
||||
public class BitmapTools {
|
||||
public static Bitmap
|
||||
ChangeOrientationBitmap(String pathString, int degree) {
|
||||
Bitmap bitmap = null;
|
||||
Bitmap bMapRotate = null;
|
||||
try {
|
||||
File file = new File(pathString);
|
||||
if (file.exists()) {
|
||||
BitmapFactory.Options opt = new BitmapFactory.Options();
|
||||
opt.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||
opt.inPurgeable = true;
|
||||
opt.inInputShareable = true;
|
||||
opt.inTempStorage = new byte[1024 * 1024 * 10];
|
||||
long length = file.length();
|
||||
//Log.d(this, "file.length() = " + length);
|
||||
if (length / (1024 * 1024) > 4) {
|
||||
opt.inSampleSize = 16;
|
||||
// LogUtils.d(this, "opt.inSampleSize = 16;");
|
||||
} else if (length / (1024 * 1024) >= 1) {
|
||||
opt.inSampleSize = 8;
|
||||
// LogUtils.d(this, "opt.inSampleSize = 8;");
|
||||
} else if (length / (1024 * 512) >= 1) {
|
||||
opt.inSampleSize = 4;
|
||||
//LogUtils.d(this, "opt.inSampleSize = 4;");
|
||||
} else if (length / (1024 * 256) >= 1) {
|
||||
opt.inSampleSize = 2;
|
||||
//LogUtils.d(this, "opt.inSampleSize = 2;");
|
||||
} else {
|
||||
opt.inSampleSize = 1;
|
||||
//LogUtils.d(this, "opt.inSampleSize = 1;");
|
||||
}
|
||||
bitmap = BitmapFactory.decodeFile(pathString, opt);
|
||||
//LogUtils.i("fangdd", "图片旋转度数:" + readPictureDegree(pathString));
|
||||
// ///////////
|
||||
// if(pathString.contains("floor/imgs")){
|
||||
// YLog.i("fangdd", "处理旋转:"+isGetImage);
|
||||
int orientation = 0;
|
||||
if (degree == 0) {
|
||||
orientation = readPictureDegree(pathString);
|
||||
} else orientation = degree;
|
||||
/*
|
||||
* if(bitmap.getHeight() < bitmap.getWidth()){ orientation = 90;
|
||||
* } else { orientation = 0; }
|
||||
*/
|
||||
if (orientation != 0) {
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postRotate(orientation);
|
||||
bMapRotate = Bitmap
|
||||
.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
|
||||
bitmap.getHeight(), matrix, true);
|
||||
} else {
|
||||
bMapRotate = Bitmap.createScaledBitmap(bitmap,
|
||||
bitmap.getWidth(), bitmap.getHeight(), true);
|
||||
}
|
||||
// }
|
||||
// //////////////
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bMapRotate != null) {
|
||||
return bMapRotate;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取图片属性:旋转的角度
|
||||
*
|
||||
* @param path 图片绝对路径
|
||||
* @return degree旋转的角度
|
||||
*/
|
||||
public static int readPictureDegree(String path) {
|
||||
int degree = 0;
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(path);
|
||||
int orientation = exifInterface.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL);
|
||||
switch (orientation) {
|
||||
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||
degree = 90;
|
||||
break;
|
||||
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||
degree = 180;
|
||||
break;
|
||||
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||
degree = 270;
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return degree;
|
||||
}
|
||||
|
||||
public static String getPathByUri(Context context, Uri data) {
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
if (isKitKat) return getPathByUri4kitkat(context, data);
|
||||
String filename = null;
|
||||
if (data.getScheme().toString().compareTo("content") == 0) {
|
||||
Cursor cursor = context.getContentResolver().query(data, new String[]{"_data"}, null, null, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
filename = cursor.getString(0);
|
||||
}
|
||||
} else if (data.getScheme().toString().compareTo("file") == 0) {// file:///开头的uri
|
||||
filename = data.toString().replace("file://", "");// 替换file://
|
||||
if (!filename.startsWith("/mnt")) {// 加上"/mnt"头
|
||||
filename += "/mnt";
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public static String getPathByUri4kitkat(final Context context, final Uri uri) {
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
// DocumentProvider
|
||||
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
|
||||
if (isExternalStorageDocument(uri)) {// ExternalStorageProvider
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
} else if (isDownloadsDocument(uri)) {// DownloadsProvider
|
||||
final String id = DocumentsContract.getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
|
||||
Long.valueOf(id));
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
} else if (isMediaDocument(uri)) {// MediaProvider
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type)) {
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("video".equals(type)) {
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("audio".equals(type)) {
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[]{split[1]};
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
} else if ("content".equalsIgnoreCase(uri.getScheme())) {// MediaStore
|
||||
// (and
|
||||
// general)
|
||||
return getDataColumn(context, uri, null, null);
|
||||
} else if ("file".equalsIgnoreCase(uri.getScheme())) {// File
|
||||
return uri.getPath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
*
|
||||
* @param context The context.
|
||||
* @param uri The Uri to query.
|
||||
* @param selection (Optional) Filter used in the query.
|
||||
* @param selectionArgs (Optional) Selection arguments used in the query.
|
||||
* @return The value of the _data column, which is typically a file path.
|
||||
*/
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = {column};
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int column_index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(column_index);
|
||||
}
|
||||
}
|
||||
catch (Exception e){}
|
||||
finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||
*/
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is DownloadsProvider.
|
||||
*/
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri The Uri to check.
|
||||
* @return Whether the Uri authority is MediaProvider.
|
||||
*/
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将Bitmap转换成文件
|
||||
* 保存文件
|
||||
*
|
||||
* @param bm
|
||||
* @param fileName
|
||||
* @throws IOException
|
||||
*/
|
||||
public static File saveFile(Bitmap bm, String path, String fileName) throws IOException {
|
||||
File dirFile = new File(path);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdir();
|
||||
}
|
||||
File myCaptureFile = new File(path, fileName);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
|
||||
bm.compress(Bitmap.CompressFormat.JPEG, 60, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
return myCaptureFile;
|
||||
}
|
||||
|
||||
public static File saveFile(Bitmap bm, String filePath) throws IOException {
|
||||
File myCaptureFile = new File(filePath);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
|
||||
bm.compress(Bitmap.CompressFormat.JPEG, 60, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
return myCaptureFile;
|
||||
}
|
||||
|
||||
|
||||
public static void deleteFile(File file) {
|
||||
if (file.exists()) { // 判断文件是否存在
|
||||
if (file.isFile()) { // 判断是否是文件
|
||||
file.delete(); // delete()方法 你应该知道 是删除的意思;
|
||||
} else if (file.isDirectory()) { // 否则如果它是一个目录
|
||||
File files[] = file.listFiles(); // 声明目录下所有的文件 files[];
|
||||
for (int i = 0; i < files.length; i++) { // 遍历目录下所有的文件
|
||||
deleteFile(files[i]); // 把每个文件 用这个方法进行迭代
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
} else {
|
||||
// Constants.Logdada("文件不存在!"+"\n");
|
||||
}
|
||||
}
|
||||
public static Bitmap imageZoom(Bitmap bitMap, double maxSize) {
|
||||
//图片允许最大空间 单位:KB
|
||||
|
||||
//将bitmap放至数组中,意在bitmap的大小(与实际读取的原文件要大)
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
bitMap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
||||
byte[] b = baos.toByteArray();
|
||||
//将字节换成KB
|
||||
double mid = b.length/1024;
|
||||
//判断bitmap占用空间是否大于允许最大空间 如果大于则压缩 小于则不压缩
|
||||
if (mid > maxSize) {
|
||||
//获取bitmap大小 是允许最大大小的多少倍
|
||||
double i = mid / maxSize;
|
||||
//开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍 (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小)
|
||||
bitMap = zoomImage(bitMap, bitMap.getWidth() / Math.sqrt(i),
|
||||
bitMap.getHeight() / Math.sqrt(i),maxSize);
|
||||
}
|
||||
try {
|
||||
baos.flush();
|
||||
baos.close();
|
||||
baos = null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return bitMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* 图片的缩放方法
|
||||
*
|
||||
* @param bgimage
|
||||
* :源图片资源
|
||||
* @param newWidth
|
||||
* :缩放后宽度
|
||||
* @param newHeight
|
||||
* :缩放后高度
|
||||
* @return
|
||||
*/
|
||||
public static Bitmap zoomImage(Bitmap bgimage, double newWidth,
|
||||
double newHeight,double maxsize) {
|
||||
// 获取这个图片的宽和高
|
||||
float width = bgimage.getWidth();
|
||||
float height = bgimage.getHeight();
|
||||
// 创建操作图片用的matrix对象
|
||||
Matrix matrix = new Matrix();
|
||||
// 计算宽高缩放率
|
||||
float scaleWidth = ((float) newWidth) / width;
|
||||
float scaleHeight = ((float) newHeight) / height;
|
||||
// 缩放图片动作
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
|
||||
// InputStream inputStream=compressImage3(bgimage,maxsize);
|
||||
|
||||
//Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
return compressImage3(bgimage,maxsize);
|
||||
}
|
||||
/**
|
||||
* 压缩图片获取输入流
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public static Bitmap compressImage3(Bitmap image,double maxsize) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int times= (int) (100/((baos.toByteArray().length / (1024*maxsize))));
|
||||
image.compress(Bitmap.CompressFormat.JPEG, times, baos);// 质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
|
||||
/* int options = 1000;
|
||||
while (baos.toByteArray().length / 1024 > maxsize) { // 循环判断如果压缩后图片是否大于100kb,大于继续压缩
|
||||
baos.reset();// 重置baos即清空baos
|
||||
options -= 10;// 每次都减少10
|
||||
image.compress(Bitmap.CompressFormat.JPEG, options, baos);// 这里压缩options%,把压缩后的数据存放到baos中
|
||||
|
||||
}*/
|
||||
|
||||
//ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());// 把压缩后的数据baos存放到ByteArrayInputStream中
|
||||
//Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);// 把ByteArrayInputStream数据生成图片
|
||||
//return bitmap;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap
|
||||
adjustPhotoRotation(Bitmap bm, final int orientationDegree)
|
||||
{
|
||||
|
||||
Matrix m = new Matrix();
|
||||
m.setRotate(orientationDegree, (float) bm.getWidth() / 2, (float) bm.getHeight() / 2);
|
||||
float targetX, targetY;
|
||||
if (orientationDegree == 90) {
|
||||
targetX = bm.getHeight();
|
||||
targetY = 0;
|
||||
} else {
|
||||
targetX = bm.getHeight();
|
||||
targetY = bm.getWidth();
|
||||
}
|
||||
|
||||
final float[] values = new float[9];
|
||||
m.getValues(values);
|
||||
|
||||
float x1 = values[Matrix.MTRANS_X];
|
||||
float y1 = values[Matrix.MTRANS_Y];
|
||||
|
||||
m.postTranslate(targetX - x1, targetY - y1);
|
||||
|
||||
Bitmap bm1 = Bitmap.createBitmap(bm.getHeight(), bm.getWidth(), Bitmap.Config.ARGB_8888);
|
||||
Paint paint = new Paint();
|
||||
Canvas canvas = new Canvas(bm1);
|
||||
canvas.drawBitmap(bm, m, paint);
|
||||
|
||||
return bm1;
|
||||
}
|
||||
|
||||
public static Bitmap decodeUriAsBitmap(Context context,Uri uri,int i){
|
||||
Bitmap bitmap = null;
|
||||
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
|
||||
bitmapOptions.inSampleSize = i;//压缩,数值越大越模糊
|
||||
bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
||||
bitmapOptions.inPurgeable = true;
|
||||
bitmapOptions.inInputShareable = true;
|
||||
try {
|
||||
//bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStrea(uri));
|
||||
|
||||
|
||||
bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri), null , bitmapOptions);
|
||||
// bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));//报oom
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
} catch (OutOfMemoryError e) {//内存溢出捕获再压缩
|
||||
bitmap=decodeUriAsBitmap(context,uri,i*2);
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
38
app/src/main/java/utils/BottomNavigationViewHelper.java
Normal file
38
app/src/main/java/utils/BottomNavigationViewHelper.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.support.design.internal.BottomNavigationItemView;
|
||||
import android.support.design.internal.BottomNavigationMenuView;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by 90432 on 2018/1/10.
|
||||
*/
|
||||
|
||||
public class BottomNavigationViewHelper {
|
||||
@SuppressLint("RestrictedApi")
|
||||
public static void disableShiftMode(BottomNavigationView view) {
|
||||
BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
|
||||
try {
|
||||
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
|
||||
shiftingMode.setAccessible(true);
|
||||
shiftingMode.setBoolean(menuView, false);
|
||||
shiftingMode.setAccessible(false);
|
||||
for (int i = 0; i < menuView.getChildCount(); i++) {
|
||||
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
|
||||
//noinspection RestrictedApi
|
||||
item.setShiftingMode(false);
|
||||
// set once again checked value, so view will be updated
|
||||
//noinspection RestrictedApi
|
||||
item.setChecked(item.getItemData().isChecked());
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e("BNVHelper", "Unable to get shift mode field", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("BNVHelper", "Unable to change value of shift mode", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
161
app/src/main/java/utils/CacheDataManager.java
Normal file
161
app/src/main/java/utils/CacheDataManager.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class CacheDataManager {
|
||||
|
||||
public static String getTotalCacheSize(Context context) throws Exception {
|
||||
|
||||
long cacheSize = getFolderSize(context.getCacheDir());
|
||||
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
|
||||
cacheSize += getFolderSize(context.getExternalCacheDir());
|
||||
|
||||
}
|
||||
|
||||
return getFormatSize(cacheSize);
|
||||
|
||||
}
|
||||
|
||||
public static void clearAllCache(Context context) {
|
||||
|
||||
deleteDir(context.getCacheDir());
|
||||
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
|
||||
deleteDir(context.getExternalCacheDir());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean deleteDir(File dir) {
|
||||
|
||||
if (dir != null && dir.isDirectory()) {
|
||||
|
||||
String[] children = dir.list();
|
||||
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
|
||||
boolean success = deleteDir(new File(dir, children[i]));
|
||||
|
||||
if (!success) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return dir.delete();
|
||||
|
||||
}
|
||||
|
||||
// 获取文件
|
||||
|
||||
// Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/
|
||||
|
||||
// 目录,一般放一些长时间保存的数据
|
||||
|
||||
// Context.getExternalCacheDir() -->
|
||||
|
||||
// SDCard/Android/data/你的应用包名/cache/目录,一般存放临时缓存数据
|
||||
|
||||
public static long getFolderSize(File file) throws Exception {
|
||||
|
||||
long size = 0;
|
||||
|
||||
try {
|
||||
|
||||
File[] fileList = file.listFiles();
|
||||
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
|
||||
// 如果下面还有文件
|
||||
|
||||
if (fileList[i].isDirectory()) {
|
||||
|
||||
size = size + getFolderSize(fileList[i]);
|
||||
|
||||
} else {
|
||||
|
||||
size = size + fileList[i].length();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 格式化单位
|
||||
|
||||
*
|
||||
|
||||
* @param size
|
||||
|
||||
*/
|
||||
|
||||
public static String getFormatSize(double size) {
|
||||
|
||||
double kiloByte = size / 1024;
|
||||
|
||||
if (kiloByte < 1) {
|
||||
|
||||
return size + "Byte";
|
||||
|
||||
}
|
||||
|
||||
double megaByte = kiloByte / 1024;
|
||||
|
||||
if (megaByte < 1) {
|
||||
|
||||
BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
|
||||
|
||||
return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB";
|
||||
|
||||
}
|
||||
|
||||
double gigaByte = megaByte / 1024;
|
||||
|
||||
if (gigaByte < 1) {
|
||||
|
||||
BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
|
||||
|
||||
return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
|
||||
|
||||
}
|
||||
|
||||
double teraBytes = gigaByte / 1024;
|
||||
|
||||
if (teraBytes < 1) {
|
||||
|
||||
BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
|
||||
|
||||
return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB";
|
||||
|
||||
}
|
||||
|
||||
BigDecimal result4 = new BigDecimal(teraBytes);
|
||||
|
||||
return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
10
app/src/main/java/utils/ConfigTitiles.java
Normal file
10
app/src/main/java/utils/ConfigTitiles.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package utils;
|
||||
|
||||
/**
|
||||
* Created by 90432 on 2018/1/10.
|
||||
*/
|
||||
|
||||
public class ConfigTitiles {
|
||||
public static String ONCEORNOT="onceornot";//判断是否下载后第一次使用
|
||||
public static String DESKDATA="deskdata";//保存课程表
|
||||
}
|
||||
28
app/src/main/java/utils/Constants.java
Normal file
28
app/src/main/java/utils/Constants.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package utils;
|
||||
|
||||
/**
|
||||
* 常量类
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* 费用类型
|
||||
*/
|
||||
public interface FeeCategory {
|
||||
String HOUSEKEEPING = "1"; //家政服务订单
|
||||
String PROPERTY_FEE = "2"; //用户交业费费用
|
||||
String RECHARGE = "3"; //用户充值
|
||||
String PARKING_FEE = "4"; //临停费用
|
||||
}
|
||||
|
||||
public static final int PAY_REQUEST_CODE = 5000;
|
||||
|
||||
/**
|
||||
* 支付结果码
|
||||
*/
|
||||
public interface PayResultCode {
|
||||
int OK = 1; //支付失败
|
||||
int FAIL = 0; //支付成功
|
||||
}
|
||||
|
||||
}
|
||||
91
app/src/main/java/utils/DataManager.java
Normal file
91
app/src/main/java/utils/DataManager.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package utils;
|
||||
|
||||
/**
|
||||
* Created by pengfengwang on 2017/1/15.
|
||||
*/
|
||||
|
||||
public class DataManager {
|
||||
public static final String NIGHT_SKIN = "night.skin";
|
||||
public static final String[] SKIN_NAMES = {
|
||||
"官方红", "官方白", "自选颜色"
|
||||
};
|
||||
public static final String[] SKIN_LIBS = {
|
||||
"", "white.skin", "color.skin"
|
||||
};
|
||||
public static final String[] BANNER_IMAGES = {
|
||||
"http://img15.3lian.com/2016/h1/11/126.jpg",
|
||||
"http://i01.pictn.sogoucdn.com/9e67bbad95eedd4e",
|
||||
"http://img15.3lian.com/2016/h1/74/57.jpg",
|
||||
"http://img15.3lian.com/2016/h1/160/138.jpg",
|
||||
"http://img15.3lian.com/2016/h1/93/158.jpg",
|
||||
"http://img16.3lian.com/gif2016/q20/32/82.jpg",
|
||||
"http://img15.3lian.com/2016/h1/256/78.jpg",
|
||||
"http://pic55.nipic.com/file/20141208/19462408_171130145000_2.jpg"
|
||||
/* R.drawable.home_banner_1, R.drawable.home_banner_2, R.drawable.home_banner_3,
|
||||
R.drawable.home_banner_4, R.drawable.home_banner_5, R.drawable.home_banner_6,
|
||||
R.drawable.home_banner_7, R.drawable.home_banner_8, R.drawable.home_banner_9,
|
||||
R.drawable.home_banner_10, R.drawable.home_banner_11, R.drawable.home_banner_12*/
|
||||
};
|
||||
public static final int[] IMAGES = {
|
||||
/* R.drawable.home_six_1, R.drawable.home_six_2, R.drawable.home_six_3,
|
||||
R.drawable.home_six_4, R.drawable.home_six_5, R.drawable.home_six_6,
|
||||
R.drawable.home_six_7, R.drawable.home_six_8, R.drawable.home_six_9,
|
||||
R.drawable.home_six_10, R.drawable.home_six_11, R.drawable.home_six_12,
|
||||
R.drawable.home_six_13, R.drawable.home_six_14, R.drawable.home_six_15,
|
||||
R.drawable.home_six_16, R.drawable.home_six_17, R.drawable.home_six_18,
|
||||
R.drawable.home_six_19, R.drawable.home_six_20, R.drawable.home_six_21,
|
||||
R.drawable.home_six_22, R.drawable.home_six_23, R.drawable.home_six_24,
|
||||
R.drawable.home_six_25, R.drawable.home_six_26, R.drawable.home_six_27,
|
||||
R.drawable.home_six_28, R.drawable.home_six_29, R.drawable.home_six_30,*/
|
||||
};
|
||||
public static final String[] LABELS = {
|
||||
"推荐歌曲", "独家放送", "最新音乐", "推荐MV", "主播电台"
|
||||
};
|
||||
public static final int[] LABELS_INDICATOR = {
|
||||
/* R.drawable.ic_indicator_0, R.drawable.ic_indicator_1, R.drawable.ic_indicator_2,
|
||||
R.drawable.ic_indicator_3, R.drawable.ic_indicator_4*/
|
||||
};
|
||||
public static final String[] TITLES = {
|
||||
"海明威", "小说", "中国文学",
|
||||
"村上春树", "王小波", "余华",
|
||||
"鲁迅", "米兰·昆德拉", "外国文学",
|
||||
"经典", "童话", "儿童文学",
|
||||
"名著", "缘分", "杜拉斯",
|
||||
"文学", "散文", "诗歌",
|
||||
"张爱玲", "钱钟书", "诗词",
|
||||
"港台", "随笔", "日本文学",
|
||||
"杂文", "古典文学", "村上春树",
|
||||
"米兰·昆德拉", "童话", "张爱玲"};
|
||||
public static final String[] SUBTITLES = {
|
||||
"美国作家和记者,被认为是20世纪最著名的小说家之一。出生于美国伊利诺伊州芝加哥市郊区的奥克帕克,晚年在爱达荷州凯彻姆的家中自杀身亡。海明威一生中的感情错综复杂,先后结过四次婚,是美国“迷惘的一代”(Lost Generation)作家中的代表人物,作品中对人生、世界、社会都表现出了迷茫和彷徨。",
|
||||
"以刻画人物形象为中心,通过完整的故事情节和环境描写来反映社会生活的文学体裁。",
|
||||
"中国文学分为古典文学、现代文学与当代文学。古典文学以唐宋诗词及四大名著为代表,现代文学以鲁迅小说为代表,当代文学则以具有独立思想的中国自由文学为标志。",
|
||||
"村上春树(1949年1月12日—),日本现代小说家,生于京都伏见区。毕业于早稻田大学第一文学部演剧科。",
|
||||
"王小波(1952-1997),中国当代学者、作家。代表作品有《黄金时代》、《白银时代》、《青铜时代》、《黑铁时代》等。",
|
||||
"余华,1960年4月3日生于浙江杭州,当代作家。中国作家协会第九届全国委员会委员。",
|
||||
"鲁迅(1881年9月25日-1936年10月19日),原名周樟寿,后改名周树人,字豫山,后改豫才,“鲁迅”是他1918年发表《狂人日记》时所用的笔名,也是他影响最为广泛的笔名,浙江绍兴人。著名文学家、思想家,五四新文化运动的重要参与者,中国现代文学的奠基人。",
|
||||
"米兰·昆德拉(Milan Kundera),小说家,出生于捷克斯洛伐克布尔诺,自1975年起,在法国定居。长篇小说《玩笑》、《生活在别处》、《告别圆舞曲》、《笑忘录》、《不能承受的生命之轻》和《不朽》,以及短篇小说集《好笑的爱》是以作者母语捷克文写成。而他最新出版的长篇小说《慢》、《身份》和《无知》及随笔集《小说的艺术》和《被背叛的遗嘱》是以法文写成。《雅克和他的主人》系作者戏剧代表作。",
|
||||
"外国文学是指除中国文学以外的世界各国文学。世界文学源远流长,绚丽多姿。早在几千年以前,在人类文明的发祥地就已经孕育出了人类最初的文学瑰宝。在而后的岁月里,东西方许多民族都出现过杰出的文学大师和众多的名家名著。人们热爱和珍视这些作家及其作品,是因为优秀的文学作品体现了人类对客观世界的认识,显示了人类成长的精神轨迹,并给世世代代的人们以审美的愉悦。",
|
||||
"经典读音jīngdiǎn英文名classics:指具有典范性、权威性的;经久不衰的万世之作;经过历史选择出来的“最有价值经典的”;最能表现本行业的精髓的;最具代表性的;最完美的作品。",
|
||||
"《童话》是光良演唱的一首歌曲,由光良作词、作曲,收录在光良2005年1月21日发行的同名专辑《童话》中[1-2] 。《童话》是光良的代表作品之一。",
|
||||
"《儿童文学》是由共青团中央和中国作家协会于1963年共同创办的杂志,被誉为“中国儿童文学的一面旗帜”。目前为月刊,月发行量110多万份。",
|
||||
"名著就是指具有较高艺术价值和知名度,且包含永恒主题和经典的人物形象,能够经过时间考验经久不衰,被广泛认识以及流传的文字作品。能给人们以警世和深远影响的著作,以及对世人生存环境的感悟。",
|
||||
"缘分,它是出自佛教的一个宗教概念,儒家与道家并不讲缘分,也不讲你与我有缘之说。",
|
||||
"玛格丽特·杜拉斯1914年出生于法属印度支那。十八岁时定居巴黎。自1942年开始发表小说,1950年的《抵挡太平洋的堤坝》使杜拉斯成名。这段时期的作品富有自传色彩。自1953年的《塔基尼亚的小马群》起,杜拉斯探索新的叙事语言,逐渐抹去小说情节,更强调主观感受和心理变化。1955—1965年是她创作上的高峰期,代表作有小说《如歌的中板》、《副领事》,以及剧本《广岛之恋》等。1984年发表《情人》,获当年龚古尔文学奖。",
|
||||
"文学是以语言文字为工具,形象化地反映客观现实、表现作家心灵世界的艺术,包括诗歌、散文、小说、剧本、寓言童话等,是文化的重要表现形式,以不同的形式即体裁,表现内心情感,再现一定时期和一定地域的社会生活。作为学科门类理解的文学,包括中国语言文学、外国语言文学及新闻传播学。",
|
||||
"散文是一种作者写自己经历见闻中的真情实感、灵活的文学体裁。",
|
||||
"用高度凝练的语言,形象表达作者丰富情感,集中反映社会生活并具有一定节奏和韵律的文学体裁。",
|
||||
"张爱玲,中国现代作家,原籍河北省唐山市,原名张煐。1920年9月30日出生在上海公共租界西区一幢没落贵族府邸。",
|
||||
"钱钟书(1910年-1998年),江苏无锡人,原名仰先,字哲良,后改名钟书,字默存,号槐聚,曾用笔名中书君,中国现代作家、文学研究家。",
|
||||
"诗词,是指以古体诗、近体诗和格律词为代表的中国古代传统诗歌。亦是汉字文化圈的特色之一。通常认为,诗较为适合“言志”,而词则更为适合“抒情”。",
|
||||
"香港电台(Radio Television Hong Kong,简称:RTHK),中文简称“港台”。现为商务及经济发展局辖下的部门,是香港广播史上首家广播机构,同时也是香港唯一的公共广播机构,亦是最具公信力的传媒机构之一。",
|
||||
"随笔,顾名思义:随笔一记,是散文的一个分支,是议论文的一个变体,兼有议论和抒情两种特性,通常篇幅短小,形式多样,写作者惯常用各种修辞手法曲折传达自己的见解和情感,语言灵动,婉而多讽,是言禁未开之社会较为流行的一种文体。随笔作为一种文学样式,是由法国散文家蒙田所创的。",
|
||||
"日本文学指的是以日本语写作的文学作品,横跨的时间大约有两千年。早期的文学作品受到中国文学一些的影响,但在后来日本也渐渐形成自有的文学风格和特色。19世纪日本重启港口与西方国家贸易及展开外交关系之后,西方文学也开始影响日本的作家,直到今天仍然得见其影响力。",
|
||||
"杂文是一种直接、迅速反映社会事变或动向的文艺性论文。特点是“杂而有文”,短小、锋利、隽永,富于文艺工作者色彩和诗的语言,具有独特的艺术感染力。在剧烈的社会斗争中,杂文是战斗的利器,比如鲁迅先生的杂文就如同“匕首”“投枪”直刺一切黑暗的心脏。在和平建设年代,它也能起到赞扬真善美,鞭挞假恶丑的针砭时弊的喉舌作用。比如《庄周买水》、《剃光头发微》等文章就是如此。",
|
||||
"古典文学泛指各民族的古代文学作品,是文学的一部分,是现代文学的发展基础,它是承上启下的,是文学发展史上不可缺少的部分。它是中国文学最根本的东西。 现在所谓的古典文学,也专指优秀的、有一定价值的古代文学作品。“古典”在拉丁文中是“第一流的、典范的”意思。欧洲文艺复兴时期,文艺理论家以古希腊、罗马的优秀作品为典范,称为古典文学。在中国,把从远古流传下来的原始歌谣和神话传说,直到五四以前大量的有一定价值的文学作品,叫古典文学。",
|
||||
"村上春树(1949年1月12日—),日本现代小说家,生于京都伏见区。毕业于早稻田大学第一文学部演剧科。",
|
||||
"米兰·昆德拉(Milan Kundera),小说家,出生于捷克斯洛伐克布尔诺,自1975年起,在法国定居。长篇小说《玩笑》、《生活在别处》、《告别圆舞曲》、《笑忘录》、《不能承受的生命之轻》和《不朽》,以及短篇小说集《好笑的爱》是以作者母语捷克文写成。而他最新出版的长篇小说《慢》、《身份》和《无知》及随笔集《小说的艺术》和《被背叛的遗嘱》是以法文写成。《雅克和他的主人》系作者戏剧代表作。",
|
||||
"《童话》是光良演唱的一首歌曲,由光良作词、作曲,收录在光良2005年1月21日发行的同名专辑《童话》中[1-2] 。《童话》是光良的代表作品之一。",
|
||||
"用高度凝练的语言,形象表达作者丰富情感,集中反映社会生活并具有一定节奏和韵律的文学体裁。"
|
||||
};
|
||||
}
|
||||
32
app/src/main/java/utils/EditInputtype.java
Normal file
32
app/src/main/java/utils/EditInputtype.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class EditInputtype {
|
||||
public static boolean isNumber(String text){
|
||||
Pattern p = Pattern.compile("[0-9]*");
|
||||
Matcher m = p.matcher(text);
|
||||
if(m.matches() ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isAZaz(String text){
|
||||
Pattern p = Pattern.compile("[a-zA-Z]");
|
||||
Matcher m = p.matcher(text);
|
||||
if(m.matches() ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isChinese(String text){
|
||||
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
|
||||
Matcher m = p.matcher(text);
|
||||
if(m.matches() ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
100
app/src/main/java/utils/IndentTextWatcher.java
Normal file
100
app/src/main/java/utils/IndentTextWatcher.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package utils;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
|
||||
public class IndentTextWatcher implements TextWatcher {
|
||||
|
||||
int markStart = -1;
|
||||
int changeCount = -1;
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
this.markStart = -1;
|
||||
this.changeCount = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
this.markStart = start;
|
||||
this.changeCount = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
int start = this.markStart;
|
||||
int count = this.changeCount;
|
||||
|
||||
if (count == 1 && s.charAt(start) == '\n') {
|
||||
indent(s, start);
|
||||
}
|
||||
|
||||
this.markStart = -1;
|
||||
this.changeCount = -1;
|
||||
}
|
||||
|
||||
static void indent(Editable s, int start) {
|
||||
CharSequence value = getIndent(s, start);
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
s.insert(start + 1, value);
|
||||
}
|
||||
}
|
||||
|
||||
static CharSequence getIndent(Editable s, int start) {
|
||||
int begin = lastIndexOf(s, '\n', start - 1);
|
||||
begin = (begin < 0) ? 0 : (begin + 1);
|
||||
int end = begin;
|
||||
for (int i = begin, length = start + 1; i < length; i++) {
|
||||
char c = s.charAt(i);
|
||||
if (!isWhitespace(c)) {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (end > begin) {
|
||||
return s.subSequence(begin, end).toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static boolean isWhitespace(char c) {
|
||||
return (c == ' ')
|
||||
|| (c == '\t')
|
||||
|| (c == '\u3000');
|
||||
}
|
||||
|
||||
private static int lastIndexOf(Editable s, char ch, int fromIndex) {
|
||||
if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
|
||||
// handle most cases here (ch is a BMP code point or a
|
||||
// negative value (invalid code point))
|
||||
int i = Math.min(fromIndex, s.length() - 1);
|
||||
for (; i >= 0; i--) {
|
||||
if (s.charAt(i) == ch) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
return lastIndexOfSupplementary(s, ch, fromIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private static int lastIndexOfSupplementary(Editable s, int ch, int fromIndex) {
|
||||
if (Character.isValidCodePoint(ch)) {
|
||||
char hi = Character.highSurrogate(ch);
|
||||
char lo = Character.lowSurrogate(ch);
|
||||
int i = Math.min(fromIndex, s.length() - 2);
|
||||
for (; i >= 0; i--) {
|
||||
if (s.charAt(i) == hi && s.charAt(i + 1) == lo) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
194
app/src/main/java/utils/KeyboardUtil.java
Normal file
194
app/src/main/java/utils/KeyboardUtil.java
Normal file
@@ -0,0 +1,194 @@
|
||||
package utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.sl.house_property.R;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Created by yechao on 2018/5/15/015.
|
||||
* Describe :
|
||||
*/
|
||||
public class KeyboardUtil {
|
||||
|
||||
private Activity mActivity;
|
||||
private KeyboardView mKeyboardView;
|
||||
private EditText mEdit;
|
||||
/**
|
||||
* 省份简称键盘
|
||||
*/
|
||||
private Keyboard provinceKeyboard;
|
||||
/**
|
||||
* 数字与大写字母键盘
|
||||
*/
|
||||
private Keyboard numberKeyboard;
|
||||
|
||||
public KeyboardUtil(Activity activity, EditText edit) {
|
||||
mActivity = activity;
|
||||
mEdit = edit;
|
||||
provinceKeyboard = new Keyboard(activity, R.xml.province_abbreviation);
|
||||
numberKeyboard = new Keyboard(activity, R.xml.number_or_letters);
|
||||
mKeyboardView = (KeyboardView) activity.findViewById(R.id.keyboard_view);
|
||||
mKeyboardView.setKeyboard(provinceKeyboard);
|
||||
mKeyboardView.setEnabled(true);
|
||||
mKeyboardView.setPreviewEnabled(false);
|
||||
mKeyboardView.setOnKeyboardActionListener(listener);
|
||||
}
|
||||
|
||||
public KeyboardUtil(Activity activity,KeyboardView mKeyboardView, EditText edit) {
|
||||
mActivity = activity;
|
||||
mEdit = edit;
|
||||
provinceKeyboard = new Keyboard(activity, R.xml.province_abbreviation);
|
||||
numberKeyboard = new Keyboard(activity, R.xml.number_or_letters);
|
||||
this.mKeyboardView = mKeyboardView;
|
||||
mKeyboardView.setKeyboard(provinceKeyboard);
|
||||
mKeyboardView.setEnabled(true);
|
||||
mKeyboardView.setPreviewEnabled(false);
|
||||
mKeyboardView.setOnKeyboardActionListener(listener);
|
||||
}
|
||||
|
||||
|
||||
private KeyboardView.OnKeyboardActionListener listener = new KeyboardView.OnKeyboardActionListener() {
|
||||
@Override
|
||||
public void swipeUp() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeRight() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeLeft() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeDown() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onText(CharSequence text) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(int primaryCode) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress(int primaryCode) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKey(int primaryCode, int[] keyCodes) {
|
||||
Editable editable = mEdit.getText();
|
||||
int start = mEdit.getSelectionStart();
|
||||
//判定是否是中文的正则表达式 [\\u4e00-\\u9fa5]判断一个中文 [\\u4e00-\\u9fa5]+多个中文
|
||||
String reg = "[\\u4e00-\\u9fa5]";
|
||||
if (primaryCode == -1) {// 省份简称与数字键盘切换
|
||||
if (mEdit.getText().toString().matches(reg)) {
|
||||
changeKeyboard(true);
|
||||
}
|
||||
} else if (primaryCode == -3) {
|
||||
if (editable != null && editable.length() > 0) {
|
||||
//没有输入内容时软键盘重置为省份简称软键盘
|
||||
if (editable.length() == 1) {
|
||||
changeKeyboard(false);
|
||||
}
|
||||
if (start > 0) {
|
||||
editable.delete(start - 1, start);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
editable.insert(start, Character.toString((char) primaryCode));
|
||||
// 判断第一个字符是否是中文,是,则自动切换到数字软键盘
|
||||
if (mEdit.getText().toString().matches(reg)) {
|
||||
changeKeyboard(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 指定切换软键盘 isNumber false表示要切换为省份简称软键盘 true表示要切换为数字软键盘
|
||||
*/
|
||||
private void changeKeyboard(boolean isNumber) {
|
||||
if (isNumber) {
|
||||
mKeyboardView.setKeyboard(numberKeyboard);
|
||||
} else {
|
||||
mKeyboardView.setKeyboard(provinceKeyboard);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 软键盘展示状态
|
||||
*/
|
||||
public boolean isShow() {
|
||||
return mKeyboardView.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 软键盘展示
|
||||
*/
|
||||
public void showKeyboard() {
|
||||
int visibility = mKeyboardView.getVisibility();
|
||||
if (visibility == View.GONE || visibility == View.INVISIBLE) {
|
||||
mKeyboardView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 软键盘隐藏
|
||||
*/
|
||||
public void hideKeyboard() {
|
||||
int visibility = mKeyboardView.getVisibility();
|
||||
if (visibility == View.VISIBLE) {
|
||||
mKeyboardView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁掉系统软键盘
|
||||
*/
|
||||
public void hideSoftInputMethod() {
|
||||
mActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
int currentVersion = android.os.Build.VERSION.SDK_INT;
|
||||
String methodName = null;
|
||||
if (currentVersion >= 16) {
|
||||
// 4.2
|
||||
methodName = "setShowSoftInputOnFocus";
|
||||
} else if (currentVersion >= 14) {
|
||||
// 4.0
|
||||
methodName = "setSoftInputShownOnFocus";
|
||||
}
|
||||
if (methodName == null) {
|
||||
mEdit.setInputType(InputType.TYPE_NULL);
|
||||
} else {
|
||||
Class<EditText> cls = EditText.class;
|
||||
Method setShowSoftInputOnFocus;
|
||||
try {
|
||||
setShowSoftInputOnFocus = cls.getMethod(methodName, boolean.class);
|
||||
setShowSoftInputOnFocus.setAccessible(true);
|
||||
setShowSoftInputOnFocus.invoke(mEdit, false);
|
||||
} catch (NoSuchMethodException e) {
|
||||
mEdit.setInputType(InputType.TYPE_NULL);
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
126
app/src/main/java/utils/Md5.java
Normal file
126
app/src/main/java/utils/Md5.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class Md5 {
|
||||
public static String md5(String string) {
|
||||
if (TextUtils.isEmpty(string)) {
|
||||
return "";
|
||||
}
|
||||
MessageDigest md5 = null;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] bytes = md5.digest(string.getBytes());
|
||||
String result = "";
|
||||
for (byte b : bytes) {
|
||||
String temp = Integer.toHexString(b & 0xff);
|
||||
if (temp.length() == 1) {
|
||||
temp = "0" + temp;
|
||||
}
|
||||
result += temp;
|
||||
}
|
||||
return result;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
// 计算文件的 MD5 值
|
||||
public static String md5(File file) {
|
||||
if (file == null || !file.isFile() || !file.exists()) {
|
||||
return "";
|
||||
}
|
||||
FileInputStream in = null;
|
||||
String result = "";
|
||||
byte buffer[] = new byte[8192];
|
||||
int len;
|
||||
try {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
in = new FileInputStream(file);
|
||||
while ((len = in.read(buffer)) != -1) {
|
||||
md5.update(buffer, 0, len);
|
||||
}
|
||||
byte[] bytes = md5.digest();
|
||||
|
||||
for (byte b : bytes) {
|
||||
String temp = Integer.toHexString(b & 0xff);
|
||||
if (temp.length() == 1) {
|
||||
temp = "0" + temp;
|
||||
}
|
||||
result += temp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(null!=in){
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static String md55(File file) {
|
||||
String result = "";
|
||||
FileInputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(file);
|
||||
MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.update(byteBuffer);
|
||||
byte[] bytes = md5.digest();
|
||||
for (byte b : bytes) {
|
||||
String temp = Integer.toHexString(b & 0xff);
|
||||
if (temp.length() == 1) {
|
||||
temp = "0" + temp;
|
||||
}
|
||||
result += temp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (null != in) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String md5(String string, String slat) {
|
||||
if (TextUtils.isEmpty(string)) {
|
||||
return "";
|
||||
}
|
||||
MessageDigest md5 = null;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] bytes = md5.digest((string + slat).getBytes());
|
||||
String result = "";
|
||||
for (byte b : bytes) {
|
||||
String temp = Integer.toHexString(b & 0xff);
|
||||
if (temp.length() == 1) {
|
||||
temp = "0" + temp;
|
||||
}
|
||||
result += temp;
|
||||
}
|
||||
return result;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String secret="O]dWlJ,[*g)%k\"?q!`+~g6=Co!`cQvV>>Ilvw";
|
||||
}
|
||||
78
app/src/main/java/utils/MyPhoneValue.java
Normal file
78
app/src/main/java/utils/MyPhoneValue.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
public class MyPhoneValue {
|
||||
|
||||
public static String getMacAddress="";
|
||||
|
||||
public static int getDecorHeight(Context context){
|
||||
Rect frame = new Rect();
|
||||
Activity aty=(Activity) context;
|
||||
aty.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
|
||||
int statusBarHeight = frame.top;
|
||||
return statusBarHeight;
|
||||
}
|
||||
public static int getScreenHeight(Context context){
|
||||
Activity aty=(Activity)context;
|
||||
DisplayMetrics metric = new DisplayMetrics();
|
||||
aty.getWindowManager().getDefaultDisplay().getMetrics(metric);
|
||||
int height = metric.heightPixels;
|
||||
|
||||
return height;
|
||||
}
|
||||
public static int getScreeWidth(Context context){
|
||||
Activity aty=(Activity)context;
|
||||
DisplayMetrics metric = new DisplayMetrics();
|
||||
aty.getWindowManager().getDefaultDisplay().getMetrics(metric);
|
||||
int width = metric.widthPixels;
|
||||
return width;
|
||||
}
|
||||
|
||||
public static String getSdkVersion() {
|
||||
return android.os.Build.VERSION.RELEASE;
|
||||
}
|
||||
public static int[] getSDKVersion() {
|
||||
String a= android.os.Build.VERSION.RELEASE;//4.0.4
|
||||
String[] m=a.split("\\.");//用点分开必须加双斜杠
|
||||
int[] n=new int[m.length];
|
||||
for (int i=0;i<m.length;i++){
|
||||
n[i]=Integer.parseInt(m[i]);
|
||||
}
|
||||
return n;}
|
||||
public static int getStatusBarHeight(Context context) {
|
||||
Class<?> c = null;
|
||||
|
||||
Object obj = null;
|
||||
|
||||
Field field = null;
|
||||
|
||||
int x = 0, sbar = 0;
|
||||
|
||||
try {
|
||||
|
||||
c = Class.forName("com.android.internal.R$dimen");
|
||||
|
||||
obj = c.newInstance();
|
||||
|
||||
field = c.getField("status_bar_height");
|
||||
|
||||
x = Integer.parseInt(field.get(obj).toString());
|
||||
|
||||
sbar = context.getResources().getDimensionPixelSize(x);
|
||||
|
||||
} catch (Exception e1) {
|
||||
|
||||
e1.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return sbar;
|
||||
}
|
||||
}
|
||||
24
app/src/main/java/utils/ProviderUtil.java
Normal file
24
app/src/main/java/utils/ProviderUtil.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class ProviderUtil {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用于解决provider冲突的util
|
||||
*
|
||||
* Author: nanchen
|
||||
* Email: liushilin520@foxmail.com
|
||||
* Date: 2017-03-22 18:55
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public static String getFileProviderName(Context context){
|
||||
return context.getPackageName()+".provider";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
99
app/src/main/java/utils/QRCodeUtil.java
Normal file
99
app/src/main/java/utils/QRCodeUtil.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class QRCodeUtil {
|
||||
|
||||
/**
|
||||
* 创建二维码位图
|
||||
*
|
||||
* @param content 字符串内容(支持中文)
|
||||
* @param width 位图宽度(单位:px)
|
||||
* @param height 位图高度(单位:px)
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public static Bitmap createQRCodeBitmap(String content, int width, int height){
|
||||
return createQRCodeBitmap(content, width, height, "UTF-8", "H", "2", Color.BLACK, Color.WHITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建二维码位图 (支持自定义配置和自定义样式)
|
||||
*
|
||||
* @param content 字符串内容
|
||||
* @param width 位图宽度,要求>=0(单位:px)
|
||||
* @param height 位图高度,要求>=0(单位:px)
|
||||
* @param character_set 字符集/字符转码格式 (支持格式:{@link })。传null时,zxing源码默认使用 "ISO-8859-1"
|
||||
* @param error_correction 容错级别 (支持级别:{@link })。传null时,zxing源码默认使用 "L"
|
||||
* @param margin 空白边距 (可修改,要求:整型且>=0), 传null时,zxing源码默认使用"4"。
|
||||
* @param color_black 黑色色块的自定义颜色值
|
||||
* @param color_white 白色色块的自定义颜色值
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public static Bitmap createQRCodeBitmap(String content, int width, int height,
|
||||
@Nullable String character_set, @Nullable String error_correction, @Nullable String margin,
|
||||
@ColorInt int color_black, @ColorInt int color_white){
|
||||
|
||||
/** 1.参数合法性判断 */
|
||||
if(TextUtils.isEmpty(content)){ // 字符串内容判空
|
||||
return null;
|
||||
}
|
||||
|
||||
if(width < 0 || height < 0){ // 宽和高都需要>=0
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
/** 2.设置二维码相关配置,生成BitMatrix(位矩阵)对象 */
|
||||
Hashtable<EncodeHintType, String> hints = new Hashtable<>();
|
||||
|
||||
if(!TextUtils.isEmpty(character_set)) {
|
||||
hints.put(EncodeHintType.CHARACTER_SET, character_set); // 字符转码格式设置
|
||||
}
|
||||
|
||||
if(!TextUtils.isEmpty(error_correction)){
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, error_correction); // 容错级别设置
|
||||
}
|
||||
|
||||
if(!TextUtils.isEmpty(margin)){
|
||||
hints.put(EncodeHintType.MARGIN, margin); // 空白边距设置
|
||||
}
|
||||
BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
|
||||
/** 3.创建像素数组,并根据BitMatrix(位矩阵)对象为数组元素赋颜色值 */
|
||||
int[] pixels = new int[width * height];
|
||||
for(int y = 0; y < height; y++){
|
||||
for(int x = 0; x < width; x++){
|
||||
if(bitMatrix.get(x, y)){
|
||||
pixels[y * width + x] = color_black; // 黑色色块像素设置
|
||||
} else {
|
||||
pixels[y * width + x] = color_white; // 白色色块像素设置
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 4.创建Bitmap对象,根据像素数组设置Bitmap每个像素点的颜色值,之后返回Bitmap对象 */
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bitmap;
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
404
app/src/main/java/utils/SelectPicDanimicActivity.java
Normal file
404
app/src/main/java/utils/SelectPicDanimicActivity.java
Normal file
@@ -0,0 +1,404 @@
|
||||
package utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.sl.house_property.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class SelectPicDanimicActivity extends Activity implements OnClickListener {
|
||||
private TextView btn_take_photo, btn_pick_photo, btn_cancel;
|
||||
private String fileolod1 = "cameraidface.jpg";
|
||||
private String fileolod2 = "cameraidback.jpg";
|
||||
private String fileolod33 = "cameraidworkface.jpg";
|
||||
private String fileolod44 = "cameraidworkback.jpg";
|
||||
private String filelodother = "otherphoto.jpg";
|
||||
private String fileolod = "";
|
||||
private LinearLayout layout;
|
||||
private Intent intent;
|
||||
private static final int PHOTO_REQUEST_CAMERA = 1;// 拍照
|
||||
private static final int PHOTO_REQUEST_GALLERY = 2;// 从相册中选择
|
||||
private static final int PHOTO_REQUEST_CUT = 3;// 结果
|
||||
private int photeid;
|
||||
private boolean crop;//裁剪
|
||||
private int cropx, cropy;//裁剪的高和宽
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_select_pic_danimic);
|
||||
final String permission = Manifest.permission.CAMERA; //相机权限
|
||||
final String permission1 = Manifest.permission.WRITE_EXTERNAL_STORAGE; //写入数据权限
|
||||
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(this, permission1) != PackageManager.PERMISSION_GRANTED) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 2);
|
||||
}
|
||||
}
|
||||
intent = getIntent();
|
||||
btn_take_photo = (Button) this.findViewById(R.id.btn_take_photo);
|
||||
btn_pick_photo = (Button) this.findViewById(R.id.btn_pick_photo);
|
||||
btn_cancel = (Button) this.findViewById(R.id.btn_cancel);
|
||||
layout = (LinearLayout) findViewById(R.id.pop_layout);
|
||||
// 添加按钮监听
|
||||
btn_cancel.setOnClickListener(this);
|
||||
btn_pick_photo.setOnClickListener(this);
|
||||
btn_take_photo.setOnClickListener(this);
|
||||
Window win = getWindow();
|
||||
win.getDecorView().setPadding(0, 0, 0, 0);
|
||||
WindowManager.LayoutParams lp = win.getAttributes();
|
||||
lp.width = WindowManager.LayoutParams.FILL_PARENT;//设置弹框的边界
|
||||
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
win.setAttributes(lp);
|
||||
|
||||
photeid
|
||||
= getIntent().getIntExtra("photoid", 0);
|
||||
String string = "/" + System.currentTimeMillis();
|
||||
switch (photeid) {
|
||||
case 0:
|
||||
break;
|
||||
/*case R.id.iv_card_face:
|
||||
fileolod=Environment.getExternalStorageDirectory().getPath()+string+fileolod1;
|
||||
break;
|
||||
case R.id.iv_card_back:
|
||||
fileolod=Environment.getExternalStorageDirectory().getPath()+string+fileolod2;
|
||||
break;
|
||||
case R.id.iv_card_work_face:
|
||||
fileolod= Environment.getExternalStorageDirectory().getPath()+string+fileolod33;
|
||||
break;
|
||||
case R.id.iv_card_work_back:
|
||||
fileolod= Environment.getExternalStorageDirectory().getPath()+string+fileolod44;
|
||||
break;*/
|
||||
default:
|
||||
crop = getIntent().getBooleanExtra("crop", false);
|
||||
cropx = getIntent().getIntExtra("cropx", 1);
|
||||
cropy = getIntent().getIntExtra("cropy", 2);
|
||||
fileolod = Environment.getExternalStorageDirectory().getPath() + string + filelodother;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
finish();//消失
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode != RESULT_OK) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
switch (requestCode) {
|
||||
case 1:
|
||||
/* if(photeid==R.id.iv_card_face||photeid==R.id.iv_card_back){
|
||||
Intent intent=new Intent();
|
||||
intent.putExtra("path",fileolod);
|
||||
setResult(photeid,intent);
|
||||
finish();}
|
||||
if(photeid==R.id.iv_card_work_face ||photeid==R.id.iv_card_work_back) {
|
||||
File temp = new File(fileolod);
|
||||
startPhotoZoom(Uri.fromFile(temp),photeid);
|
||||
}
|
||||
|
||||
else{*/
|
||||
if (crop) {//裁剪
|
||||
File temp = new File(fileolod);
|
||||
startPhotoZoom(Uri.fromFile(temp), photeid);
|
||||
}
|
||||
if (!crop) {
|
||||
Intent intent = new Intent();//不裁剪,直接返回
|
||||
intent.putExtra("path", fileolod);
|
||||
setResult(photeid, intent);
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
/*}*/
|
||||
break;
|
||||
case 2:
|
||||
|
||||
|
||||
/*if(photeid==R.id.iv_card_face||photeid==R.id.iv_card_back){
|
||||
Intent intent2=new Intent();
|
||||
String picturePath="";
|
||||
|
||||
picturePath=BitmapTools.getPathByUri(SelectPicDanimicActivity.this,data.getData());
|
||||
|
||||
intent2.putExtra("path",picturePath );
|
||||
setResult(photeid,intent2);
|
||||
finish();
|
||||
}
|
||||
if(photeid==R.id.iv_card_work_face ||photeid==R.id.iv_card_work_back) {
|
||||
String picturePath=BitmapTools.getPathByUri(SelectPicDanimicActivity.this,data.getData());//获得路径
|
||||
if(picturePath==null){
|
||||
CommonUtils.toastUtil(getString(R.string.cannotgetpath), SelectPicDanimicActivity.this);
|
||||
finish();
|
||||
}
|
||||
|
||||
if(!(picturePath==null)) {File tempFile = new File(picturePath);
|
||||
// intent.putExtra("output", Uri.fromFile(tempFile));
|
||||
startPhotoZoom(Uri.fromFile(tempFile),photeid);}
|
||||
}
|
||||
|
||||
else{*/
|
||||
if (crop) {
|
||||
String picturePath = BitmapTools.getPathByUri(SelectPicDanimicActivity.this, data.getData());//获得路径
|
||||
if (picturePath == null) {
|
||||
Toast.makeText(SelectPicDanimicActivity.this, "Cannot get path", Toast.LENGTH_SHORT).show();
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
if (!(picturePath == null)) {
|
||||
File tempFile = new File(picturePath);
|
||||
startPhotoZoom(Uri.fromFile(tempFile), photeid);
|
||||
}
|
||||
|
||||
}
|
||||
if (!crop) {
|
||||
Intent intent2 = new Intent();
|
||||
String picturePath = "";
|
||||
|
||||
picturePath = BitmapTools.getPathByUri(SelectPicDanimicActivity.this, data.getData());
|
||||
|
||||
intent2.putExtra("path", picturePath);
|
||||
setResult(photeid, intent2);
|
||||
finish();
|
||||
}
|
||||
|
||||
/*}*/
|
||||
break;
|
||||
case 200:
|
||||
if (data.getData() == null) {
|
||||
data.setData(getTempUri());//华为手机调用不了,必须写上这一句
|
||||
}
|
||||
setResult(photeid, data);
|
||||
finish();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
final String permission = Manifest.permission.CAMERA; //相机权限
|
||||
final String permission1 = Manifest.permission.WRITE_EXTERNAL_STORAGE; //写入数据权限
|
||||
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(this, permission1) != PackageManager.PERMISSION_GRANTED) { //先判断是否被赋予权限,没有则申请权限
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) { //给出权限申请说明
|
||||
/* ActivityCompat.requestPermissions(SelectPicDanimicActivity.this, new String[]{permission, permission1}, 1);
|
||||
ActivityCompat.requestPermissions(SelectPicDanimicActivity.this, new String[]{permission1}, 1);*/
|
||||
Toast.makeText(SelectPicDanimicActivity.this, "No pemission", Toast.LENGTH_SHORT).show();
|
||||
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_take_photo:
|
||||
try {
|
||||
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri
|
||||
.fromFile(new File(fileolod)));
|
||||
startActivityForResult(intent, 1);
|
||||
|
||||
|
||||
//拍照我们用Action为MediaStore.ACTION_IMAGE_CAPTURE,
|
||||
//有些人使用其他的Action但我发现在有些机子中会出问题,所以优先选择这个
|
||||
|
||||
|
||||
/* Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(
|
||||
Environment.getExternalStorageDirectory(), "temp.jpg")));
|
||||
System.out.println("=============" + Environment.getExternalStorageDirectory());*/
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case R.id.btn_pick_photo:
|
||||
try {
|
||||
//选择照片的时候也一样,我们用Action为Intent.ACTION_GET_CONTENT,
|
||||
//有些人使用其他的Action但我发现在有些机子中会出问题,所以优先选择这个
|
||||
/* Intent intent = new Intent();
|
||||
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(intent, 2);*/
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
"image/*");
|
||||
// intent.setType("image/*");
|
||||
/* intent.putExtra("return-data", false);*/
|
||||
startActivityForResult(intent, 2);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
break;
|
||||
case R.id.btn_cancel:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 裁剪图片方法实现
|
||||
*
|
||||
* @param uri
|
||||
*/
|
||||
public void startPhotoZoom(Uri uri, int nubmer) {
|
||||
//String path= BitmapTools.getRealFilePath(SelectPicDanimicActivity.this,uri);
|
||||
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||
intent.setDataAndType(uri, "image/*");
|
||||
Bitmap bitmap = BitmapTools.decodeUriAsBitmap(SelectPicDanimicActivity.this, uri, 1);
|
||||
if (bitmap == null) return;
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
int may = width <= height ? width : height;
|
||||
|
||||
//下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
|
||||
intent.putExtra("crop", "true");
|
||||
// aspectX aspectY 是宽高的比例
|
||||
switch (nubmer) {
|
||||
/* case R.id.iv_card_work_face:
|
||||
intent.putExtra("aspectX", 10);
|
||||
intent.putExtra("aspectY",10);
|
||||
//intent.putExtra("path", path);
|
||||
// outputX outputY 是裁剪图片宽高
|
||||
*//* intent.putExtra("outputX", 300);
|
||||
intent.putExtra("outputY", 300);*//*
|
||||
double xy2=10/10;
|
||||
intent.putExtra("outputX", (int)(may*xy2));
|
||||
intent.putExtra("outputY", may);
|
||||
break;
|
||||
case R.id.iv_card_work_back:
|
||||
intent.putExtra("aspectX", 27);
|
||||
intent.putExtra("aspectY",34);
|
||||
//intent.putExtra("path", path);
|
||||
// outputX outputY 是裁剪图片宽高
|
||||
*//* intent.putExtra("outputX", 270);
|
||||
intent.putExtra("outputY", 340);*//*
|
||||
double xy1=27.0/34.0;
|
||||
intent.putExtra("outputX",(int)(may*xy1));
|
||||
intent.putExtra("outputY", (int)(may));
|
||||
break;*/
|
||||
default:
|
||||
int xx = 100;
|
||||
if (cropx > 10 || cropy > 10) {
|
||||
xx = 10;
|
||||
}
|
||||
double xy = ((double) cropx / (double) cropy);
|
||||
intent.putExtra("aspectX", cropx);
|
||||
intent.putExtra("aspectY", cropy);
|
||||
//intent.putExtra("path", path);
|
||||
// outputX outputY 是裁剪图片宽高
|
||||
/* intent.putExtra("outputX", cropx*xx);
|
||||
intent.putExtra("outputY", cropy*xx);*/
|
||||
|
||||
/*intent.putExtra("outputX", (int)(may*xy));
|
||||
intent.putExtra("outputY", (int)(may));*/
|
||||
intent.putExtra("outputX", (cropx));
|
||||
intent.putExtra("outputY", (cropy));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* String string="/"+System.currentTimeMillis();
|
||||
String fileolodone=Environment.getExternalStorageDirectory().getPath()+string+"tepm.jpg";
|
||||
File tempFile = new File(fileolodone);
|
||||
if(!tempFile.exists()){
|
||||
tempFile.mkdir();
|
||||
}*/
|
||||
//intent.putExtra("output", Uri.fromFile(tempFile));// 保存到原文件*/
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());//图像输出
|
||||
/* String tempFile=fileolod;
|
||||
Uri imageUri = Uri.parse(tempFile);*/
|
||||
//intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
|
||||
intent.putExtra("outputFormat", "JPEG");// 返回格式
|
||||
intent.putExtra("return-data", false);//大图返回uri,小图返回data,data为true是小图,大图是false
|
||||
intent.putExtra("noFaceDetection", true); // no face detection
|
||||
intent.putExtra("scale", true);//黑边
|
||||
intent.putExtra("scaleUpIfNeeded", true);//黑边
|
||||
// intent.putExtra(MediaStore.EXTRA_OUTPUT, tempFile);
|
||||
startActivityForResult(intent, 200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Uri getTempUri() {
|
||||
return Uri.fromFile(getTempFile());
|
||||
}
|
||||
|
||||
private File getTempFile() {
|
||||
if (isSDCARDMounted()) {
|
||||
File f = new File(Environment.getExternalStorageDirectory(),
|
||||
"tepm.jpg");
|
||||
try {
|
||||
f.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
Toast.makeText(SelectPicDanimicActivity.this, "No pemission", Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
return f;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSDCARDMounted() {
|
||||
String status = Environment.getExternalStorageState();
|
||||
if (status.equals(Environment.MEDIA_MOUNTED))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
BitmapTools.deleteFile(new File(fileolod));
|
||||
}
|
||||
}
|
||||
23
app/src/main/java/utils/SetBigMap.java
Normal file
23
app/src/main/java/utils/SetBigMap.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Created by jiao on 2016/1/13.
|
||||
*/
|
||||
public class SetBigMap {
|
||||
public static Bitmap readBitMap(Context context, int resId){
|
||||
BitmapFactory.Options opt = new BitmapFactory.Options();
|
||||
opt.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||
opt.inPurgeable = true;
|
||||
opt.inInputShareable = true;
|
||||
opt.inInputShareable = true;
|
||||
//获取资源图片
|
||||
InputStream is = context.getResources().openRawResource(resId);
|
||||
return BitmapFactory.decodeStream(is,null,opt);
|
||||
}
|
||||
}
|
||||
156
app/src/main/java/utils/SharedPreferencesUtils.java
Normal file
156
app/src/main/java/utils/SharedPreferencesUtils.java
Normal file
@@ -0,0 +1,156 @@
|
||||
package utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
public class SharedPreferencesUtils {
|
||||
|
||||
Context context;
|
||||
String name;
|
||||
// public final static String KEY_NAME_USER = "KEY_NAME_USER";
|
||||
private static SharedPreferencesUtils shpu;
|
||||
|
||||
public SharedPreferencesUtils(Context context, String name) {
|
||||
this.context = context;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static SharedPreferencesUtils getInstance(Context context){
|
||||
if(shpu==null){
|
||||
return new SharedPreferencesUtils(context, "SharedPreUtil");
|
||||
}
|
||||
return shpu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key和预期的value类型获取value的值
|
||||
*
|
||||
* @param key
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public <T> T getValue(String key, Class<T> clazz) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("请先调用带有context,name参数的构造!");
|
||||
}
|
||||
SharedPreferences sp = this.context.getSharedPreferences(this.name, Context.MODE_PRIVATE);
|
||||
return getValue(key, clazz, sp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对复杂类型存储<对象>
|
||||
*
|
||||
* @param key
|
||||
* @param val
|
||||
*/
|
||||
public void setObject(String key, Object object) {
|
||||
SharedPreferences sp = this.context.getSharedPreferences(this.name, Context.MODE_PRIVATE);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = null;
|
||||
try {
|
||||
|
||||
out = new ObjectOutputStream(baos);
|
||||
out.writeObject(object);
|
||||
String objectVal = new String(Base64.encode(baos.toByteArray(), Base64.DEFAULT));
|
||||
Editor editor = sp.edit();
|
||||
editor.putString(key, objectVal);
|
||||
editor.commit();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (baos != null) {
|
||||
baos.close();
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getObject(String key, Class<T> clazz) {
|
||||
SharedPreferences sp = this.context.getSharedPreferences(this.name, Context.MODE_PRIVATE);
|
||||
if (sp.contains(key)) {
|
||||
String objectVal = sp.getString(key, null);
|
||||
byte[] buffer = Base64.decode(objectVal, Base64.DEFAULT);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
ObjectInputStream ois = null;
|
||||
try {
|
||||
ois = new ObjectInputStream(bais);
|
||||
T t = (T) ois.readObject();
|
||||
return t;
|
||||
} catch (StreamCorruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bais != null) {
|
||||
bais.close();
|
||||
}
|
||||
if (ois != null) {
|
||||
ois.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对于外部不可见的过渡方法
|
||||
*
|
||||
* @param key
|
||||
* @param clazz
|
||||
* @param sp
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T getValue(String key, Class<T> clazz, SharedPreferences sp) {
|
||||
T t;
|
||||
try {
|
||||
|
||||
t = clazz.newInstance();
|
||||
|
||||
if (t instanceof Integer) {
|
||||
return (T) Integer.valueOf(sp.getInt(key, 0));
|
||||
} else if (t instanceof String) {
|
||||
return (T) sp.getString(key, "");
|
||||
} else if (t instanceof Boolean) {
|
||||
return (T) Boolean.valueOf(sp.getBoolean(key, false));
|
||||
} else if (t instanceof Long) {
|
||||
return (T) Long.valueOf(sp.getLong(key, 0L));
|
||||
} else if (t instanceof Float) {
|
||||
return (T) Float.valueOf(sp.getFloat(key, 0L));
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("system", "类型输入错误或者复杂类型无法解析[" + e.getMessage() + "]");
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("system", "类型输入错误或者复杂类型无法解析[" + e.getMessage() + "]");
|
||||
}
|
||||
Log.e("system", "无法找到" + key + "对应的值");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
33
app/src/main/java/utils/SoftKeyboardUtil.java
Normal file
33
app/src/main/java/utils/SoftKeyboardUtil.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SoftKeyboardUtil {
|
||||
|
||||
/**
|
||||
* 隐藏软键盘(只适用于Activity,不适用于Fragment)
|
||||
*/
|
||||
public static void hideSoftKeyboard(Activity activity) {
|
||||
View view = activity.getCurrentFocus();
|
||||
if (view != null) {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏软键盘(可用于Activity,Fragment)
|
||||
*/
|
||||
public static void hideSoftKeyboard(Context context, List<View> viewList) {
|
||||
if (viewList == null) return;
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
for (View v : viewList) {
|
||||
inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
73
app/src/main/java/utils/TestManager.java
Normal file
73
app/src/main/java/utils/TestManager.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package utils;
|
||||
|
||||
|
||||
/**
|
||||
* Created by pengfengwang on 2017/1/15.
|
||||
*/
|
||||
|
||||
public class TestManager {
|
||||
public static final String NIGHT_SKIN = "night.skin";
|
||||
public static final String[] SKIN_NAMES = {
|
||||
"官方红", "官方白", "自选颜色"
|
||||
};
|
||||
public static final String[] SKIN_LIBS = {
|
||||
"", "white.skin", "color.skin"
|
||||
};
|
||||
/*public static final int[] BANNER_IMAGES = {
|
||||
R.drawable.home_banner_1, R.drawable.home_banner_2, R.drawable.home_banner_3,
|
||||
R.drawable.home_banner_4, R.drawable.home_banner_5, R.drawable.home_banner_6,
|
||||
R.drawable.home_banner_7, R.drawable.home_banner_8, R.drawable.home_banner_9,
|
||||
R.drawable.home_banner_10, R.drawable.home_banner_11, R.drawable.home_banner_12
|
||||
};*/
|
||||
|
||||
public static final String[] LABELS = {
|
||||
"推荐歌曲", "独家放送", "最新音乐", "推荐MV", "主播电台"
|
||||
};
|
||||
/*public static final int[] LABELS_INDICATOR = {
|
||||
R.drawable.ic_indicator_0, R.drawable.ic_indicator_1, R.drawable.ic_indicator_2,
|
||||
R.drawable.ic_indicator_3, R.drawable.ic_indicator_4
|
||||
};*/
|
||||
public static final String[] TITLES = {
|
||||
"海明威", "小说", "中国文学",
|
||||
"村上春树", "王小波", "余华",
|
||||
"鲁迅", "米兰·昆德拉", "外国文学",
|
||||
"经典", "童话", "儿童文学",
|
||||
"名著", "缘分", "杜拉斯",
|
||||
"文学", "散文", "诗歌",
|
||||
"张爱玲", "钱钟书", "诗词",
|
||||
"港台", "随笔", "日本文学",
|
||||
"杂文", "古典文学", "村上春树",
|
||||
"米兰·昆德拉", "童话", "张爱玲"};
|
||||
public static final String[] SUBTITLES = {
|
||||
"美国作家和记者,被认为是20世纪最著名的小说家之一。出生于美国伊利诺伊州芝加哥市郊区的奥克帕克,晚年在爱达荷州凯彻姆的家中自杀身亡。海明威一生中的感情错综复杂,先后结过四次婚,是美国“迷惘的一代”(Lost Generation)作家中的代表人物,作品中对人生、世界、社会都表现出了迷茫和彷徨。",
|
||||
"以刻画人物形象为中心,通过完整的故事情节和环境描写来反映社会生活的文学体裁。",
|
||||
"中国文学分为古典文学、现代文学与当代文学。古典文学以唐宋诗词及四大名著为代表,现代文学以鲁迅小说为代表,当代文学则以具有独立思想的中国自由文学为标志。",
|
||||
"村上春树(1949年1月12日—),日本现代小说家,生于京都伏见区。毕业于早稻田大学第一文学部演剧科。",
|
||||
"王小波(1952-1997),中国当代学者、作家。代表作品有《黄金时代》、《白银时代》、《青铜时代》、《黑铁时代》等。",
|
||||
"余华,1960年4月3日生于浙江杭州,当代作家。中国作家协会第九届全国委员会委员。",
|
||||
"鲁迅(1881年9月25日-1936年10月19日),原名周樟寿,后改名周树人,字豫山,后改豫才,“鲁迅”是他1918年发表《狂人日记》时所用的笔名,也是他影响最为广泛的笔名,浙江绍兴人。著名文学家、思想家,五四新文化运动的重要参与者,中国现代文学的奠基人。",
|
||||
"米兰·昆德拉(Milan Kundera),小说家,出生于捷克斯洛伐克布尔诺,自1975年起,在法国定居。长篇小说《玩笑》、《生活在别处》、《告别圆舞曲》、《笑忘录》、《不能承受的生命之轻》和《不朽》,以及短篇小说集《好笑的爱》是以作者母语捷克文写成。而他最新出版的长篇小说《慢》、《身份》和《无知》及随笔集《小说的艺术》和《被背叛的遗嘱》是以法文写成。《雅克和他的主人》系作者戏剧代表作。",
|
||||
"外国文学是指除中国文学以外的世界各国文学。世界文学源远流长,绚丽多姿。早在几千年以前,在人类文明的发祥地就已经孕育出了人类最初的文学瑰宝。在而后的岁月里,东西方许多民族都出现过杰出的文学大师和众多的名家名著。人们热爱和珍视这些作家及其作品,是因为优秀的文学作品体现了人类对客观世界的认识,显示了人类成长的精神轨迹,并给世世代代的人们以审美的愉悦。",
|
||||
"经典读音jīngdiǎn英文名classics:指具有典范性、权威性的;经久不衰的万世之作;经过历史选择出来的“最有价值经典的”;最能表现本行业的精髓的;最具代表性的;最完美的作品。",
|
||||
"《童话》是光良演唱的一首歌曲,由光良作词、作曲,收录在光良2005年1月21日发行的同名专辑《童话》中[1-2] 。《童话》是光良的代表作品之一。",
|
||||
"《儿童文学》是由共青团中央和中国作家协会于1963年共同创办的杂志,被誉为“中国儿童文学的一面旗帜”。目前为月刊,月发行量110多万份。",
|
||||
"名著就是指具有较高艺术价值和知名度,且包含永恒主题和经典的人物形象,能够经过时间考验经久不衰,被广泛认识以及流传的文字作品。能给人们以警世和深远影响的著作,以及对世人生存环境的感悟。",
|
||||
"缘分,它是出自佛教的一个宗教概念,儒家与道家并不讲缘分,也不讲你与我有缘之说。",
|
||||
"玛格丽特·杜拉斯1914年出生于法属印度支那。十八岁时定居巴黎。自1942年开始发表小说,1950年的《抵挡太平洋的堤坝》使杜拉斯成名。这段时期的作品富有自传色彩。自1953年的《塔基尼亚的小马群》起,杜拉斯探索新的叙事语言,逐渐抹去小说情节,更强调主观感受和心理变化。1955—1965年是她创作上的高峰期,代表作有小说《如歌的中板》、《副领事》,以及剧本《广岛之恋》等。1984年发表《情人》,获当年龚古尔文学奖。",
|
||||
"文学是以语言文字为工具,形象化地反映客观现实、表现作家心灵世界的艺术,包括诗歌、散文、小说、剧本、寓言童话等,是文化的重要表现形式,以不同的形式即体裁,表现内心情感,再现一定时期和一定地域的社会生活。作为学科门类理解的文学,包括中国语言文学、外国语言文学及新闻传播学。",
|
||||
"散文是一种作者写自己经历见闻中的真情实感、灵活的文学体裁。",
|
||||
"用高度凝练的语言,形象表达作者丰富情感,集中反映社会生活并具有一定节奏和韵律的文学体裁。",
|
||||
"张爱玲,中国现代作家,原籍河北省唐山市,原名张煐。1920年9月30日出生在上海公共租界西区一幢没落贵族府邸。",
|
||||
"钱钟书(1910年-1998年),江苏无锡人,原名仰先,字哲良,后改名钟书,字默存,号槐聚,曾用笔名中书君,中国现代作家、文学研究家。",
|
||||
"诗词,是指以古体诗、近体诗和格律词为代表的中国古代传统诗歌。亦是汉字文化圈的特色之一。通常认为,诗较为适合“言志”,而词则更为适合“抒情”。",
|
||||
"香港电台(Radio Television Hong Kong,简称:RTHK),中文简称“港台”。现为商务及经济发展局辖下的部门,是香港广播史上首家广播机构,同时也是香港唯一的公共广播机构,亦是最具公信力的传媒机构之一。",
|
||||
"随笔,顾名思义:随笔一记,是散文的一个分支,是议论文的一个变体,兼有议论和抒情两种特性,通常篇幅短小,形式多样,写作者惯常用各种修辞手法曲折传达自己的见解和情感,语言灵动,婉而多讽,是言禁未开之社会较为流行的一种文体。随笔作为一种文学样式,是由法国散文家蒙田所创的。",
|
||||
"日本文学指的是以日本语写作的文学作品,横跨的时间大约有两千年。早期的文学作品受到中国文学一些的影响,但在后来日本也渐渐形成自有的文学风格和特色。19世纪日本重启港口与西方国家贸易及展开外交关系之后,西方文学也开始影响日本的作家,直到今天仍然得见其影响力。",
|
||||
"杂文是一种直接、迅速反映社会事变或动向的文艺性论文。特点是“杂而有文”,短小、锋利、隽永,富于文艺工作者色彩和诗的语言,具有独特的艺术感染力。在剧烈的社会斗争中,杂文是战斗的利器,比如鲁迅先生的杂文就如同“匕首”“投枪”直刺一切黑暗的心脏。在和平建设年代,它也能起到赞扬真善美,鞭挞假恶丑的针砭时弊的喉舌作用。比如《庄周买水》、《剃光头发微》等文章就是如此。",
|
||||
"古典文学泛指各民族的古代文学作品,是文学的一部分,是现代文学的发展基础,它是承上启下的,是文学发展史上不可缺少的部分。它是中国文学最根本的东西。 现在所谓的古典文学,也专指优秀的、有一定价值的古代文学作品。“古典”在拉丁文中是“第一流的、典范的”意思。欧洲文艺复兴时期,文艺理论家以古希腊、罗马的优秀作品为典范,称为古典文学。在中国,把从远古流传下来的原始歌谣和神话传说,直到五四以前大量的有一定价值的文学作品,叫古典文学。",
|
||||
"村上春树(1949年1月12日—),日本现代小说家,生于京都伏见区。毕业于早稻田大学第一文学部演剧科。",
|
||||
"米兰·昆德拉(Milan Kundera),小说家,出生于捷克斯洛伐克布尔诺,自1975年起,在法国定居。长篇小说《玩笑》、《生活在别处》、《告别圆舞曲》、《笑忘录》、《不能承受的生命之轻》和《不朽》,以及短篇小说集《好笑的爱》是以作者母语捷克文写成。而他最新出版的长篇小说《慢》、《身份》和《无知》及随笔集《小说的艺术》和《被背叛的遗嘱》是以法文写成。《雅克和他的主人》系作者戏剧代表作。",
|
||||
"《童话》是光良演唱的一首歌曲,由光良作词、作曲,收录在光良2005年1月21日发行的同名专辑《童话》中[1-2] 。《童话》是光良的代表作品之一。",
|
||||
"用高度凝练的语言,形象表达作者丰富情感,集中反映社会生活并具有一定节奏和韵律的文学体裁。"
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user