Skip to content

Commit

Permalink
database
Browse files Browse the repository at this point in the history
  • Loading branch information
aryan2305 committed Apr 5, 2019
1 parent 8e47cf2 commit d5f30f4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.iml
.gradle
/local.properties
/gradle.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28
Expand All @@ -20,9 +21,12 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/com/example/merchandiseapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.firebase.FirebaseApp;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class MainActivity extends AppCompatActivity {
//FirebaseDatabase database = FirebaseDatabase.getInstance();




private Button btn;
public static final String Database_PATH = "Merchandise";
private TextView mTextMessage;

private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
Expand Down Expand Up @@ -36,6 +49,19 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// final DatabaseReference myRef = database.getReference();
//String recordId = myRef.push().getKey();
//myRef.child(recordId).setValue("Reebok");
btn = findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final DatabaseReference myRef = FirebaseDatabase.getInstance().getReference();

myRef.setValue("Hello, World!");
}
});

mTextMessage = (TextView) findViewById(R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="173dp"
tools:layout_editor_absoluteY="480dp" />

</android.support.constraint.ConstraintLayout>
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'

classpath 'com.google.gms:google-services:4.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down

0 comments on commit d5f30f4

Please sign in to comment.