├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── menu │ │ │ │ └── menu_chat.xml │ │ │ └── layout │ │ │ │ ├── activity_initial.xml │ │ │ │ ├── fragment_chat.xml │ │ │ │ ├── row_chat.xml │ │ │ │ ├── fragment_create_account.xml │ │ │ │ └── fragment_login.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── dekoservidoni │ │ │ │ └── firebasechat │ │ │ │ ├── ActivityCallback.java │ │ │ │ ├── utils │ │ │ │ ├── Constants.java │ │ │ │ └── Utils.java │ │ │ │ ├── models │ │ │ │ └── ChatData.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── adapters │ │ │ │ └── ChatAdapter.java │ │ │ │ └── fragments │ │ │ │ ├── CreateAccountFragment.java │ │ │ │ ├── LoginFragment.java │ │ │ │ └── ChatFragment.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── dekoservidoni │ │ │ └── firebasechat │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── dekoservidoni │ │ └── firebasechat │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro ├── google-services.json └── build.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── firebase_android_logo.gif ├── firebase_app_structure.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /firebase_android_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/firebase_android_logo.gif -------------------------------------------------------------------------------- /firebase_app_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/firebase_app_structure.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.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 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeKoServidoni/FirebaseChatAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #0D47A1 4 | #1A237E 5 | #0277BD 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FirebaseChatAndroid 2 | 3 | The complete guide showing how this sample was developed can be found at: 4 | https://medium.com/@dekoservidoni/realtime-chats-with-firebase-in-android-a2a131f94e0c 5 | 6 | ### App Structure 7 | 8 | ![Firebase Structure](firebase_app_structure.png) 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Apr 03 21:52:01 BRT 2017 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-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/dekoservidoni/firebasechat/ActivityCallback.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat; 2 | 3 | /** 4 | * Class responsible to register all the callbacks necessary 5 | * for the application 6 | */ 7 | public interface ActivityCallback { 8 | void openChat(); 9 | void openCreateAccount(); 10 | void logout(); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_initial.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/dekoservidoni/firebasechat/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat; 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 | } -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/dekoservidoni/firebasechat/utils/Constants.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat.utils; 2 | 3 | /** 4 | * Interface responsible to hold all the constants 5 | * of the application 6 | */ 7 | public interface Constants { 8 | 9 | String SHARED_PREFERENCES = "APP_PREFS"; 10 | 11 | String PREFERENCES_USER_NAME = "username"; 12 | String PREFERENCES_USER_EMAIL = "email"; 13 | String PREFERENCES_USER_ID = "id"; 14 | 15 | String DATABASE_NAME = "chat"; 16 | 17 | String LOG_TAG = "FirebaseChat"; 18 | 19 | String DEFAULT_USER = "User"; 20 | String DEFAULT_ID = "0000"; 21 | } 22 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FirebaseChat 3 | 4 | 5 | Username 6 | Enter! 7 | Please fill your username! 8 | Please fill your password! 9 | 10 | 11 | Enter message here! 12 | Failed to connect to database! 13 | Logout 14 | 15 | 16 | Password 17 | Email 18 | Create Account 19 | Failed to create account! 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/dekoservidoni/firebasechat/models/ChatData.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat.models; 2 | 3 | /** 4 | * Class responsible to hold the name and the message to the user 5 | * to send to firebase 6 | */ 7 | public class ChatData { 8 | 9 | private String mName; 10 | private String mId; 11 | private String mMessage; 12 | 13 | public ChatData() { 14 | // empty constructor 15 | } 16 | 17 | public String getName() { 18 | return mName; 19 | } 20 | 21 | public void setName(String name) { 22 | mName = name; 23 | } 24 | 25 | public String getId() { 26 | return mId; 27 | } 28 | 29 | public String getMessage() { 30 | return mMessage; 31 | } 32 | 33 | public void setMessage(String message) { 34 | mMessage = message; 35 | } 36 | 37 | public void setId(String id) { 38 | mId = id; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/dekoservidoni/firebasechat/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat; 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.dekoservidoni.firebasechat", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_chat.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | 15 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /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 /Users/avenuecode/Library/Android/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "335662141076", 4 | "firebase_url": "https://fir-chatandroid-784d5.firebaseio.com", 5 | "project_id": "fir-chatandroid-784d5", 6 | "storage_bucket": "fir-chatandroid-784d5.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:335662141076:android:36f658ca8e1f30d0", 12 | "android_client_info": { 13 | "package_name": "com.dekoservidoni.firebasechat" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "335662141076-9j1jdt53c99uene637q3rguc3b2g1d2q.apps.googleusercontent.com", 19 | "client_type": 3 20 | } 21 | ], 22 | "api_key": [ 23 | { 24 | "current_key": "AIzaSyA4Y4hE80DBjN7bBa4EWxw75Ze9R6vYMfs" 25 | } 26 | ], 27 | "services": { 28 | "analytics_service": { 29 | "status": 1 30 | }, 31 | "appinvite_service": { 32 | "status": 1, 33 | "other_platform_oauth_client": [] 34 | }, 35 | "ads_service": { 36 | "status": 2 37 | } 38 | } 39 | } 40 | ], 41 | "configuration_version": "1" 42 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.google.gms.google-services' 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.2" 7 | defaultConfig { 8 | applicationId "com.dekoservidoni.firebasechat" 9 | minSdkVersion 15 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 26 | exclude group: 'com.android.support', module: 'support-annotations' 27 | }) 28 | compile 'com.google.firebase:firebase-core:9.6.1' 29 | compile 'com.google.firebase:firebase-database:9.6.1' 30 | compile 'com.google.firebase:firebase-auth:9.6.1' 31 | compile 'com.android.support:cardview-v7:25.3.1' 32 | compile 'com.android.support:appcompat-v7:25.3.1' 33 | compile 'com.android.support:design:25.3.1' 34 | testCompile 'junit:junit:4.12' 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/dekoservidoni/firebasechat/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | import android.os.Bundle; 7 | 8 | import com.dekoservidoni.firebasechat.fragments.ChatFragment; 9 | import com.dekoservidoni.firebasechat.fragments.CreateAccountFragment; 10 | import com.dekoservidoni.firebasechat.fragments.LoginFragment; 11 | 12 | /** 13 | * A login screen that offers sign up via username. 14 | */ 15 | public class MainActivity extends AppCompatActivity implements ActivityCallback { 16 | 17 | /// Lifecycle methods 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_initial); 23 | 24 | getSupportFragmentManager() 25 | .beginTransaction() 26 | .add(R.id.container, LoginFragment.newInstance()) 27 | .commit(); 28 | } 29 | 30 | /// Callback methods 31 | 32 | @Override 33 | public void openChat() { 34 | replaceFragment(ChatFragment.newInstance()); 35 | } 36 | 37 | @Override 38 | public void openCreateAccount() { 39 | replaceFragment(CreateAccountFragment.newInstance()); 40 | } 41 | 42 | @Override 43 | public void logout() { 44 | replaceFragment(LoginFragment.newInstance()); 45 | } 46 | 47 | /// Private methods 48 | 49 | private void replaceFragment(Fragment fragment) { 50 | getSupportFragmentManager() 51 | .beginTransaction() 52 | .replace(R.id.container, fragment) 53 | .commit(); 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/dekoservidoni/firebasechat/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.view.View; 6 | import android.view.inputmethod.InputMethodManager; 7 | 8 | import java.text.DateFormat; 9 | import java.util.Date; 10 | 11 | /** 12 | * Class responsible to hold all the utility 13 | * methods of the application 14 | */ 15 | public class Utils { 16 | 17 | public static void closeKeyboard(Context context, View view) { 18 | InputMethodManager manager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); 19 | manager.hideSoftInputFromWindow(view.getWindowToken(), 0); 20 | } 21 | 22 | public static void saveLocalUser(Context context, String username, String email, String id) { 23 | SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE); 24 | sharedPreferences.edit() 25 | .putString(Constants.PREFERENCES_USER_NAME,username) 26 | .putString(Constants.PREFERENCES_USER_EMAIL,email) 27 | .putString(Constants.PREFERENCES_USER_ID,id) 28 | .apply(); 29 | 30 | } 31 | 32 | public static String getLocalUsername(Context context) { 33 | SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE); 34 | return sharedPreferences.getString(Constants.PREFERENCES_USER_NAME, Constants.DEFAULT_USER); 35 | } 36 | 37 | public static String getLocalUserId(Context context) { 38 | SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE); 39 | return sharedPreferences.getString(Constants.PREFERENCES_USER_ID, Constants.DEFAULT_ID); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/dekoservidoni/firebasechat/adapters/ChatAdapter.java: -------------------------------------------------------------------------------- 1 | package com.dekoservidoni.firebasechat.adapters; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import com.dekoservidoni.firebasechat.R; 10 | import com.dekoservidoni.firebasechat.models.ChatData; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Class responsible to show all the messages 17 | * in the chat 18 | */ 19 | public class ChatAdapter extends RecyclerView.Adapter { 20 | 21 | /** 22 | * ViewHolder to be the item of the list 23 | */ 24 | static final class ChatViewHolder extends RecyclerView.ViewHolder { 25 | 26 | TextView name; 27 | TextView message; 28 | 29 | ChatViewHolder(View view) { 30 | super(view); 31 | 32 | name = (TextView) view.findViewById(R.id.item_username); 33 | message = (TextView) view.findViewById(R.id.item_message); 34 | } 35 | } 36 | 37 | private List mContent = new ArrayList<>(); 38 | 39 | public void clearData() { 40 | mContent.clear(); 41 | } 42 | 43 | public void addData(ChatData data) { 44 | mContent.add(data); 45 | } 46 | 47 | @Override 48 | public int getItemCount() { 49 | return mContent.size(); 50 | } 51 | 52 | @Override 53 | public ChatViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 54 | View root = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_chat, parent, false); 55 | return new ChatViewHolder(root); 56 | } 57 | 58 | @Override 59 | public void onBindViewHolder(ChatViewHolder holder, int position) { 60 | ChatData data = mContent.get(position); 61 | 62 | holder.message.setText(data.getMessage()); 63 | holder.name.setText(data.getName()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/row_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 21 | 22 | 26 | 27 | 38 | 39 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_create_account.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 19 | 20 | 24 | 25 | 30 | 31 | 34 | 35 | 42 | 43 | 44 | 45 | 48 | 49 | 56 | 57 | 58 | 59 | 66 | 67 |