-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1904 from XvSir0/master
- Loading branch information
Showing
38 changed files
with
1,954 additions
and
76 deletions.
There are no files selected for viewing
11 changes: 6 additions & 5 deletions
11
...80902117/app/src/main/AndroidManifest.xml → ...nts/soft1714080902117/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="edu.hzuapps.androidlabs.soft1714080902117"> | ||
package="fun.zzti.memoire"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:icon="@mipmap/ic_launcher_new" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:roundIcon="@mipmap/ic_launcher_new" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".Soft1714080902117"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".EditActivity"/> | ||
<activity android:name=".AmendActivity"/> | ||
</application> | ||
|
||
</manifest> |
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
...902117/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902117/Soft1714080902117.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
students/soft1714080902117/app/src/main/res/layout/activity_soft_1714080902117_activity.xml
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
students/soft1714080902117/app/src/main/res/values/strings.xml
This file was deleted.
Oops, something went wrong.
228 changes: 228 additions & 0 deletions
228
students/soft1714080902117/java/fun/zzti/memoire/AmendActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
package fun.zzti.memoire; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.ContentValues; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AlertDialog; | ||
import android.util.Log; | ||
import android.view.KeyEvent; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import fun.zzti.memoire.database.MyDB; | ||
import fun.zzti.memoire.enity.Record; | ||
|
||
/** | ||
* create_by Android Studio | ||
* | ||
* @author zouguo0212@ | ||
* @package_name fun.zzti | ||
* @description | ||
* @date 2018/10/27 13:20 | ||
*/ | ||
public class AmendActivity extends BaseActivity implements View.OnClickListener{ | ||
|
||
private final static String TAG = "AmendActivity"; | ||
|
||
MyDB myDB; | ||
private Button btnSave; | ||
private Button btnBack; | ||
private TextView amendTime; | ||
private TextView amendTitle; | ||
private EditText amendBody; | ||
private Record record; | ||
private AlertDialog.Builder dialog; | ||
|
||
private Button btnUpcoming; | ||
private Button btnNotice; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.amend_linear_layout); | ||
init(); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void onClick(View v) { | ||
String body; | ||
body = amendBody.getText().toString(); | ||
switch (v.getId()){ | ||
case R.id.button_save: | ||
if (updateFunction(body)){ | ||
intentStart(); | ||
} | ||
break; | ||
case R.id.button_back: | ||
showDialog(body); | ||
clearDialog(); | ||
break; | ||
case R.id.btn_amend_menu_notice: | ||
Log.i("AmendActivity","这是修改页面的提醒按钮被点击"); | ||
break; | ||
case R.id.btn_amend_menu_upcoming: | ||
Log.i("AmendActivity","这是修改页面的待办按钮被点击"); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public boolean onKeyDown(int keyCode, KeyEvent event) { | ||
if (keyCode == KeyEvent.KEYCODE_BACK) { | ||
//当返回按键被按下 | ||
if (!isShowIng()){ | ||
showDialog(amendBody.getText().toString()); | ||
clearDialog(); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/* | ||
* 初始化函数 | ||
*/ | ||
@SuppressLint("SetTextI18n") | ||
void init(){ | ||
myDB = new MyDB(this); | ||
btnBack = findViewById(R.id.button_back); | ||
btnSave = findViewById(R.id.button_save); | ||
amendTitle = findViewById(R.id.amend_title); | ||
amendBody = findViewById(R.id.amend_body); | ||
amendTime = findViewById(R.id.amend_title_time); | ||
|
||
btnUpcoming = findViewById(R.id.btn_amend_menu_upcoming); | ||
btnNotice = findViewById(R.id.btn_amend_menu_notice); | ||
|
||
btnSave.setOnClickListener(this); | ||
btnBack.setOnClickListener(this); | ||
|
||
btnNotice.setOnClickListener(this); | ||
btnUpcoming.setOnClickListener(this); | ||
|
||
Intent intent = this.getIntent(); | ||
if (intent!=null){ | ||
|
||
record = new Record(); | ||
|
||
record.setId(Integer.valueOf(intent.getStringExtra(MyDB.RECORD_ID))); | ||
record.setTitleName(intent.getStringExtra(MyDB.RECORD_TITLE)); | ||
record.setTextBody(intent.getStringExtra(MyDB.RECORD_BODY)); | ||
record.setCreateTime(intent.getStringExtra(MyDB.RECORD_TIME)); | ||
record.setNoticeTime(intent.getStringExtra(MyDB.NOTICE_TIME)); | ||
|
||
amendTitle.setText(record.getTitleName()); | ||
String str=""; | ||
if (record.getNoticeTime()!=null){ | ||
str = " 提醒时间:"+record.getNoticeTime(); | ||
} | ||
amendTime.setText(record.getCreateTime()+str); | ||
amendBody.setText(record.getTextBody()); | ||
} | ||
} | ||
|
||
/* | ||
* 返回主界面 | ||
*/ | ||
void intentStart(){ | ||
Intent intent = new Intent(AmendActivity.this,MainActivity.class); | ||
startActivity(intent); | ||
this.finish(); | ||
} | ||
|
||
/* | ||
* 保存函数 | ||
*/ | ||
boolean updateFunction(String body){ | ||
|
||
SQLiteDatabase db; | ||
ContentValues values; | ||
|
||
boolean flag = true; | ||
if (body.length()>200){ | ||
Toast.makeText(this,"内容过长",Toast.LENGTH_SHORT).show(); | ||
flag = false; | ||
} | ||
if(flag){ | ||
// update | ||
db = myDB.getWritableDatabase(); | ||
values = new ContentValues(); | ||
values.put(MyDB.RECORD_BODY,body); | ||
values.put(MyDB.RECORD_TIME,getNowTime()); | ||
db.update(MyDB.TABLE_NAME_RECORD,values,MyDB.RECORD_ID +"=?", | ||
new String[]{record.getId().toString()}); | ||
Toast.makeText(this,"修改成功",Toast.LENGTH_SHORT).show(); | ||
db.close(); | ||
} | ||
return flag; | ||
} | ||
|
||
/* | ||
* 弹窗函数 | ||
* @param title | ||
* @param body | ||
* @param createDate | ||
*/ | ||
void showDialog(final String body){ | ||
dialog = new AlertDialog.Builder(AmendActivity.this); | ||
dialog.setTitle("提示"); | ||
dialog.setMessage("是否保存当前编辑内容"); | ||
dialog.setPositiveButton("保存", | ||
new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
updateFunction(body); | ||
intentStart(); | ||
} | ||
}); | ||
|
||
dialog.setNegativeButton("取消", | ||
new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
intentStart(); | ||
} | ||
}); | ||
dialog.show(); | ||
} | ||
|
||
void clearDialog(){ | ||
dialog = null; | ||
} | ||
|
||
boolean isShowIng(){ | ||
if (dialog!=null){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
|
||
/* | ||
* 得到当前时间 | ||
* @return | ||
*/ | ||
String getNowTime(){ | ||
@SuppressLint("SimpleDateFormat") | ||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm"); | ||
//获取当前时间 | ||
Date date = new Date(System.currentTimeMillis()); | ||
return simpleDateFormat.format(date); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
students/soft1714080902117/java/fun/zzti/memoire/BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fun.zzti.memoire; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.pm.ActivityInfo; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
/** | ||
* create_by Android Studio | ||
* | ||
* @author zouguo0212@ | ||
* @package_name fun.zzti.memoire | ||
* @description | ||
* @date 2018/10/26 17:30 | ||
*/ | ||
@SuppressLint("Registered") | ||
public class BaseActivity extends AppCompatActivity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// 设置强制竖屏 | ||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
} | ||
} |
Oops, something went wrong.