Skip to content
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
1 change: 1 addition & 0 deletions .idea/.name

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

17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

63 changes: 41 additions & 22 deletions .idea/misc.xml

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

7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.basgeekball:awesome-validation:4.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class AdminAddNewProductActivity extends AppCompatActivity {
private String CategoryName, Description, Price, Pname, saveCurrentDate, saveCurrentTime;
private Button AddNewProductButton;
private Button Back_btn;
private ImageView InputProductImage;
private EditText InputProductName, InputProductDescription, InputProductPrice;
private static final int GalleryPick = 1;
Expand All @@ -44,8 +45,7 @@ public class AdminAddNewProductActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState)
{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_add_new_product);

Expand All @@ -56,6 +56,7 @@ protected void onCreate(Bundle savedInstanceState)


AddNewProductButton = (Button) findViewById(R.id.add_new_product);
Back_btn = (Button) findViewById(R.id.admin_new_itempage_back);
InputProductImage = (ImageView) findViewById(R.id.select_product_image);
InputProductName = (EditText) findViewById(R.id.product_name);
InputProductDescription = (EditText) findViewById(R.id.product_description);
Expand All @@ -65,32 +66,40 @@ protected void onCreate(Bundle savedInstanceState)

InputProductImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
public void onClick(View view) {

OpenGallery();
}
});


AddNewProductButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
public void onClick(View view) {

ValidateProductData();
}
});
}

Back_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent btnIntent = new Intent(AdminAddNewProductActivity.this,AdminCategoryActivity.class);
startActivity(btnIntent);
}
});
}

//Sub Function 01
//Pick a image from the device gallery
private void OpenGallery(){
Intent galleryIntent = new Intent();
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent, GalleryPick);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode==GalleryPick && resultCode==RESULT_OK && data!=null)
Expand All @@ -99,6 +108,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data)
InputProductImage.setImageURI(ImageUri);
}
}

//Sub Function 02
//Validate input fields fullfill with correct data or not
private void ValidateProductData() {
Description = InputProductDescription.getText().toString();
Price = InputProductPrice.getText().toString();
Expand All @@ -125,8 +137,10 @@ else if (TextUtils.isEmpty(Pname))
}

}
private void StoreProductInformation()
{

//Sub Function 03
//Set data for firebase storage
private void StoreProductInformation() {
loadingBar.setTitle("Add New Product");
loadingBar.setMessage("Dear Admin, please wait while we are adding the new product.");
loadingBar.setCanceledOnTouchOutside(false);
Expand Down Expand Up @@ -187,8 +201,10 @@ public void onComplete(@NonNull Task<Uri> task) {
});

}
private void SaveProductInfoToDatabase()
{

//Sub Function 04
//Input data save to the DB
private void SaveProductInfoToDatabase() {
HashMap<String, Object> productMap = new HashMap<>();
productMap.put("pid", productRandomKey);
productMap.put("date", saveCurrentDate);
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/dhruva/shopping/DAOFeed.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dhruva.shopping;

import com.dhruva.shopping.Model.Feed;
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
Expand All @@ -11,14 +12,13 @@ public class DAOFeed
private DatabaseReference databaseReference;
public DAOFeed()
{
FirebaseDatabase db = FirebaseDatabase.getInstance("https://foodie-app-fdc64-default-rtdb.firebaseio.com/");
FirebaseDatabase db = FirebaseDatabase.getInstance();
databaseReference = db.getReference(Feed.class.getSimpleName());
}

public Task<Void> add(Feed feed)

{

return databaseReference.push().setValue(feed);
}

Expand All @@ -29,7 +29,6 @@ public Task<Void> update(String key, HashMap<String, Object> hashMap)

public Task<Void> remove(String key)
{

return databaseReference.child(key).removeValue();
}

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/com/dhruva/shopping/DAOFeed2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.dhruva.shopping;

import com.dhruva.shopping.Model.Feed2;
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class DAOFeed2 {
private DatabaseReference databaseReference;
public DAOFeed2()
{
FirebaseDatabase db = FirebaseDatabase.getInstance();
databaseReference = db.getReference(Feed2.class.getSimpleName());
}

public Task<Void> add(Feed2 feed2)
{
return databaseReference.push().setValue(feed2);
}
}
Loading