會議時間:2016年3月30日 13:00~13:20
會議成員:冉華,張敏,王巍,夏一鳴。
會議目的:匯報前一天工作,全體成員評論,確定會后修改內容或分配下一步任務。
會議內容:
1.前端,完成功能點為“將獲取信息轉化為中端所需格式”,“發送獲取的信息給中端”。以下是代碼部分

1 package com.onezero.account; 2 3 import java.text.ParseException; 4 import java.text.SimpleDateFormat; 5 import java.util.Date; 6 7 import com.onezero.account.controller.Account; 8 import com.onezero.account.controller.AccountManager; 9 import com.onezero.account.controller.AccountManagerImpl; 10 11 import android.app.Activity; 12 import android.os.Bundle; 13 import android.util.Log; 14 import android.view.Menu; 15 import android.view.MenuItem; 16 import android.view.View; 17 import android.widget.Button; 18 import android.widget.EditText; 19 import android.widget.TextView; 20 import android.widget.Toast; 21 22 public class add extends Activity { 23 24 @Override 25 protected void onCreate(Bundle savedInstanceState) { 26 super.onCreate(savedInstanceState); 27 setContentView(R.layout.add_main); 28 // 顯示當前時間 29 SimpleDateFormat formatter = new SimpleDateFormat( 30 "yyyy年MM月dd日 HH:mm:ss"); 31 Date curDate = new Date(System.currentTimeMillis());// 獲取當前時間 32 String str = formatter.format(curDate); 33 34 TextView mTime = (TextView) findViewById(R.id.mytime); 35 mTime.setText(str); 36 37 // 實現事件類型選擇,點擊並改變顯示。 38 final TextView accounttype = (TextView) findViewById(R.id.accounttype); 39 // 一般 40 Button button1 = (Button) findViewById(R.id.button1); 41 button1.setOnClickListener(new Button.OnClickListener() { 42 public void onClick(View v) { 43 Button button1 = (Button) findViewById(R.id.button1); 44 accounttype.setText(button1.getText()); 45 46 } 47 }); 48 // 餐飲 49 Button button2 = (Button) findViewById(R.id.button2); 50 button2.setOnClickListener(new Button.OnClickListener() { 51 public void onClick(View v) { 52 Button button2 = (Button) findViewById(R.id.button2); 53 accounttype.setText(button2.getText()); 54 55 } 56 }); 57 58 // 購物 59 Button button3 = (Button) findViewById(R.id.button3); 60 button3.setOnClickListener(new Button.OnClickListener() { 61 public void onClick(View v) { 62 Button button3 = (Button) findViewById(R.id.button3); 63 accounttype.setText(button3.getText()); 64 65 } 66 }); 67 // 交通 68 Button button4 = (Button) findViewById(R.id.button4); 69 button4.setOnClickListener(new Button.OnClickListener() { 70 public void onClick(View v) { 71 Button button4 = (Button) findViewById(R.id.button4); 72 accounttype.setText(button4.getText()); 73 74 } 75 }); 76 // 娛樂 77 Button button5 = (Button) findViewById(R.id.button5); 78 button5.setOnClickListener(new Button.OnClickListener() { 79 public void onClick(View v) { 80 Button button5 = (Button) findViewById(R.id.button5); 81 accounttype.setText(button5.getText()); 82 83 } 84 }); 85 86 // 醫療 87 Button button6 = (Button) findViewById(R.id.button6); 88 button6.setOnClickListener(new Button.OnClickListener() { 89 public void onClick(View v) { 90 Button button6 = (Button) findViewById(R.id.button6); 91 accounttype.setText(button6.getText()); 92 93 } 94 }); 95 96 Button button7 = (Button) findViewById(R.id.button7); 97 button7.setOnClickListener(new Button.OnClickListener() { 98 public void onClick(View v) { 99 OK(); 100 101 } 102 }); 103 104 } 105 106 public boolean onCreateOptionsMenu(Menu menu) { 107 // Inflate the menu; this adds items to the action bar if it is present. 108 getMenuInflater().inflate(R.menu.add, menu); 109 return true; 110 } 111 112 @Override 113 public boolean onOptionsItemSelected(MenuItem item) { 114 // Handle action bar item clicks here. The action bar will 115 // automatically handle clicks on the Home/Up button, so long 116 // as you specify a parent activity in AndroidManifest.xml. 117 118 // 獲取“錄入”的返回鍵,並執行返回。 119 int id = item.getItemId(); 120 if (id == R.id.action_add_back) { 121 122 onBackPressed(); 123 } 124 125 return super.onOptionsItemSelected(item); 126 } 127 128 // OK按鈕 129 public void OK() { 130 131 TextView mytime = (TextView) findViewById(R.id.mytime); 132 String text1 = mytime.getText().toString(); 133 134 TextView accounttype = (TextView) findViewById(R.id.accounttype); 135 String text2 = accounttype.getText().toString(); 136 137 EditText editText1 = (EditText) findViewById(R.id.editText1); 138 String text3 = editText1.getText().toString(); 139 140 EditText editText2 = (EditText) findViewById(R.id.editText2); 141 String text4 = editText2.getText().toString(); 142 143 144 if (text3.equals("")) { 145 146 Log.e("$%^", "toast"); 147 Toast toast = Toast.makeText(add.this, "請輸入金額。", 148 Toast.LENGTH_SHORT); 149 toast.show(); 150 } 151 152 else if(text3.equals(".")||text3.substring(0, 1).equals("0")){ 153 154 Toast toast = Toast.makeText(add.this, "輸入有誤,請重新輸入。", 155 Toast.LENGTH_SHORT); 156 toast.show(); 157 158 159 160 } 161 162 else{ 163 164 AccountManager accountManager = new AccountManagerImpl(); 165 Account account = new Account(); 166 account.setAccountId(1); 167 168 try { 169 account.setAccountDate(new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").parse(text1)); 170 } catch (ParseException e) { 171 // TODO Auto-generated catch block 172 e.printStackTrace(); 173 } 174 175 account.setAccountType(text2); 176 account.setAccountSum(text3); 177 accountManager.addAcount(account); 178 179 onBackPressed(); 180 } 181 182 183 184 185 } 186 187 }
2.中端,完成功能點為“接收前端發送的數據”,“發送數據給后端”,“提供查詢接口”。以下是代碼部分

1 package com.onezero.account; 2 3 import java.text.ParseException; 4 import java.text.SimpleDateFormat; 5 import java.util.Date; 6 7 import com.onezero.account.controller.Account; 8 import com.onezero.account.controller.AccountManager; 9 import com.onezero.account.controller.AccountManagerImpl; 10 11 import android.app.Activity; 12 import android.os.Bundle; 13 import android.util.Log; 14 import android.view.Menu; 15 import android.view.MenuItem; 16 import android.view.View; 17 import android.widget.Button; 18 import android.widget.EditText; 19 import android.widget.TextView; 20 import android.widget.Toast; 21 22 public class add extends Activity { 23 24 @Override 25 protected void onCreate(Bundle savedInstanceState) { 26 super.onCreate(savedInstanceState); 27 setContentView(R.layout.add_main); 28 // 顯示當前時間 29 SimpleDateFormat formatter = new SimpleDateFormat( 30 "yyyy年MM月dd日 HH:mm:ss"); 31 Date curDate = new Date(System.currentTimeMillis());// 獲取當前時間 32 String str = formatter.format(curDate); 33 34 TextView mTime = (TextView) findViewById(R.id.mytime); 35 mTime.setText(str); 36 37 // 實現事件類型選擇,點擊並改變顯示。 38 final TextView accounttype = (TextView) findViewById(R.id.accounttype); 39 // 一般 40 Button button1 = (Button) findViewById(R.id.button1); 41 button1.setOnClickListener(new Button.OnClickListener() { 42 public void onClick(View v) { 43 Button button1 = (Button) findViewById(R.id.button1); 44 accounttype.setText(button1.getText()); 45 46 } 47 }); 48 // 餐飲 49 Button button2 = (Button) findViewById(R.id.button2); 50 button2.setOnClickListener(new Button.OnClickListener() { 51 public void onClick(View v) { 52 Button button2 = (Button) findViewById(R.id.button2); 53 accounttype.setText(button2.getText()); 54 55 } 56 }); 57 58 // 購物 59 Button button3 = (Button) findViewById(R.id.button3); 60 button3.setOnClickListener(new Button.OnClickListener() { 61 public void onClick(View v) { 62 Button button3 = (Button) findViewById(R.id.button3); 63 accounttype.setText(button3.getText()); 64 65 } 66 }); 67 // 交通 68 Button button4 = (Button) findViewById(R.id.button4); 69 button4.setOnClickListener(new Button.OnClickListener() { 70 public void onClick(View v) { 71 Button button4 = (Button) findViewById(R.id.button4); 72 accounttype.setText(button4.getText()); 73 74 } 75 }); 76 // 娛樂 77 Button button5 = (Button) findViewById(R.id.button5); 78 button5.setOnClickListener(new Button.OnClickListener() { 79 public void onClick(View v) { 80 Button button5 = (Button) findViewById(R.id.button5); 81 accounttype.setText(button5.getText()); 82 83 } 84 }); 85 86 // 醫療 87 Button button6 = (Button) findViewById(R.id.button6); 88 button6.setOnClickListener(new Button.OnClickListener() { 89 public void onClick(View v) { 90 Button button6 = (Button) findViewById(R.id.button6); 91 accounttype.setText(button6.getText()); 92 93 } 94 }); 95 96 Button button7 = (Button) findViewById(R.id.button7); 97 button7.setOnClickListener(new Button.OnClickListener() { 98 public void onClick(View v) { 99 OK(); 100 101 } 102 }); 103 104 } 105 106 public boolean onCreateOptionsMenu(Menu menu) { 107 // Inflate the menu; this adds items to the action bar if it is present. 108 getMenuInflater().inflate(R.menu.add, menu); 109 return true; 110 } 111 112 @Override 113 public boolean onOptionsItemSelected(MenuItem item) { 114 // Handle action bar item clicks here. The action bar will 115 // automatically handle clicks on the Home/Up button, so long 116 // as you specify a parent activity in AndroidManifest.xml. 117 118 // 獲取“錄入”的返回鍵,並執行返回。 119 int id = item.getItemId(); 120 if (id == R.id.action_add_back) { 121 122 onBackPressed(); 123 } 124 125 return super.onOptionsItemSelected(item); 126 } 127 128 // OK按鈕 129 public void OK() { 130 131 TextView mytime = (TextView) findViewById(R.id.mytime); 132 String text1 = mytime.getText().toString(); 133 134 TextView accounttype = (TextView) findViewById(R.id.accounttype); 135 String text2 = accounttype.getText().toString(); 136 137 EditText editText1 = (EditText) findViewById(R.id.editText1); 138 String text3 = editText1.getText().toString(); 139 140 EditText editText2 = (EditText) findViewById(R.id.editText2); 141 String text4 = editText2.getText().toString(); 142 143 144 if (text3.equals("")) { 145 146 Log.e("$%^", "toast"); 147 Toast toast = Toast.makeText(add.this, "請輸入金額。", 148 Toast.LENGTH_SHORT); 149 toast.show(); 150 } 151 152 else if(text3.equals(".")||text3.substring(0, 1).equals("0")){ 153 154 Toast toast = Toast.makeText(add.this, "輸入有誤,請重新輸入。", 155 Toast.LENGTH_SHORT); 156 toast.show(); 157 158 159 160 } 161 162 else{ 163 164 AccountManager accountManager = new AccountManagerImpl(); 165 Account account = new Account(); 166 account.setAccountId(1); 167 168 try { 169 account.setAccountDate(new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").parse(text1)); 170 } catch (ParseException e) { 171 // TODO Auto-generated catch block 172 e.printStackTrace(); 173 } 174 175 account.setAccountType(text2); 176 account.setAccountSum(text3); 177 accountManager.addAcount(account); 178 179 onBackPressed(); 180 } 181 182 183 184 185 } 186 187 }

1 package com.onezero.account.controller; 2 3 import java.util.List; 4 5 public interface AccountManager { 6 7 /** 8 * 添加賬本信息 9 * 10 * @param account 帳本信息 11 * @return true 添加成功 false:添加失敗 12 * 13 *TODO: 需要確認添加失敗是否拋出異常,給用戶友好提示 14 */ 15 boolean addAcount(Account account); 16 17 /** 18 * 查詢全部賬本信息,返回信息按時間降序排序 19 * 20 * @return 全部賬本信息 21 */ 22 List<Account> queryAcount(); 23 }

1 package com.onezero.account.controller; 2 3 import java.util.Date; 4 import java.util.List; 5 import java.util.ArrayList; 6 public class AccountManagerImpl implements AccountManager{ 7 8 /** 9 * 添加賬本信息 10 * 11 * @param account 帳本信息 12 * @return true 添加成功 false:添加失敗 13 * 14 *TODO: 需要確認添加失敗是否拋出異常,給用戶友好提示 15 */ 16 public boolean addAcount(Account account){ 17 // TODO:調用數據庫層 18 return true; 19 } 20 21 /** 22 * 查詢全部賬本信息,返回信息按時間降序排序 23 * 24 * @return 全部賬本信息 25 */ 26 public List<Account> queryAcount(){ 27 List<Account> accountList = new ArrayList<Account>(); 28 29 // TODO: 調用數據庫層 (暫時寫假的) 30 Account account = new Account(); 31 account.setAccountId(1); 32 account.setAccountDate(new Date()); 33 account.setAccountType("transportation"); 34 account.setAccountSum("50"); 35 36 accountList.add(account); 37 return accountList; 38 } 39 }
3.后端,完成功能點為“將獲取的數據插入數據庫”。
會議體會:昨天布置的任務大家都順利完成,繼續努力。以下是本周的燃盡圖,我對昨天的燃盡圖進行了修改。
以上是OneZero第二周第三次站立會議。