瀏覽代碼

1.完成一元捐基本的界面逻辑开发,接入支付宝,完成支付宝相关功能
2.移除测试数据
3.添加异常处理,提交测试

Bitliker 8 年之前
父節點
當前提交
570117ac84

+ 143 - 143
app_modular/appworks/src/main/java/com/uas/appworks/widget/SelectPlayPop.java

@@ -33,155 +33,155 @@ import com.uas.appworks.R;
 
 public class SelectPlayPop {
 
-	public static void showPlay(final Activity ct, CharitModel model, OnSureListener onSureListener) {
-		if (model == null) return;
-		final PopupWindow window = new PopupWindow(ct);
+    public static void showPlay(final Activity ct, CharitModel model, OnSureListener onSureListener) {
+        if (model == null) return;
+        final PopupWindow window = new PopupWindow(ct);
 //		window.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
-		window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
-		View view = LayoutInflater.from(ct).inflate(R.layout.pop_play_select, null);
-		window.setContentView(view);
-		window.getContentView().measure(0, 0);
-		int height = DisplayUtil.dip2px(ct, 270);
-		window.setHeight(height);
-		window.setWidth(DisplayUtil.getSreechWidth(ct));
-		initView(ct, window, view, model, onSureListener);
-		window.setBackgroundDrawable(ct.getResources().getDrawable(R.color.background));
-		DisplayUtil.backgroundAlpha(ct, 0.4f);
-		window.setTouchable(true);
-		window.setOutsideTouchable(false);
-		window.setFocusable(true);
-		window.setOnDismissListener(new PopupWindow.OnDismissListener() {
-			@Override
-			public void onDismiss() {
-				DisplayUtil.backgroundAlpha(ct, 1f);
-			}
-		});
-		window.showAtLocation(view, Gravity.CENTER, 0, height);
-	}
+        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+        View view = LayoutInflater.from(ct).inflate(R.layout.pop_play_select, null);
+        window.setContentView(view);
+        window.getContentView().measure(0, 0);
+        int height = DisplayUtil.dip2px(ct, 270);
+        window.setHeight(height);
+        window.setWidth(DisplayUtil.getSreechWidth(ct));
+        initView(ct, window, view, model, onSureListener);
+        window.setBackgroundDrawable(ct.getResources().getDrawable(R.color.background));
+        DisplayUtil.backgroundAlpha(ct, 0.4f);
+        window.setTouchable(true);
+        window.setOutsideTouchable(false);
+        window.setFocusable(true);
+        window.setOnDismissListener(new PopupWindow.OnDismissListener() {
+            @Override
+            public void onDismiss() {
+                DisplayUtil.backgroundAlpha(ct, 1f);
+            }
+        });
+        window.showAtLocation(view, Gravity.CENTER, 0, height);
+    }
 
 
-	private static void initView(final Context ct, final PopupWindow window, View view, final CharitModel model, final OnSureListener onSureListener) {
-		TextView nameTv = (TextView) view.findViewById(R.id.nameTv);
-		nameTv.setText(model.getName());
-		final EditText autoNumEd = (EditText) view.findViewById(R.id.autoNumEd);
-		final TextView agreeNoteTv = (TextView) view.findViewById(R.id.agreeNoteTv);
-		final TextView payNumTv = (TextView) view.findViewById(R.id.payNumTv);
-		final CheckBox agreeCb = (CheckBox) view.findViewById(R.id.agreeCb);
-		final RadioGroup selectRg = (RadioGroup) view.findViewById(R.id.selectRg);
-		final RadioGroup typeRg = (RadioGroup) view.findViewById(R.id.typeRg);
-		final RadioButton wxRb = (RadioButton) view.findViewById(R.id.wxRb);
-		final RadioButton aliPlayRb = (RadioButton) view.findViewById(R.id.aliPlayRb);
-		payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + 1 + "元");
-		autoNumEd.addTextChangedListener(new EditChangeListener() {
-			@Override
-			public void afterTextChanged(Editable editable) {
-				try {
-					double num = Double.valueOf(editable.toString());
-					payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num);
-				} catch (Exception e) {
+    private static void initView(final Context ct, final PopupWindow window, View view, final CharitModel model, final OnSureListener onSureListener) {
+        TextView nameTv = (TextView) view.findViewById(R.id.nameTv);
+        nameTv.setText(model.getName());
+        final EditText autoNumEd = (EditText) view.findViewById(R.id.autoNumEd);
+        final TextView agreeNoteTv = (TextView) view.findViewById(R.id.agreeNoteTv);
+        final TextView payNumTv = (TextView) view.findViewById(R.id.payNumTv);
+        final CheckBox agreeCb = (CheckBox) view.findViewById(R.id.agreeCb);
+        final RadioGroup selectRg = (RadioGroup) view.findViewById(R.id.selectRg);
+        final RadioGroup typeRg = (RadioGroup) view.findViewById(R.id.typeRg);
+        final RadioButton wxRb = (RadioButton) view.findViewById(R.id.wxRb);
+        final RadioButton aliPlayRb = (RadioButton) view.findViewById(R.id.aliPlayRb);
+        payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + 1 + "元");
+        autoNumEd.addTextChangedListener(new EditChangeListener() {
+            @Override
+            public void afterTextChanged(Editable editable) {
+                try {
+                    double num = Double.valueOf(editable.toString());
+                    payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num);
+                } catch (Exception e) {
 
-				}
-			}
-		});
-		selectRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
-			@Override
-			public void onCheckedChanged(RadioGroup radioGroup, int i) {
-				hideKeyboard(ct, autoNumEd);
-				autoNumEd.setText("");
-				int num = 1;
-				if (i == R.id.oneRb) {
-					num = 1;
-				} else if (i == R.id.twoRb) {
-					num = 2;
-				} else if (i == R.id.fiveRb) {
-					num = 5;
-				} else if (i == R.id.tenRb) {
-					num = 10;
-				}
-				payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num + "元");
-			}
-		});
-		typeRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
-			@Override
-			public void onCheckedChanged(RadioGroup radioGroup, int i) {
-				hideKeyboard(ct, autoNumEd);
-				if (i == R.id.wxRb) {
-					ToastUtil.showToast(ct, "暂不支持微信支付");
-					aliPlayRb.setChecked(true);
-					wxRb.setChecked(false);
-				}
-			}
-		});
-		agreeCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
-			@Override
-			public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
-				if (b) {
-					agreeNoteTv.setVisibility(View.GONE);
-				}
-			}
-		});
-		view.setOnClickListener(new View.OnClickListener() {
-			@Override
-			public void onClick(View view) {
-				hideKeyboard(ct, autoNumEd);
-			}
-		});
-		view.findViewById(R.id.giftBtn).setOnClickListener(new View.OnClickListener() {
-			@Override
-			public void onClick(View view) {
-				hideKeyboard(ct, autoNumEd);
-				if (agreeCb.isChecked()) {
-					giftBtn(window, autoNumEd, selectRg, typeRg, model, onSureListener);
-				} else {
-					agreeNoteTv.setVisibility(View.VISIBLE);
-				}
-			}
-		});
-	}
+                }
+            }
+        });
+        selectRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup radioGroup, int i) {
+                hideKeyboard(ct, autoNumEd);
+                autoNumEd.setText("");
+                int num = 1;
+                if (i == R.id.oneRb) {
+                    num = 1;
+                } else if (i == R.id.twoRb) {
+                    num = 2;
+                } else if (i == R.id.fiveRb) {
+                    num = 5;
+                } else if (i == R.id.tenRb) {
+                    num = 10;
+                }
+                payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num + "元");
+            }
+        });
+        typeRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup radioGroup, int i) {
+                hideKeyboard(ct, autoNumEd);
+                if (i == R.id.wxRb) {
+                    ToastUtil.showToast(ct, "暂不支持微信支付");
+                    aliPlayRb.setChecked(true);
+                    wxRb.setChecked(false);
+                }
+            }
+        });
+        agreeCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+                if (b) {
+                    agreeNoteTv.setVisibility(View.GONE);
+                }
+            }
+        });
+        view.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                hideKeyboard(ct, autoNumEd);
+            }
+        });
+        view.findViewById(R.id.giftBtn).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                hideKeyboard(ct, autoNumEd);
+                if (agreeCb.isChecked()) {
+                    giftBtn(window, autoNumEd, selectRg, typeRg, model, onSureListener);
+                } else {
+                    agreeNoteTv.setVisibility(View.VISIBLE);
+                }
+            }
+        });
+    }
 
-	/*隐藏软键盘并显示头布局*/
-	private static void hideKeyboard(Context context, EditText chatEd) {
-		InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
-		imm.hideSoftInputFromWindow(chatEd.getWindowToken(), 0);
-	}
+    /*隐藏软键盘并显示头布局*/
+    private static void hideKeyboard(Context context, EditText chatEd) {
+        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+        imm.hideSoftInputFromWindow(chatEd.getWindowToken(), 0);
+    }
 
-	private static synchronized void giftBtn(PopupWindow window, EditText autoNumEd, RadioGroup selectRg, RadioGroup typeRg, CharitModel model, OnSureListener onSureListener) {
-		double num = 1;
-		if (TextUtils.isEmpty(autoNumEd.getText())) {
-			int selectId = selectRg.getCheckedRadioButtonId();
-			if (selectId == R.id.twoRb) {
-				num = 2;
-			} else if (selectId == R.id.fiveRb) {
-				num = 5;
-			} else if (selectId == R.id.tenRb) {
-				num = 10;
-			}
-		} else {
-			String message = autoNumEd.getText().toString();
-			LogUtil.i("message=" + message);
-			try {
-				num = Double.valueOf(message);
-			} catch (Exception e) {
-				if (e != null) {
-					LogUtil.i("giftBtn Exception =" + e.getMessage());
-				}
-			}
-		}
-		int typeId = typeRg.getCheckedRadioButtonId();
-		int type = 2;
-		if (typeId == R.id.wxRb) {
-			type = 1;
-		}
-		if (onSureListener != null) {
-			onSureListener.sure(num, type, model);
-		}
-		if (window != null && window.isShowing()) {
-			window.dismiss();
-		}
-	}
+    private static synchronized void giftBtn(PopupWindow window, EditText autoNumEd, RadioGroup selectRg, RadioGroup typeRg, CharitModel model, OnSureListener onSureListener) {
+        double num = 1;
+        if (TextUtils.isEmpty(autoNumEd.getText())) {
+            int selectId = selectRg.getCheckedRadioButtonId();
+            if (selectId == R.id.twoRb) {
+                num = 2;
+            } else if (selectId == R.id.fiveRb) {
+                num = 5;
+            } else if (selectId == R.id.tenRb) {
+                num = 10;
+            }
+        } else {
+            String message = autoNumEd.getText().toString();
+            LogUtil.i("message=" + message);
+            try {
+                num = Double.valueOf(message);
+            } catch (Exception e) {
+                if (e != null) {
+                    LogUtil.i("giftBtn Exception =" + e.getMessage());
+                }
+            }
+        }
+        int typeId = typeRg.getCheckedRadioButtonId();
+        int type = 2;
+        if (typeId == R.id.wxRb) {
+            type = 1;
+        }
+        if (onSureListener != null) {
+            onSureListener.sure(num, type, model);
+        }
+        if (window != null && window.isShowing()) {
+            window.dismiss();
+        }
+    }
 
 
-	public interface OnSureListener {
-		void sure(double num, int type, CharitModel model);
-	}
+    public interface OnSureListener {
+        void sure(double num, int type, CharitModel model);
+    }
 }

+ 3 - 0
app_modular/appworks/src/main/res/layout/item_charitable_list.xml

@@ -85,9 +85,12 @@
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:layout_alignTop="@id/typeTv"
+        android:layout_marginBottom="@dimen/padding"
+        android:layout_marginRight="@dimen/padding"
         android:background="@color/indianred"
         android:padding="8dp"
         android:text="我要捐款"
+        android:textSize="@dimen/text_hine"
         android:textColor="@color/white" />
 
 </RelativeLayout>

+ 5 - 5
app_modular/appworks/src/main/res/layout/pop_play_select.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="270dp"
+    android:layout_height="290dp"
     android:background="@color/background"
     android:padding="@dimen/padding">
 
@@ -113,6 +113,7 @@
             android:layout_height="wrap_content"
             android:background="@null"
             android:hint="自定义金额"
+            android:maxWidth="300dp"
             android:inputType="numberDecimal"
             android:minWidth="40dp"
             android:textSize="@dimen/text_main" />
@@ -131,9 +132,8 @@
         android:id="@+id/payNumTv"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_alignBottom="@id/autoRl"
         android:layout_marginLeft="10dp"
-        android:layout_toRightOf="@id/autoRl"
+        android:layout_below="@id/autoRl"
         android:text="*当前选择1元*"
         android:textColor="@color/indianred" />
 
@@ -141,8 +141,8 @@
         android:id="@+id/typeTv"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_alignLeft="@id/autoRl"
-        android:layout_below="@id/autoRl"
+        android:layout_alignLeft="@id/payNumTv"
+        android:layout_below="@id/payNumTv"
         android:layout_marginTop="10dp"
         android:paddingTop="10dp"
         android:text="付款方式:"