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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.code.yashladha.android_user.Login;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -46,6 +45,7 @@ public class Login extends Fragment {
private Button login;
private ProgressBar progressBar;
private LinearLayout mainLayout;
private FirebaseUser user;

public Login() {
// Required empty public constructor
Expand All @@ -58,7 +58,7 @@ public static Login newInstance() {
@Override
public void onStart() {
super.onStart();
FirebaseUser user = mAuth.getCurrentUser();
user = mAuth.getCurrentUser();
if (user != null) {
Log.i(TITLE, "User already present");
}
Expand Down Expand Up @@ -180,9 +180,9 @@ private boolean validatePassword() {
PasswordLayout.setError("Password is not valid");
requestFocus(LoginPassword);
return false;
} else {
} else
PasswordLayout.setErrorEnabled(false);
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.code.yashladha.android_user.Models;

/**
* Created by User on 10/25/2017.
*/

public class Product {
private int pid;
private String p_name;
private int price;
private String class1;
private int availability;
private int ratings;
private int discount;
private boolean onSale;
private String details;
private int image;

public Product() {
}

public int getPid() {
return pid;
}

public String getP_name() {
return p_name;
}

public int getPrice() {
return price;
}

public String getClass1() {
return class1;
}

public int getAvailability() {
return availability;
}

public int getRatings() {
return ratings;
}

public int getDiscount() {
return discount;
}

public boolean isOnSale() {
return onSale;
}

public String getDetails() {
return details;
}

public int getImage() {
return image;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.code.yashladha.android_user.Models;

/**
* Created by User on 10/24/2017.
*/

public class ProductSold {

private int item_id;
private int order_id;
private int pid;
private int image_id;
private String date;
private int price;
private String p_name;

public ProductSold(int item_id, int order_id, int pid, int image_id, String date, int price, String p_name) {
this.item_id = item_id;
this.order_id = order_id;
this.pid = pid;
this.image_id = image_id;
this.date = date;
this.price = price;
this.p_name = p_name;
}

public int getItem_id() {
return item_id;
}

public int getOrder_id() {
return order_id;
}

public int getPid() {
return pid;
}

public int getImage_id() {
return image_id;
}

public String getDate() {
return date;
}

public int getPrice() {
return price;
}

public String getP_name() {
return p_name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.code.yashladha.android_user.Portal.Adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.code.yashladha.android_user.Models.ProductSold;
import com.code.yashladha.android_user.R;

import java.util.ArrayList;

/**
* Created by User on 10/24/2017.
*/

public class LogsAdapter extends ArrayAdapter<ProductSold> {

public LogsAdapter(Context context, ArrayList<ProductSold> soldItems, int resource) {
super(context, 0, soldItems);
}

public View getView(int position, View convertView, ViewGroup parent) {

View pro_list_view = convertView;

if (pro_list_view == null) {
pro_list_view = LayoutInflater.from(getContext()).inflate(
R.layout.sold_item, parent, false);
}
ProductSold currentPro = getItem(position);

TextView nameTextView = (TextView) pro_list_view.findViewById(R.id.pname);
nameTextView.setText(currentPro.getP_name());

TextView pDateTextView = (TextView) pro_list_view.findViewById(R.id.purchase_date);
pDateTextView.setText(currentPro.getDate());

TextView priceTextView = (TextView) pro_list_view.findViewById(R.id.price);
priceTextView.setText(currentPro.getPrice());

TextView dDateTextView = (TextView) pro_list_view.findViewById(R.id.deliver_date);

ImageView iconView = (ImageView) pro_list_view.findViewById(R.id.image);

iconView.setVisibility(View.VISIBLE);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.code.yashladha.android_user.R
import com.code.yashladha.android_user.Login.Login;
import com.code.yashladha.android_user.Models.Product;
import com.code.yashladha.android_user.Models.Item;


/**
* Created by yashladha on 17/10/17.
Expand All @@ -21,4 +25,60 @@ class LogsFragment: Fragment() {
val view = inflater!!.inflate(R.layout.fragment_logs, container, false)
return view
}

val user_id;
user_id = Login.user.getUid();

val list: List<Product> = ArrayList<Product>()

val itemRef: CollectionReference = db.collection("Item")

// Create a query against the collection.

val query: Query = itemRef.whereEqualTo("uid","user_id")

val task: Task<QuerySnapshot> = query.get()

if(task.isSuccessful())
{
int n = task.getResult().size()
val list: List<DocumentSnapshot> = task.getResult().getDocuments()

for(i in n)
{
val data: Map<item_id, Item> = list[i].getData()

val item: Item = data.getValue()
val item_id = item.item_id
val product_id = item.pid
val date = item.order_date
val order_id = item.order_id


val productRef: CollectionReference = db.collection("Product")

// Create a query against the collection.

val query1: Query = productRef.whereEqualTo("pid","product_id")

val task1: Task<QuerySnapshot> = query1.get()

val list1: List<DocumentSnapshot> = task1.getRsult().getDocuments()

val data1: Map<pid, Product> = list1[0].getData()

val pro: Product = data1.getValue()
val pname: String = pro.p_name
val price: Int = pro.price
val image_id: Int = pro.image_id

val soldItem: ProductSold = ProductSold(item_id, order_id, product_id, image_id, date,price, p_name)

}
}

else {
Toast.makeText(getActivity(), "No products purchased till now", Toast.LENGTH_SHORT).show();
}

}
19 changes: 9 additions & 10 deletions app/src/main/res/layout/fragment_logs.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Logs Fragment" />
</LinearLayout>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/list"
>
</ListView>
70 changes: 70 additions & 0 deletions app/src/main/res/layout/sold_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="88dp"
android:padding = "10dp">


<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/image" />

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="100dp"
android:paddingLeft="16dp"
android:id="@+id/text_container"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/image"
>

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
android:id="@+id/pname"
android:textStyle="bold"
android:textColor="@android:color/white" />

<TextView
android:layout_width="match_parent"
android:id="@+id/price"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:textStyle="bold"
android:textColor="@android:color/white" />

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="top"
android:textStyle="bold"
android:id="@+id/purchase_date" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="top"
android:textStyle="bold"
android:id = "@+id/deliver_date"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="top"
android:textStyle="bold"
/>
</LinearLayout>

</RelativeLayout>
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}