├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── wentongwang │ │ └── notebook │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── about_us.html │ ├── java │ │ └── com │ │ │ └── wentongwang │ │ │ └── notebook │ │ │ ├── managers │ │ │ ├── MediaPlayerManager.java │ │ │ ├── MyActivityManager.java │ │ │ └── RecorderManager.java │ │ │ ├── model │ │ │ ├── Constants.java │ │ │ ├── DiaryItem.java │ │ │ ├── NoteItem.java │ │ │ ├── Response.java │ │ │ ├── UpdataEvent.java │ │ │ ├── User.java │ │ │ └── business │ │ │ │ ├── DiaryBiz.java │ │ │ │ ├── NoteBiz.java │ │ │ │ ├── OnResponseListener.java │ │ │ │ └── UserBiz.java │ │ │ ├── presenters │ │ │ ├── CreatDiaryPresenter.java │ │ │ ├── CreatNotePresenter.java │ │ │ ├── DiariesFragmentPresenter.java │ │ │ ├── EditDiaryPresenter.java │ │ │ ├── EditNotePresenter.java │ │ │ ├── HomePresenter.java │ │ │ ├── LoginPresenter.java │ │ │ ├── NotesFragmentPresenter.java │ │ │ ├── SignUpPresenter.java │ │ │ ├── SplashPresenter.java │ │ │ └── UserInfoPresenter.java │ │ │ ├── utils │ │ │ ├── AccountUtils.java │ │ │ ├── DatabaseUtils.java │ │ │ ├── ImageLoader.java │ │ │ ├── ImageUtils.java │ │ │ ├── MD5Util.java │ │ │ ├── MyDatabaseHelper.java │ │ │ ├── MyToast.java │ │ │ ├── RealImageLoader.java │ │ │ └── SPUtils.java │ │ │ └── view │ │ │ ├── BaseView.java │ │ │ ├── activity │ │ │ ├── BaseActivity.java │ │ │ ├── CreateDiaryActivity.java │ │ │ ├── CreateNoteActivity.java │ │ │ ├── EditDiaryActivity.java │ │ │ ├── EditNoteActivity.java │ │ │ ├── HomeActivity.java │ │ │ ├── LoginActivity.java │ │ │ ├── SignUpActivity.java │ │ │ ├── SplashActivity.java │ │ │ ├── UserInfoActivity.java │ │ │ └── interfaces │ │ │ │ ├── CreatDiaryView.java │ │ │ │ ├── CreatNoteView.java │ │ │ │ ├── EditDiaryView.java │ │ │ │ ├── EditNoteView.java │ │ │ │ ├── HomeView.java │ │ │ │ ├── LoginView.java │ │ │ │ ├── SignUpView.java │ │ │ │ ├── SplashView.java │ │ │ │ └── UserInfoView.java │ │ │ ├── custome │ │ │ ├── AudioRecoderButton.java │ │ │ ├── CircleImageView.java │ │ │ ├── PasswordInputView.java │ │ │ └── RecoderDialog.java │ │ │ └── fragment │ │ │ ├── AboutUsFragment.java │ │ │ ├── DiariesFragment.java │ │ │ ├── NotesFragment.java │ │ │ └── interfaces │ │ │ ├── DiariesView.java │ │ │ └── NotesView.java │ └── res │ │ ├── anim │ │ ├── popupwindow_hidden_anim.xml │ │ └── popupwindow_show_anim.xml │ │ ├── drawable-hdpi │ │ ├── about_us_icon.png │ │ ├── back_btn.png │ │ ├── back_btn_dark.png │ │ ├── circle_background.png │ │ ├── confirm.png │ │ ├── confirm_btn.png │ │ ├── delete.png │ │ ├── diaries.png │ │ ├── diary_icon.png │ │ ├── diary_pwd.png │ │ ├── edit_btn.png │ │ ├── email.png │ │ ├── female.png │ │ ├── left_btn.png │ │ ├── lock.png │ │ ├── locked.png │ │ ├── male.png │ │ ├── nickname.png │ │ ├── nolock.png │ │ ├── note_icon.png │ │ ├── notes.png │ │ ├── password.png │ │ ├── photo.png │ │ ├── recode_btn.png │ │ ├── refresh_btn.png │ │ ├── search.png │ │ ├── setting_icon.png │ │ ├── time_icon.png │ │ ├── to_right.png │ │ ├── user_head_defaut.jpg │ │ ├── user_name.png │ │ ├── voice1.png │ │ ├── voice2.png │ │ ├── voice3.png │ │ ├── voice4.png │ │ ├── voice5.png │ │ ├── voice6.png │ │ ├── voice7.png │ │ └── write_icon.png │ │ ├── drawable-xhdpi │ │ └── white_background.jpg │ │ ├── drawable │ │ ├── bottom_line.xml │ │ ├── btn_dark_blue_background.xml │ │ ├── btn_light_blue_background.xml │ │ ├── btn_light_red_background.xml │ │ ├── btn_orange_background.xml │ │ ├── circle_btn_background.xml │ │ ├── divider_line.xml │ │ ├── login_divider_line.xml │ │ ├── login_et_background.xml │ │ ├── login_ll_background.xml │ │ └── recoder_dialog_background.xml │ │ ├── layout │ │ ├── about_us_fragment_layout.xml │ │ ├── change_info_dialog_layout.xml │ │ ├── create_diary_activity_layout.xml │ │ ├── create_note_activity_layout.xml │ │ ├── diaries_fragment_layout.xml │ │ ├── diaries_listview_item.xml │ │ ├── edit_diray_activity_layout.xml │ │ ├── edit_note_activity_layout.xml │ │ ├── home_activity_content.xml │ │ ├── home_activity_layout.xml │ │ ├── home_activity_left_menu.xml │ │ ├── input_diarypwd_dialog_layout.xml │ │ ├── login_activity_layout.xml │ │ ├── notes_fragment_layout.xml │ │ ├── notes_listview_item.xml │ │ ├── popupwindow_choose_layout.xml │ │ ├── recoder_dialog_layout.xml │ │ ├── signup_activity_layout.xml │ │ ├── splash_activity_layout.xml │ │ ├── toolbar_layout.xml │ │ └── userinfo_activity_layout.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── icon_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── wentongwang │ └── notebook │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | NoteBook -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 功能 2 | 1.便签 3 | 2.日记(带锁) 4 | 全部都是上传到服务器的(第三方的Bmob),本地并不保存 5 | 6 | 7 | 8 | ### 目的: 9 | 1.尝试使用mvp 10 | 2.熟练android的基础的api 11 | 3.学习Material Design 12 | 13 | ###TODO: 14 | 1.完善mvp 15 | 2.完善功能 使日记之中可以插图片之类的 16 | 3.添加计划功能 可提醒用户之类的 17 | *.创建自己的服务器来保存数据(后话) 18 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | //兼容Android6.0系统所需,如果这句话报错,可在dependencies标签下使用compile 'cn.bmob.android:http-legacy:1.0' 8 | useLibrary 'org.apache.http.legacy' 9 | 10 | 11 | defaultConfig { 12 | applicationId "com.wentongwang.notebook" 13 | minSdkVersion 18 14 | targetSdkVersion 23 15 | versionCode 1 16 | versionName "1.0" 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:appcompat-v7:23.2.1' 30 | compile 'org.greenrobot:eventbus:3.0.0' 31 | compile 'com.android.support:support-v4:23.2.1' 32 | compile 'cn.bmob.android:http-legacy:1.0' 33 | //bmob-sdk:Bmob的android sdk包,包含了Bmob的数据存储、文件等服务,以下是最新的bmob-sdk: 34 | //3.4.7-aar:请务必查看下面注释[1] 35 | compile 'cn.bmob.android:bmob-sdk:3.4.7-aar' 36 | compile 'com.android.support:cardview-v7:24.0.0' 37 | compile 'com.jakewharton:disklrucache:2.0.2' 38 | } 39 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/wentongwang/notebook/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 41 | 44 | 47 | 49 | 50 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/assets/about_us.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 关于APP 6 | 7 | 8 |

这是个可以将你随手记录下来的东西都存入到服务器的便签本

9 |
10 |
11 |

服务器暂时用的是bmob,等开发好自己的服务器后,转移到自己的服务器上

12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/managers/MediaPlayerManager.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.managers; 2 | 3 | import android.media.AudioManager; 4 | import android.media.MediaPlayer; 5 | 6 | import java.io.IOException; 7 | 8 | /** 9 | * 播放管理类(目前只是音频) 10 | * Created by Wentong WANG on 2016/7/8. 11 | */ 12 | public class MediaPlayerManager { 13 | 14 | 15 | private MediaPlayer mediaPlayer; 16 | private boolean isPause; 17 | 18 | /** 19 | * 播放本地文件 20 | * 21 | * @param filePath 22 | */ 23 | public void playNative(String filePath, MediaPlayer.OnCompletionListener onCompletionListener) { 24 | if (mediaPlayer == null) { 25 | mediaPlayer = new MediaPlayer(); 26 | 27 | //设置一个error监听器 28 | mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { 29 | 30 | public boolean onError(MediaPlayer arg0, int arg1, int arg2) { 31 | mediaPlayer.reset(); 32 | return false; 33 | } 34 | }); 35 | } else { 36 | mediaPlayer.reset(); 37 | } 38 | 39 | try { 40 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 41 | mediaPlayer.setOnCompletionListener(onCompletionListener); 42 | mediaPlayer.setDataSource(filePath); 43 | mediaPlayer.prepare(); 44 | mediaPlayer.start(); 45 | } catch (Exception e) { 46 | 47 | } 48 | 49 | 50 | } 51 | 52 | /** 53 | * 播放网络文件 54 | * @param url 55 | * @param onCompletionListener 56 | */ 57 | public void playUrl(String url, MediaPlayer.OnCompletionListener onCompletionListener) { 58 | if (mediaPlayer == null) { 59 | mediaPlayer = new MediaPlayer(); 60 | //设置一个error监听器 61 | mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { 62 | public boolean onError(MediaPlayer arg0, int arg1, int arg2) { 63 | mediaPlayer.reset(); 64 | return false; 65 | } 66 | }); 67 | } else { 68 | mediaPlayer.reset(); 69 | } 70 | 71 | try { 72 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 73 | mediaPlayer.setOnCompletionListener(onCompletionListener); 74 | mediaPlayer.setDataSource(url); 75 | mediaPlayer.prepare(); 76 | mediaPlayer.start(); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | } 81 | 82 | /** 83 | * 暂停播放 84 | */ 85 | public void pause() { 86 | if (mediaPlayer != null && mediaPlayer.isPlaying()) { //正在播放的时候 87 | mediaPlayer.pause(); 88 | isPause = true; 89 | } 90 | } 91 | 92 | /** 93 | * 当前是isPause状态 94 | */ 95 | public void resume() { 96 | if (mediaPlayer != null && isPause) { 97 | mediaPlayer.start(); 98 | isPause = false; 99 | } 100 | } 101 | 102 | /** 103 | * 释放资源 104 | */ 105 | public void release() { 106 | if (mediaPlayer != null) { 107 | mediaPlayer.release(); 108 | mediaPlayer = null; 109 | } 110 | } 111 | 112 | /** 113 | * 获取文件播放时长 114 | * @return 115 | */ 116 | public String getDuration() { 117 | if (mediaPlayer != null) { 118 | return "" + mediaPlayer.getDuration(); 119 | } 120 | return ""; 121 | } 122 | 123 | /** 124 | * 获取播放位置 125 | * @return 126 | */ 127 | public int getPosition(){ 128 | if (mediaPlayer != null) { 129 | return mediaPlayer.getCurrentPosition(); 130 | } 131 | return 0; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/managers/MyActivityManager.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.managers; 2 | 3 | import android.app.Activity; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | /** 10 | * Activity栈堆管理,用来实现APP完全退出 11 | * Created by Wentong WANG on 2016/7/4. 12 | */ 13 | public class MyActivityManager { 14 | 15 | private List activities = new ArrayList(); 16 | 17 | private static MyActivityManager instance = new MyActivityManager(); 18 | 19 | public static MyActivityManager getInstance() { 20 | return instance; 21 | } 22 | 23 | public void addActivity(Activity activity) { 24 | activities.add(activity); 25 | } 26 | 27 | /** 28 | * 将一个Activity出栈 29 | */ 30 | public void pop() { 31 | if (activities != null && activities.size() > 0) { 32 | activities.remove(activities.size() - 1).finish(); 33 | } 34 | } 35 | 36 | 37 | /** 38 | * 关闭所有Activity并退出 39 | */ 40 | public void onTerminate() { 41 | Iterator e = activities.iterator(); 42 | while(e.hasNext()){ 43 | Activity element = e.next(); 44 | e.remove(); 45 | element.finish(); 46 | } 47 | System.exit(0); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/managers/RecorderManager.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.managers; 2 | 3 | import android.media.MediaRecorder; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * 音频录制管理类 12 | * Created by Wentong WANG on 2016/7/8. 13 | */ 14 | public class RecorderManager { 15 | 16 | private MediaRecorder mediaRecorder; 17 | private boolean isRecoding = false; 18 | //音频存储文件夹 19 | private String mDir; 20 | //当前录制的录音文件的位置 21 | private String mCurrentFilePath; 22 | 23 | public void setSaveDir(String dir) { 24 | mDir = dir; 25 | } 26 | 27 | public void recorde() { 28 | 29 | try { 30 | File dir = new File(mDir); 31 | if (!dir.exists()) { 32 | dir.mkdirs(); 33 | } 34 | String fileName = generateFileName(); 35 | File file = new File(dir, fileName); 36 | 37 | mCurrentFilePath = file.getAbsolutePath(); 38 | 39 | mediaRecorder = new MediaRecorder(); 40 | //设置输出文件 41 | mediaRecorder.setOutputFile(mCurrentFilePath); 42 | // 设置MediaRecorder的音频源为麦克风 43 | mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); 44 | // 设置音频格式 45 | mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); 46 | // 设置音频编码 47 | mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 48 | 49 | // 准备录音 50 | mediaRecorder.prepare(); 51 | 52 | if (listener != null) { 53 | listener.endPrepare(); 54 | } 55 | 56 | // 开始录音 57 | mediaRecorder.start(); 58 | isRecoding = true; 59 | 60 | 61 | } catch (IOException e) { 62 | e.printStackTrace(); 63 | } 64 | 65 | 66 | } 67 | 68 | /** 69 | * 生成文件的名称 70 | */ 71 | private String generateFileName() { 72 | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss"); 73 | return sdf.format(new Date())+ ".amr"; 74 | } 75 | 76 | // /** 77 | // * 开始录音 78 | // */ 79 | // public void startRecode() { 80 | // 81 | // if (mediaRecorder == null || !isPrepare) { 82 | // prepareRecorde(); 83 | // } 84 | // 85 | // if (mediaRecorder != null) { 86 | // mediaRecorder.start(); 87 | // isRecoding = true; 88 | // } 89 | // } 90 | // 91 | // public void stopRecode(){ 92 | // if (mediaRecorder != null && isRecoding) { 93 | // mediaRecorder.stop(); 94 | // isRecoding = false; 95 | // } 96 | // } 97 | 98 | /** 99 | * 录音完成,释放资源 100 | */ 101 | public void release() { 102 | mediaRecorder.reset(); //reset是可以从任何状态恢复到初始 stop只能在录音状态恢复到初始 103 | mediaRecorder = null; 104 | isRecoding = false; 105 | } 106 | 107 | /** 108 | * 取消录音,删除本地文件 109 | */ 110 | public void cancel() { 111 | if (mediaRecorder != null && isRecoding) { 112 | release(); 113 | if (mCurrentFilePath != null) { 114 | File file = new File(mCurrentFilePath); 115 | file.delete(); 116 | mCurrentFilePath = null; 117 | } 118 | } 119 | } 120 | 121 | /** 122 | * 获取音量 123 | * @param maxlevel 124 | * @return 125 | */ 126 | public int getVoiceLevel(int maxlevel) { 127 | if (isRecoding) { 128 | try { 129 | // mMediaRecorder.getMaxAmplitude() 1~32767 130 | return maxlevel * mediaRecorder.getMaxAmplitude() / 32768 + 1; 131 | } catch (Exception e) { 132 | } 133 | } 134 | return 1; 135 | } 136 | 137 | public String getmCurrentFilePath() { 138 | return mCurrentFilePath; 139 | } 140 | 141 | 142 | private RecoderStateListener listener; 143 | public void setRecoderStateListener(RecoderStateListener listener) { 144 | this.listener = listener; 145 | } 146 | public interface RecoderStateListener{ 147 | void endPrepare(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/Constants.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model; 2 | 3 | 4 | /** 5 | * 常量类 6 | * Created by Wentong WANG on 2016/6/7. 7 | */ 8 | public class Constants { 9 | 10 | public static final String APPLICATION_ID = "cc592c3272e04dcdf55d3dce0df6618e"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/DiaryItem.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.Serializable; 6 | 7 | import cn.bmob.v3.BmobObject; 8 | 9 | /** 10 | * 日记数据封装类 11 | * Created by Wentong WANG on 2016/6/3. 12 | */ 13 | public class DiaryItem extends BmobObject implements Serializable{ 14 | 15 | public static final String ID = "_id"; 16 | public static final String DIARY_DATE = "diary_date"; 17 | public static final String DIARY_TITLE = "diary_title"; 18 | public static final String DIARY_CONTENT = "diary_content"; 19 | public static final String DIARY_IS_LOCKED = "islocked"; 20 | public static final String DIARY_USER_ID = "diary_user_id"; 21 | 22 | private String diary_id; 23 | private String diary_date; 24 | private String diary_title; 25 | private String diary_content; 26 | private boolean isLocked; 27 | private String diary_user_id; 28 | 29 | 30 | public String getDiary_id() { 31 | return diary_id; 32 | } 33 | 34 | public void setDiary_id(String diary_id) { 35 | this.diary_id = diary_id; 36 | } 37 | 38 | public String getDiary_date() { 39 | return diary_date; 40 | } 41 | 42 | public void setDiary_date(String diary_date) { 43 | this.diary_date = diary_date; 44 | } 45 | 46 | public String getDiary_title() { 47 | return diary_title; 48 | } 49 | 50 | public void setDiary_title(String diary_title) { 51 | this.diary_title = diary_title; 52 | } 53 | 54 | public String getDiary_content() { 55 | return diary_content; 56 | } 57 | 58 | public void setDiary_content(String diary_content) { 59 | this.diary_content = diary_content; 60 | } 61 | 62 | public String isLocked() { 63 | return isLocked ? "1" : "0"; 64 | } 65 | public Boolean isLockedInBoolean() { 66 | return isLocked; 67 | } 68 | 69 | public void setIsLocked(String isLocked) { 70 | 71 | if (isLocked.equals("1")) { 72 | this.isLocked = true; 73 | }else if (isLocked.equals("0")) { 74 | this.isLocked = false; 75 | } else { 76 | Log.e("DiaryItem error", "数据内容有误"); 77 | this.isLocked = true; 78 | } 79 | 80 | } 81 | 82 | public void setIsLocked(boolean isLocked) { 83 | this.isLocked = isLocked; 84 | } 85 | 86 | public String getDiary_user_id() { 87 | return diary_user_id; 88 | } 89 | 90 | public void setDiary_user_id(String diary_user_id) { 91 | this.diary_user_id = diary_user_id; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/NoteItem.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import cn.bmob.v3.BmobObject; 6 | 7 | /** 8 | * 便签数据封装类 9 | * Created by Wentong WANG on 2016/6/3. 10 | */ 11 | public class NoteItem extends BmobObject implements Serializable { 12 | 13 | public static final String ID = "_id"; 14 | public static final String NOTE_DATE = "note_date"; 15 | public static final String NOTE_CONTENT = "note_content"; 16 | public static final String NOTE_PRIORITY = "note_priority"; 17 | public static final String NOTE_USER_ID = "note_user_id"; 18 | 19 | 20 | private String note_id; 21 | private String note_date; 22 | private String note_content; 23 | private Integer note_priority; 24 | private String note_user_id; 25 | 26 | public String getNote_date() { 27 | return note_date; 28 | } 29 | 30 | public void setNote_date(String note_date) { 31 | this.note_date = note_date; 32 | } 33 | 34 | public String getNote_content() { 35 | return note_content; 36 | } 37 | 38 | public void setNote_content(String note_content) { 39 | this.note_content = note_content; 40 | } 41 | 42 | public String getNote_id() { 43 | return note_id; 44 | } 45 | 46 | public void setNote_id(String note_id) { 47 | this.note_id = note_id; 48 | } 49 | 50 | public Integer getNote_priority() { 51 | return note_priority; 52 | } 53 | 54 | public void setNote_priority(Integer note_priority) { 55 | this.note_priority = note_priority; 56 | } 57 | 58 | public String getNote_user_id() { 59 | return note_user_id; 60 | } 61 | 62 | public void setNote_user_id(String note_user_id) { 63 | this.note_user_id = note_user_id; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/Response.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 服务器响应的封装 9 | * Created by Wentong WANG on 2016/7/5. 10 | */ 11 | public class Response { 12 | 13 | private String msg; 14 | private boolean isSucces; 15 | 16 | private List noteItemList; 17 | private List diaryItemList; 18 | private Bitmap bitmap; 19 | 20 | public Bitmap getBitmap() { 21 | return bitmap; 22 | } 23 | 24 | public void setBitmap(Bitmap bitmap) { 25 | this.bitmap = bitmap; 26 | } 27 | 28 | public String getMsg() { 29 | return msg; 30 | } 31 | 32 | public void setMsg(String msg) { 33 | this.msg = msg; 34 | } 35 | 36 | public boolean isSucces() { 37 | return isSucces; 38 | } 39 | 40 | public void setIsSucces(boolean isSucces) { 41 | this.isSucces = isSucces; 42 | } 43 | 44 | public List getNoteItemList() { 45 | return noteItemList; 46 | } 47 | 48 | public void setNoteItemList(List noteItemList) { 49 | this.noteItemList = noteItemList; 50 | } 51 | 52 | public List getDiaryItemList() { 53 | return diaryItemList; 54 | } 55 | 56 | public void setDiaryItemList(List diaryItemList) { 57 | this.diaryItemList = diaryItemList; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/UpdataEvent.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model; 2 | 3 | /** 4 | * Created by Wentong WANG on 2016/6/6. 5 | */ 6 | public class UpdataEvent { 7 | public static final int UPDATE_NOTES = 0; 8 | public static final int UPDATE_DIARIES = 1; 9 | public static final int UPDATE_USER_INFOS = 2; 10 | private int type; 11 | 12 | public void setType(int type) { 13 | this.type = type; 14 | } 15 | 16 | public int getType() { 17 | return type; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/User.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model; 2 | import android.text.TextUtils; 3 | 4 | import java.io.Serializable; 5 | 6 | import cn.bmob.v3.BmobUser; 7 | 8 | /** 9 | * 用户信息封装类 10 | * Created by Wentong WANG on 2016/6/7. 11 | */ 12 | public class User extends BmobUser implements Serializable{ 13 | 14 | private String user_nickname; 15 | private String user_sex; 16 | private String user_diraypwd; 17 | private String user_head_url; 18 | 19 | public String getUser_nickname() { 20 | if (!TextUtils.isEmpty(user_nickname)) 21 | return user_nickname; 22 | else 23 | return ""; 24 | } 25 | 26 | public void setUser_nickname(String user_nickname) { 27 | this.user_nickname = user_nickname; 28 | } 29 | 30 | public String getUser_sex() { 31 | if (!TextUtils.isEmpty(user_sex)) 32 | return user_sex; 33 | else 34 | return ""; 35 | } 36 | 37 | public void setUser_sex(String user_sex) { 38 | this.user_sex = user_sex; 39 | } 40 | 41 | public String getUser_diraypwd() { 42 | if (!TextUtils.isEmpty(user_diraypwd)) 43 | return user_diraypwd; 44 | else 45 | return ""; 46 | } 47 | 48 | public void setUser_diraypwd(String user_diraypwd) { 49 | this.user_diraypwd = user_diraypwd; 50 | } 51 | 52 | public String getUser_head_url() { 53 | if (!TextUtils.isEmpty(user_head_url)) 54 | return user_head_url; 55 | else 56 | return ""; 57 | } 58 | 59 | public void setUser_head_url(String user_head_url) { 60 | this.user_head_url = user_head_url; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/business/DiaryBiz.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model.business; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.model.DiaryItem; 6 | import com.wentongwang.notebook.model.Response; 7 | 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | 11 | import cn.bmob.v3.listener.DeleteListener; 12 | import cn.bmob.v3.listener.SaveListener; 13 | import cn.bmob.v3.listener.UpdateListener; 14 | 15 | /** 16 | * 日记的业务逻辑 17 | * Created by Wentong WANG on 2016/7/5. 18 | */ 19 | public class DiaryBiz { 20 | 21 | 22 | /** 23 | * 创建新的日记 24 | * 25 | * @param context 上下文 26 | * @param diary_content 日记内容 27 | * @param diary_title 日记标题 28 | * @param isLocked 是否上锁 29 | * @param userId 用户id 30 | * @param listener 回调监听 31 | */ 32 | public void creatDiary(Context context, String diary_content, String diary_title, 33 | Boolean isLocked, String userId, final OnResponseListener listener) { 34 | DiaryItem diaryItem = new DiaryItem(); 35 | //获取当前时间 36 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd " + "hh:mm:ss"); 37 | diaryItem.setDiary_date(sdf.format(new Date())); 38 | diaryItem.setDiary_title(diary_title); 39 | diaryItem.setDiary_content(diary_content); 40 | diaryItem.setIsLocked(isLocked); 41 | diaryItem.setDiary_user_id(userId); 42 | 43 | diaryItem.save(context, new SaveListener() { 44 | @Override 45 | public void onSuccess() { 46 | if (listener != null) { 47 | Response response = new Response(); 48 | response.setIsSucces(true); 49 | listener.onResponse(response); 50 | } 51 | } 52 | 53 | @Override 54 | public void onFailure(int code, String msg) { 55 | if (listener != null) { 56 | Response response = new Response(); 57 | response.setIsSucces(false); 58 | response.setMsg(msg); 59 | listener.onResponse(response); 60 | } 61 | } 62 | }); 63 | } 64 | 65 | /** 66 | * 更改日记 67 | * 68 | * @param context 69 | * @param diaryItem 70 | * @param newContent 71 | * @param listener 72 | */ 73 | public void editDiary(Context context, DiaryItem diaryItem, String newContent, final OnResponseListener listener) { 74 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd " + "hh:mm:ss"); 75 | diaryItem.setDiary_date(sdf.format(new Date())); 76 | diaryItem.setDiary_content(newContent); 77 | 78 | diaryItem.update(context, diaryItem.getObjectId(), new UpdateListener() { 79 | @Override 80 | public void onSuccess() { 81 | if (listener != null) { 82 | Response response = new Response(); 83 | response.setIsSucces(true); 84 | listener.onResponse(response); 85 | } 86 | } 87 | 88 | @Override 89 | public void onFailure(int code, String msg) { 90 | if (listener != null) { 91 | Response response = new Response(); 92 | response.setIsSucces(false); 93 | response.setMsg(msg); 94 | listener.onResponse(response); 95 | } 96 | } 97 | }); 98 | } 99 | 100 | /** 101 | * 删除日记 102 | * @param context 103 | * @param id 104 | */ 105 | public void deleteDiary(Context context, String id, final OnResponseListener listener){ 106 | DiaryItem item = new DiaryItem(); 107 | item.setObjectId(id); 108 | item.delete(context, new DeleteListener() { 109 | @Override 110 | public void onSuccess() { 111 | if (listener != null) { 112 | Response response = new Response(); 113 | response.setIsSucces(true); 114 | listener.onResponse(response); 115 | } 116 | } 117 | 118 | @Override 119 | public void onFailure(int code, String msg) { 120 | if (listener != null) { 121 | Response response = new Response(); 122 | response.setIsSucces(false); 123 | response.setMsg(msg); 124 | listener.onResponse(response); 125 | } 126 | } 127 | }); 128 | } 129 | } 130 | 131 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/business/NoteBiz.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model.business; 2 | 3 | 4 | import android.content.Context; 5 | 6 | import com.wentongwang.notebook.model.NoteItem; 7 | import com.wentongwang.notebook.model.Response; 8 | import com.wentongwang.notebook.utils.MyToast; 9 | 10 | import java.text.SimpleDateFormat; 11 | import java.util.Date; 12 | 13 | import cn.bmob.v3.listener.DeleteListener; 14 | import cn.bmob.v3.listener.SaveListener; 15 | import cn.bmob.v3.listener.UpdateListener; 16 | 17 | /** 18 | * 便签的业务逻辑 19 | * Created by Wentong WANG on 2016/7/5. 20 | */ 21 | public class NoteBiz { 22 | 23 | /** 24 | * 创建便签 25 | * @param context 26 | * @param note_content 27 | * @param userId 28 | * @param listener 29 | */ 30 | public void creatNote(Context context, String note_content, String userId, final OnResponseListener listener){ 31 | 32 | NoteItem noteItem = new NoteItem(); 33 | //获取当前时间 34 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd " + "hh:mm:ss"); 35 | noteItem.setNote_date(sdf.format(new Date())); 36 | noteItem.setNote_content(note_content); 37 | noteItem.setNote_priority(0); 38 | noteItem.setNote_user_id(userId); 39 | 40 | noteItem.save(context, new SaveListener() { 41 | @Override 42 | public void onSuccess() { 43 | if (listener != null) { 44 | Response response = new Response(); 45 | response.setIsSucces(true); 46 | listener.onResponse(response); 47 | } 48 | } 49 | @Override 50 | public void onFailure(int code, String msg) { 51 | if (listener != null) { 52 | Response response = new Response(); 53 | response.setIsSucces(false); 54 | response.setMsg(msg); 55 | listener.onResponse(response); 56 | } 57 | } 58 | }); 59 | 60 | } 61 | 62 | /** 63 | * 更改便签 64 | * 65 | * @param context 66 | * @param noteItem 67 | * @param newContent 68 | * @param listener 69 | */ 70 | public void editNote(Context context, NoteItem noteItem, String newContent, final OnResponseListener listener){ 71 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd " + "hh:mm:ss"); 72 | noteItem.setNote_date(sdf.format(new Date())); 73 | noteItem.setNote_content(newContent); 74 | 75 | noteItem.update(context, noteItem.getObjectId(), new UpdateListener() { 76 | @Override 77 | public void onSuccess() { 78 | if (listener != null) { 79 | Response response = new Response(); 80 | response.setIsSucces(true); 81 | listener.onResponse(response); 82 | } 83 | } 84 | 85 | @Override 86 | public void onFailure(int code, String msg) { 87 | if (listener != null) { 88 | Response response = new Response(); 89 | response.setIsSucces(false); 90 | response.setMsg(msg); 91 | listener.onResponse(response); 92 | } 93 | } 94 | }); 95 | } 96 | 97 | /** 98 | * 删除便签 99 | * @param context 100 | * @param id 101 | */ 102 | public void deleteNote(Context context, String id, final OnResponseListener listener){ 103 | NoteItem item = new NoteItem(); 104 | item.setObjectId(id); 105 | item.delete(context, new DeleteListener() { 106 | @Override 107 | public void onSuccess() { 108 | if (listener != null) { 109 | Response response = new Response(); 110 | response.setIsSucces(true); 111 | listener.onResponse(response); 112 | } 113 | } 114 | 115 | @Override 116 | public void onFailure(int code, String msg) { 117 | if (listener != null) { 118 | Response response = new Response(); 119 | response.setIsSucces(false); 120 | response.setMsg(msg); 121 | listener.onResponse(response); 122 | } 123 | } 124 | }); 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/model/business/OnResponseListener.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.model.business; 2 | 3 | import com.wentongwang.notebook.model.Response; 4 | 5 | /** 6 | * 7 | * 服务器回复的回调接口 8 | * Created by Wentong WANG on 2016/7/5. 9 | */ 10 | public interface OnResponseListener { 11 | 12 | /** 13 | * 成功 14 | * @param response 回复的结果 15 | */ 16 | void onResponse(Response response); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/CreatDiaryPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.text.TextUtils; 4 | import android.widget.Toast; 5 | 6 | import com.wentongwang.notebook.model.Response; 7 | import com.wentongwang.notebook.model.business.DiaryBiz; 8 | import com.wentongwang.notebook.model.business.OnResponseListener; 9 | import com.wentongwang.notebook.utils.AccountUtils; 10 | import com.wentongwang.notebook.view.activity.interfaces.CreatDiaryView; 11 | 12 | 13 | /** 14 | * Created by Wentong WANG on 2016/7/4. 15 | */ 16 | public class CreatDiaryPresenter { 17 | 18 | private CreatDiaryView creatDiaryView; 19 | private DiaryBiz diaryBiz; 20 | 21 | public CreatDiaryPresenter(CreatDiaryView creatDiaryView) { 22 | this.creatDiaryView = creatDiaryView; 23 | diaryBiz = new DiaryBiz(); 24 | } 25 | 26 | public void creatDiary() { 27 | 28 | String userId = AccountUtils.getUserId(creatDiaryView.getMyContext()); 29 | String diary_content = creatDiaryView.getDiaryContent(); 30 | String diary_title = creatDiaryView.getDiaryTitle(); 31 | if (TextUtils.isEmpty(userId)) { 32 | Toast.makeText(creatDiaryView.getMyContext(), "登录异常,请重新登录", Toast.LENGTH_LONG).show(); 33 | return; 34 | } 35 | if (TextUtils.isEmpty(diary_title)) { 36 | Toast.makeText(creatDiaryView.getMyContext(), "请填上标题", Toast.LENGTH_LONG).show(); 37 | return; 38 | } 39 | if (TextUtils.isEmpty(diary_content)) { 40 | Toast.makeText(creatDiaryView.getMyContext(), "你还没写内容呢~", Toast.LENGTH_LONG).show(); 41 | return; 42 | } 43 | diaryBiz.creatDiary(creatDiaryView.getMyContext(), diary_content, diary_title, creatDiaryView.isLocked(), userId, 44 | new OnResponseListener() { 45 | /** 46 | * 成功 47 | * @param response 回复的结果 48 | */ 49 | @Override 50 | public void onResponse(Response response) { 51 | creatDiaryView.hidePorgressBar(); 52 | if (response.isSucces()) { 53 | creatDiaryView.goBack(); 54 | } else { 55 | Toast.makeText(creatDiaryView.getMyContext(), "操作失败: " + response.getMsg(), Toast.LENGTH_LONG).show(); 56 | } 57 | } 58 | }); 59 | } 60 | 61 | /** 62 | * 日记上锁操作 63 | */ 64 | public void lockDiary() { 65 | if (creatDiaryView.isLocked()) { 66 | creatDiaryView.setLock(false); 67 | creatDiaryView.updateBtnImg(); 68 | Toast.makeText(creatDiaryView.getMyContext(), "日记已解锁", Toast.LENGTH_SHORT).show(); 69 | } else { 70 | creatDiaryView.setLock(true); 71 | creatDiaryView.updateBtnImg(); 72 | Toast.makeText(creatDiaryView.getMyContext(), "日记已上锁", Toast.LENGTH_SHORT).show(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/CreatNotePresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.text.TextUtils; 4 | 5 | import android.widget.Toast; 6 | 7 | import com.wentongwang.notebook.model.Response; 8 | import com.wentongwang.notebook.model.business.NoteBiz; 9 | import com.wentongwang.notebook.model.business.OnResponseListener; 10 | import com.wentongwang.notebook.utils.AccountUtils; 11 | 12 | import com.wentongwang.notebook.view.activity.interfaces.CreatNoteView; 13 | 14 | 15 | /** 16 | * Created by Wentong WANG on 2016/7/4. 17 | */ 18 | public class CreatNotePresenter { 19 | 20 | private CreatNoteView creatNoteView; 21 | private NoteBiz noteBiz; 22 | 23 | public CreatNotePresenter(CreatNoteView creatNoteView) { 24 | this.creatNoteView = creatNoteView; 25 | noteBiz = new NoteBiz(); 26 | } 27 | 28 | public void creatNote() { 29 | String note_content = creatNoteView.getNoteContent(); 30 | String userId = AccountUtils.getUserId(creatNoteView.getMyContext()); 31 | if (TextUtils.isEmpty(userId)) { 32 | Toast.makeText(creatNoteView.getMyContext(), "登录异常,请重新登录", Toast.LENGTH_LONG).show(); 33 | return; 34 | } 35 | if (TextUtils.isEmpty(note_content)) { 36 | Toast.makeText(creatNoteView.getMyContext(), "你还没写内容呢~", Toast.LENGTH_LONG).show(); 37 | return; 38 | } 39 | 40 | noteBiz.creatNote(creatNoteView.getMyContext(), note_content, userId, new OnResponseListener() { 41 | /** 42 | * 成功 43 | * 44 | * @param response 回复的结果 45 | */ 46 | @Override 47 | public void onResponse(Response response) { 48 | creatNoteView.hidePorgressBar(); 49 | if (response.isSucces()) { 50 | creatNoteView.goBack(); 51 | } else { 52 | Toast.makeText(creatNoteView.getMyContext(), "操作失败: " + response.getMsg(), Toast.LENGTH_LONG).show(); 53 | } 54 | } 55 | }); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/EditDiaryPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.wentongwang.notebook.model.DiaryItem; 6 | import com.wentongwang.notebook.model.NoteItem; 7 | import com.wentongwang.notebook.model.Response; 8 | import com.wentongwang.notebook.model.business.DiaryBiz; 9 | import com.wentongwang.notebook.model.business.OnResponseListener; 10 | import com.wentongwang.notebook.utils.MyToast; 11 | import com.wentongwang.notebook.view.activity.interfaces.EditDiaryView; 12 | 13 | /** 14 | * Created by Wentong WANG on 2016/7/7. 15 | */ 16 | public class EditDiaryPresenter { 17 | 18 | private EditDiaryView editDiaryView; 19 | private DiaryBiz diaryBiz; 20 | 21 | public EditDiaryPresenter(EditDiaryView editDiaryView) { 22 | this.editDiaryView = editDiaryView; 23 | diaryBiz = new DiaryBiz(); 24 | } 25 | 26 | 27 | /** 28 | * 初始化 29 | */ 30 | public void initDiary() { 31 | DiaryItem diaryItem = editDiaryView.getDiaryFromIntent(); 32 | String content = diaryItem.getDiary_content(); 33 | String title = diaryItem.getDiary_title(); 34 | editDiaryView.setDiary(content,title); 35 | } 36 | 37 | /** 38 | * 更新 39 | */ 40 | public void edit(){ 41 | if (!editDiaryView.canEdit()) { 42 | //EditText可编辑状态 43 | editDiaryView.beginEdit(); 44 | } else { 45 | editDiaryView.finishEdit(); 46 | submitText(); 47 | } 48 | } 49 | 50 | /** 51 | * 提交更改到服务器 52 | */ 53 | private void submitText(){ 54 | DiaryItem diaryItem = editDiaryView.getDiaryFromIntent(); 55 | 56 | String content; 57 | content = editDiaryView.getDiaryContent(); 58 | 59 | if (TextUtils.isEmpty(content)) { 60 | MyToast.showLong(editDiaryView.getMyContext(), "你忘写内容啦!"); 61 | return; 62 | } 63 | editDiaryView.showPorgressBar(); 64 | diaryBiz.editDiary(editDiaryView.getMyContext(), diaryItem, content, new OnResponseListener() { 65 | @Override 66 | public void onResponse(Response response) { 67 | editDiaryView.hidePorgressBar(); 68 | if (response.isSucces()) { 69 | editDiaryView.finishAndBack(); 70 | } else { 71 | MyToast.showLong(editDiaryView.getMyContext(), "操作失败: " + response.getMsg()); 72 | } 73 | } 74 | }); 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/EditNotePresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.wentongwang.notebook.model.NoteItem; 6 | import com.wentongwang.notebook.model.Response; 7 | import com.wentongwang.notebook.model.business.NoteBiz; 8 | import com.wentongwang.notebook.model.business.OnResponseListener; 9 | import com.wentongwang.notebook.utils.MyToast; 10 | import com.wentongwang.notebook.view.activity.interfaces.EditNoteView; 11 | 12 | /** 13 | * 14 | * Created by Wentong WANG on 2016/7/5. 15 | */ 16 | public class EditNotePresenter { 17 | 18 | private EditNoteView editNoteView; 19 | private NoteBiz noteBiz; 20 | public EditNotePresenter(EditNoteView editNoteView) { 21 | this.editNoteView = editNoteView; 22 | noteBiz = new NoteBiz(); 23 | } 24 | 25 | /** 26 | * 初始化 27 | */ 28 | public void setNoteContent() { 29 | NoteItem noteItem = editNoteView.getNoteFromIntent(); 30 | String content = noteItem.getNote_content(); 31 | editNoteView.setNoteContent(content); 32 | } 33 | 34 | /** 35 | * 更新 36 | */ 37 | public void edit(){ 38 | 39 | if (!editNoteView.canEdit()) { 40 | //EditText可编辑状态 41 | editNoteView.beginEdit(); 42 | } else { 43 | editNoteView.finishEdit(); 44 | submitText(); 45 | } 46 | } 47 | 48 | /** 49 | * 提交更改到服务器 50 | */ 51 | private void submitText(){ 52 | NoteItem noteItem = editNoteView.getNoteFromIntent(); 53 | 54 | String note_content; 55 | note_content = editNoteView.getNoteContent(); 56 | 57 | if (TextUtils.isEmpty(note_content)) { 58 | MyToast.showLong(editNoteView.getMyContext(), "你忘写内容啦!"); 59 | return; 60 | } 61 | editNoteView.showPorgressBar(); 62 | noteBiz.editNote(editNoteView.getMyContext(), noteItem, note_content, new OnResponseListener() { 63 | @Override 64 | public void onResponse(Response response) { 65 | editNoteView.hidePorgressBar(); 66 | if (response.isSucces()) { 67 | editNoteView.finishAndBack(); 68 | } else { 69 | MyToast.showLong(editNoteView.getMyContext(), "操作失败: " + response.getMsg()); 70 | } 71 | } 72 | }); 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/HomePresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.graphics.Bitmap; 4 | import android.text.TextUtils; 5 | import android.widget.Toast; 6 | 7 | import com.wentongwang.notebook.R; 8 | import com.wentongwang.notebook.model.Response; 9 | import com.wentongwang.notebook.model.business.OnResponseListener; 10 | import com.wentongwang.notebook.model.business.UserBiz; 11 | import com.wentongwang.notebook.utils.AccountUtils; 12 | import com.wentongwang.notebook.utils.MyToast; 13 | import com.wentongwang.notebook.view.activity.interfaces.HomeView; 14 | 15 | /** 16 | * 主界面的交互类 17 | * Created by Wentong WANG on 2016/6/23. 18 | */ 19 | public class HomePresenter { 20 | 21 | 22 | private int currentPage; 23 | private HomeView homeView; 24 | private UserBiz userBiz; 25 | public HomePresenter(HomeView homeView) { 26 | this.homeView = homeView; 27 | this.userBiz = new UserBiz(); 28 | } 29 | 30 | /** 31 | * 设置ViewPager当前页 32 | * @param currentPage 33 | */ 34 | public void setCurrentPage(int currentPage) { 35 | this.currentPage = currentPage; 36 | if (currentPage == 0) { 37 | homeView.setTitle("我的便签"); 38 | } else { 39 | homeView.setTitle("我的日记"); 40 | } 41 | homeView.setCurrentPage(currentPage); 42 | } 43 | 44 | public void showAboutUsFragment(){ 45 | homeView.setTitle("关于"); 46 | homeView.showAboutUsFragment(); 47 | } 48 | 49 | /** 50 | * 刷新界面内容 51 | */ 52 | public void refresh(){ 53 | homeView.refresh(currentPage); 54 | } 55 | 56 | /** 57 | * 设置用户头像 58 | */ 59 | public void setUserHead() { 60 | userBiz.getUserHeadFromServer(homeView.getMyContext(), homeView.getCachePath(), new OnResponseListener() { 61 | @Override 62 | public void onResponse(Response response) { 63 | if (response.isSucces()) { 64 | Bitmap bitmap = response.getBitmap(); 65 | homeView.setUserHead(bitmap); 66 | } else { 67 | MyToast.showLong(homeView.getMyContext(), "设置头像失败:" + response.getMsg()); 68 | } 69 | } 70 | }); 71 | } 72 | 73 | /** 74 | * 设置用户昵称 75 | */ 76 | public void setUserNickName() { 77 | String nickName = AccountUtils.getUserNickName(homeView.getMyContext()); 78 | if (!TextUtils.isEmpty(nickName)) { 79 | homeView.setUserNickName(nickName); 80 | } else { 81 | homeView.setUserNickName(AccountUtils.getUserName(homeView.getMyContext())); 82 | } 83 | } 84 | 85 | /** 86 | * 设置用户性别 87 | */ 88 | public void setUserSex(){ 89 | String sex = AccountUtils.getUserSex(homeView.getMyContext()); 90 | if (!TextUtils.isEmpty(sex) && !sex.equals("")) { 91 | if (sex.equals("女")) 92 | homeView.setUserSex(homeView.getResources().getDrawable(R.drawable.female)); 93 | else 94 | homeView.setUserSex(homeView.getResources().getDrawable(R.drawable.male)); 95 | } else { 96 | homeView.setUserSex(homeView.getResources().getDrawable(R.drawable.male)); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/LoginPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | 4 | 5 | import com.wentongwang.notebook.model.Response; 6 | import com.wentongwang.notebook.model.business.OnResponseListener; 7 | import com.wentongwang.notebook.model.business.UserBiz; 8 | import com.wentongwang.notebook.utils.MyToast; 9 | import com.wentongwang.notebook.view.activity.interfaces.LoginView; 10 | 11 | 12 | /** 13 | * 连接View与model层的登录界面的presenter 14 | * Created by Wentong WANG on 2016/6/21. 15 | */ 16 | public class LoginPresenter { 17 | private LoginView loginView; 18 | private UserBiz userBiz; 19 | 20 | public LoginPresenter(LoginView loginView) { 21 | this.loginView = loginView; 22 | this.userBiz = new UserBiz(); 23 | } 24 | 25 | /** 26 | * 用户登录功能 27 | */ 28 | public void login() { 29 | loginView.showPorgressBar(); 30 | userBiz.login(loginView.getMyContext(), loginView.getUserName(), loginView.getUserPwd(), new OnResponseListener() { 31 | @Override 32 | public void onResponse(Response response) { 33 | loginView.hidePorgressBar(); 34 | if (response.isSucces()) { 35 | loginView.goToHomeActivity(); 36 | } else { 37 | MyToast.showLong(loginView.getMyContext(), "登录失败:" + response.getMsg()); 38 | } 39 | } 40 | }); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/NotesFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.text.TextUtils; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.widget.Toast; 7 | 8 | import com.wentongwang.notebook.model.Constants; 9 | import com.wentongwang.notebook.model.NoteItem; 10 | import com.wentongwang.notebook.model.Response; 11 | import com.wentongwang.notebook.model.business.NoteBiz; 12 | import com.wentongwang.notebook.model.business.OnResponseListener; 13 | import com.wentongwang.notebook.model.business.UserBiz; 14 | import com.wentongwang.notebook.utils.AccountUtils; 15 | import com.wentongwang.notebook.utils.MyToast; 16 | import com.wentongwang.notebook.view.fragment.interfaces.NotesView; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collection; 20 | import java.util.List; 21 | 22 | import cn.bmob.v3.Bmob; 23 | import cn.bmob.v3.BmobQuery; 24 | import cn.bmob.v3.listener.DeleteListener; 25 | import cn.bmob.v3.listener.FindListener; 26 | 27 | /** 28 | * Created by Wentong WANG on 2016/6/27. 29 | */ 30 | public class NotesFragmentPresenter { 31 | 32 | private NotesView notesView; 33 | private NoteBiz noteBiz; 34 | private UserBiz userBiz; 35 | 36 | public NotesFragmentPresenter(NotesView notesView) { 37 | this.notesView = notesView; 38 | noteBiz = new NoteBiz(); 39 | userBiz = new UserBiz(); 40 | } 41 | 42 | /** 43 | * 获取用户所有的便签 44 | */ 45 | public void getNotes() { 46 | notesView.showPorgressBar(); 47 | 48 | //查询该用户有的notes 49 | String user_id = AccountUtils.getUserId(notesView.getActivity()); 50 | 51 | userBiz.getUserNotes(notesView.getActivity(), user_id, new OnResponseListener() { 52 | 53 | @Override 54 | public void onResponse(Response response) { 55 | notesView.hidePorgressBar(); 56 | if (response.isSucces()) { 57 | List list = new ArrayList(); 58 | list.addAll(response.getNoteItemList()); 59 | if (list.size() > 0) { 60 | notesView.hideNoDatas(); 61 | notesView.updataList(list); 62 | } else { 63 | notesView.showNoDatas(); 64 | } 65 | } else { 66 | notesView.showNoDatas(); 67 | MyToast.showLong(notesView.getActivity(), "操作失败: " + response.getMsg()); 68 | } 69 | } 70 | }); 71 | } 72 | 73 | /** 74 | * 删除一条note 75 | * 76 | * @param position 77 | */ 78 | public void deleteNote(final int position) { 79 | final List list = notesView.getNotesList(); 80 | String id = list.get(position).getObjectId(); 81 | 82 | if (TextUtils.isEmpty(id)) { 83 | MyToast.showLong(notesView.getActivity(), "客户端数据有误,删除失败,请重新登录"); 84 | return; 85 | } 86 | 87 | notesView.showPorgressBar(); 88 | noteBiz.deleteNote(notesView.getActivity(), id, new OnResponseListener() { 89 | @Override 90 | public void onResponse(Response response) { 91 | notesView.hidePorgressBar(); 92 | if (response.isSucces()) { 93 | MyToast.showShort(notesView.getActivity(), "删除成功"); 94 | list.remove(position); 95 | if (list.size() == 0) { 96 | notesView.showNoDatas(); 97 | } else { 98 | notesView.hideNoDatas(); 99 | } 100 | notesView.updataList(list); 101 | } else { 102 | MyToast.showLong(notesView.getActivity(), "删除失败" + response.getMsg()); 103 | } 104 | } 105 | }); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/SignUpPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import com.wentongwang.notebook.model.Response; 4 | import com.wentongwang.notebook.model.business.OnResponseListener; 5 | import com.wentongwang.notebook.model.business.UserBiz; 6 | import com.wentongwang.notebook.utils.MyToast; 7 | import com.wentongwang.notebook.view.activity.interfaces.SignUpView; 8 | 9 | /** 10 | * 注册界面交互类 11 | * Created by Wentong WANG on 2016/6/23. 12 | */ 13 | public class SignUpPresenter { 14 | 15 | private SignUpView signUpView; 16 | private UserBiz userBiz; 17 | public SignUpPresenter(SignUpView signUpView) { 18 | this.signUpView = signUpView; 19 | this.userBiz = new UserBiz(); 20 | } 21 | 22 | /** 23 | * 注册 24 | */ 25 | public void signUp() { 26 | if (signUpView.getUserPwd().equals(signUpView.getUserPwdConfirm())) { 27 | signUpView.showPorgressBar(); 28 | userBiz.registre(signUpView.getMyContext(), signUpView.getUserName(), signUpView.getUserPwd(), new OnResponseListener() { 29 | @Override 30 | public void onResponse(Response response) { 31 | signUpView.hidePorgressBar(); 32 | if (response.isSucces()) { 33 | MyToast.showShort(signUpView.getMyContext(), "注册成功"); 34 | signUpView.goToLoginActivity(); 35 | } else { 36 | MyToast.showLong(signUpView.getMyContext(),"注册失败" + response.getMsg()); 37 | } 38 | } 39 | }); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/presenters/SplashPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.presenters; 2 | 3 | import android.content.Intent; 4 | import android.util.Log; 5 | import android.widget.Toast; 6 | 7 | import com.wentongwang.notebook.model.Response; 8 | import com.wentongwang.notebook.model.User; 9 | import com.wentongwang.notebook.model.business.OnResponseListener; 10 | import com.wentongwang.notebook.model.business.UserBiz; 11 | import com.wentongwang.notebook.utils.AccountUtils; 12 | import com.wentongwang.notebook.utils.MD5Util; 13 | import com.wentongwang.notebook.utils.MyToast; 14 | import com.wentongwang.notebook.utils.SPUtils; 15 | import com.wentongwang.notebook.view.activity.LoginActivity; 16 | import com.wentongwang.notebook.view.activity.interfaces.SplashView; 17 | 18 | import cn.bmob.v3.BmobUser; 19 | import cn.bmob.v3.listener.SaveListener; 20 | 21 | /** 22 | * Created by Wentong WANG on 2016/6/21. 23 | */ 24 | public class SplashPresenter { 25 | 26 | private SplashView splashView; 27 | private UserBiz userBiz; 28 | 29 | private String user_name; 30 | private String user_pwd; 31 | 32 | public SplashPresenter(SplashView splashView) { 33 | this.splashView = splashView; 34 | userBiz = new UserBiz(); 35 | } 36 | 37 | /** 38 | * 判断自动登录 39 | */ 40 | public void autoLogin(){ 41 | if (SPUtils.contains(splashView.getMyContext(), "user_name")) { 42 | //本地有记录,实行登录 43 | user_name = AccountUtils.getUserName(splashView.getMyContext()); 44 | user_pwd = AccountUtils.getUserPwd(splashView.getMyContext()); 45 | login(); 46 | } else { 47 | //本地无记录,跳转到登录界面 48 | splashView.goToLoginActivity(); 49 | } 50 | } 51 | 52 | /** 53 | * 用户登录 54 | */ 55 | private void login() { 56 | 57 | userBiz.login(splashView.getMyContext(), user_name, user_pwd, new OnResponseListener() { 58 | @Override 59 | public void onResponse(Response response) { 60 | if (response.isSucces()) { 61 | MyToast.showShort(splashView.getMyContext(), "登录成功"); 62 | splashView.goToHomeActivity(); 63 | } else { 64 | MyToast.showShort(splashView.getMyContext(), "登录失败:" + response.getMsg()); 65 | splashView.goToLoginActivity(); 66 | } 67 | } 68 | }); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/AccountUtils.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | 6 | import com.wentongwang.notebook.model.User; 7 | 8 | /** 9 | * 用户信息管理类 10 | * Created by Wentong WANG on 2016/6/12. 11 | */ 12 | public class AccountUtils { 13 | 14 | private static final String USER_NAME = "user_name"; 15 | private static final String USER_PWD = "user_pwd"; 16 | private static final String USER_ID = "user_id"; 17 | private static final String USER_EMAIL = "user_email"; 18 | private static final String USER_NICK_NAME = "user_nickname"; 19 | private static final String USER_DIARY_PWD = "user_diraypwd"; 20 | private static final String USER_SEX = "user_sex"; 21 | private static final String USER_HEAD_URL = "user_head_url"; 22 | 23 | /** 24 | * 保存用户的所有信息 25 | * @param context 26 | * @param user 27 | * @param user_pwd 用户的登录密码 28 | */ 29 | public static void saveUserInfos(Context context, User user, String user_pwd) { 30 | saveUserName(context, user.getUsername()); 31 | saveUserPwd(context, user_pwd); 32 | saveUserId(context, user.getObjectId()); 33 | saveUserNickName(context, user.getUser_nickname()); 34 | saveUserEmail(context, user.getEmail()); 35 | saveUserDiaryPwd(context, user.getUser_diraypwd()); 36 | saveUserSex(context, user.getUser_sex()); 37 | saveUserHead(context, user.getUser_head_url()); 38 | } 39 | 40 | 41 | public static String getUserName(Context context) { 42 | return (String) SPUtils.get(context, USER_NAME, ""); 43 | } 44 | 45 | public static void saveUserName(Context context, String str) { 46 | SPUtils.put(context, USER_NAME, str); 47 | } 48 | 49 | public static String getUserPwd(Context context) { 50 | return (String) SPUtils.get(context, USER_PWD, ""); 51 | } 52 | 53 | public static void saveUserPwd(Context context, String str) { 54 | SPUtils.put(context, USER_PWD, str); 55 | } 56 | 57 | public static String getUserId(Context context) { 58 | return (String) SPUtils.get(context, USER_ID, ""); 59 | } 60 | 61 | public static void saveUserId(Context context, String str) { 62 | SPUtils.put(context, USER_ID, str); 63 | } 64 | 65 | public static String getUserEmail(Context context) { 66 | return (String) SPUtils.get(context, USER_EMAIL, ""); 67 | } 68 | 69 | public static void saveUserEmail(Context context, String str) { 70 | if (!TextUtils.isEmpty(str)) { 71 | SPUtils.put(context, USER_EMAIL, str); 72 | } 73 | } 74 | 75 | public static String getUserNickName(Context context) { 76 | return (String) SPUtils.get(context, USER_NICK_NAME, ""); 77 | } 78 | 79 | public static void saveUserNickName(Context context, String str) { 80 | SPUtils.put(context, USER_NICK_NAME, str); 81 | } 82 | 83 | public static String getUserDiaryPwd(Context context) { 84 | return (String) SPUtils.get(context, USER_DIARY_PWD, ""); 85 | } 86 | 87 | public static void saveUserDiaryPwd(Context context, String str) { 88 | SPUtils.put(context, USER_DIARY_PWD, str); 89 | } 90 | 91 | public static String getUserSex(Context context) { 92 | return (String) SPUtils.get(context, USER_SEX, ""); 93 | } 94 | 95 | public static void saveUserSex(Context context, String str) { 96 | SPUtils.put(context, USER_SEX, str); 97 | } 98 | 99 | public static String getUserHeadUrl(Context context){ 100 | return (String) SPUtils.get(context, USER_HEAD_URL, ""); 101 | } 102 | public static void saveUserHead(Context context, String str) { 103 | SPUtils.put(context, USER_HEAD_URL, str); 104 | } 105 | public static void clearAllInfos(Context context){ 106 | SPUtils.clear(context); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/DatabaseUtils.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.util.Log; 8 | 9 | import com.wentongwang.notebook.model.DiaryItem; 10 | import com.wentongwang.notebook.model.NoteItem; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Wentong WANG on 2016/6/6. 17 | */ 18 | public class DatabaseUtils { 19 | 20 | // 数据库名称 21 | private static String DB_NAME = "mynotes.db"; 22 | // 数据库版本 23 | private static int DB_VERSION = 2; 24 | private SQLiteDatabase db; 25 | private MyDatabaseHelper dbUtil; 26 | 27 | public DatabaseUtils(Context context) { 28 | dbUtil = new MyDatabaseHelper(context, DB_NAME, null, DB_VERSION); 29 | db = dbUtil.getWritableDatabase(); 30 | } 31 | 32 | public void close() { 33 | db.close(); 34 | dbUtil.close(); 35 | } 36 | 37 | 38 | // 添加notes表的记录 39 | public Long saveNote(NoteItem note) { 40 | ContentValues values = new ContentValues(); 41 | values.put(NoteItem.NOTE_DATE, note.getNote_date()); 42 | values.put(NoteItem.NOTE_CONTENT, note.getNote_content()); 43 | Long uid = db.insert(MyDatabaseHelper.NOTE_TB_NAME, null, values); 44 | Log.e("SaveNoteInfo", uid + ""); 45 | return uid; 46 | } 47 | 48 | 49 | //从数据库中查询notes表数据 50 | public List getNotes() { 51 | List userList = new ArrayList<>(); 52 | Cursor cursor = db.query(MyDatabaseHelper.NOTE_TB_NAME, null, null, null, null, 53 | null, NoteItem.ID + " DESC"); 54 | cursor.moveToFirst(); 55 | while (!cursor.isAfterLast() && (cursor.getString(1) != null)) { 56 | NoteItem note = new NoteItem(); 57 | note.setNote_id(cursor.getString(0)); 58 | note.setNote_date(cursor.getString(1)); 59 | note.setNote_content(cursor.getString(2)); 60 | userList.add(note); 61 | cursor.moveToNext(); 62 | } 63 | cursor.close(); 64 | return userList; 65 | } 66 | 67 | // 更新notes表的记录 68 | public int UpdateNoteInfo(NoteItem note) { 69 | ContentValues values = new ContentValues(); 70 | values.put(NoteItem.ID, note.getNote_id()); 71 | values.put(NoteItem.NOTE_DATE, note.getNote_date()); 72 | values.put(NoteItem.NOTE_CONTENT, note.getNote_content()); 73 | int id = db.update(MyDatabaseHelper.NOTE_TB_NAME, values, NoteItem.ID + "=" 74 | + note.getNote_id(), null); 75 | Log.e("UpdateNoteInfo", id + ""); 76 | return id; 77 | } 78 | 79 | 80 | //对日记操作的 81 | 82 | 83 | // 添加Diary表的记录 84 | public Long saveDiary(DiaryItem diary) { 85 | ContentValues values = new ContentValues(); 86 | values.put(DiaryItem.DIARY_DATE, diary.getDiary_date()); 87 | values.put(DiaryItem.DIARY_TITLE, diary.getDiary_title()); 88 | values.put(DiaryItem.DIARY_CONTENT, diary.getDiary_content()); 89 | values.put(DiaryItem.DIARY_IS_LOCKED, diary.isLocked()); 90 | Long uid = db.insert(MyDatabaseHelper.DIARY_TB_NAME, null, values); 91 | Log.e("SaveDiaryInfo", uid + ""); 92 | return uid; 93 | } 94 | 95 | 96 | //从数据库中查询Diary表数据 97 | public List getDiaries() { 98 | List userList = new ArrayList<>(); 99 | Cursor cursor = db.query(MyDatabaseHelper.DIARY_TB_NAME, null, null, null, null, 100 | null, DiaryItem.ID + " DESC"); 101 | cursor.moveToFirst(); 102 | //不是最后一条,且有值 103 | while (!cursor.isAfterLast() && (cursor.getString(1) != null)) { 104 | DiaryItem diary = new DiaryItem(); 105 | diary.setDiary_id(cursor.getString(0)); 106 | diary.setDiary_date(cursor.getString(1)); 107 | diary.setDiary_title(cursor.getString(2)); 108 | diary.setDiary_content(cursor.getString(3)); 109 | diary.setIsLocked(cursor.getString(4)); 110 | userList.add(diary); 111 | //到下一条数据 112 | cursor.moveToNext(); 113 | } 114 | cursor.close(); 115 | return userList; 116 | } 117 | 118 | // 更新Diary表 119 | public int UpdateDiaryInfo(DiaryItem diary) { 120 | ContentValues values = new ContentValues(); 121 | values.put(NoteItem.ID, diary.getDiary_id()); 122 | values.put(DiaryItem.DIARY_DATE, diary.getDiary_date()); 123 | values.put(DiaryItem.DIARY_TITLE, diary.getDiary_title()); 124 | values.put(DiaryItem.DIARY_CONTENT, diary.getDiary_content()); 125 | values.put(DiaryItem.DIARY_IS_LOCKED, diary.isLocked()); 126 | int id = db.update(MyDatabaseHelper.DIARY_TB_NAME, values, NoteItem.ID + "=" 127 | + diary.getDiary_id(), null); 128 | Log.e("UpdateDiaryInfo", id + ""); 129 | return id; 130 | } 131 | 132 | 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/ImageUtils.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.Canvas; 8 | import android.graphics.Matrix; 9 | import android.graphics.Paint; 10 | import android.graphics.PorterDuff; 11 | import android.graphics.PorterDuffXfermode; 12 | import android.media.ThumbnailUtils; 13 | import android.os.Build; 14 | 15 | import java.io.FileDescriptor; 16 | 17 | /** 18 | * bitmap的工具类 19 | * Created by Wentong WANG on 2016/5/17. 20 | */ 21 | public class ImageUtils { 22 | 23 | /** 24 | * 由资源id获取位图 25 | */ 26 | 27 | public static Bitmap getBitmapById(Context context, int resId) { 28 | if (context == null) { 29 | return null; 30 | } 31 | return BitmapFactory.decodeResource(context.getResources(), resId); 32 | } 33 | 34 | /** 35 | * bitmap裁剪成圆形 36 | * 37 | * @param source 38 | * @param r 直径 39 | * @return 40 | */ 41 | public static Bitmap creatCircleBitmap(Bitmap source, int r) { 42 | Paint mPaint = new Paint(); 43 | mPaint.setAntiAlias(true); 44 | Bitmap mtraget = Bitmap.createBitmap(r, r, Bitmap.Config.ARGB_8888); 45 | 46 | //产生同样大小的画布 47 | Canvas canvas = new Canvas(mtraget); 48 | //画圆 49 | canvas.drawCircle(r / 2, r / 2, r / 2, mPaint); 50 | //用src_in 51 | mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); 52 | 53 | if (source != null) { 54 | //最后裁剪 55 | if (r / 2 < source.getWidth()) { 56 | canvas.drawBitmap(source, 0, 0, mPaint); 57 | } else { 58 | canvas.drawBitmap(source, r / 2 - source.getWidth() / 2, r / 2 - source.getWidth() / 2, mPaint); 59 | } 60 | } 61 | 62 | 63 | 64 | return mtraget; 65 | } 66 | 67 | /** 68 | * 对图片进行压缩(不改变宽高), 展示在ImageView中 69 | * 70 | * @param res getResource()获取 71 | * @param resId 資源id 72 | * @param reqWidth 要求的宽度, 单位像素 73 | * @param reqHeight 要求的高度, 单位像素 74 | * @return 压缩后的bitmap 75 | */ 76 | public static Bitmap decodeBitmapFromResource(Resources res, int resId, 77 | int reqWidth, int reqHeight) { 78 | // 第一次解析将inJustDecodeBounds设置为true,来获取图片大小,不会占据内存 79 | final BitmapFactory.Options options = new BitmapFactory.Options(); 80 | options.inJustDecodeBounds = true; 81 | BitmapFactory.decodeResource(res, resId, options); 82 | // 调用上面定义的方法计算inSampleSize值 83 | options.inSampleSize = calculateInSampleSize(options, reqWidth, 84 | reqHeight); 85 | // 使用获取到的inSampleSize值再次解析图片 86 | options.inJustDecodeBounds = false; 87 | return BitmapFactory.decodeResource(res, resId, options); 88 | } 89 | /** 90 | * 对图片进行压缩(不改变宽高), 展示在ImageView中 91 | * @param reqWidth 要求的宽度, 单位像素 92 | * @param reqHeight 要求的高度, 单位像素 93 | * @return 压缩后的bitmap 94 | */ 95 | public static Bitmap decodeBitmapFromFileDescriptor(FileDescriptor fileDescriptor, 96 | int reqWidth, int reqHeight) { 97 | // 第一次解析将inJustDecodeBounds设置为true,来获取图片大小,不会占据内存 98 | final BitmapFactory.Options options = new BitmapFactory.Options(); 99 | options.inJustDecodeBounds = true; 100 | BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); 101 | // 调用上面定义的方法计算inSampleSize值 102 | options.inSampleSize = calculateInSampleSize(options, reqWidth, 103 | reqHeight); 104 | // 使用获取到的inSampleSize值再次解析图片 105 | options.inJustDecodeBounds = false; 106 | return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); 107 | } 108 | /** 109 | * 计算压缩比例 110 | * 111 | * @param options 112 | * @param reqWidth 113 | * @param reqHeight 114 | * @return 115 | */ 116 | public static int calculateInSampleSize(BitmapFactory.Options options, 117 | int reqWidth, int reqHeight) { 118 | // 源图片的高度和宽度 119 | final int height = options.outHeight; 120 | final int width = options.outWidth; 121 | int inSampleSize = 1; 122 | if (height > reqHeight || width > reqWidth) { 123 | // 计算出实际宽高和目标宽高的比率 124 | final int heightRatio = Math.round((float) height 125 | / (float) reqHeight); 126 | final int widthRatio = Math.round((float) width / (float) reqWidth); 127 | // 选择宽和高中最小的比率作为inSampleSize的值,这样可以保证最终图片的宽和高 128 | // 一定都会大于等于目标的宽和高。 129 | inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; 130 | } 131 | return inSampleSize; 132 | } 133 | 134 | /** 135 | * 改变图片的宽高 136 | * 137 | * @param bm 所要转换的bitmap 138 | * @param newWidth 新的宽 139 | * @param newHeight 新的高 140 | * @return 指定宽高的bitmap 141 | */ 142 | public static Bitmap resize(Bitmap bm, int newWidth, int newHeight) { 143 | 144 | Bitmap newbm = null; 145 | if (bm != null) { 146 | // 获得图片的宽高 147 | int width = bm.getWidth(); 148 | int height = bm.getHeight(); 149 | // 计算缩放比例 150 | float scaleWidth = ((float) newWidth) / width; 151 | float scaleHeight = ((float) newHeight) / height; 152 | // 取得想要缩放的matrix参数 153 | Matrix matrix = new Matrix(); 154 | matrix.postScale(scaleWidth, scaleHeight); 155 | // 得到新的图片 156 | newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true); 157 | } 158 | return newbm; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import java.security.MessageDigest; 4 | 5 | /** 6 | * Created by Wentong WANG on 2016/6/7. 7 | */ 8 | public class MD5Util { 9 | public static String MD5(String str) { 10 | MessageDigest md5 = null; 11 | try { 12 | md5 = MessageDigest.getInstance("MD5"); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | return ""; 16 | } 17 | 18 | char[] charArray = str.toCharArray(); 19 | byte[] byteArray = new byte[charArray.length]; 20 | 21 | for (int i = 0; i < charArray.length; i++) { 22 | byteArray[i] = (byte) charArray[i]; 23 | } 24 | byte[] md5Bytes = md5.digest(byteArray); 25 | 26 | StringBuffer hexValue = new StringBuffer(); 27 | for (int i = 0; i < md5Bytes.length; i++) { 28 | int val = ((int) md5Bytes[i]) & 0xff; 29 | if (val < 16) { 30 | hexValue.append("0"); 31 | } 32 | hexValue.append(Integer.toHexString(val)); 33 | } 34 | return hexValue.toString(); 35 | } 36 | 37 | // 可逆的加密算法 38 | public static String encryptmd5(String str) { 39 | char[] a = str.toCharArray(); 40 | for (int i = 0; i < a.length; i++) { 41 | a[i] = (char) (a[i] ^ 'l'); 42 | } 43 | String s = new String(a); 44 | return s; 45 | } 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/MyDatabaseHelper.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteOpenHelper; 6 | import android.util.Log; 7 | 8 | import com.wentongwang.notebook.model.DiaryItem; 9 | import com.wentongwang.notebook.model.NoteItem; 10 | 11 | /** 12 | * 创建数据库中表的类 13 | * Created by Wentong WANG on 2016/6/6. 14 | */ 15 | public class MyDatabaseHelper extends SQLiteOpenHelper { 16 | 17 | public static final String NOTE_TB_NAME = "note_info"; 18 | public static final String DIARY_TB_NAME = "diary_info"; 19 | 20 | public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { 21 | super(context, name, factory, version); 22 | } 23 | 24 | @Override 25 | public void onCreate(SQLiteDatabase db) { 26 | //创建便签表 27 | db.execSQL("CREATE TABLE IF NOT EXISTS " + 28 | NOTE_TB_NAME + "(" + 29 | NoteItem.ID + " integer primary key autoincrement," + 30 | NoteItem.NOTE_DATE + " varchar," + 31 | NoteItem.NOTE_CONTENT + " varchar" + 32 | ")" 33 | ); 34 | Log.e("Database", "onCreate"); 35 | 36 | //创建日记表 37 | db.execSQL("CREATE TABLE IF NOT EXISTS " + 38 | DIARY_TB_NAME + "(" + 39 | DiaryItem.ID + " integer primary key autoincrement," + 40 | DiaryItem.DIARY_DATE + " varchar," + 41 | DiaryItem.DIARY_TITLE + " varchar," + 42 | DiaryItem.DIARY_CONTENT + " varchar," + 43 | DiaryItem.DIARY_IS_LOCKED + " varchar" + 44 | ")" 45 | ); 46 | Log.e("Database", "onCreate"); 47 | } 48 | 49 | @Override 50 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 51 | db.execSQL("DROP TABLE IF EXISTS " + NOTE_TB_NAME); 52 | db.execSQL("DROP TABLE IF EXISTS " + DIARY_TB_NAME); 53 | onCreate(db); 54 | Log.e("Database", "onUpgrade"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/MyToast.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import android.content.Context; 4 | import android.widget.Toast; 5 | 6 | /** 7 | * Toast管理工具类 8 | * Created by Wentong WANG on 2016/6/21. 9 | */ 10 | public class MyToast { 11 | private MyToast() 12 | { 13 | /* cannot be instantiated */ 14 | throw new UnsupportedOperationException("cannot be instantiated"); 15 | } 16 | 17 | public static boolean isShow = true; 18 | 19 | /** 20 | * 短时间显示Toast 21 | * 22 | * @param context 23 | * @param message 24 | */ 25 | public static void showShort(Context context, CharSequence message) 26 | { 27 | if (isShow) 28 | Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); 29 | } 30 | 31 | /** 32 | * 短时间显示Toast 33 | * 34 | * @param context 35 | * @param message 36 | */ 37 | public static void showShort(Context context, int message) 38 | { 39 | if (isShow) 40 | Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); 41 | } 42 | 43 | /** 44 | * 长时间显示Toast 45 | * 46 | * @param context 47 | * @param message 48 | */ 49 | public static void showLong(Context context, CharSequence message) 50 | { 51 | if (isShow) 52 | Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 53 | } 54 | 55 | /** 56 | * 长时间显示Toast 57 | * 58 | * @param context 59 | * @param message 60 | */ 61 | public static void showLong(Context context, int message) 62 | { 63 | if (isShow) 64 | Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 65 | } 66 | 67 | /** 68 | * 自定义显示Toast时间 69 | * 70 | * @param context 71 | * @param message 72 | * @param duration 73 | */ 74 | public static void show(Context context, CharSequence message, int duration) 75 | { 76 | if (isShow) 77 | Toast.makeText(context, message, duration).show(); 78 | } 79 | 80 | /** 81 | * 自定义显示Toast时间 82 | * 83 | * @param context 84 | * @param message 85 | * @param duration 86 | */ 87 | public static void show(Context context, int message, int duration) 88 | { 89 | if (isShow) 90 | Toast.makeText(context, message, duration).show(); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/utils/SPUtils.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import java.lang.reflect.InvocationTargetException; 7 | import java.lang.reflect.Method; 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by Wentong WANG on 2016/6/6. 12 | */ 13 | public class SPUtils { 14 | /** 15 | * 保存在手机里面的文件名 16 | */ 17 | public static final String FILE_NAME = "user_data"; 18 | 19 | /** 20 | * 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法 21 | * 22 | * @param context 23 | * @param key 24 | * @param object 25 | */ 26 | public static void put(Context context, String key, Object object) 27 | { 28 | 29 | SharedPreferences sp = context.getSharedPreferences(FILE_NAME, 30 | Context.MODE_PRIVATE); 31 | SharedPreferences.Editor editor = sp.edit(); 32 | 33 | if (object instanceof String) 34 | { 35 | editor.putString(key, (String) object); 36 | } else if (object instanceof Integer) 37 | { 38 | editor.putInt(key, (Integer) object); 39 | } else if (object instanceof Boolean) 40 | { 41 | editor.putBoolean(key, (Boolean) object); 42 | } else if (object instanceof Float) 43 | { 44 | editor.putFloat(key, (Float) object); 45 | } else if (object instanceof Long) 46 | { 47 | editor.putLong(key, (Long) object); 48 | } else 49 | { 50 | editor.putString(key, object.toString()); 51 | } 52 | 53 | SharedPreferencesCompat.apply(editor); 54 | } 55 | 56 | /** 57 | * 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值 58 | * 59 | * @param context 60 | * @param key 61 | * @param defaultObject 62 | * @return 63 | */ 64 | public static Object get(Context context, String key, Object defaultObject) 65 | { 66 | SharedPreferences sp = context.getSharedPreferences(FILE_NAME, 67 | Context.MODE_PRIVATE); 68 | 69 | if (defaultObject instanceof String) 70 | { 71 | return sp.getString(key, (String) defaultObject); 72 | } else if (defaultObject instanceof Integer) 73 | { 74 | return sp.getInt(key, (Integer) defaultObject); 75 | } else if (defaultObject instanceof Boolean) 76 | { 77 | return sp.getBoolean(key, (Boolean) defaultObject); 78 | } else if (defaultObject instanceof Float) 79 | { 80 | return sp.getFloat(key, (Float) defaultObject); 81 | } else if (defaultObject instanceof Long) 82 | { 83 | return sp.getLong(key, (Long) defaultObject); 84 | } 85 | 86 | return null; 87 | } 88 | 89 | /** 90 | * 移除某个key值已经对应的值 91 | * @param context 92 | * @param key 93 | */ 94 | public static void remove(Context context, String key) 95 | { 96 | SharedPreferences sp = context.getSharedPreferences(FILE_NAME, 97 | Context.MODE_PRIVATE); 98 | SharedPreferences.Editor editor = sp.edit(); 99 | editor.remove(key); 100 | SharedPreferencesCompat.apply(editor); 101 | } 102 | 103 | /** 104 | * 清除所有数据 105 | * @param context 106 | */ 107 | public static void clear(Context context) 108 | { 109 | SharedPreferences sp = context.getSharedPreferences(FILE_NAME, 110 | Context.MODE_PRIVATE); 111 | SharedPreferences.Editor editor = sp.edit(); 112 | editor.clear(); 113 | SharedPreferencesCompat.apply(editor); 114 | } 115 | 116 | /** 117 | * 查询某个key是否已经存在 118 | * @param context 119 | * @param key 120 | * @return 121 | */ 122 | public static boolean contains(Context context, String key) 123 | { 124 | SharedPreferences sp = context.getSharedPreferences(FILE_NAME, 125 | Context.MODE_PRIVATE); 126 | return sp.contains(key); 127 | } 128 | 129 | /** 130 | * 返回所有的键值对 131 | * 132 | * @param context 133 | * @return 134 | */ 135 | public static Map getAll(Context context) 136 | { 137 | SharedPreferences sp = context.getSharedPreferences(FILE_NAME, 138 | Context.MODE_PRIVATE); 139 | return sp.getAll(); 140 | } 141 | 142 | /** 143 | * 创建一个解决SharedPreferencesCompat.apply方法的一个兼容类 144 | * 145 | * @author zhy 146 | * 147 | */ 148 | private static class SharedPreferencesCompat 149 | { 150 | private static final Method sApplyMethod = findApplyMethod(); 151 | 152 | /** 153 | * 反射查找apply的方法 154 | * 155 | * @return 156 | */ 157 | @SuppressWarnings({ "unchecked", "rawtypes" }) 158 | private static Method findApplyMethod() 159 | { 160 | try 161 | { 162 | Class clz = SharedPreferences.Editor.class; 163 | return clz.getMethod("apply"); 164 | } catch (NoSuchMethodException e) 165 | { 166 | } 167 | 168 | return null; 169 | } 170 | 171 | /** 172 | * 如果找到则使用apply执行,否则使用commit 173 | * 174 | * @param editor 175 | */ 176 | public static void apply(SharedPreferences.Editor editor) 177 | { 178 | try 179 | { 180 | if (sApplyMethod != null) 181 | { 182 | sApplyMethod.invoke(editor); 183 | return; 184 | } 185 | } catch (IllegalArgumentException e) 186 | { 187 | } catch (IllegalAccessException e) 188 | { 189 | } catch (InvocationTargetException e) 190 | { 191 | } 192 | editor.commit(); 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by Wentong WANG on 2016/7/12. 7 | */ 8 | public interface BaseView { 9 | 10 | /** 11 | * 获取当前界面的Context 12 | * @return context 13 | */ 14 | Context getMyContext(); 15 | 16 | /** 17 | * 显示进度条 18 | */ 19 | void showPorgressBar(); 20 | 21 | /** 22 | * 隐藏进度条 23 | */ 24 | void hidePorgressBar(); 25 | 26 | /** 27 | * 返回 28 | */ 29 | void goBack(); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentActivity; 5 | 6 | import com.wentongwang.notebook.managers.MyActivityManager; 7 | 8 | 9 | /** 10 | * 基础的Activity 11 | * Created by Wentong WANG on 2016/6/21. 12 | */ 13 | public abstract class BaseActivity extends FragmentActivity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | MyActivityManager.getInstance().addActivity(this); 19 | this.setContentView(getLayoutId()); 20 | this.initDatas(); 21 | this.initViews(); 22 | this.initEvents(); 23 | } 24 | 25 | /** 26 | * 初始化数据 27 | */ 28 | protected abstract void initDatas(); 29 | 30 | /** 31 | * 初始化View 32 | */ 33 | protected abstract void initViews(); 34 | 35 | /** 36 | * 初始化View的事件 37 | */ 38 | protected abstract void initEvents(); 39 | 40 | /** 41 | * 获取布局 42 | * @return 布局界面的Id 43 | */ 44 | protected abstract int getLayoutId(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/CreateDiaryActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.widget.Button; 9 | import android.widget.EditText; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.wentongwang.notebook.R; 14 | import com.wentongwang.notebook.model.UpdataEvent; 15 | import com.wentongwang.notebook.presenters.CreatDiaryPresenter; 16 | import com.wentongwang.notebook.managers.MyActivityManager; 17 | import com.wentongwang.notebook.view.activity.interfaces.CreatDiaryView; 18 | 19 | import org.greenrobot.eventbus.EventBus; 20 | 21 | /** 22 | * 创建新的日记 23 | * Created by Wentong WANG on 2016/6/6. 24 | */ 25 | public class CreateDiaryActivity extends BaseActivity implements CreatDiaryView{ 26 | //顶部toolbar部分 27 | private View toolbar; 28 | private TextView title; 29 | private ImageView leftBtn; 30 | private ImageView rightBtn; 31 | //创建日记的按钮 32 | private Button confirmBtn; 33 | //日记部分 34 | private EditText titleText; 35 | private EditText contentText; 36 | private boolean isLocked = false; 37 | 38 | //进度条 39 | private View progressBar; 40 | //上锁和不上锁的两个图片 41 | private Bitmap nolock; 42 | private Bitmap lock; 43 | 44 | private CreatDiaryPresenter mPresenter = new CreatDiaryPresenter(this); 45 | /** 46 | * 获取布局 47 | * 48 | * @return 布局界面的Id 49 | */ 50 | @Override 51 | protected int getLayoutId() { 52 | return R.layout.create_diary_activity_layout; 53 | } 54 | 55 | @Override 56 | public void onCreate(Bundle savedInstanceState) { 57 | super.onCreate(savedInstanceState); 58 | // Bmob.initialize(this, Constants.APPLICATION_ID); 59 | initDatas(); 60 | initViews(); 61 | initEvents(); 62 | } 63 | @Override 64 | protected void initDatas() { 65 | nolock = BitmapFactory.decodeResource(getResources(), R.drawable.nolock); 66 | lock = BitmapFactory.decodeResource(getResources(), R.drawable.lock); 67 | } 68 | @Override 69 | protected void initViews() { 70 | toolbar = findViewById(R.id.top_toolbar); 71 | title = (TextView) toolbar.findViewById(R.id.title); 72 | title.setText("创建新的日记"); 73 | //设置左侧返回按钮 74 | leftBtn = (ImageView) toolbar.findViewById(R.id.left_btn); 75 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.back_btn); 76 | leftBtn.setImageBitmap(bitmap); 77 | //设置toolbar右侧加锁按钮 78 | rightBtn = (ImageView) toolbar.findViewById(R.id.right_btn); 79 | 80 | rightBtn.setImageBitmap(nolock); 81 | rightBtn.setVisibility(View.VISIBLE); 82 | 83 | confirmBtn = (Button) findViewById(R.id.confirm_btn); 84 | 85 | contentText = (EditText) findViewById(R.id.diary_content); 86 | titleText = (EditText) findViewById(R.id.diary_title); 87 | 88 | 89 | progressBar = findViewById(R.id.progress_bar); 90 | } 91 | 92 | @Override 93 | protected void initEvents() { 94 | leftBtn.setOnClickListener(new View.OnClickListener() { 95 | @Override 96 | public void onClick(View v) { 97 | MyActivityManager.getInstance().pop(); 98 | onBackPressed(); 99 | } 100 | }); 101 | rightBtn.setOnClickListener(new View.OnClickListener() { 102 | @Override 103 | public void onClick(View v) { 104 | mPresenter.lockDiary(); 105 | } 106 | }); 107 | confirmBtn.setOnClickListener(new View.OnClickListener() { 108 | @Override 109 | public void onClick(View v) { 110 | mPresenter.creatDiary(); 111 | } 112 | }); 113 | } 114 | 115 | 116 | /** 117 | * 获取当前界面的Context 118 | * 119 | * @return context 120 | */ 121 | @Override 122 | public Context getMyContext() { 123 | return CreateDiaryActivity.this; 124 | } 125 | 126 | /** 127 | * 获取日记内容 128 | * 129 | * @return 130 | */ 131 | @Override 132 | public String getDiaryContent() { 133 | return contentText.getText().toString(); 134 | } 135 | 136 | /** 137 | * 获取日记标题 138 | * 139 | * @return 140 | */ 141 | @Override 142 | public String getDiaryTitle() { 143 | return titleText.getText().toString(); 144 | } 145 | 146 | /** 147 | * 返回 148 | */ 149 | @Override 150 | public void goBack() { 151 | UpdataEvent event = new UpdataEvent(); 152 | event.setType(UpdataEvent.UPDATE_DIARIES); 153 | EventBus.getDefault().post(event); 154 | MyActivityManager.getInstance().pop(); 155 | onBackPressed(); 156 | } 157 | 158 | /** 159 | * 显示进度条 160 | */ 161 | @Override 162 | public void showPorgressBar() { 163 | progressBar.setVisibility(View.VISIBLE); 164 | } 165 | 166 | /** 167 | * 隐藏进度条 168 | */ 169 | @Override 170 | public void hidePorgressBar() { 171 | progressBar.setVisibility(View.GONE); 172 | } 173 | 174 | @Override 175 | public boolean isLocked() { 176 | return isLocked; 177 | } 178 | 179 | @Override 180 | public void setLock(boolean is) { 181 | this.isLocked = is; 182 | } 183 | 184 | /** 185 | * 更换锁的图片 186 | */ 187 | @Override 188 | public void updateBtnImg() { 189 | if (isLocked) { 190 | rightBtn.setImageBitmap(lock); 191 | } else { 192 | rightBtn.setImageBitmap(nolock); 193 | } 194 | } 195 | 196 | 197 | } 198 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/CreateNoteActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.widget.Button; 9 | import android.widget.EditText; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.wentongwang.notebook.R; 14 | 15 | import com.wentongwang.notebook.model.UpdataEvent; 16 | import com.wentongwang.notebook.presenters.CreatNotePresenter; 17 | import com.wentongwang.notebook.managers.MyActivityManager; 18 | import com.wentongwang.notebook.view.activity.interfaces.CreatNoteView; 19 | import com.wentongwang.notebook.view.custome.AudioRecoderButton; 20 | 21 | import org.greenrobot.eventbus.EventBus; 22 | 23 | 24 | /** 25 | * 创建新的便签 26 | * Created by Wentong WANG on 2016/6/3. 27 | */ 28 | public class CreateNoteActivity extends BaseActivity implements CreatNoteView { 29 | 30 | private View toolbar; 31 | private TextView title; 32 | private ImageView leftBtn; 33 | private Button confirmBtn; 34 | 35 | private AudioRecoderButton audioRecoderButton; 36 | 37 | private EditText text; 38 | 39 | //进度条 40 | private View progressBar; 41 | 42 | private CreatNotePresenter mPresenter = new CreatNotePresenter(this); 43 | /** 44 | * 获取布局 45 | * 46 | * @return 布局界面的Id 47 | */ 48 | @Override 49 | protected int getLayoutId() { 50 | return R.layout.create_note_activity_layout; 51 | } 52 | 53 | 54 | @Override 55 | public void onCreate(Bundle savedInstanceState) { 56 | super.onCreate(savedInstanceState); 57 | // Bmob.initialize(this, Constants.APPLICATION_ID); 58 | initViews(); 59 | initEvents(); 60 | } 61 | 62 | /** 63 | * 初始化数据 64 | */ 65 | @Override 66 | protected void initDatas() { 67 | 68 | } 69 | @Override 70 | protected void initViews() { 71 | toolbar = findViewById(R.id.top_toolbar); 72 | title = (TextView) toolbar.findViewById(R.id.title); 73 | title.setText("创建新的便签"); 74 | leftBtn = (ImageView) toolbar.findViewById(R.id.left_btn); 75 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.back_btn); 76 | leftBtn.setImageBitmap(bitmap); 77 | 78 | confirmBtn = (Button) findViewById(R.id.confirm_btn); 79 | 80 | text = (EditText) findViewById(R.id.note_content); 81 | 82 | progressBar = findViewById(R.id.progress_bar); 83 | 84 | audioRecoderButton = (AudioRecoderButton) findViewById(R.id.audio_recoder); 85 | } 86 | 87 | @Override 88 | protected void initEvents() { 89 | leftBtn.setOnClickListener(new View.OnClickListener() { 90 | @Override 91 | public void onClick(View v) { 92 | MyActivityManager.getInstance().pop(); 93 | onBackPressed(); 94 | } 95 | }); 96 | 97 | confirmBtn.setOnClickListener(new View.OnClickListener() { 98 | @Override 99 | public void onClick(View v) { 100 | mPresenter.creatNote(); 101 | } 102 | }); 103 | } 104 | 105 | 106 | /** 107 | * 获取当前界面的Context 108 | * 109 | * @return context 110 | */ 111 | @Override 112 | public Context getMyContext() { 113 | return CreateNoteActivity.this; 114 | } 115 | 116 | /** 117 | * 获取日记内容 118 | * 119 | * @return 120 | */ 121 | @Override 122 | public String getNoteContent() { 123 | return text.getText().toString(); 124 | } 125 | 126 | /** 127 | * 返回 128 | */ 129 | @Override 130 | public void goBack() { 131 | UpdataEvent event = new UpdataEvent(); 132 | event.setType(UpdataEvent.UPDATE_NOTES); 133 | EventBus.getDefault().post(event); 134 | MyActivityManager.getInstance().pop(); 135 | onBackPressed(); 136 | } 137 | 138 | /** 139 | * 显示进度条 140 | */ 141 | @Override 142 | public void showPorgressBar() { 143 | progressBar.setVisibility(View.VISIBLE); 144 | } 145 | 146 | /** 147 | * 隐藏进度条 148 | */ 149 | @Override 150 | public void hidePorgressBar() { 151 | progressBar.setVisibility(View.GONE); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/EditNoteActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.view.inputmethod.InputMethodManager; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | import com.wentongwang.notebook.R; 16 | import com.wentongwang.notebook.model.NoteItem; 17 | import com.wentongwang.notebook.model.UpdataEvent; 18 | import com.wentongwang.notebook.presenters.EditNotePresenter; 19 | import com.wentongwang.notebook.managers.MyActivityManager; 20 | import com.wentongwang.notebook.view.activity.interfaces.EditNoteView; 21 | 22 | import org.greenrobot.eventbus.EventBus; 23 | 24 | 25 | /** 26 | * 观看,修改note的界面 27 | * Created by Wentong WANG on 2016/6/6. 28 | */ 29 | public class EditNoteActivity extends BaseActivity implements View.OnClickListener,EditNoteView{ 30 | private View toolbar; 31 | private TextView title; 32 | private ImageView leftBtn; 33 | 34 | private Button editBtn; 35 | 36 | private EditText text; 37 | 38 | private NoteItem thisNote; 39 | 40 | private boolean onEdit = false; 41 | //进度条 42 | private View progressBar; 43 | 44 | private EditNotePresenter mPresenter = new EditNotePresenter(this); 45 | /** 46 | * 获取布局 47 | * 48 | * @return 布局界面的Id 49 | */ 50 | @Override 51 | protected int getLayoutId() { 52 | return R.layout.edit_note_activity_layout; 53 | } 54 | 55 | @Override 56 | public void onCreate(Bundle savedInstanceState) { 57 | super.onCreate(savedInstanceState); 58 | 59 | initDatas(); 60 | initViews(); 61 | initEvents(); 62 | } 63 | @Override 64 | protected void initDatas() { 65 | Bundle bundle = getIntent().getExtras(); 66 | thisNote = (NoteItem) bundle.getSerializable("my_note"); 67 | } 68 | @Override 69 | protected void initViews() { 70 | toolbar = findViewById(R.id.top_toolbar); 71 | title = (TextView) toolbar.findViewById(R.id.title); 72 | title.setText(thisNote.getNote_date()); 73 | leftBtn = (ImageView) toolbar.findViewById(R.id.left_btn); 74 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.back_btn); 75 | leftBtn.setImageBitmap(bitmap); 76 | 77 | text = (EditText) findViewById(R.id.note_content); 78 | //初始化 79 | mPresenter.setNoteContent(); 80 | 81 | editBtn = (Button) findViewById(R.id.edit_btn); 82 | 83 | progressBar = findViewById(R.id.progress_bar); 84 | } 85 | @Override 86 | protected void initEvents() { 87 | 88 | leftBtn.setOnClickListener(this); 89 | editBtn.setOnClickListener(this); 90 | } 91 | 92 | 93 | 94 | @Override 95 | public void onClick(View v) { 96 | switch (v.getId()) { 97 | case R.id.left_btn: 98 | goBack(); 99 | break; 100 | case R.id.right_btn: 101 | 102 | break; 103 | case R.id.edit_btn: 104 | mPresenter.edit(); 105 | break; 106 | } 107 | } 108 | 109 | 110 | 111 | /** 112 | * 获取当前界面的Context 113 | * 114 | * @return context 115 | */ 116 | @Override 117 | public Context getMyContext() { 118 | return EditNoteActivity.this; 119 | } 120 | 121 | /** 122 | * 获取便签 123 | * 124 | * @return 125 | */ 126 | @Override 127 | public NoteItem getNoteFromIntent() { 128 | Bundle bundle = getIntent().getExtras(); 129 | return (NoteItem) bundle.getSerializable("my_note"); 130 | } 131 | 132 | /** 133 | * 设置便签内容 134 | * 135 | * @return 136 | */ 137 | @Override 138 | public void setNoteContent(String content) { 139 | text.setText(content); 140 | text.setEnabled(false); 141 | } 142 | 143 | /** 144 | * 获取日记内容 145 | * 146 | * @return 147 | */ 148 | @Override 149 | public String getNoteContent() { 150 | return text.getText().toString(); 151 | } 152 | 153 | /** 154 | * 返回 155 | */ 156 | @Override 157 | public void goBack() { 158 | MyActivityManager.getInstance().pop(); 159 | onBackPressed(); 160 | } 161 | 162 | /** 163 | * 修改完成跳转 164 | */ 165 | @Override 166 | public void finishAndBack() { 167 | UpdataEvent event = new UpdataEvent(); 168 | event.setType(UpdataEvent.UPDATE_NOTES); 169 | EventBus.getDefault().post(event); 170 | MyActivityManager.getInstance().pop(); 171 | onBackPressed(); 172 | } 173 | 174 | /** 175 | * 显示进度条 176 | */ 177 | @Override 178 | public void showPorgressBar() { 179 | progressBar.setVisibility(View.VISIBLE); 180 | } 181 | 182 | /** 183 | * 隐藏进度条 184 | */ 185 | @Override 186 | public void hidePorgressBar() { 187 | progressBar.setVisibility(View.GONE); 188 | } 189 | 190 | /** 191 | * 开启编辑 192 | */ 193 | @Override 194 | public void beginEdit() { 195 | //EditText可编辑状态 196 | text.setEnabled(true); 197 | text.setSelection(text.getText().toString().length()); 198 | //弹出软键盘的操作 199 | InputMethodManager inputMethodManager=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 200 | inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 201 | 202 | editBtn.setBackground(getResources().getDrawable(R.drawable.confirm_btn)); 203 | onEdit = true; 204 | } 205 | 206 | /** 207 | * 完成编辑 208 | */ 209 | @Override 210 | public void finishEdit() { 211 | text.setEnabled(false); 212 | editBtn.setBackground(getResources().getDrawable(R.drawable.edit_btn)); 213 | onEdit = false; 214 | } 215 | 216 | /** 217 | * 判断是否是可编辑状态 218 | * 219 | * @return 220 | */ 221 | @Override 222 | public boolean canEdit() { 223 | return onEdit; 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Build; 6 | import android.os.Bundle; 7 | import android.view.KeyEvent; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | 13 | import com.wentongwang.notebook.R; 14 | import com.wentongwang.notebook.presenters.LoginPresenter; 15 | import com.wentongwang.notebook.managers.MyActivityManager; 16 | import com.wentongwang.notebook.view.activity.interfaces.LoginView; 17 | 18 | /** 19 | * 登陆界面 20 | * Created by Wentong WANG on 2016/6/7. 21 | */ 22 | public class LoginActivity extends BaseActivity implements LoginView,View.OnClickListener { 23 | private Button loginBtn; 24 | private Button signUpBtn; 25 | 26 | private EditText userName; 27 | private EditText userPwd; 28 | 29 | private View porgessBar; 30 | private LoginPresenter mPresenter = new LoginPresenter(this); 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 34 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 35 | //getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 36 | } 37 | super.onCreate(savedInstanceState); 38 | } 39 | 40 | /** 41 | * 获取布局 42 | * 43 | * @return 布局界面的Id 44 | */ 45 | @Override 46 | protected int getLayoutId() { 47 | return R.layout.login_activity_layout; 48 | } 49 | @Override 50 | protected void initDatas() { 51 | // Bmob.initialize(this, Constants.APPLICATION_ID); 52 | } 53 | @Override 54 | protected void initViews() { 55 | loginBtn = (Button) findViewById(R.id.btn_sign_in); 56 | signUpBtn = (Button) findViewById(R.id.btn_sign_up); 57 | 58 | userName = (EditText) findViewById(R.id.login_user_name); 59 | userPwd = (EditText) findViewById(R.id.login_user_pwd); 60 | 61 | porgessBar = findViewById(R.id.progress_bar); 62 | } 63 | @Override 64 | protected void initEvents() { 65 | loginBtn.setOnClickListener(this); 66 | signUpBtn.setOnClickListener(this); 67 | } 68 | 69 | 70 | @Override 71 | public void onClick(View v) { 72 | switch (v.getId()) { 73 | case R.id.btn_sign_in: 74 | mPresenter.login(); 75 | break; 76 | case R.id.btn_sign_up: 77 | goToSignUpActivity(); 78 | break; 79 | } 80 | } 81 | 82 | @Override 83 | public boolean onKeyDown(int keyCode, KeyEvent event) { 84 | if (keyCode == KeyEvent.KEYCODE_BACK) { 85 | MyActivityManager.getInstance().onTerminate(); 86 | } 87 | return true; 88 | } 89 | 90 | @Override 91 | public String getUserName() { 92 | return userName.getText().toString(); 93 | } 94 | 95 | @Override 96 | public String getUserPwd() { 97 | return userPwd.getText().toString(); 98 | } 99 | 100 | @Override 101 | public Context getMyContext() { 102 | return LoginActivity.this; 103 | } 104 | 105 | /** 106 | * 跳转到主界面 107 | */ 108 | @Override 109 | public void goToHomeActivity() { 110 | Intent it = new Intent(); 111 | it.setClass(LoginActivity.this, HomeActivity.class); 112 | startActivity(it); 113 | } 114 | 115 | /** 116 | * 跳转到注册界面 117 | */ 118 | @Override 119 | public void goToSignUpActivity() { 120 | Intent it = new Intent(); 121 | it.setClass(LoginActivity.this, SignUpActivity.class); 122 | startActivity(it); 123 | } 124 | 125 | /** 126 | * 显示进度条 127 | */ 128 | @Override 129 | public void showPorgressBar() { 130 | porgessBar.setVisibility(View.VISIBLE); 131 | } 132 | 133 | /** 134 | * 隐藏进度条 135 | */ 136 | @Override 137 | public void hidePorgressBar() { 138 | porgessBar.setVisibility(View.GONE); 139 | } 140 | 141 | /** 142 | * 返回 143 | */ 144 | @Override 145 | public void goBack() { 146 | 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/SignUpActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Build; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | import android.widget.Toast; 13 | 14 | import com.wentongwang.notebook.R; 15 | import com.wentongwang.notebook.managers.MyActivityManager; 16 | import com.wentongwang.notebook.model.Constants; 17 | import com.wentongwang.notebook.model.User; 18 | import com.wentongwang.notebook.presenters.SignUpPresenter; 19 | import com.wentongwang.notebook.utils.AccountUtils; 20 | import com.wentongwang.notebook.utils.MD5Util; 21 | import com.wentongwang.notebook.view.activity.interfaces.SignUpView; 22 | 23 | import cn.bmob.v3.Bmob; 24 | import cn.bmob.v3.BmobUser; 25 | import cn.bmob.v3.listener.SaveListener; 26 | 27 | /** 28 | * 注册界面 29 | * Created by Wentong WANG on 2016/6/7. 30 | */ 31 | public class SignUpActivity extends Activity implements SignUpView{ 32 | 33 | private EditText userName; 34 | private EditText userPwd; 35 | private EditText userPwd2; 36 | private Button singUpBtn; 37 | 38 | private View progressBar; 39 | 40 | private SignUpPresenter mPresenter = new SignUpPresenter(this); 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 45 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 46 | //getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 47 | } 48 | 49 | setContentView(R.layout.signup_activity_layout); 50 | Bmob.initialize(this, Constants.APPLICATION_ID); 51 | initViews(); 52 | 53 | initEvents(); 54 | } 55 | 56 | private void initViews() { 57 | userName = (EditText) findViewById(R.id.et_sign_up_username); 58 | userPwd = (EditText) findViewById(R.id.et_sign_up_pwd); 59 | userPwd2 = (EditText) findViewById(R.id.et_sign_up_pwd_confirm); 60 | 61 | singUpBtn = (Button) findViewById(R.id.btn_sign_up); 62 | 63 | progressBar = findViewById(R.id.progress_bar); 64 | } 65 | 66 | private void initEvents() { 67 | singUpBtn.setOnClickListener(new View.OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | //执行注册功能 71 | mPresenter.signUp(); 72 | } 73 | }); 74 | } 75 | 76 | 77 | @Override 78 | public Context getMyContext() { 79 | return SignUpActivity.this; 80 | } 81 | 82 | /** 83 | * 显示进度条 84 | */ 85 | @Override 86 | public void showPorgressBar() { 87 | progressBar.setVisibility(View.VISIBLE); 88 | } 89 | 90 | /** 91 | * 隐藏进度条 92 | */ 93 | @Override 94 | public void hidePorgressBar() { 95 | progressBar.setVisibility(View.GONE); 96 | } 97 | 98 | /** 99 | * 返回 100 | */ 101 | @Override 102 | public void goBack() { 103 | MyActivityManager.getInstance().pop(); 104 | onBackPressed(); 105 | } 106 | 107 | /** 108 | * 获取注册用户名 109 | * 110 | * @return 111 | */ 112 | @Override 113 | public String getUserName() { 114 | return userName.getText().toString(); 115 | } 116 | 117 | /** 118 | * 获取注册密码 119 | * 120 | * @return 121 | */ 122 | @Override 123 | public String getUserPwd() { 124 | return userPwd.getText().toString(); 125 | } 126 | 127 | /** 128 | * 获取注册密码校验 129 | * 130 | * @return 131 | */ 132 | @Override 133 | public String getUserPwdConfirm() { 134 | return userPwd2.getText().toString(); 135 | } 136 | 137 | @Override 138 | public void goToLoginActivity() { 139 | Intent it = new Intent(); 140 | it.setClass(SignUpActivity.this, LoginActivity.class); 141 | startActivity(it); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Build; 6 | import android.os.Bundle; 7 | import android.view.WindowManager; 8 | import android.view.animation.AlphaAnimation; 9 | import android.view.animation.Animation; 10 | import android.widget.RelativeLayout; 11 | 12 | import com.wentongwang.notebook.R; 13 | import com.wentongwang.notebook.model.Constants; 14 | import com.wentongwang.notebook.presenters.SplashPresenter; 15 | import com.wentongwang.notebook.view.activity.interfaces.SplashView; 16 | 17 | import cn.bmob.v3.Bmob; 18 | 19 | /** 20 | * 欢迎界面 21 | * Created by Wentong WANG on 2016/6/12. 22 | */ 23 | public class SplashActivity extends BaseActivity implements SplashView{ 24 | private AlphaAnimation myAnima; 25 | private RelativeLayout root; 26 | 27 | private SplashPresenter mPresenter = new SplashPresenter(this); 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 31 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 32 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 33 | } 34 | super.onCreate(savedInstanceState); 35 | } 36 | /** 37 | * 获取布局 38 | * 39 | * @return 布局界面的Id 40 | */ 41 | @Override 42 | protected int getLayoutId() { 43 | return R.layout.splash_activity_layout; 44 | } 45 | @Override 46 | protected void initDatas() { 47 | Bmob.initialize(this, Constants.APPLICATION_ID); 48 | } 49 | @Override 50 | protected void initViews() { 51 | root = (RelativeLayout) findViewById(R.id.splash_root); 52 | initAnimation(); 53 | } 54 | 55 | /** 56 | * 初始化开始动画 57 | */ 58 | private void initAnimation() { 59 | //0表示全透明,1表示不透明 60 | //alphaanimation渐变动画 61 | myAnima = new AlphaAnimation(0.0f, 1.0f); 62 | myAnima.setDuration(2000); 63 | //界面停留在动画结束状态 64 | myAnima.setFillAfter(true); 65 | root.setAnimation(myAnima); 66 | } 67 | protected void initEvents() { 68 | myAnima.setAnimationListener(new Animation.AnimationListener() { 69 | @Override 70 | public void onAnimationStart(Animation animation) { 71 | 72 | } 73 | 74 | @Override 75 | public void onAnimationEnd(Animation animation) { 76 | //动画结束后,实行自动登录 77 | mPresenter.autoLogin(); 78 | } 79 | 80 | @Override 81 | public void onAnimationRepeat(Animation animation) { 82 | 83 | } 84 | }); 85 | } 86 | 87 | /** 88 | * 获取Context 89 | */ 90 | @Override 91 | public Context getMyContext() { 92 | return SplashActivity.this; 93 | } 94 | 95 | /** 96 | * 显示进度条 97 | */ 98 | @Override 99 | public void showPorgressBar() { 100 | 101 | } 102 | 103 | /** 104 | * 隐藏进度条 105 | */ 106 | @Override 107 | public void hidePorgressBar() { 108 | 109 | } 110 | 111 | /** 112 | * 返回 113 | */ 114 | @Override 115 | public void goBack() { 116 | 117 | } 118 | 119 | /** 120 | * 跳转到主界面 121 | */ 122 | @Override 123 | public void goToHomeActivity() { 124 | Intent it = new Intent(); 125 | it.setClass(SplashActivity.this, HomeActivity.class); 126 | startActivity(it); 127 | } 128 | 129 | /** 130 | * 跳转到登录界面 131 | */ 132 | @Override 133 | public void goToLoginActivity() { 134 | //自动登录失败,跳转到登录界面 135 | Intent it = new Intent(); 136 | it.setClass(SplashActivity.this, LoginActivity.class); 137 | startActivity(it); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/CreatDiaryView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.view.BaseView; 6 | 7 | /** 8 | * Created by Wentong WANG on 2016/7/4. 9 | */ 10 | public interface CreatDiaryView extends BaseView{ 11 | /** 12 | * 获取日记内容 13 | * @return 14 | */ 15 | String getDiaryContent(); 16 | 17 | /** 18 | * 获取日记标题 19 | * @return 20 | */ 21 | String getDiaryTitle(); 22 | 23 | boolean isLocked(); 24 | 25 | void setLock(boolean lock); 26 | 27 | /** 28 | * 更换锁的图片 29 | */ 30 | void updateBtnImg(); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/CreatNoteView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.view.BaseView; 6 | 7 | /** 8 | * Created by Wentong WANG on 2016/7/4. 9 | */ 10 | public interface CreatNoteView extends BaseView{ 11 | 12 | /** 13 | * 获取日记内容 14 | * @return 15 | */ 16 | String getNoteContent(); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/EditDiaryView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.model.DiaryItem; 6 | import com.wentongwang.notebook.view.BaseView; 7 | 8 | /** 9 | * Created by Wentong WANG on 2016/7/5. 10 | */ 11 | public interface EditDiaryView extends BaseView { 12 | /** 13 | * 获取日记内容 14 | * @return 15 | */ 16 | String getDiaryContent(); 17 | 18 | /** 19 | * 完成任务后返回 20 | */ 21 | void finishAndBack(); 22 | 23 | /** 24 | * 从意图中获取日记 25 | * @return 26 | */ 27 | DiaryItem getDiaryFromIntent(); 28 | 29 | /** 30 | * 设置日记内容 31 | * @param content 32 | */ 33 | void setDiary(String content, String title); 34 | 35 | 36 | /** 37 | * 开启编辑 38 | */ 39 | void beginEdit(); 40 | 41 | /** 42 | * 完成编辑 43 | */ 44 | void finishEdit(); 45 | 46 | /** 47 | * 判断是否是可编辑状态 48 | * @return 49 | */ 50 | boolean canEdit(); 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/EditNoteView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.model.NoteItem; 6 | import com.wentongwang.notebook.view.BaseView; 7 | 8 | /** 9 | * Created by Wentong WANG on 2016/7/5. 10 | */ 11 | public interface EditNoteView extends BaseView{ 12 | 13 | /** 14 | * 获取便签 15 | * @return 16 | */ 17 | NoteItem getNoteFromIntent(); 18 | /** 19 | * 设置便签内容 20 | * @return 21 | */ 22 | void setNoteContent(String content); 23 | 24 | /** 25 | * 获取便签内容 26 | * @return 27 | */ 28 | String getNoteContent(); 29 | 30 | /** 31 | * 修改完成跳转 32 | */ 33 | void finishAndBack(); 34 | 35 | /** 36 | * 开启编辑 37 | */ 38 | void beginEdit(); 39 | 40 | /** 41 | * 完成编辑 42 | */ 43 | void finishEdit(); 44 | 45 | /** 46 | * 判断是否是可编辑状态 47 | * @return 48 | */ 49 | boolean canEdit(); 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/HomeView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.graphics.Bitmap; 6 | import android.graphics.drawable.Drawable; 7 | 8 | /** 9 | * Created by Wentong WANG on 2016/6/23. 10 | */ 11 | public interface HomeView { 12 | Context getMyContext(); 13 | /** 14 | * 头像设置 15 | */ 16 | void setUserHead(Bitmap bitmap); 17 | 18 | /** 19 | * 设置用户昵称 20 | */ 21 | void setUserNickName(String nickName); 22 | 23 | /** 24 | * 设置用户性别 25 | * @param sex 26 | */ 27 | void setUserSex(Drawable sex); 28 | /** 29 | * 跳转到用户中心界面 30 | */ 31 | void goToUserInfoActivity(); 32 | 33 | /** 34 | * 获取缓存文件夹目录 35 | * @return 36 | */ 37 | String getCachePath(); 38 | 39 | Resources getResources(); 40 | 41 | /** 42 | * 刷新界面 43 | * @param currentPage 44 | */ 45 | void refresh(int currentPage); 46 | 47 | void setCurrentPage(int page); 48 | 49 | /** 50 | * 显示关于我们 51 | */ 52 | void showAboutUsFragment(); 53 | /** 54 | * 设置toolbar标题 55 | * @param title 56 | */ 57 | void setTitle(String title); 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/LoginView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.view.BaseView; 6 | 7 | /** 8 | * 登录界面View的功能 9 | * Created by Wentong WANG on 2016/6/21. 10 | */ 11 | public interface LoginView extends BaseView{ 12 | 13 | /** 14 | * 获取用户名 15 | * @return 用户名 16 | */ 17 | String getUserName(); 18 | 19 | /** 20 | * 获取用户密码 21 | * @return 密码 22 | */ 23 | String getUserPwd(); 24 | 25 | /** 26 | * 跳转到主界面 27 | */ 28 | void goToHomeActivity(); 29 | 30 | /** 31 | * 跳转到注册界面 32 | */ 33 | void goToSignUpActivity(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/SignUpView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.view.BaseView; 6 | 7 | /** 8 | * 注册界面的功能 9 | * Created by Wentong WANG on 2016/6/23. 10 | */ 11 | public interface SignUpView extends BaseView{ 12 | 13 | /** 14 | * 获取注册用户名 15 | * @return 16 | */ 17 | String getUserName(); 18 | 19 | /** 20 | * 获取注册密码 21 | * @return 22 | */ 23 | String getUserPwd(); 24 | 25 | /** 26 | * 获取注册密码校验 27 | * @return 28 | */ 29 | String getUserPwdConfirm(); 30 | 31 | void goToLoginActivity(); 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/SplashView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | 5 | import com.wentongwang.notebook.view.BaseView; 6 | 7 | /** 8 | * 9 | * Created by Wentong WANG on 2016/6/21. 10 | */ 11 | public interface SplashView extends BaseView{ 12 | /** 13 | * 跳转到主界面 14 | */ 15 | void goToHomeActivity(); 16 | 17 | /** 18 | * 跳转到登录界面 19 | */ 20 | void goToLoginActivity(); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/activity/interfaces/UserInfoView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.activity.interfaces; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.drawable.Drawable; 6 | import android.view.LayoutInflater; 7 | 8 | import com.wentongwang.notebook.view.BaseView; 9 | 10 | /** 11 | * 12 | * Created by Wentong WANG on 2016/6/22. 13 | */ 14 | public interface UserInfoView extends BaseView{ 15 | 16 | /** 17 | * 设置用户名 18 | * @param userName 19 | */ 20 | void setUserName(String userName); 21 | /** 22 | * 设置用户昵称 23 | */ 24 | void setUserNickName(String userNickName); 25 | 26 | /** 27 | * 设置用户邮箱 28 | * @param email 29 | */ 30 | void setUserEmail(String email); 31 | 32 | /** 33 | * 设置用户性别 34 | * @param sex 35 | */ 36 | void setUserSex(String sex); 37 | 38 | /** 39 | * 设置日记密码 40 | * @param pwd 41 | */ 42 | void setUserDiaryPwd(String pwd); 43 | 44 | /** 45 | * 设置用户头像 46 | */ 47 | void setUserHead(Bitmap bitmap); 48 | 49 | /** 50 | * 跳转到登录界面 51 | */ 52 | void goToLoginActivity(); 53 | 54 | /** 55 | * 获取缓存文件夹目录 56 | * @return 57 | */ 58 | String getCachePath(); 59 | 60 | /** 61 | * 刷新其他界面的头像 62 | */ 63 | void toUpdateUserInfo(); 64 | 65 | /** 66 | * 获取布局加载器 67 | * @return 68 | */ 69 | LayoutInflater getLayoutInflater(); 70 | 71 | /** 72 | * 根据资源id获取drawable 73 | * @param id 74 | * @return 75 | */ 76 | Drawable getDrawableByResource(int id); 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/custome/CircleImageView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.custome; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.util.AttributeSet; 8 | import android.util.Log; 9 | import android.view.View; 10 | 11 | import com.wentongwang.notebook.R; 12 | import com.wentongwang.notebook.utils.ImageUtils; 13 | 14 | 15 | /** 16 | * Created by Wentong WANG on 2016/6/2. 17 | */ 18 | public class CircleImageView extends View { 19 | //该view的长宽 20 | private int imageSize; 21 | private int resourceId = -1; 22 | //要显示的图片 23 | private Bitmap bitmap; 24 | private Bitmap defaut; 25 | 26 | private Context mContext; 27 | private Paint mPaint; 28 | 29 | 30 | private static final int DEFAUT = 0; 31 | private static final int RESOURCE = 1; 32 | private static final int BITMAP = 2; 33 | private int mPicFrom = DEFAUT; 34 | public CircleImageView(Context context) { 35 | this(context, null); 36 | } 37 | 38 | public CircleImageView(Context context, AttributeSet attrs) { 39 | super(context, attrs); 40 | mContext = context; 41 | mPaint = new Paint(); 42 | } 43 | 44 | @Override 45 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 46 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 47 | int height = measure(heightMeasureSpec); 48 | int width = measure(widthMeasureSpec); 49 | 50 | imageSize = Math.max(width, height); 51 | setMeasuredDimension(imageSize, imageSize); 52 | } 53 | 54 | /** 55 | * 测量宽高 56 | * 57 | * @param measureSpec 58 | * @return 59 | */ 60 | private int measure(int measureSpec) { 61 | int mode = MeasureSpec.getMode(measureSpec); 62 | int size = MeasureSpec.getSize(measureSpec); 63 | 64 | int result = 0; 65 | if (mode == MeasureSpec.EXACTLY) { 66 | result = size; 67 | } else { 68 | result = 50; 69 | if (mode == MeasureSpec.AT_MOST) { 70 | result = Math.min(size, result); 71 | } 72 | } 73 | return result; 74 | } 75 | 76 | @Override 77 | protected void onDraw(Canvas canvas) { 78 | super.onDraw(canvas); 79 | mPaint.setAntiAlias(true); 80 | //显示圆形图片有问题 81 | switch (mPicFrom) { 82 | case DEFAUT: 83 | //最后使用默认 84 | Log.i("xxxx", "使用默认"); 85 | defaut = ImageUtils.decodeBitmapFromResource(getResources(), R.drawable.user_head_defaut, imageSize, imageSize); 86 | defaut = ImageUtils.resize(bitmap, imageSize, imageSize); 87 | canvas.drawBitmap(ImageUtils.creatCircleBitmap(defaut, imageSize), 0, 0, mPaint); 88 | break; 89 | case RESOURCE: 90 | bitmap = ImageUtils.decodeBitmapFromResource(getResources(), resourceId, imageSize, imageSize); 91 | bitmap = ImageUtils.resize(bitmap, imageSize, imageSize); 92 | canvas.drawBitmap(ImageUtils.creatCircleBitmap(bitmap, imageSize), 0, 0, mPaint); 93 | break; 94 | case BITMAP: 95 | //如果使用的是bitmap 96 | Log.i("xxxx", "使用bitmap"); 97 | bitmap = ImageUtils.resize(bitmap, imageSize, imageSize); 98 | canvas.drawBitmap(ImageUtils.creatCircleBitmap(bitmap, imageSize), 0, 0, mPaint); 99 | break; 100 | } 101 | 102 | } 103 | 104 | public void setImage(int resourceId) { 105 | this.resourceId = resourceId; 106 | // bitmap = ImageUtils.decodeBitmapFromResource(getResources(),resourceId,imageSize,imageSize); 107 | mPicFrom = RESOURCE; 108 | invalidate(); 109 | } 110 | 111 | public void setImage(Bitmap bitmap) { 112 | this.bitmap = bitmap; 113 | mPicFrom = BITMAP; 114 | invalidate(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/custome/RecoderDialog.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.custome; 2 | 3 | 4 | import android.app.Dialog; 5 | import android.content.Context; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.Window; 9 | import android.view.WindowManager; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.wentongwang.notebook.R; 14 | 15 | 16 | /** 17 | * 录音时弹出对话框 18 | * Created by Wentong WANG on 2016/7/8. 19 | */ 20 | public class RecoderDialog { 21 | 22 | private ImageView mVoice; 23 | private TextView mLable; 24 | 25 | private Context mContext; 26 | 27 | private Dialog dialog; 28 | 29 | /** 30 | * 构造方法 传入上下文 31 | */ 32 | public RecoderDialog(Context context) { 33 | this.mContext = context; 34 | } 35 | 36 | // 显示录音的对话框 37 | public void showRecordingDialog() { 38 | 39 | dialog = new Dialog(mContext, R.style.mydialog_translucent_style); 40 | LayoutInflater inflater = LayoutInflater.from(mContext); 41 | View view = inflater.inflate(R.layout.recoder_dialog_layout, null); 42 | 43 | 44 | mVoice = (ImageView) view.findViewById(R.id.tv_voice); 45 | mLable = (TextView) view.findViewById(R.id.tv_recoder_state); 46 | 47 | dialog.setCanceledOnTouchOutside(true); 48 | dialog.setContentView(view); 49 | //透明 50 | Window window = dialog.getWindow(); 51 | WindowManager.LayoutParams lp = window.getAttributes(); 52 | lp.alpha = 0.8f; 53 | window.setAttributes(lp); 54 | dialog.show(); 55 | } 56 | 57 | public void recording() { 58 | if (dialog != null && dialog.isShowing()) { //显示状态 59 | 60 | mVoice.setVisibility(View.VISIBLE); 61 | mLable.setVisibility(View.VISIBLE); 62 | 63 | mLable.setText("正在录音,手指上滑可取消"); 64 | } 65 | } 66 | 67 | // 显示想取消的对话框 68 | public void wantToCancel() { 69 | if (dialog != null && dialog.isShowing()) { //显示状态 70 | 71 | mVoice.setVisibility(View.VISIBLE); 72 | mLable.setVisibility(View.VISIBLE); 73 | 74 | 75 | mLable.setText("松开手指,取消录音"); 76 | } 77 | } 78 | 79 | // 显示时间过短的对话框 80 | public void tooShort() { 81 | if (dialog != null && dialog.isShowing()) { //显示状态 82 | mVoice.setVisibility(View.GONE); 83 | mLable.setVisibility(View.VISIBLE); 84 | 85 | mLable.setText("录音时间过短"); 86 | } 87 | } 88 | 89 | // 显示取消的对话框 90 | public void dimissDialog() { 91 | if (dialog != null && dialog.isShowing()) { //显示状态 92 | dialog.dismiss(); 93 | dialog = null; 94 | } 95 | } 96 | 97 | 98 | /** 99 | * 100 | * 更新音量 101 | * 利用getIdentifier()方法获取资源ID 102 | * 方法描述: 103 | * getIdentifier(String name, String defType, String defPackage) 104 | * 第一个参数:资源的名称 105 | * 第二个参数:资源的类型(drawable,string) 106 | * 第三个参数:包名 107 | */ 108 | public void updateVoiceLevel(int level) { 109 | if (dialog != null && dialog.isShowing()) { //显示状态 110 | mVoice.setVisibility(View.VISIBLE); 111 | mLable.setVisibility(View.VISIBLE); 112 | //设置图片的id 113 | int resId = mContext.getResources().getIdentifier("voice" + level, "drawable", mContext.getPackageName()); 114 | mVoice.setImageResource(resId); 115 | } 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/fragment/AboutUsFragment.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.webkit.WebChromeClient; 9 | import android.webkit.WebSettings; 10 | import android.webkit.WebView; 11 | import android.widget.TextView; 12 | 13 | import com.wentongwang.notebook.R; 14 | 15 | /** 16 | * 这里尝试下webview 17 | * Created by Wentong WANG on 2016/7/1. 18 | */ 19 | public class AboutUsFragment extends Fragment{ 20 | 21 | private WebView myWeb; 22 | private TextView tvTitle; 23 | @Override 24 | public void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | } 27 | 28 | @Override 29 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 30 | View root = inflater.inflate(R.layout.about_us_fragment_layout, container, false); 31 | myWeb = (WebView) root.findViewById(R.id.my_web); 32 | tvTitle = (TextView) root.findViewById(R.id.title); 33 | initWeb(); 34 | return root; 35 | } 36 | 37 | private void initWeb() { 38 | WebChromeClient wvcc = new WebChromeClient() { 39 | @Override 40 | public void onReceivedTitle(WebView view, String title) { 41 | super.onReceivedTitle(view, title); 42 | tvTitle.setText(title); 43 | } 44 | 45 | }; 46 | // 设置setWebChromeClient对象 47 | myWeb.setWebChromeClient(wvcc); 48 | 49 | myWeb.loadUrl("file:///android_asset/about_us.html"); 50 | } 51 | 52 | @Override 53 | public void onResume() { 54 | super.onResume(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/fragment/interfaces/DiariesView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.fragment.interfaces; 2 | 3 | import android.app.Activity; 4 | 5 | import com.wentongwang.notebook.model.DiaryItem; 6 | 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by Wentong WANG on 2016/6/27. 12 | */ 13 | public interface DiariesView { 14 | 15 | Activity getActivity(); 16 | 17 | /** 18 | * 显示进度条 19 | */ 20 | void showPorgressBar(); 21 | 22 | /** 23 | * 隐藏进度条 24 | */ 25 | void hidePorgressBar(); 26 | 27 | void showNoDatas(); 28 | 29 | void hideNoDatas(); 30 | 31 | List getDiariesList(); 32 | 33 | void updataList(List list); 34 | 35 | void startDiaryActivity(DiaryItem diaryItem); 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/wentongwang/notebook/view/fragment/interfaces/NotesView.java: -------------------------------------------------------------------------------- 1 | package com.wentongwang.notebook.view.fragment.interfaces; 2 | 3 | import android.app.Activity; 4 | 5 | import com.wentongwang.notebook.model.NoteItem; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Wentong WANG on 2016/6/27. 11 | */ 12 | public interface NotesView { 13 | 14 | Activity getActivity(); 15 | 16 | /** 17 | * 显示进度条 18 | */ 19 | void showPorgressBar(); 20 | 21 | /** 22 | * 隐藏进度条 23 | */ 24 | void hidePorgressBar(); 25 | 26 | void showNoDatas(); 27 | 28 | void hideNoDatas(); 29 | 30 | List getNotesList(); 31 | 32 | void updataList(List list); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/anim/popupwindow_hidden_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/anim/popupwindow_show_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/about_us_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/about_us_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/back_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/back_btn.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/back_btn_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/back_btn_dark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/circle_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/circle_background.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/confirm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/confirm_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/confirm_btn.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/delete.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/diaries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/diaries.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/diary_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/diary_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/diary_pwd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/diary_pwd.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/edit_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/edit_btn.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/email.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/female.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/left_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/left_btn.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/lock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/locked.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/male.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/nickname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/nickname.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/nolock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/nolock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/note_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/note_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/notes.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/password.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/photo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/recode_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/recode_btn.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/refresh_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/refresh_btn.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/setting_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/setting_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/time_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/time_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/to_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/to_right.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/user_head_defaut.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/user_head_defaut.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/user_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/user_name.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice4.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice5.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice6.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/voice7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/voice7.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/write_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-hdpi/write_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/white_background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chalTi/NoteBook/6bf470b2472845d29121d76a5d987711697b25e0/app/src/main/res/drawable-xhdpi/white_background.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/bottom_line.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_dark_blue_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_light_blue_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_light_red_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_orange_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_btn_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/login_divider_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/login_et_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/login_ll_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/recoder_dialog_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/about_us_fragment_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/change_info_dialog_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 13 | 18 | 23 | 24 | 25 | 29 | 33 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/create_diary_activity_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 20 | 21 | 31 | 32 |