Arisono 9 лет назад
Родитель
Сommit
2023ac2b78

+ 266 - 247
WeiChat/src/main/java/com/xzjmyk/pm/activity/MyApplication.java

@@ -33,251 +33,270 @@ import org.apache.http.cookie.Cookie;
 import java.io.File;
 
 public class MyApplication extends Application {
-   
-	/**@注释:记录Cookie */
-
-	public  String JSESSION_B2B;
-	public static Cookie cookie;
-	
-	
-	private static MyApplication INSTANCE = null;
-
-	public static MyApplication getInstance() {
-		return INSTANCE;
-	}
-
-
-	@Override
-	public void onCreate() {
-		super.onCreate();
-		INSTANCE = this;
-		PreferenceUtils.putBoolean(this, Constants.IS_NOTIFICATION, false);//不进行通知
-		new Handler().postDelayed(new Runnable() {
-			@Override
-			public void run() {
-				//定位场景设置
-				MobclickAgent.setScenarioType(MyApplication.this, MobclickAgent.EScenarioType. E_UM_NORMAL);
-
-				SDKInitializer.initialize(getApplicationContext());
-				// 初始化数据库
-				SQLiteHelper.copyDatabaseFile(getApplicationContext());
-				// 初始化定位
-				getBdLocationHelper();
-				// 初始化App目录
-				initAppDir();
-				// 初始化图片加载
-				initImageLoader();
-			}
-		}, 1);
-		if (AppConfig.DEBUG) {
-			Log.d(AppConfig.TAG, "MyApplication onCreate");
-		}
-		if (AppConfig.DEBUG) {
-			StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
-			StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
-		}
-		// 初始化网络监听
-		mNetWorkObservable = new NetWorkObservable(this);
-	}
-
-	/**
-	 * 在程序内部关闭时,调用此方法
-	 */
-	public void destory() {
-		if (AppConfig.DEBUG) {
-			Log.d(AppConfig.TAG, "MyApplication destory");
-		}
-		// 结束百度定位
-		if (mBdLocationHelper != null) {
-			mBdLocationHelper.release();
-		}
-		// 关闭网络状态的监听
-		if (mNetWorkObservable != null) {
-			mNetWorkObservable.release();
-		}
-		// 清除图片加载
-		ImageLoader.getInstance().destroy();
-		//
-		releaseFastVolley();
-		// 释放数据库
-		// SQLiteHelper.release();
-		android.os.Process.killProcess(android.os.Process.myPid());
-	}
-
-	/********************* 百度地图定位服务 ************************/
-	private BdLocationHelper mBdLocationHelper;
-
-	public BdLocationHelper getBdLocationHelper() {
-		if (mBdLocationHelper == null) {
-			mBdLocationHelper = new BdLocationHelper(this);
-		}
-		return mBdLocationHelper;
-	}
-
-	/********************* 提供网络全局监听 ************************/
-	private NetWorkObservable mNetWorkObservable;
-
-	public boolean isNetworkActive() {
-		if (mNetWorkObservable != null) {
-			return mNetWorkObservable.isNetworkActive();
-		}
-		return true;
-	}
-
-	public void registerNetWorkObserver(NetWorkObservable.NetWorkObserver observer) {
-		if (mNetWorkObservable != null) {
-			mNetWorkObservable.registerObserver(observer);
-		}
-	}
-
-	public void unregisterNetWorkObserver(NetWorkObservable.NetWorkObserver observer) {
-		if (mNetWorkObservable != null) {
-			mNetWorkObservable.unregisterObserver(observer);
-		}
-	}
-
-	/* 文件缓存的目录 */
-	public String mAppDir;
-	public String mPicturesDir;
-	public String mVoicesDir;
-	public String mVideosDir;
-	public String mFilesDir;
-
-	private void initAppDir() {
-		File file = getExternalFilesDir(null);
-		if(file!=null) {
-			if (!file.exists()) {
-				file.mkdirs();
-			}
-			mAppDir = file.getAbsolutePath();
-		}
-
-		file = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
-		if(file!=null) {
-			if (!file.exists()) {
-				file.mkdirs();
-			}
-			mPicturesDir = file.getAbsolutePath();
-		}
-
-		file = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
-		if(file!=null) {
-			if (!file.exists()) {
-				file.mkdirs();
-			}
-			mVoicesDir = file.getAbsolutePath();
-		}
-		file = getExternalFilesDir(Environment.DIRECTORY_MOVIES);
-		if(file!=null) {
-			if (!file.exists()) {
-				file.mkdirs();
-			}
-			mVideosDir = file.getAbsolutePath();
-		}
-		file = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
-		if(file!=null) {
-			if (!file.exists()) {
-				file.mkdirs();
-			}
-		mFilesDir = file.getAbsolutePath();
-		}
-	}
-
-	/******************* 初始化图片加载 **********************/
-	// 显示的设置
-	public static DisplayImageOptions mNormalImageOptions;
-	public static DisplayImageOptions mAvatarRoundImageOptions;
-	public static DisplayImageOptions mAvatarNormalImageOptions;
-
-	private void initImageLoader() {
-		int memoryCacheSize = (int) (Runtime.getRuntime().maxMemory() / 5);
-		MemoryCacheAware<String, Bitmap> memoryCache;
-		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
-			memoryCache = new LruMemoryCache(memoryCacheSize);
-		} else {
-			memoryCache = new LRULimitedMemoryCache(memoryCacheSize);
-		}
-
-		mNormalImageOptions = new DisplayImageOptions.Builder().bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
-				.resetViewBeforeLoading(false).showImageForEmptyUri(com.xzjmyk.pm.activity.R.drawable.image_download_fail_icon)
-				.showImageOnFail(com.xzjmyk.pm.activity.R.drawable.image_download_fail_icon).build();
-
-		mAvatarRoundImageOptions = new DisplayImageOptions.Builder().bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
-				.displayer(new RoundedBitmapDisplayer(10)).resetViewBeforeLoading(true).showImageForEmptyUri(com.xzjmyk.pm.activity.R.drawable.avatar_normal)
-				.showImageOnFail(com.xzjmyk.pm.activity.R.drawable.avatar_normal).showImageOnLoading(com.xzjmyk.pm.activity.R.drawable.avatar_normal).build();
-
-		mAvatarNormalImageOptions = new DisplayImageOptions.Builder().bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
-				.resetViewBeforeLoading(true).showImageForEmptyUri(com.xzjmyk.pm.activity.R.drawable.avatar_normal).showImageOnFail(com.xzjmyk.pm.activity.R.drawable.avatar_normal)
-				.showImageOnLoading(com.xzjmyk.pm.activity.R.drawable.avatar_normal).build();
-
-		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).defaultDisplayImageOptions(mNormalImageOptions)
-				// .denyCacheImageMultipleSizesInMemory()
-				.discCache(new TotalSizeLimitedDiscCache(new File(mPicturesDir), 50 * 1024 * 1024))
-				// 最多缓存50M的图片
-				.discCacheFileNameGenerator(new Md5FileNameGenerator()).memoryCache(memoryCache).tasksProcessingOrder(QueueProcessingType.LIFO)
-				.threadPriority(Thread.NORM_PRIORITY - 2).threadPoolSize(4).build();
-		// Initialize ImageLoader with configuration.
-		ImageLoader.getInstance().init(config);
-	}
-
-	/********************* 提供全局配置 ************************/
-	private AppConfig mConfig;
-
-	public void setConfig(AppConfig config) {
-		mConfig = config;
-	}
-
-	public AppConfig getConfig() {
-		if (mConfig == null) {
-			mConfig = AppConfig.initConfig(getApplicationContext(), new ConfigBean());
-		}
-		return mConfig;
-	}
-
-	/***************** 提供全局的Volley ***************************/
-
-	private FastVolley mFastVolley;
-
-	public FastVolley getFastVolley() {
-		if (mFastVolley == null) {
-			synchronized (MyApplication.class) {
-				if (mFastVolley == null) {
-					mFastVolley = new FastVolley(this);
-					mFastVolley.start();
-				}
-			}
-		}
-		return mFastVolley;
-	}
-
-	private void releaseFastVolley() {
-		if (mFastVolley != null) {
-			mFastVolley.stop();
-		}
-	}
-
-	/*********************** 保存当前登陆用户的全局信息 ***************/
-	public String roomName;
-	public String mAccessToken;
-	public long mExpiresIn;
-	public int mUserStatus;
-	public boolean mUserStatusChecked = false;
-	public User mLoginUser = new User();// 当前登陆的用户
-	
-	/*********************** 保存其他用户坐标信息 ***************/
-
-	public String getJSESSION_B2B() {
-		return JSESSION_B2B;
-	}
-	public void setJSESSION_B2B(String jSESSION_B2B) {
-		JSESSION_B2B = jSESSION_B2B;
-	}
-
-	public static Cookie getCookie() {
-		return cookie;
-	}
-
-	public static void setCookie(Cookie cookie) {
-		MyApplication.cookie = cookie;
-	}
+
+    /**
+     * @注释:记录Cookie
+     */
+
+    public String JSESSION_B2B;
+    public static Cookie cookie;
+
+
+    private static MyApplication INSTANCE = null;
+
+    public static MyApplication getInstance() {
+        return INSTANCE;
+    }
+
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        INSTANCE = this;
+        PreferenceUtils.putBoolean(this, Constants.IS_NOTIFICATION, false);//不进行通知
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                //定位场景设置
+                MobclickAgent.setScenarioType(MyApplication.this, MobclickAgent.EScenarioType.E_UM_NORMAL);
+
+                SDKInitializer.initialize(getApplicationContext());
+                // 初始化数据库
+                SQLiteHelper.copyDatabaseFile(getApplicationContext());
+                // 初始化定位
+                getBdLocationHelper();
+                // 初始化App目录
+                initAppDir();
+                // 初始化图片加载
+                initImageLoader();
+            }
+        }, 1);
+        if (AppConfig.DEBUG) {
+            Log.d(AppConfig.TAG, "MyApplication onCreate");
+        }
+        if (AppConfig.DEBUG) {
+            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
+            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
+        }
+        // 初始化网络监听
+        mNetWorkObservable = new NetWorkObservable(this);
+    }
+
+    /**
+     * 在程序内部关闭时,调用此方法
+     */
+    public void destory() {
+        if (AppConfig.DEBUG) {
+            Log.d(AppConfig.TAG, "MyApplication destory");
+        }
+        // 结束百度定位
+        if (mBdLocationHelper != null) {
+            mBdLocationHelper.release();
+        }
+        // 关闭网络状态的监听
+        if (mNetWorkObservable != null) {
+            mNetWorkObservable.release();
+        }
+        // 清除图片加载
+        ImageLoader.getInstance().destroy();
+        //
+        releaseFastVolley();
+        // 释放数据库
+        // SQLiteHelper.release();
+        android.os.Process.killProcess(android.os.Process.myPid());
+    }
+
+    /*********************
+     * 百度地图定位服务
+     ************************/
+    private BdLocationHelper mBdLocationHelper;
+
+    public BdLocationHelper getBdLocationHelper() {
+        if (mBdLocationHelper == null) {
+            mBdLocationHelper = new BdLocationHelper(this);
+        }
+        return mBdLocationHelper;
+    }
+
+    /*********************
+     * 提供网络全局监听
+     ************************/
+    private NetWorkObservable mNetWorkObservable;
+
+    public boolean isNetworkActive() {
+        if (mNetWorkObservable != null) {
+            return mNetWorkObservable.isNetworkActive();
+        }
+        return true;
+    }
+
+    public void registerNetWorkObserver(NetWorkObservable.NetWorkObserver observer) {
+        if (mNetWorkObservable != null) {
+            mNetWorkObservable.registerObserver(observer);
+        }
+    }
+
+    public void unregisterNetWorkObserver(NetWorkObservable.NetWorkObserver observer) {
+        if (mNetWorkObservable != null) {
+            mNetWorkObservable.unregisterObserver(observer);
+        }
+    }
+
+    /* 文件缓存的目录 */
+    public String mAppDir;
+    public String mPicturesDir;
+    public String mVoicesDir;
+    public String mVideosDir;
+    public String mFilesDir;
+
+    private void initAppDir() {
+        File file = getExternalFilesDir(null);
+        if (file != null) {
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            mAppDir = file.getAbsolutePath();
+        }
+
+        file = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
+        if (file != null) {
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            mPicturesDir = file.getAbsolutePath();
+        }
+
+        file = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
+        if (file != null) {
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            mVoicesDir = file.getAbsolutePath();
+        }
+        file = getExternalFilesDir(Environment.DIRECTORY_MOVIES);
+        if (file != null) {
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            mVideosDir = file.getAbsolutePath();
+        }
+        file = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
+        if (file != null) {
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            mFilesDir = file.getAbsolutePath();
+        }
+    }
+
+    /*******************
+     * 初始化图片加载
+     **********************/
+    // 显示的设置
+    public static DisplayImageOptions mNormalImageOptions;
+    public static DisplayImageOptions mAvatarRoundImageOptions;
+    public static DisplayImageOptions mAvatarNormalImageOptions;
+
+    private void initImageLoader() {
+        int memoryCacheSize = (int) (Runtime.getRuntime().maxMemory() / 5);
+        MemoryCacheAware<String, Bitmap> memoryCache;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+            memoryCache = new LruMemoryCache(memoryCacheSize);
+        } else {
+            memoryCache = new LRULimitedMemoryCache(memoryCacheSize);
+        }
+
+        mNormalImageOptions = new DisplayImageOptions.Builder().bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
+                .resetViewBeforeLoading(false).showImageForEmptyUri(com.xzjmyk.pm.activity.R.drawable.image_download_fail_icon)
+                .showImageOnFail(com.xzjmyk.pm.activity.R.drawable.image_download_fail_icon).build();
+
+        mAvatarRoundImageOptions = new DisplayImageOptions.Builder().bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
+                .displayer(new RoundedBitmapDisplayer(10)).resetViewBeforeLoading(true).showImageForEmptyUri(com.xzjmyk.pm.activity.R.drawable.avatar_normal)
+                .showImageOnFail(com.xzjmyk.pm.activity.R.drawable.avatar_normal).showImageOnLoading(com.xzjmyk.pm.activity.R.drawable.avatar_normal).build();
+
+        mAvatarNormalImageOptions = new DisplayImageOptions.Builder().bitmapConfig(Config.RGB_565).cacheInMemory(true).cacheOnDisc(true)
+                .resetViewBeforeLoading(true).showImageForEmptyUri(com.xzjmyk.pm.activity.R.drawable.avatar_normal).showImageOnFail(com.xzjmyk.pm.activity.R.drawable.avatar_normal)
+                .showImageOnLoading(com.xzjmyk.pm.activity.R.drawable.avatar_normal).build();
+
+        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).defaultDisplayImageOptions(mNormalImageOptions)
+                // .denyCacheImageMultipleSizesInMemory()
+                .discCache(new TotalSizeLimitedDiscCache(new File(mPicturesDir), 50 * 1024 * 1024))
+                        // 最多缓存50M的图片
+                .discCacheFileNameGenerator(new Md5FileNameGenerator()).memoryCache(memoryCache).tasksProcessingOrder(QueueProcessingType.LIFO)
+                .threadPriority(Thread.NORM_PRIORITY - 2)
+                .threadPoolSize(4)
+                .build();
+        // Initialize ImageLoader with configuration.
+        ImageLoader.getInstance().init(config);
+    }
+
+    /*********************
+     * 提供全局配置
+     ************************/
+    private AppConfig mConfig;
+
+    public void setConfig(AppConfig config) {
+        mConfig = config;
+    }
+
+    public AppConfig getConfig() {
+        if (mConfig == null) {
+            mConfig = AppConfig.initConfig(getApplicationContext(), new ConfigBean());
+        }
+        return mConfig;
+    }
+
+    /*****************
+     * 提供全局的Volley
+     ***************************/
+
+    private FastVolley mFastVolley;
+
+    public FastVolley getFastVolley() {
+        if (mFastVolley == null) {
+            synchronized (MyApplication.class) {
+                if (mFastVolley == null) {
+                    mFastVolley = new FastVolley(this);
+                    mFastVolley.start();
+                }
+            }
+        }
+        return mFastVolley;
+    }
+
+    private void releaseFastVolley() {
+        if (mFastVolley != null) {
+            mFastVolley.stop();
+        }
+    }
+
+    /***********************
+     * 保存当前登陆用户的全局信息
+     ***************/
+    public String roomName;
+    public String mAccessToken;
+    public long mExpiresIn;
+    public int mUserStatus;
+    public boolean mUserStatusChecked = false;
+    public User mLoginUser = new User();// 当前登陆的用户
+
+    /***********************
+     * 保存其他用户坐标信息
+     ***************/
+
+    public String getJSESSION_B2B() {
+        return JSESSION_B2B;
+    }
+
+    public void setJSESSION_B2B(String jSESSION_B2B) {
+        JSESSION_B2B = jSESSION_B2B;
+    }
+
+    public static Cookie getCookie() {
+        return cookie;
+    }
+
+    public static void setCookie(Cookie cookie) {
+        MyApplication.cookie = cookie;
+    }
 }

+ 1 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/helper/AvatarHelper.java

@@ -137,6 +137,7 @@ public class AvatarHelper {
 
     public void displayAvatar(String userId, final ImageView imageView, final boolean isThumb) {
         final String url = getAvatarUrl(userId, isThumb);
+        Log.i("Arison","AvatarHelper:displayAvatar:140:"+url);
         if (TextUtils.isEmpty(url)) {
             return;
         }

+ 17 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/ScheduleActivity.java

@@ -32,6 +32,8 @@ import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
@@ -199,6 +201,21 @@ public class ScheduleActivity extends BaseActivity{
 	        Looper.loop();  
 	 }
 
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		return super.onCreateOptionsMenu(menu);
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		switch (item.getItemId()){
+			case android.R.id.home:
+				onBackPressed();
+				break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+
 	@Override
 	public void onBackPressed() {
 		super.onBackPressed();

+ 3 - 3
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/net/HttpUtil.java

@@ -254,10 +254,10 @@ public class HttpUtil {
         try {
             URL url = new URL(httpurl);
             HttpURLConnection connection = (HttpURLConnection)url.openConnection();
-            connection.setRequestMethod("POST");
+            connection.setRequestMethod("GET");
             connection.setRequestProperty("Charset","UTF-8");
-            connection.setReadTimeout(10*1000);
-            connection.setConnectTimeout(10*1000);
+            connection.setReadTimeout(50*1000);
+            connection.setConnectTimeout(50*1000);
             connection.connect();
             int file_leng = connection.getContentLength();
             System.out.println("file length---->"+file_leng);

+ 319 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/util/BitmapUtil.java

@@ -0,0 +1,319 @@
+package com.xzjmyk.pm.activity.ui.erp.util;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.PixelFormat;
+import android.graphics.PointF;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Environment;
+import android.util.DisplayMetrics;
+import android.util.Log;
+
+import com.xzjmyk.pm.activity.ui.groupchat.SelectContactsActivity;
+import com.xzjmyk.pm.activity.util.FileUtil;
+
+
+public class BitmapUtil {
+	static public Drawable getScaleDraw(String imgPath, Context mContext) {
+
+		Bitmap bitmap = null;
+		try {
+			Log.d("BitmapUtil",
+					"[getScaleDraw]imgPath is " + imgPath.toString());
+			File imageFile = new File(imgPath);
+			if (!imageFile.exists()) {
+				Log.d("BitmapUtil", "[getScaleDraw]file not  exists");
+				return null;
+			}
+			BitmapFactory.Options opts = new BitmapFactory.Options();
+			opts.inJustDecodeBounds = true;
+			BitmapFactory.decodeFile(imgPath, opts);
+
+			opts.inSampleSize = computeSampleSize(opts, -1, 800 * 480);
+			// Log.d("BitmapUtil","inSampleSize===>"+opts.inSampleSize);
+			opts.inJustDecodeBounds = false;
+			bitmap = BitmapFactory.decodeFile(imgPath, opts);
+
+		} catch (OutOfMemoryError err) {
+			Log.d("BitmapUtil", "[getScaleDraw] out of memory");
+
+		}
+		if (bitmap == null) {
+			return null;
+		}
+		Drawable resizeDrawable = new BitmapDrawable(mContext.getResources(),
+				bitmap);
+		return resizeDrawable;
+	}
+
+	public static void saveMyBitmap(Context mContext, Bitmap bitmap,
+									String desName) throws IOException {
+		FileOutputStream fOut = null;
+		Log.i("Arison", "Environment.getExternalStorageState()="+Environment.getExternalStorageState());
+		Log.i("Arison", "Environment.MEDIA_MOUNTED="+Environment.MEDIA_MOUNTED);
+		if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+			LogUtil.d("sdcard doesn't exit, save png to app dir");
+			fOut = mContext.openFileOutput(desName + ".png",
+					Context.MODE_PRIVATE);
+		} else {
+			Log.i("Arison", "path="+Environment.getExternalStorageDirectory()
+					.getPath());
+			File dir=new File(Environment.getExternalStorageDirectory()
+					.getPath() + "/demo/");
+			dir.mkdir();
+			File f = new File(Environment.getExternalStorageDirectory()
+					.getPath() + "/demo/" + desName + ".png");
+			f.createNewFile();
+			fOut = new FileOutputStream(f);
+		}
+		bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
+		try {
+			fOut.flush();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		try {
+			fOut.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	static public Bitmap getScaleBitmap(Resources res, int id) {
+
+		Bitmap bitmap = null;
+		try {
+			BitmapFactory.Options opts = new BitmapFactory.Options();
+			opts.inJustDecodeBounds = true;
+			BitmapFactory.decodeResource(res, id, opts);
+
+			opts.inSampleSize = computeSampleSize(opts, -1, 800 * 480);
+			// Log.d("BitmapUtil","inSampleSize===>"+opts.inSampleSize);
+			opts.inJustDecodeBounds = false;
+			bitmap = BitmapFactory.decodeResource(res, id, opts);
+		} catch (OutOfMemoryError err) {
+			Log.d("BitmapUtil", "[getScaleBitmap] out of memory");
+
+		}
+		return bitmap;
+	}
+
+	public static int computeSampleSize(BitmapFactory.Options options,
+										int minSideLength, int maxNumOfPixels) {
+
+		int initialSize = computeInitialSampleSize(options, minSideLength,
+				maxNumOfPixels);
+		int roundedSize;
+		if (initialSize <= 8) {
+			roundedSize = 1;
+			while (roundedSize < initialSize) {
+				roundedSize <<= 1;
+			}
+		} else {
+			roundedSize = (initialSize + 7) / 8 * 8;
+		}
+
+		return roundedSize;
+
+	}
+
+	private static int computeInitialSampleSize(BitmapFactory.Options options,
+												int minSideLength, int maxNumOfPixels) {
+
+		double w = options.outWidth;
+		double h = options.outHeight;
+		int lowerBound = (maxNumOfPixels == -1) ? 1 : (int) Math.ceil(Math
+				.sqrt(w * h / maxNumOfPixels));
+		int upperBound = (minSideLength == -1) ? 128 : (int) Math.min(
+				Math.floor(w / minSideLength), Math.floor(h / minSideLength));
+
+		if (upperBound < lowerBound) {
+			// return the larger one when there is no overlapping zone.
+			return lowerBound;
+		}
+
+		if ((maxNumOfPixels == -1) && (minSideLength == -1)) {
+			return 1;
+		} else if (minSideLength == -1) {
+			return lowerBound;
+		} else {
+			return upperBound;
+		}
+
+	}
+
+	public static Bitmap drawableToBitmap(Drawable drawable) {
+
+		Bitmap bitmap = Bitmap
+				.createBitmap(
+						drawable.getIntrinsicWidth(),
+						drawable.getIntrinsicHeight(),
+						drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
+								: Bitmap.Config.RGB_565);
+		Canvas canvas = new Canvas(bitmap);
+		canvas.setBitmap(bitmap);
+		drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
+				drawable.getIntrinsicHeight());
+		drawable.draw(canvas);
+		return bitmap;
+	}
+
+	public static Bitmap decodeBitmap(Resources res, int id) {
+		BitmapFactory.Options options = new BitmapFactory.Options();
+		options.inJustDecodeBounds = true;
+		// 通过这个bitmap获取图片的宽和高
+		Bitmap bitmap = BitmapFactory.decodeResource(res, id, options);
+		if (bitmap == null) {
+			LogUtil.d("bitmap为空");
+		}
+		float realWidth = options.outWidth;
+		float realHeight = options.outHeight;
+		LogUtil.d("真实图片高度:" + realHeight + "宽度:" + realWidth);
+		// 计算缩放比
+		int scale = (int) ((realHeight > realWidth ? realHeight : realWidth) / 100);
+		if (scale <= 0) {
+			scale = 1;
+		}
+		LogUtil.d("scale=>" + scale);
+		options.inSampleSize = scale;
+		options.inJustDecodeBounds = false;
+		// 注意这次要把options.inJustDecodeBounds 设为 false,这次图片是要读取出来的。
+		bitmap = BitmapFactory.decodeResource(res, id, options);
+		int w = bitmap.getWidth();
+		int h = bitmap.getHeight();
+		LogUtil.d("缩略图高度:" + h + "宽度:" + w);
+		return bitmap;
+	}
+
+	public static Bitmap getCombineBitmaps(List<SelectContactsActivity.MyBitmapEntity> mEntityList,
+										   Bitmap... bitmaps) {
+		LogUtil.d("count=>" + mEntityList.size());
+		Bitmap newBitmap = Bitmap.createBitmap(200, 200, Config.ARGB_8888);
+		LogUtil.d("newBitmap=>" + newBitmap.getWidth() + ","
+				+ newBitmap.getHeight());
+		for (int i = 0; i < mEntityList.size(); i++) {
+			LogUtil.d("i==>" + i);
+			newBitmap = mixtureBitmap(newBitmap, bitmaps[i], new PointF(
+					mEntityList.get(i).x, mEntityList.get(i).y));
+		}
+		return newBitmap;
+	}
+
+	/**
+	 * 将多个Bitmap合并成一个图片。
+	 *
+	 * @param int 将多个图合成多少列
+	 * @param Bitmap
+	 *            ... 要合成的图片
+	 * @return
+	 */
+	public static Bitmap combineBitmaps(int columns, Bitmap... bitmaps) {
+		if (columns <= 0 || bitmaps == null || bitmaps.length == 0) {
+			throw new IllegalArgumentException(
+					"Wrong parameters: columns must > 0 and bitmaps.length must > 0.");
+		}
+		int maxWidthPerImage = 20;
+		int maxHeightPerImage = 20;
+		for (Bitmap b : bitmaps) {
+			maxWidthPerImage = maxWidthPerImage > b.getWidth() ? maxWidthPerImage
+					: b.getWidth();
+			maxHeightPerImage = maxHeightPerImage > b.getHeight() ? maxHeightPerImage
+					: b.getHeight();
+		}
+		LogUtil.d("maxWidthPerImage=>" + maxWidthPerImage
+				+ ";maxHeightPerImage=>" + maxHeightPerImage);
+		int rows = 0;
+		if (columns >= bitmaps.length) {
+			rows = 1;
+			columns = bitmaps.length;
+		} else {
+			rows = bitmaps.length % columns == 0 ? bitmaps.length / columns
+					: bitmaps.length / columns + 1;
+		}
+		Bitmap newBitmap = Bitmap.createBitmap(columns * maxWidthPerImage, rows
+				* maxHeightPerImage, Config.ARGB_8888);
+		LogUtil.d("newBitmap=>" + newBitmap.getWidth() + ","
+				+ newBitmap.getHeight());
+		for (int x = 0; x < rows; x++) {
+			for (int y = 0; y < columns; y++) {
+				int index = x * columns + y;
+				if (index >= bitmaps.length)
+					break;
+				LogUtil.d("y=>" + y + " * maxWidthPerImage=>"
+						+ maxWidthPerImage + " = " + (y * maxWidthPerImage));
+				LogUtil.d("x=>" + x + " * maxHeightPerImage=>"
+						+ maxHeightPerImage + " = " + (x * maxHeightPerImage));
+				newBitmap = mixtureBitmap(newBitmap, bitmaps[index],
+						new PointF(y * maxWidthPerImage, x * maxHeightPerImage));
+			}
+		}
+		return newBitmap;
+	}
+
+	/**
+	 * Mix two Bitmap as one.
+	 *
+	 * @param bitmapOne
+	 * @param bitmapTwo
+	 * @param point
+	 *            where the second bitmap is painted.
+	 * @return
+	 */
+	public static Bitmap mixtureBitmap(Bitmap first, Bitmap second,
+									   PointF fromPoint) {
+		if (first == null || second == null || fromPoint == null) {
+			return null;
+		}
+		Bitmap newBitmap = Bitmap.createBitmap(first.getWidth(),
+				first.getHeight(), Config.ARGB_8888);
+		Canvas cv = new Canvas(newBitmap);
+		cv.drawBitmap(first, 0, 0, null);
+		cv.drawBitmap(second, fromPoint.x, fromPoint.y, null);
+		cv.save(Canvas.ALL_SAVE_FLAG);
+		cv.restore();
+		return newBitmap;
+	}
+
+	public static void getScreenWidthAndHeight(Activity mContext) {
+		DisplayMetrics metric = new DisplayMetrics();
+		mContext.getWindowManager().getDefaultDisplay().getMetrics(metric);
+		int width = metric.widthPixels; // 屏幕宽度(像素)
+		int height = metric.heightPixels; // 屏幕高度(像素)
+		LogUtil.d("screen width=>" + width + ",height=>" + height);
+	}
+
+
+	/**
+	 * 保存文件
+	 * @param bm
+	 * @param fileName
+	 * @throws IOException
+	 */
+	public static File saveFile(Bitmap bm, String fileName) throws IOException {
+		String path = FileUtils.getSDRoot() +"/uu/chat/";
+		Log.i("Arison","BitmapUtil:saveFile:306:path:"+path);
+		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, 80, bos);
+		bos.flush();
+		bos.close();
+
+		return  myCaptureFile;
+	}
+}

+ 76 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/util/LogUtil.java

@@ -0,0 +1,76 @@
+package com.xzjmyk.pm.activity.ui.erp.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import android.util.Log;
+
+public class LogUtil {
+	private static final boolean DEBUG = true;
+	
+	public static void d(String TAG, String method, String msg) {
+		Log.d(TAG, "[" + method + "]" + msg);
+	}
+	
+	public static void d(String TAG, String msg){
+		if (DEBUG) {
+			Log.d(TAG, "[" + getFileLineMethod() + "]" + msg);
+		}
+	}
+	
+	public static void d(String msg){
+		if (DEBUG) {
+			Log.d(_FILE_(), "[" + getLineMethod() + "]" + msg);
+		}
+	}
+	
+	public static void e(String msg){
+		if (DEBUG) {
+			Log.e(_FILE_(), getLineMethod() + msg);
+		}
+	}
+	
+	public static void e(String TAG, String msg){
+		if (DEBUG) {
+			Log.e(TAG, getLineMethod() + msg);
+		}
+	}
+
+	public static String getFileLineMethod() {
+		StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
+		StringBuffer toStringBuffer = new StringBuffer("[")
+				.append(traceElement.getFileName()).append(" | ")
+				.append(traceElement.getLineNumber()).append(" | ")
+				.append(traceElement.getMethodName()).append("]");
+		return toStringBuffer.toString();
+	}
+	
+	public static String getLineMethod() {
+		StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
+		StringBuffer toStringBuffer = new StringBuffer("[")
+				.append(traceElement.getLineNumber()).append(" | ")
+				.append(traceElement.getMethodName()).append("]");
+		return toStringBuffer.toString();
+	}
+
+	public static String _FILE_() {
+		StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
+		return traceElement.getFileName();
+	}
+
+	public static String _FUNC_() {
+		StackTraceElement traceElement = ((new Exception()).getStackTrace())[1];
+		return traceElement.getMethodName();
+	}
+
+	public static int _LINE_() {
+		StackTraceElement traceElement = ((new Exception()).getStackTrace())[1];
+		return traceElement.getLineNumber();
+	}
+
+	public static String _TIME_() {
+		Date now = new Date();
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+		return sdf.format(now);
+	}
+}

+ 70 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/util/PropertiesUtil.java

@@ -0,0 +1,70 @@
+package com.xzjmyk.pm.activity.ui.erp.util;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Properties;
+
+import android.content.Context;
+
+public class PropertiesUtil {
+
+	/**
+	 * 指定property文件 我使用request.getRealPath("/")获取的绝对路径,这里就直接写出
+	 */
+	private static final String PROPERTY_FILE = "c://nine_rect.properties";
+
+	/**
+	 * 根据Key 读取Value
+	 *
+	 * @param key
+	 * @return
+	 */
+	public static String readData(Context mContext, String key, int resId) {
+		Properties props = new Properties();
+		try {
+			InputStream in = new BufferedInputStream(mContext.getResources().openRawResource(resId));
+			props.load(in);
+			in.close();
+			String value = props.getProperty(key);
+			return value;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 修改或添加键值对 如果key存在,修改 反之,添加。
+	 *
+	 * @param key
+	 * @param value
+	 */
+	public static void writeData(String key, String value) {
+		Properties prop = new Properties();
+		try {
+			File file = new File(PROPERTY_FILE);
+			if (!file.exists())
+				file.createNewFile();
+			InputStream fis = new FileInputStream(file);
+			prop.load(fis);
+			fis.close();// 一定要在修改值之前关闭fis
+			OutputStream fos = new FileOutputStream(PROPERTY_FILE);
+			prop.setProperty(key, value);
+			prop.store(fos, "Update '" + key + "' value");
+			fos.close();
+		} catch (IOException e) {
+			System.err.println("Visit " + PROPERTY_FILE + " for updating "
+					+ value + " value error");
+		}
+	}
+}
+// 注意:
+
+// 1可以读写property文件,而且可修改已经存在的键值对。
+
+// 2应该特别注意IOl流关闭的时间和顺序,否则读写不成功,尤其在改写数据的时候。
+

+ 14 - 5
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/groupchat/GroupChatFragment.java

@@ -39,6 +39,7 @@ import com.xzjmyk.pm.activity.db.dao.FriendDao;
 import com.xzjmyk.pm.activity.helper.AvatarHelper;
 import com.xzjmyk.pm.activity.ui.base.BaseActivity;
 import com.xzjmyk.pm.activity.ui.base.EasyFragment;
+import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
 import com.xzjmyk.pm.activity.ui.message.MucChatActivity;
 import com.xzjmyk.pm.activity.util.ProgressDialogUtil;
 import com.xzjmyk.pm.activity.util.TimeUtils;
@@ -135,14 +136,14 @@ public class GroupChatFragment extends EasyFragment {
 
     boolean b = false;
 
-    private void test() {
+ /*   private void test() {
         for (int i = 0; i < mMucRooms.size(); i++) {
             Log.i("gongpengming", mMucRooms.get(i).getId());
             Log.i("gongpengming", mMucRooms.get(i).getJid());
             Log.i("gongpengming", mMucRooms.get(i).getName());
             Log.i("gongpengming", mMucRooms.get(i).getUserId());
         }
-    }
+    }*/
 
     private void uploadAvatar() {
         File file = new File(Environment.getExternalStorageDirectory() + "/head1.jpg");
@@ -352,7 +353,7 @@ public class GroupChatFragment extends EasyFragment {
                 if (!b) {
                     b = true;
 //                    uploadAvatar();
-                    test();
+                   // test();
                 }
 
                 mPullToRefreshListView.onRefreshComplete();
@@ -392,8 +393,16 @@ public class GroupChatFragment extends EasyFragment {
             TextView time_tv = ViewHolder.get(convertView, R.id.time_tv);
 
             final MucRoom room = mMucRooms.get(position);
-            AvatarHelper.getInstance().displayAvatar(room.getUserId(),
-                    avatar_img, false);
+            if (!StringUtils.isEmpty(room.getSubject()))
+            {
+                //合成图像下载
+                AvatarHelper.getInstance().displayAvatar(room.getSubject(),
+                        avatar_img, false);
+            }else{
+                AvatarHelper.getInstance().displayAvatar(room.getUserId(),
+                        avatar_img, false);
+            }
+
 
             nick_name_tv.setText(room.getName());
             time_tv.setText(TimeUtils.getFriendlyTimeDesc(getActivity(),

+ 241 - 3
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/groupchat/SelectContactsActivity.java

@@ -5,9 +5,16 @@ import android.app.ProgressDialog;
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.media.ThumbnailUtils;
 import android.os.Bundle;
+import android.os.Handler;
 import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
 import android.text.TextUtils;
+import android.text.format.DateFormat;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -22,8 +29,13 @@ import android.widget.ListView;
 import android.widget.TextView;
 
 import com.alibaba.fastjson.JSON;
+import com.android.volley.Request;
 import com.android.volley.Response;
 import com.android.volley.VolleyError;
+import com.loopj.android.http.AsyncHttpClient;
+import com.loopj.android.http.AsyncHttpResponseHandler;
+import com.loopj.android.http.RequestParams;
+import com.nostra13.universalimageloader.core.ImageLoader;
 import com.xzjmyk.pm.activity.AppConstant;
 import com.xzjmyk.pm.activity.MyApplication;
 import com.xzjmyk.pm.activity.R;
@@ -38,10 +50,19 @@ import com.xzjmyk.pm.activity.db.dao.FriendDao;
 import com.xzjmyk.pm.activity.db.dao.UserDao;
 import com.xzjmyk.pm.activity.helper.AvatarHelper;
 import com.xzjmyk.pm.activity.ui.base.BaseActivity;
+import com.xzjmyk.pm.activity.ui.erp.net.HttpUtil;
+import com.xzjmyk.pm.activity.ui.erp.util.BitmapUtil;
+import com.xzjmyk.pm.activity.ui.erp.util.FileUtils;
+import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
+import com.xzjmyk.pm.activity.ui.erp.util.PropertiesUtil;
 import com.xzjmyk.pm.activity.ui.message.MucChatActivity;
 import com.xzjmyk.pm.activity.util.Constants;
+import com.xzjmyk.pm.activity.util.DateFormatUtil;
 import com.xzjmyk.pm.activity.util.DisplayUtil;
+import com.xzjmyk.pm.activity.util.FileUtil;
+import com.xzjmyk.pm.activity.util.ImageUtil;
 import com.xzjmyk.pm.activity.util.ProgressDialogUtil;
+import com.xzjmyk.pm.activity.util.SystemUtil;
 import com.xzjmyk.pm.activity.util.TimeUtils;
 import com.xzjmyk.pm.activity.util.ToastUtil;
 import com.xzjmyk.pm.activity.util.ViewHolder;
@@ -52,8 +73,15 @@ import com.xzjmyk.pm.activity.volley.Result;
 import com.xzjmyk.pm.activity.volley.StringJsonObjectRequest;
 import com.xzjmyk.pm.activity.xmpp.CoreService;
 
+import org.apache.http.Header;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -280,8 +308,13 @@ public class SelectContactsActivity extends BaseActivity {
         }
     }
 
-
-    private void showCreateGroupChatDialog() {
+     /**
+      * @功能:创建群对话框
+      * @author:Arisono
+      * @param:
+      * @return:
+      */
+     private void showCreateGroupChatDialog() {
 
         if (mXmppService == null || !mXmppService.isMucEnable()) {
             ToastUtil.showToast(mContext, R.string.service_start_failed);
@@ -362,7 +395,7 @@ public class SelectContactsActivity extends BaseActivity {
         if (longitude != 0)
             params.put("longitude", String.valueOf(longitude));
 
-        List<String> inviteUsers = new ArrayList<String>();
+       final   List<String> inviteUsers = new LinkedList<String>();
         // 邀请好友
         for (int i = 0; i < mSelectPositions.size(); i++) {
             if (mSelectPositions.get(i) == -1) {
@@ -371,6 +404,18 @@ public class SelectContactsActivity extends BaseActivity {
             String userId = mFriendList.get(mSelectPositions.get(i)).getUserId();
             inviteUsers.add(userId);
         }
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                inviteUsers.add(0, MyApplication.getInstance().mLoginUser.getUserId());
+                image=  createChatImage(inviteUsers);
+                Message msg=mhandler.obtainMessage();
+                msg.getData().putString("roomjId",roomJid);
+                msg.what=uploadFile;
+                mhandler.sendMessage(msg);
+            }
+        }).start();
+
         params.put("text", JSON.toJSONString(inviteUsers));
 
         ProgressDialogUtil.show(mProgressDialog);
@@ -394,6 +439,20 @@ public class SelectContactsActivity extends BaseActivity {
         addDefaultRequest(request);
     }
 
+    private final int uploadFile=1;
+    File image;
+    private Handler mhandler=new Handler(){
+        @Override
+        public void handleMessage(Message msg) {
+          switch (msg.what){
+              case uploadFile:
+                  String roomjId=msg.getData().getString("roomjId");
+                  uploadAvatar(image,roomjId);
+                  break;
+          }
+
+        }
+    };
 
 
     private void createRoomSuccess(String roomId, String roomJid, String roomName, String roomDesc) {
@@ -443,7 +502,186 @@ public class SelectContactsActivity extends BaseActivity {
         finish();
     }
 
+   /**
+    * @功能:合成九宫图头像--耗时操作
+    * @author:Arisono
+    * @param:
+    * @return:
+    */
+    private File createChatImage(List<String> inviteUsers){
+        Log.i("Arison","SelectContactsActivity:createChatImage:473:开始合成图片:"+DateFormatUtil.getFormatDate(System.currentTimeMillis()));
+        File file=null;
+        if (!ListUtils.isEmpty(inviteUsers)){
+            int size=inviteUsers.size()>9?9:inviteUsers.size();
+            List<MyBitmapEntity> mEntityList = getBitmapEntitys(size);
+            Bitmap mBitmaps[]=new Bitmap[size];
+            for (int i=0;i<size;i++){
+                String url=AvatarHelper.getAvatarUrl(inviteUsers.get(i), false);
+                Bitmap nextBitmap=null;
+                String filepath=HttpUtil.download(url, FileUtils.getSDRoot()+"/uu/chat/head"+i+".png");
+                Log.i("Arison","SelectContactsActivity:createChatImage:493:filepath:"+filepath);
+                nextBitmap= ImageUtil.compressBitmapWithFilePath(filepath,300,300);
+                Bitmap tempBitmap=ThumbnailUtils.extractThumbnail(nextBitmap, (int) mEntityList
+                        .get(i).width, (int) mEntityList.get(i).width);
+                Log.i("Arison","createChatImage:499:tempBitmap:"+url);
+                Log.i("Arison","createChatImage:499:tempBitmap:"+nextBitmap);
+                mBitmaps[i]=tempBitmap;
+            }
+
+            Bitmap combineBitmap = BitmapUtil.getCombineBitmaps(mEntityList, mBitmaps);
+
+            try {
+              file=  BitmapUtil.saveFile(combineBitmap,"chatImage.png");
+            } catch (IOException e) {
+                e.printStackTrace();
+            } catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+        Log.i("Arison","SelectContactsActivity:createChatImage:473:合成图片结束:"+DateFormatUtil.getFormatDate(System.currentTimeMillis())+";file="+file);
+        return  file;
+    }
+
+
+    private void uploadAvatar(File file, final String roomjId) {
+        if (!file.exists()) {// 文件不存在
+            return;
+        }
+        // 显示正在上传的ProgressDialog
+        //Looper.prepare();
+//        ProgressDialogUtil.show(mProgressDialog, getString(R.string.upload_avataring));
+        RequestParams params = new RequestParams();
+        final String loginUserId = MyApplication.getInstance().mLoginUser.getUserId();
+        long time=System.currentTimeMillis();
+//
+        long roomImgId=Long.valueOf(loginUserId)+time;
+        Log.i("Arison","SelectContactsActivity:uploadAvatar:471:roomImgId:"+roomImgId
+        +"时间:"+ DateFormatUtil.getDateTimeStr(new Date(time)));
+       final String  photoId="101010";
+        params.put("userId", photoId);//群主id+当前系统时间
+        try {
+            params.put("file1", file);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        AsyncHttpClient client = new AsyncHttpClient();
+        client.post(MyApplication.getInstance().getConfig().AVATAR_UPLOAD_URL, params, new AsyncHttpResponseHandler() {
+            @Override
+            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
+                boolean success = false;
+                if (arg0 == 200) {
+                    Result result = null;
+                    try {
+                        result = JSON.parseObject(new String(arg2), Result.class);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                    if (result != null && result.getResultCode() == Result.CODE_SUCCESS) {
+                        success = true;
+                    }
+                }
+
+//                ProgressDialogUtil.dismiss(mProgressDialog);
+                if (success) {
+                    Log.i("Arison", "SelectContactsActivity:onSuccess:567:" + "上次头像成功!");
+                    ToastUtil.showToast(SelectContactsActivity.this, R.string.upload_avatar_success);
+                    //更新服务器
+                    updateIMChatImageId(roomjId,photoId);
+                } else {
+                    Log.i("Arison", "SelectContactsActivity:onSuccess:567:" + "上次头失败!");
+                    ToastUtil.showToast(SelectContactsActivity.this, R.string.upload_avatar_failed);
+                }
+
+                finish();
+            }
+
+            @Override
+            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
+                // ProgressDialogUtil.dismiss(mProgressDialog);
+                ToastUtil.showToast(SelectContactsActivity.this, R.string.upload_avatar_failed);
+                Log.i("Arison", "SelectContactsActivity:onSuccess:567:" + "上次头失败!");
+            }
+        });
+       // Looper.loop();
+    }
+
+    /**
+     * @功能:上传文件后,需要上传更新图像id
+     * @author:Arisono
+     * @param:
+     * @return:
+     */
+    public void updateIMChatImageId(String roomjId,String photoId){
+		String url = MyApplication.getInstance().getConfig().apiUrl+"room/setRelationGroupPhoto";
+		final String requestTag = "loginManagerSystem";
+		Map<String, String> params = new HashMap<String, String>();
+        params.put("access_token", MyApplication.getInstance().mAccessToken);
+        params.put("roomId", roomjId);
+        params.put("photoid",photoId);
+		final ProgressDialog dialog = ProgressDialogUtil.init(mContext, null, getString(R.string.please_wait), true);
+		ProgressDialogUtil.show(dialog);
+        StringJsonObjectRequest<String> mRequest = new StringJsonObjectRequest<String>(
+				Request.Method.GET, url,
+				new Response.ErrorListener() {
+					@Override
+					public void onErrorResponse(VolleyError volleyError) {
+						ProgressDialogUtil.dismiss(dialog);
+						ToastUtil.showErrorNet(mContext);
+					}
+				},
+				new StringJsonObjectRequest.Listener<String>() {
+					@Override
+					public void onResponse(ObjectResult<String> result) {
+						Log.i("Arison","更新头像id result:"+ result.getResultData());
+					}
+				}, String.class, params, true);
+		mRequest.setTag(requestTag);
+		addDefaultRequest(mRequest);
 
 
+    }
 
+
+
+
+    public static class MyBitmapEntity {
+        public float x;
+        public  float y;
+        public float width;
+        public  float height;
+        public  static int devide = 1;
+        public int index = -1;
+
+        @Override
+        public String toString() {
+            return "MyBitmap [x=" + x + ", y=" + y + ", width=" + width
+                    + ", height=" + height + ", devide=" + devide + ", index="
+                    + index + "]";
+        }
+    }
+
+
+    private List<MyBitmapEntity> getBitmapEntitys(int count) {
+        List<MyBitmapEntity> mList = new LinkedList<MyBitmapEntity>();
+        String value = PropertiesUtil.readData(this, String.valueOf(count),
+                R.raw.data);
+//        LogUtil.d("value=>" + value);
+        String[] arr1 = value.split(";");
+        int length = arr1.length;
+        for (int i = 0; i < length; i++) {
+            String content = arr1[i];
+            String[] arr2 = content.split(",");
+            MyBitmapEntity entity = null;
+            for (int j = 0; j < arr2.length; j++) {
+                entity = new MyBitmapEntity();
+                entity.x = Float.valueOf(arr2[0]);
+                entity.y = Float.valueOf(arr2[1]);
+                entity.width = Float.valueOf(arr2[2]);
+                entity.height = Float.valueOf(arr2[3]);
+            }
+            mList.add(entity);
+        }
+        return mList;
+    }
 }

+ 1 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/util/ImageUtil.java

@@ -166,7 +166,7 @@ public class ImageUtil {
         Bitmap bitmap=compressBitmapWithFilePath(path,reqsW,reqsH);
         try {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();//放入内存
-            bitmap.compress(Bitmap.CompressFormat.PNG, quality, baos);//压缩质量
+            bitmap.compress(Bitmap.CompressFormat.JPEG, quality, baos);//压缩质量
             byte[] bts = baos.toByteArray();
            // Bitmap res = compressBitmapWithByte(bts, reqsW, reqsH);//压缩尺寸
             Bitmap res=bytes2Bimap(bts);

+ 6 - 3
WeiChat/src/main/res/drawable/shape_from_edit.xml

@@ -5,17 +5,20 @@
             <stroke android:width="0.6dp" android:color="#00EEEE" />
             <corners android:radius="8dp" />
             <padding android:bottom="0.5dp" android:left="0.5dp" android:right="0.5dp" android:top="0.5dp" />
-        </shape></item>
+        </shape>
+    </item>
     <item  android:state_pressed="true"><shape>
             <solid android:color="#FFFFFF" />
             <stroke android:width="0.6dp" android:color="#00EEEE" />
             <corners android:radius="8dp" />
             <padding android:bottom="0.5dp" android:left="0.5dp" android:right="0.5dp" android:top="0.5dp" />
-        </shape></item>
+        </shape>
+    </item>
     <item ><shape>
             <solid android:color="#FFFFFF" />
             <stroke android:width="0.6dp" android:color="#949494" />
             <corners android:radius="8dp" />
             <padding android:bottom="0.5dp" android:left="0.5dp" android:right="0.5dp" android:top="0.5dp" />
-        </shape></item>
+        </shape>
+    </item>
 </selector>

+ 2 - 1
WeiChat/src/main/res/layout/activity_select_contacts.xml

@@ -40,7 +40,8 @@
             android:textColor="@color/white"
             android:textSize="@dimen/text_hine" />
 
-        <com.xzjmyk.pm.activity.view.HorizontalListView xmlns:widget="http://schemas.android.com/apk/res-auto"
+        <com.xzjmyk.pm.activity.view.HorizontalListView
+            xmlns:widget="http://schemas.android.com/apk/res-auto"
             android:id="@+id/horizontal_list_view"
             android:layout_width="fill_parent"
             android:layout_height="37dp"

+ 11 - 0
WeiChat/src/main/res/raw/data.properties

@@ -0,0 +1,11 @@
+#Update '9' value
+#Tue Jul 30 16:20:56 CST 2013
+9=1.0,1.0,64.666664,64.666664;67.666664,1.0,64.666664,64.666664;134.33333,1.0,64.666664,64.666664;1.0,67.666664,64.666664,64.666664;67.666664,67.666664,64.666664,64.666664;134.33333,67.666664,64.666664,64.666664;1.0,134.33333,64.666664,64.666664;67.666664,134.33333,64.666664,64.666664;134.33333,134.33333,64.666664,64.666664;
+8=34.333332,1.0,64.666664,64.666664;101.0,1.0,64.666664,64.666664;1.0,67.666664,64.666664,64.666664;67.666664,67.666664,64.666664,64.666664;134.33333,67.666664,64.666664,64.666664;1.0,134.33333,64.666664,64.666664;67.666664,134.33333,64.666664,64.666664;134.33333,134.33333,64.666664,64.666664;
+7=67.666664,1.0,64.666664,64.666664;1.0,67.666664,64.666664,64.666664;67.666664,67.666664,64.666664,64.666664;134.33333,67.666664,64.666664,64.666664;1.0,134.33333,64.666664,64.666664;67.666664,134.33333,64.666664,64.666664;134.33333,134.33333,64.666664,64.666664;
+6=1.0,34.333336,64.666664,64.666664;67.666664,34.333336,64.666664,64.666664;134.33333,34.333336,64.666664,64.666664;1.0,101.0,64.666664,64.666664;67.666664,101.0,64.666664,64.666664;134.33333,101.0,64.666664,64.666664;
+5=34.333332,34.333336,64.666664,64.666664;101.0,34.333336,64.666664,64.666664;1.0,101.0,64.666664,64.666664;67.666664,101.0,64.666664,64.666664;134.33333,101.0,64.666664,64.666664;
+4=1.0,1.0,98.0,98.0;101.0,1.0,98.0,98.0;1.0,101.0,98.0,98.0;101.0,101.0,98.0,98.0;
+3=51.0,1.0,98.0,98.0;1.0,101.0,98.0,98.0;101.0,101.0,98.0,98.0;
+2=1.0,51.0,98.0,98.0;101.0,51.0,98.0,98.0;
+1=1.0,1.0,198.0,198.0;

+ 1 - 1
build.gradle

@@ -5,7 +5,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.0.0'
+        classpath 'com.android.tools.build:gradle:2.1.0'
     }
 }