Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 38 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,66 @@
# FirebaseUI Addons - Some more UI bindings for Firebase
FirebaseUI-Android-Addons is a set of non-essential addons to Firebase's open source library, [FirebaseUI](https://github.com/firebase/firebaseui-android). FirebaseUI Addons allows you to
back UI views such as Spinners to the [Firebase Realtime Database](https://firebase.google.com/docs/database/).
FirebaseUI-Android-Addons is a set of non-essential addons to Firebase's open source library for Android, [FirebaseUI-Android](https://github.com/firebase/FirebaseUI-Android).
FirebaseUI Addons allows you to back UI views such as Spinners to the [Firebase Realtime Database](https://firebase.google.com/docs/database/).

As for right now, there is no iOS equivalent. If you have any desire to create one,
please notify me so I can link to it.

## Usage
### FirebaseSpinnerAdapter
### `FirebaseSpinnerAdapter`
```java
// Create a Spinner in your XML file and reference it in your Activity code
Spinner spinner = (Spinner) findViewById(R.id.spinner);

// Create a DatabaseReference to the data you wish to populate your Spinner with
DatabaseReference colorReference = FirebaseDatabase.getInstance().getReference();
spinner.setAdapter(new FirebaseSpinnerAdapter<FavoriteColor>(this, FavoriteColor.class,
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_dropdown_item,
colorReference) {

// Override populateView() to modify the default (unselected) Spinner view displayed with
// the data from your model
@Override
protected void populateView(View view, FavoriteColor color, int position) {
((TextView) view.findViewById(android.R.id.text1)).setText(color.getName());
}
public class MyActivity extends AppCompatActivity {

// Override populateDropdownView() to modify the Spinner's dropdown view displayed with
// the data from your model
@Override
protected void populateDropdownView(View dropdownView, FavoriteColor color, int position) {
((TextView) dropdownView.findViewById(android.R.id.text1)).setText(color.getName());
public void onCreate(Bundle savedInstanceState) {
// Create a Spinner in your XML file and reference it in your Activity code
Spinner spinner = (Spinner) findViewById(R.id.spinner);

// Create a DatabaseReference to the data you wish to populate your Spinner with
DatabaseReference colorReference = FirebaseDatabase.getInstance().getReference();
spinner.setAdapter(new FirebaseSpinnerAdapter<FavoriteColor>(this, FavoriteColor.class,
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_dropdown_item,
colorReference) {

// Override populateView() to modify the default (unselected) Spinner view displayed with
// the data from your model
@Override
protected void populateView(View view, FavoriteColor color, int position) {
((TextView) view.findViewById(android.R.id.text1)).setText(color.getName());
}

// Override populateDropdownView() to modify the Spinner's dropdown view displayed with
// the data from your model
@Override
protected void populateDropdownView(View dropdownView, FavoriteColor color, int position) {
((TextView) dropdownView.findViewById(android.R.id.text1)).setText(color.getName());
}
});
}
});
}
```

## Installation
```groovy
dependencies {
compile 'com.craft.libraries:firebaseui-android-addons:0.1.0'
// ...
implementation 'com.craft.libraries:firebaseui-android-addons:1.0.0'
}
```
Note: using "compile" is deprecated in the latest version of Gradle build plugin. Use

## Dependencies
FirebaseUI Addons has the following transitive dependency on the Firebase SDK:
```
firebaseui-android-addons
|--- com.google.firebase:firebase-ui-database
|--- com.google.firebase:firebase-database
|--- com.firebaseui:firebase-ui-database:2.0.1
|--- com.google.firebase:firebase-database:11.0.1

```
This essentially means you shouldn't have to include the dependencies for
FirebaesUI and Firebase Database separately in your `build.gradle` file

## Sample App

There is a sample app in the `app/` directory that demonstrates the features of
FirebaseUI. Load the project in Android Studio and run it on your Android device
to see a demonstration.
There is a sample app in the `app/` directory that demonstrates the features of this library.
Before loading the project in Android Studio, make sure to connect it to a Firebase project
(preferably a test one) using Android Studio's tools or manually by following the directions on
the Firebase website. After that, build it and run it on your Android device.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import android.view.View;
import android.widget.Spinner;
import android.widget.TextView;

import com.craft.libraries.firebaseuiaddon.FirebaseSpinnerAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

/**
* An {@link android.app.Activity} that demostrates usage of this library
*/
public class MainActivity extends AppCompatActivity {

private DatabaseReference mDatabaseRoot;
Expand All @@ -24,7 +26,7 @@ protected void onCreate(Bundle savedInstanceState) {

setupTestData();

Spinner spinner = (Spinner) findViewById(R.id.spinner);
Spinner spinner = findViewById(R.id.spinner);
spinner.setAdapter(new FirebaseSpinnerAdapter<FavoriteColor>(this, FavoriteColor.class,
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_dropdown_item,
colorReference) {
Expand All @@ -34,7 +36,8 @@ protected void populateView(View view, FavoriteColor color, int position) {
}

@Override
protected void populateDropdownView(View dropdownView, FavoriteColor color, int position) {
protected void populateDropdownView(View dropdownView, FavoriteColor color,
int position) {
((TextView) dropdownView.findViewById(android.R.id.text1))
.setText(color.getLongName());
}
Expand All @@ -45,11 +48,11 @@ protected void populateDropdownView(View dropdownView, FavoriteColor color, int
* Used to push some dummy items into the Firebase Realtime Database
*/
private void setupTestData() {
String[] shortNames = new String[]{
String[] shortNames = new String[] {
"Red, Blue, Green, Orange"
};
String[] longNames = new String[]{"Royal Red", "Breezy Blue", "Easy Evergreen",
"Outrageous Orange"
String[] longNames = new String[] {
"Royal Red", "Breezy Blue", "Easy Evergreen", "Outrageous Orange"
};
for (int i = 0; i < shortNames.length; i++) {
mDatabaseRoot.child("favoriteColors").push()
Expand Down
14 changes: 8 additions & 6 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.library'
apply from: '../constants.gradle'

version = '1.0.0'

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
Expand All @@ -9,7 +11,7 @@ android {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionName "$version"

}
buildTypes {
Expand All @@ -21,12 +23,12 @@ android {
}

dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile "com.android.support:appcompat-v7:$support_library_version"
compile "com.android.support:recyclerview-v7:$support_library_version"
compile 'com.firebaseui:firebase-ui-database:2.0.1'
api "com.android.support:appcompat-v7:$support_library_version"
api "com.android.support:recyclerview-v7:$support_library_version"
api 'com.firebaseui:firebase-ui-database:2.1.0'
}
Loading