Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Repo with Demo Version #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

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

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.

6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
Expand All @@ -17,7 +17,9 @@
</activity>
<activity android:name=".ProfileActivity">
</activity>
<activity android:name=".AddCardActivity">
<activity android:name=".AddCardActivity"
android:parentActivityName=".HomeActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".AddServiceActivity"
android:parentActivityName=".HomeActivity"
Expand Down
24 changes: 21 additions & 3 deletions app/src/main/java/com/example/android/glook/AddBusinessActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.android.glook

import android.R
import android.app.Activity
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
Expand Down Expand Up @@ -32,10 +33,14 @@ class AddBusinessActivity : AppCompatActivity() {


private var upload : Upload? = null
private var image_url: String? = null


//uri to store file
private var filePath: Uri? = null

private var downloadUrl: String? = null

//firebase objects
private var storageReference: StorageReference? = null
private var mDatabase: DatabaseReference? = null
Expand All @@ -46,7 +51,7 @@ class AddBusinessActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_business)
setContentView(com.example.android.glook.R.layout.activity_add_business)

storageReference = FirebaseStorage.getInstance().getReference();
mDatabase = FirebaseDatabase.getInstance().getReference("business_image")
Expand Down Expand Up @@ -116,8 +121,20 @@ class AddBusinessActivity : AppCompatActivity() {
Toast.makeText(applicationContext, "File Uploaded ", Toast.LENGTH_LONG).show()

//creating the upload object to store uploaded image details
// sRef.downloadUrl.addOnCompleteListener{ uri ->
// if (uri.isSuccessful){
// downloadUrl = uri.result.toString()
// }else {
// toast(uri.exception!!.message.toString())
// }
//
// image_url = uri.toString()
// toast(image_url!!)
// }
upload = Upload(shop_name_et.text.toString().trim(), taskSnapshot.uploadSessionUri.toString())

image_url = taskSnapshot.uploadSessionUri.toString()

uploadBussinessDetails()
//adding an upload to firebase database
// val uploadId = mDatabase!!.push().key
Expand All @@ -143,15 +160,16 @@ class AddBusinessActivity : AppCompatActivity() {
progressDialog.setTitle("Adding Business Information to Database")
progressDialog.show()

val shop= Shops(shopName!!, shopAddress!!, shopBvn!!, upload!!)
val shop= Shops(shopName!!, shopAddress!!, shopBvn!!, image_url!!)
var database: DatabaseReference = FirebaseDatabase.getInstance().reference
// ...
database!!.child("Vendor Stores").child(userId!!).setValue(shop).
database!!.child("vendor_stores").child(userId!!).setValue(shop).
addOnSuccessListener {

progressDialog.dismiss()
toast("Upload Complete")
startActivity(Intent(this, AddServiceActivity::class.java))
finish()
}.
addOnFailureListener{exception ->
toast(exception.message!!)
Expand Down
71 changes: 71 additions & 0 deletions app/src/main/java/com/example/android/glook/AddCardActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,83 @@
package com.example.android.glook

import android.app.ProgressDialog
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.text.TextUtils
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import kotlinx.android.synthetic.main.activity_add_card.*
import kotlinx.android.synthetic.main.activity_add_service.*
import org.jetbrains.anko.toast

class AddCardActivity : AppCompatActivity() {

private var serviceName1 : String? = null
private var serviceCost1 : String? = null
// private var serviceName2 : String? = null
// private var serviceCost2 : String? = null
private var service: Service? = null

private var mDatabase: DatabaseReference? = null
var currentFirebaseUser: FirebaseUser? = null
var userId : String? =null

private var database: DatabaseReference? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_card)


database = FirebaseDatabase.getInstance().reference


currentFirebaseUser = FirebaseAuth.getInstance().currentUser
userId = currentFirebaseUser!!.uid

submit_card_btn.setOnClickListener{checkEditTextFields()}
}

private fun checkEditTextFields() {
val progressDialog = ProgressDialog(this)
progressDialog.setTitle("Processing")
progressDialog.show()

var accountName = account_name_et.text.toString()
var accountNumber = account_number_et.text.toString()
var bankName = bank_name_et.text.toString()

if(TextUtils.isEmpty(accountName) || TextUtils.isEmpty(accountNumber) || TextUtils.isEmpty(bankName)){
progressDialog.dismiss()
account_name_et.error = "Please enter your account name"
account_number_et.error = "Please enter your account number"
bank_name_et.error = "Please enter your bank name"

}else{



val cardPoko = CardPoko(accountName, accountNumber, bankName)
database!!.child("vendor_cards").child(userId!!).setValue(cardPoko).
addOnSuccessListener {
toast("Upload Successfull")
startActivity(Intent(this, HomeActivity::class.java))
finish()
}
.addOnFailureListener{exception ->
toast(exception.message!!)

}

}





}

}
31 changes: 15 additions & 16 deletions app/src/main/java/com/example/android/glook/AddServiceActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class AddServiceActivity : AppCompatActivity() {

private var serviceName1 : String? = null
private var serviceCost1 : String? = null
private var serviceName2 : String? = null
private var serviceCost2 : String? = null
// private var serviceName2 : String? = null
// private var serviceCost2 : String? = null
private var service: Service? = null

private var mDatabase: DatabaseReference? = null
var currentFirebaseUser: FirebaseUser? = null
var userId : String? =null

private lateinit var database: DatabaseReference
private var database: DatabaseReference? = null
// ...


Expand All @@ -37,7 +37,7 @@ class AddServiceActivity : AppCompatActivity() {
database = FirebaseDatabase.getInstance().reference


currentFirebaseUser = FirebaseAuth.getInstance().getCurrentUser()
currentFirebaseUser = FirebaseAuth.getInstance().currentUser
userId = currentFirebaseUser!!.uid

submit_service_btn.setOnClickListener{checkEditTextFields()}
Expand All @@ -50,8 +50,8 @@ class AddServiceActivity : AppCompatActivity() {

serviceName1 = service_name1.text.toString()
serviceCost1 = service_cost1.text.toString()
serviceName2 = service_name2.text.toString()
serviceCost2 = service_cost2.text.toString()
// serviceName2 = service_name2.text.toString()
// serviceCost2 = service_cost2.text.toString()

if(TextUtils.isEmpty(serviceName1) || TextUtils.isEmpty(serviceCost1)){
service_name1.error = "Please enter a service name"
Expand All @@ -60,23 +60,22 @@ class AddServiceActivity : AppCompatActivity() {
}else{


if(TextUtils.isEmpty(serviceName2) || TextUtils.isEmpty(serviceCost2)){
service = Service(serviceName1!!, serviceCost1!!)
}else{
service = Service(serviceName1!!, serviceCost1!!)
}
}

database.child("services").child(userId!!).setValue(service).
service = Service(serviceName1!!, serviceCost1!!, userId!!)
database!!.child("services").child(userId!!).setValue(service).
addOnSuccessListener {
toast("Upload Successfull")
startActivity(Intent(this, HomeActivity::class.java))
finish()
}
.addOnFailureListener{exception ->
toast(exception.message!!)
.addOnFailureListener{exception ->
toast(exception.message!!)

}

}


}



Expand Down
28 changes: 15 additions & 13 deletions app/src/main/java/com/example/android/glook/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ package com.example.android.glook

import android.app.ProgressDialog
import android.content.Context
import android.support.constraint.ConstraintLayout
import android.support.design.widget.Snackbar
import android.view.View
import android.widget.ProgressBar


fun showProgressDialog(message : String, context: Context){
var rootLayout: ConstraintLayout? = null
var progressBar : ProgressBar? = null
progressBar = ProgressBar(context, null, android.R.attr.progressBarStyleLargeInverse)
var params: ConstraintLayout.LayoutParams = ConstraintLayout.LayoutParams(100,100)
rootLayout!!.addView(progressBar, params)
// progressBar!!.visibility(View.VISIBLE)

//fun showProgressDialog(message : String, context: Context){
// var rootLayout: ConstraintLayout? = null
// var progressBar : ProgressBar? = null
// progressBar = ProgressBar(context, null, android.R.attr.progressBarStyleLargeInverse)
// var params: ConstraintLayout.LayoutParams = ConstraintLayout.LayoutParams(100,100)
// rootLayout!!.addView(progressBar, params)
// // progressBar!!.visibility(View.VISIBLE)
//
//
//}

interface OnItemClickListener {
fun onItemClick(item: HomePoko)
}


fun showMessage(view: View, message: String){
Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE).setAction("Action", null).show()
}
//fun showMessage(view: View, message: String){
// Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE).setAction("Action", null).show()
//}
Loading