├── settings.gradle ├── photo ├── 1.png ├── 10.png ├── 11.png ├── 12.png ├── 13.png ├── 14.png ├── 15.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png └── 9.png ├── app ├── .gitignore ├── libs │ └── android-viewbadger.jar ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ └── popup_bg.9.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── logout.png │ │ │ │ ├── edit_info.png │ │ │ │ ├── send_fail.png │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── loading_icon.png │ │ │ │ ├── logout_white.png │ │ │ │ ├── chat_bg_left.9.png │ │ │ │ ├── chat_bg_right.9.png │ │ │ │ └── edit_info_white.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── anim │ │ │ │ ├── dialog_exit.xml │ │ │ │ ├── dialog_enter.xml │ │ │ │ └── rotate_animation.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ ├── menu_main_activity.xml │ │ │ │ └── menu_room_activity.xml │ │ │ └── layout │ │ │ │ ├── item_member.xml │ │ │ │ ├── dialog_loading.xml │ │ │ │ ├── view_my_chat.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── item_room.xml │ │ │ │ ├── item_chat_left.xml │ │ │ │ ├── item_chat_right.xml │ │ │ │ ├── activity_login.xml │ │ │ │ ├── activity_room.xml │ │ │ │ ├── activity_edit_info.xml │ │ │ │ └── activity_register.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── app │ │ │ │ └── superxlcr │ │ │ │ └── mypaintboard │ │ │ │ ├── utils │ │ │ │ ├── ProtocolListener.java │ │ │ │ ├── MyLog.java │ │ │ │ ├── DensityUtil.java │ │ │ │ ├── LoadingDialogUtils.java │ │ │ │ └── UploadFileUtil.java │ │ │ │ ├── view │ │ │ │ ├── MyApplication.java │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── CascadeLayout.java │ │ │ │ ├── EditInfoActivity.java │ │ │ │ ├── MyChatView.java │ │ │ │ ├── RegisterActivity.java │ │ │ │ ├── LoginActivity.java │ │ │ │ ├── MyPaintView.java │ │ │ │ └── MainActivity.java │ │ │ │ ├── model │ │ │ │ ├── Point.java │ │ │ │ ├── Line.java │ │ │ │ ├── ChatMessage.java │ │ │ │ ├── User.java │ │ │ │ ├── Database.java │ │ │ │ ├── Room.java │ │ │ │ └── Protocol.java │ │ │ │ └── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── ChatController.java │ │ │ │ ├── RoomController.java │ │ │ │ ├── UserController.java │ │ │ │ ├── CommunicationController.java │ │ │ │ └── DrawController.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── app │ │ │ └── superxlcr │ │ │ └── mypaintboard │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── app │ │ └── superxlcr │ │ └── mypaintboard │ │ └── ExampleInstrumentedTest.java ├── build │ └── outputs │ │ └── apk │ │ └── app-debug.apk ├── proguard-rules.pro └── build.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /photo/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/1.png -------------------------------------------------------------------------------- /photo/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/10.png -------------------------------------------------------------------------------- /photo/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/11.png -------------------------------------------------------------------------------- /photo/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/12.png -------------------------------------------------------------------------------- /photo/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/13.png -------------------------------------------------------------------------------- /photo/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/14.png -------------------------------------------------------------------------------- /photo/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/15.png -------------------------------------------------------------------------------- /photo/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/2.png -------------------------------------------------------------------------------- /photo/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/3.png -------------------------------------------------------------------------------- /photo/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/4.png -------------------------------------------------------------------------------- /photo/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/5.png -------------------------------------------------------------------------------- /photo/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/6.png -------------------------------------------------------------------------------- /photo/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/7.png -------------------------------------------------------------------------------- /photo/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/8.png -------------------------------------------------------------------------------- /photo/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/photo/9.png -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | !/build/outputs 3 | /build/outputs/* 4 | !/build/outputs/apk -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/libs/android-viewbadger.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/libs/android-viewbadger.jar -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 36dp 3 | 4 | -------------------------------------------------------------------------------- /app/build/outputs/apk/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/build/outputs/apk/app-debug.apk -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/popup_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/drawable/popup_bg.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/logout.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/edit_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/edit_info.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/send_fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/send_fail.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/loading_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/loading_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/logout_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/logout_white.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/chat_bg_left.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/chat_bg_left.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/chat_bg_right.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/chat_bg_right.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/edit_info_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superxlcr/MyPaintBoard/HEAD/app/src/main/res/mipmap-xxhdpi/edit_info_white.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/anim/dialog_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/anim/dialog_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/superxlcr/mypaintboard/utils/ProtocolListener.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard.utils; 2 | 3 | import com.app.superxlcr.mypaintboard.model.Protocol; 4 | 5 | /** 6 | * Created by superxlcr on 2017/1/6. 7 | * 信息监听器 8 | */ 9 | 10 | public interface ProtocolListener { 11 | 12 | /** 13 | * 接收消息的回调方法 14 | * @param protocol 协议信息 15 | * @return 是否处理信息完毕,false则继续传递消息 16 | */ 17 | boolean onReceive(Protocol protocol); 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/superxlcr/mypaintboard/view/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard.view; 2 | 3 | import android.app.Application; 4 | 5 | import com.app.superxlcr.mypaintboard.controller.CommunicationController; 6 | 7 | /** 8 | * Created by superxlcr on 2017/1/14. 9 | */ 10 | 11 | public class MyApplication extends Application { 12 | 13 | @Override 14 | public void onTerminate() { 15 | // 关闭应用时断开连接 16 | CommunicationController.getInstance(this).clearSocket(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/anim/rotate_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 13 | -------------------------------------------------------------------------------- /app/src/test/java/com/app/superxlcr/mypaintboard/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/superxlcr/mypaintboard/model/Point.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard.model; 2 | 3 | /** 4 | * 点 5 | * @author superxlcr 6 | * 7 | */ 8 | public class Point { 9 | 10 | private double x; 11 | private double y; 12 | 13 | public Point(double x, double y) { 14 | this.x = x; 15 | this.y = y; 16 | } 17 | 18 | public double getX() { 19 | return x; 20 | } 21 | 22 | public void setX(double x) { 23 | this.x = x; 24 | } 25 | 26 | public double getY() { 27 | return y; 28 | } 29 | 30 | public void setY(double y) { 31 | this.y = y; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /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:\adt\sdk/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/main/res/layout/item_member.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MyPaintBoard 2 | 3 | 该应用为本人毕业设计多人实时画板。 4 | 5 | ## 应用介绍 6 | 这是一个实时的多人同时绘画系统。 7 | 该系统以房间为基本单位,每个房间中有多名用户,与一名管理员。 8 | 房间用户可以一起聊天,也可以在画板上同时进行绘制,每个成员绘制的图像都会经由服务器同步到别的客户端上。 9 | 管理员可以更改画板的背景,亦可以选择清空屏幕。 10 | 11 | ## 界面截图 12 | 登录注册: 13 | ![photo1](./photo/1.png) ![photo2](./photo/2.png) ![photo3](./photo/3.png) 14 | 15 | 房间列表: 16 | ![photo4](./photo/4.png) 17 | 18 | 房间界面: 19 | ![photo5](./photo/5.png) ![photo6](./photo/6.png) ![photo7](./photo/7.png) ![photo8](./photo/8.png) 20 | 21 | 房间绘制: 22 | ![photo9](./photo/9.png) ![photo10](./photo/10.png) 23 | 24 | 上传背景: 25 | ![photo11](./photo/11.png) ![photo12](./photo/12.png) ![photo13](./photo/13.png) 26 | ![photo14](./photo/14.png) ![photo15](./photo/15.png) 27 | 28 | ## 下载地址 29 | https://github.com/superxlcr/MyPaintBoard/blob/master/app/build/outputs/apk/app-debug.apk -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Thu Jan 05 11:56:34 CST 2017 16 | systemProp.http.proxyHost=127.0.0.1 17 | org.gradle.jvmargs=-Xmx1536m 18 | systemProp.http.proxyPort=8787 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/superxlcr/mypaintboard/utils/MyLog.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard.utils; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * Created by superxlcr on 2017/2/27. 7 | * 自定义工具Log类 8 | */ 9 | 10 | public class MyLog { 11 | 12 | private static String MY_TAG = "MyPaintBoard"; 13 | 14 | public static int v(String TAG, String msg) { 15 | return Log.v(MY_TAG, TAG + " | " + msg); 16 | } 17 | 18 | public static int d(String TAG, String msg) { 19 | return Log.d(MY_TAG, TAG + " | " + msg); 20 | } 21 | 22 | public static int i(String TAG, String msg) { 23 | return Log.i(MY_TAG, TAG + " | " + msg); 24 | } 25 | 26 | public static int w(String TAG, String msg) { 27 | return Log.w(MY_TAG, TAG + " | " + msg); 28 | } 29 | 30 | public static int e(String TAG, String msg) { 31 | return Log.e(MY_TAG, TAG + " | " + msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/app/superxlcr/mypaintboard/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.app.superxlcr.mypaintboard", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/superxlcr/mypaintboard/utils/DensityUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard.utils; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by superxlcr on 2017/1/18. 7 | * 像素转换工具 8 | */ 9 | 10 | public class DensityUtil { 11 | 12 | /** 13 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) 14 | * @param context 上下文 15 | * @param dpValue dp值 16 | * @return px值 17 | */ 18 | public static int dip2px(Context context, float dpValue) { 19 | final float scale = context.getResources().getDisplayMetrics().density; 20 | return (int) (dpValue * scale + 0.5f); 21 | } 22 | 23 | /** 24 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp 25 | * @param context 上下文 26 | * @param pxValue px值 27 | * @return dp值 28 | */ 29 | public static int px2dip(Context context, float pxValue) { 30 | final float scale = context.getResources().getDisplayMetrics().density; 31 | return (int) (pxValue / scale + 0.5f); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | defaultConfig { 7 | applicationId "com.app.superxlcr.mypaintboard" 8 | minSdkVersion 17 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:23.1.1' 28 | testCompile 'junit:junit:4.12' 29 | compile files('libs/android-viewbadger.jar') 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/superxlcr/mypaintboard/view/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.app.superxlcr.mypaintboard.view; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | 8 | import java.util.LinkedList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by superxlcr on 2017/3/2. 13 | * 基础Activity提供Activity管理功能 14 | */ 15 | 16 | public class BaseActivity extends AppCompatActivity { 17 | 18 | private static List activityList = new LinkedList<>(); 19 | 20 | /** 21 | * 关闭所有已开启的activity 22 | */ 23 | public static void removeAllActivity() { 24 | for (Activity activity : activityList) { 25 | activity.finish(); 26 | } 27 | } 28 | 29 | @Override 30 | protected void onCreate(@Nullable Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | activityList.add(this); 33 | } 34 | 35 | @Override 36 | protected void onDestroy() { 37 | activityList.remove(this); 38 | super.onDestroy(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_my_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 18 | 19 | 25 | 26 |