Skip to content

Commit

Permalink
Fixed: a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
shvmsaini committed Sep 26, 2021
1 parent 27bb664 commit d8da838
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetDropDown.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: 6 additions & 0 deletions .idea/render.experimental.xml

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

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<activity
android:name=".DeliveryPartnersActivity"
android:exported="true"
android:launchMode = "singleTop"/>
android:launchMode = "singleTask"/>
<activity
android:name=".ExportLogisticsActivity"
android:exported="true"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/agrobuy/app/BuyerNetworkActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
else{
DataSnapshot snapshot = task.getResult();
if(!snapshot.exists()){
emptyView.setText("No buyers found.");
return;
}
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
Map<String,Object> map = (Map<String, Object>) postSnapshot.getValue();
BuyerObject item = new BuyerObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}
else{
DataSnapshot snapshot = task.getResult();
if(!snapshot.exists()){
emptyView.setText("No delivery partners found.");
return;
}
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
Map<String,Object> map = (Map<String, Object>) postSnapshot.getValue();
ContentObject item = new ContentObject(
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/com/agrobuy/app/LoggedInActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
myRef.child(currUser.getUid()).child("name").get().addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data.", task.getException());
Toast.makeText(this, "Error getting data. Make sure your internet is stable.", Toast.LENGTH_SHORT).show();

}
else {
Log.d("firebase", String.valueOf(task.getResult().getValue()));
Expand All @@ -52,6 +50,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

}
});

//navigation drawer
loggedinLayout.topAppBar.setNavigationOnClickListener(v -> loggedinLayout.drawerLayout.openDrawer(Gravity.LEFT));
loggedinLayout.navigationDrawer.setNavigationItemSelectedListener(item -> {
Expand Down Expand Up @@ -99,7 +98,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
.get().addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data", task.getException());
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Error. Make sure your internet is stable.", Toast.LENGTH_SHORT).show();
}
else {
Log.d("firebase", String.valueOf(task.getResult().getValue()));
Expand Down Expand Up @@ -133,7 +132,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
.get().addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data", task.getException());
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Error getting data. Make sure your internet is stable.", Toast.LENGTH_SHORT).show();
}
else {
Log.d("firebase", String.valueOf(task.getResult().getValue()));
Expand Down
64 changes: 35 additions & 29 deletions app/src/main/java/com/agrobuy/app/TradeFinanceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,42 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Toast.makeText(this, "Wait...", Toast.LENGTH_SHORT).show();
//getting invoice id
myRef.child("invoice_id").get().addOnCompleteListener(snapshotTask -> {
invoice_id = String.valueOf(snapshotTask.getResult().getValue());
if(checkNotEmpty()){
//creating a map of all details
HashMap<String,String> details = new HashMap<>();
HashMap<String,Object> item = new HashMap<>();
// getting invoice from map
details.put("select_invoice",tradeFinance.invoiceSpinner.getSelectedItem().toString());
details.put("email",FirebaseAuth.getInstance().getCurrentUser().getEmail());
details.put("finance_type",tradeFinance.financeTypeSpinner.getSelectedItem().toString());
details.put("customer_name",tradeFinance.customerName.getText().toString());
details.put("invoice_id",invoice_id);
details.put("invoice_amount",tradeFinance.invoiceAmount.getText().toString());
details.put("phone_number",tradeFinance.phoneNumber.getText().toString());
item.put(FirebaseAuth.getInstance().getUid(),details);

//Changing invoice id
myRef.child("invoice_id").setValue(Integer.parseInt(invoice_id) + 1).addOnCompleteListener(task1 -> {
//putting everything in the database
database.getReference(getString(R.string.trade_finance_applied))
.child(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())).updateChildren(item);
Log.d(TradeFinanceActivity.class.getName(),"success, " + item);
//opening email
Intent i = ExportLogisticsActivity.makeMailIntent( new String[]{"[email protected]"},"Trade Finance",
"Please send this mail and we will get back to you ASAP!", item);
if (i.resolveActivity(getPackageManager())!=null)
startActivityForResult(Intent.createChooser(i, "Choose an email client"), 800);
else
Toast.makeText(this,"Failed! Please install a email app",Toast.LENGTH_SHORT).show();
});
if(!snapshotTask.isSuccessful()){
Toast.makeText(this, "Error getting data. Make sure your internet is stable.", Toast.LENGTH_SHORT).show();
}
else{
invoice_id = String.valueOf(snapshotTask.getResult().getValue());
if(checkNotEmpty()){
//creating a map of all details
HashMap<String,String> details = new HashMap<>();
HashMap<String,Object> item = new HashMap<>();
// getting invoice from map
details.put("select_invoice",tradeFinance.invoiceSpinner.getSelectedItem().toString());
details.put("email",FirebaseAuth.getInstance().getCurrentUser().getEmail());
details.put("finance_type",tradeFinance.financeTypeSpinner.getSelectedItem().toString());
details.put("customer_name",tradeFinance.customerName.getText().toString());
details.put("invoice_id",invoice_id);
details.put("invoice_amount",tradeFinance.invoiceAmount.getText().toString());
details.put("phone_number",tradeFinance.phoneNumber.getText().toString());
item.put(FirebaseAuth.getInstance().getUid(),details);

//Changing invoice id
myRef.child("invoice_id").setValue(Integer.parseInt(invoice_id) + 1).addOnCompleteListener(task1 -> {
//putting everything in the database
database.getReference(getString(R.string.trade_finance_applied))
.child(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())).updateChildren(item);
Log.d(TradeFinanceActivity.class.getName(),"success, " + item);
//opening email
Intent i = ExportLogisticsActivity.makeMailIntent( new String[]{"[email protected]"},"Trade Finance",
"Please send this mail and we will get back to you ASAP!", item);
if (i.resolveActivity(getPackageManager())!=null)
startActivityForResult(Intent.createChooser(i, "Choose an email client"), 800);
else
Toast.makeText(this,"Failed! Please install a email app",Toast.LENGTH_SHORT).show();
});
}
}

});
});
}
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:noHistory="true">
android:noHistory="true"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView"
Expand Down Expand Up @@ -33,17 +33,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView"
app:layout_constraintVertical_bias="0.129" />
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.01999998" />

<TextView
android:id="@+id/textView3"
android:layout_width="318dp"
android:layout_height="61dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/subtagline"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="16dp"
app:layout_constraintBottom_toTopOf="@id/next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/res/layout/buyer_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
android:layout_centerVertical="true"
android:text="Contact Person Name"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/name"
Expand Down Expand Up @@ -100,7 +100,7 @@
android:layout_centerVertical="true"
android:text="Categories"
android:textColor="@color/black"
android:textSize="16sp"
android:textSize="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
Expand Down Expand Up @@ -135,7 +135,7 @@
android:layout_centerVertical="true"
android:text="Date of Incorporation"
android:textColor="@color/black"
android:textSize="16sp"
android:textSize="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
Expand Down Expand Up @@ -170,7 +170,7 @@
android:layout_centerVertical="true"
android:text="Importer Credit Rating"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/rating"
Expand Down Expand Up @@ -200,7 +200,7 @@
android:layout_centerVertical="true"
android:text="Import History"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/history"
Expand All @@ -210,8 +210,8 @@
android:layout_gravity="end"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/textView6"
android:background="@drawable/input_background"
android:gravity="center"
android:background="@drawable/input_background"
android:hint="Import History"
android:minHeight="32dp"
android:paddingStart="8dp" />
Expand All @@ -234,7 +234,7 @@
android:gravity="center"
android:text="Contact Time preference"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/timepref"
Expand Down Expand Up @@ -268,7 +268,7 @@
android:gravity="center"
android:text="Contact Phone Number"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/phone_number"
Expand Down Expand Up @@ -302,7 +302,7 @@
android:gravity="center"
android:text="Contact Personal Number"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/personal_number"
Expand Down Expand Up @@ -336,7 +336,7 @@
android:gravity="center"
android:text="Contact Person Email ID"
android:textColor="@color/black"
android:textSize="16sp" />
android:textSize="16dp" />

<TextView
android:id="@+id/email"
Expand Down
Loading

0 comments on commit d8da838

Please sign in to comment.