|
|
@@ -6,7 +6,14 @@ import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.Menu;
|
|
|
+import android.view.MenuItem;
|
|
|
+import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.google.zxing.BarcodeFormat;
|
|
|
@@ -20,6 +27,7 @@ import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.helper.AvatarHelper;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
+import com.xzjmyk.pm.activity.util.DisplayUtil;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
@@ -28,7 +36,7 @@ import java.io.UnsupportedEncodingException;
|
|
|
* function:
|
|
|
*/
|
|
|
|
|
|
-public class InfoCodeActivity extends BaseActivity {
|
|
|
+public class InfoCodeActivity extends BaseActivity implements View.OnClickListener{
|
|
|
@ViewInject(R.id.code_main)
|
|
|
private ImageView code_main;
|
|
|
@ViewInject(R.id.common_docui_photo_img)
|
|
|
@@ -37,7 +45,7 @@ public class InfoCodeActivity extends BaseActivity {
|
|
|
private TextView name_tv;
|
|
|
@ViewInject(R.id.common_docui_Section_tv)
|
|
|
private TextView section_tv;
|
|
|
- // 图片宽度的一般
|
|
|
+ // 图片宽度的一半
|
|
|
private static final int IMAGE_HALFWIDTH = 20;
|
|
|
// 显示二维码图片
|
|
|
private ImageView imageview;
|
|
|
@@ -48,7 +56,7 @@ public class InfoCodeActivity extends BaseActivity {
|
|
|
private String uu_phone;
|
|
|
private String uu_name;
|
|
|
private String loginUserId;
|
|
|
-
|
|
|
+ private PopupWindow setWindow = null;//
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -112,6 +120,78 @@ public class InfoCodeActivity extends BaseActivity {
|
|
|
},1000);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
+ getMenuInflater().inflate(R.menu.menu_infocode, menu);
|
|
|
+ return super.onCreateOptionsMenu(menu);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ switch (item.getItemId()) {
|
|
|
+ case R.id.title:
|
|
|
+ showPopupWindow();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
+ }
|
|
|
+ private void showPopupWindow() {
|
|
|
+ if (setWindow == null) initPopupWindow();
|
|
|
+ setWindow.showAtLocation(getWindow().getDecorView().
|
|
|
+ findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
|
|
|
+ DisplayUtil.backgroundAlpha(this, 0.4f);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closePopupWindow() {
|
|
|
+ if (setWindow != null)
|
|
|
+ setWindow.dismiss();
|
|
|
+ DisplayUtil.backgroundAlpha(this, 1f);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initPopupWindow() {
|
|
|
+ View viewContext = LayoutInflater.from(ct).inflate(R.layout.infocode_menu_more, null);
|
|
|
+ viewContext.findViewById(R.id.share_2code).setOnClickListener(this);
|
|
|
+ viewContext.findViewById(R.id.change_style).setOnClickListener(this);
|
|
|
+ viewContext.findViewById(R.id.save_to_MBphone).setOnClickListener(this);
|
|
|
+ viewContext.findViewById(R.id.scan_2dcode).setOnClickListener(this);
|
|
|
+ viewContext.findViewById(R.id.cancel_tv).setOnClickListener(this);
|
|
|
+
|
|
|
+ setWindow = new PopupWindow(viewContext,
|
|
|
+ LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
+ LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ setWindow.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ setWindow.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_popuwin));
|
|
|
+ setWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closePopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()){
|
|
|
+ case R.id.share_2code:
|
|
|
+ closePopupWindow();
|
|
|
+ break;
|
|
|
+ case R.id.change_style:
|
|
|
+ closePopupWindow();
|
|
|
+ break;
|
|
|
+ case R.id.save_to_MBphone:
|
|
|
+ closePopupWindow();
|
|
|
+ break;
|
|
|
+ case R.id.scan_2dcode:
|
|
|
+ closePopupWindow();
|
|
|
+ break;
|
|
|
+ case R.id.cancel_tv:
|
|
|
+ closePopupWindow();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 生成二维码
|
|
|
* @throws WriterException
|
|
|
@@ -147,4 +227,5 @@ public class InfoCodeActivity extends BaseActivity {
|
|
|
|
|
|
return bitmap;
|
|
|
}
|
|
|
+
|
|
|
}
|