-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Users Orders Can be accepted and rejected now.
- Loading branch information
Showing
21 changed files
with
813 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/atul/android/ecommerce/CatalogActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.atul.android.ecommerce; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Toast; | ||
|
||
import com.atul.android.ecommerce.databinding.ActivityCatalogBinding; | ||
|
||
public class CatalogActivity extends AppCompatActivity { | ||
|
||
private ActivityCatalogBinding bind; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
bind = ActivityCatalogBinding.inflate(getLayoutInflater()); | ||
setContentView(bind.getRoot()); | ||
|
||
userActivity(); | ||
} | ||
|
||
private void userActivity() { | ||
bind.editProducts.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Toast.makeText(CatalogActivity.this,"Clicked Edit Products",Toast.LENGTH_SHORT).show(); | ||
Intent intent = new Intent(CatalogActivity.this,MainActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
bind.orders.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Toast.makeText(CatalogActivity.this,"Clicked Orders",Toast.LENGTH_SHORT).show(); | ||
Intent intent = new Intent(CatalogActivity.this,OrderActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
bind.notifyUsers.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Toast.makeText(CatalogActivity.this,"Clicked Notify Users",Toast.LENGTH_SHORT).show(); | ||
Intent intent = new Intent(CatalogActivity.this,NotificationActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/atul/android/ecommerce/NotificationActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.atul.android.ecommerce; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.atul.android.ecommerce.databinding.ActivityNotificationBinding; | ||
|
||
public class NotificationActivity extends AppCompatActivity { | ||
|
||
private ActivityNotificationBinding notifyb; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
notifyb = ActivityNotificationBinding.inflate(getLayoutInflater()); | ||
setContentView(notifyb.getRoot()); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
app/src/main/java/com/atul/android/ecommerce/OrderActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.atul.android.ecommerce; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.recyclerview.widget.DividerItemDecoration; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
|
||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.Toast; | ||
|
||
import com.atul.android.ecommerce.Constants.Constants; | ||
import com.atul.android.ecommerce.adapter.OrdersAdapter; | ||
import com.atul.android.ecommerce.databinding.ActivityOrderBinding; | ||
import com.atul.android.ecommerce.fcm.FCMSender; | ||
import com.atul.android.ecommerce.fcm.MessageFormatter; | ||
import com.atul.android.ecommerce.model.Order; | ||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.OnFailureListener; | ||
import com.google.android.gms.tasks.OnSuccessListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.firestore.Query; | ||
import com.google.firebase.firestore.QueryDocumentSnapshot; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
import com.google.firebase.firestore.SetOptions; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import okhttp3.Call; | ||
import okhttp3.Callback; | ||
import okhttp3.Response; | ||
|
||
public class OrderActivity extends AppCompatActivity { | ||
|
||
private ActivityOrderBinding orderBinding; | ||
private MyApp myApp; | ||
OrdersAdapter ordersAdapter; | ||
List<Order> orderList = new ArrayList<>(); | ||
ArrayList<String> orderIDs=new ArrayList<>(); | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
orderBinding = ActivityOrderBinding.inflate(getLayoutInflater()); | ||
setContentView(orderBinding.getRoot()); | ||
|
||
myApp = (MyApp) getApplicationContext(); | ||
fetchAllOrdersFromDB(); | ||
} | ||
|
||
private void fetchAllOrdersFromDB() { | ||
myApp.db.collection(Constants.ORDERS) | ||
.orderBy(Constants.ORDER_TIME, Query.Direction.DESCENDING) | ||
.get() | ||
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { | ||
@Override | ||
public void onComplete(@NonNull Task<QuerySnapshot> task) { | ||
for (QueryDocumentSnapshot snapshot : task.getResult()) { | ||
Order order = snapshot.toObject(Order.class); | ||
orderList.add(order); | ||
orderIDs.add(snapshot.getId()); | ||
} | ||
setupAdapter(); | ||
} | ||
}); | ||
} | ||
|
||
private void setupAdapter() { | ||
ordersAdapter = new OrdersAdapter(OrderActivity.this, orderList,myApp,orderIDs); | ||
orderBinding.allOrders.setAdapter(ordersAdapter); | ||
orderBinding.allOrders.setLayoutManager(new LinearLayoutManager(OrderActivity.this)); | ||
orderBinding.allOrders.addItemDecoration( | ||
new DividerItemDecoration(this, DividerItemDecoration.VERTICAL) | ||
); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.