diff --git a/app/src/main/java/com/network/p2pauction/BReceiver.java b/app/src/main/java/com/network/p2pauction/BReceiver.java index b27c27a..0893226 100644 --- a/app/src/main/java/com/network/p2pauction/BReceiver.java +++ b/app/src/main/java/com/network/p2pauction/BReceiver.java @@ -3,9 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.net.NetworkInfo; import android.net.wifi.p2p.WifiP2pConfig; -import android.net.wifi.p2p.WifiP2pInfo; import android.net.wifi.p2p.WifiP2pManager; import android.util.Log; diff --git a/app/src/main/java/com/network/p2pauction/GroupFormation.java b/app/src/main/java/com/network/p2pauction/GroupFormation.java index 49de2a5..dafd58f 100644 --- a/app/src/main/java/com/network/p2pauction/GroupFormation.java +++ b/app/src/main/java/com/network/p2pauction/GroupFormation.java @@ -1,64 +1,47 @@ - package com.network.p2pauction; +package com.network.p2pauction; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; - -import android.Manifest; import android.content.Context; -import android.content.pm.PackageManager; import android.graphics.Color; import android.net.nsd.NsdManager; import android.net.nsd.NsdServiceInfo; import android.net.wifi.WifiManager; import android.net.wifi.p2p.WifiP2pManager; -import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceInfo; -import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; -import android.provider.ContactsContract; import android.text.format.Formatter; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CompoundButton; -import android.widget.ListAdapter; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import com.google.android.material.button.MaterialButton; import com.google.android.material.switchmaterial.SwitchMaterial; import com.google.android.material.textview.MaterialTextView; -import org.w3c.dom.Text; - import java.io.BufferedReader; -import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; -import java.net.SocketException; import java.net.UnknownHostException; -import java.nio.DoubleBuffer; -import java.security.acl.Group; -import java.text.Normalizer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; -import java.util.List; +import java.util.concurrent.TimeUnit; - public class GroupFormation extends AppCompatActivity { +public class GroupFormation extends AppCompatActivity { TextView auctionName, noOfBidders; ListView itemsList, log; MaterialButton startButton; @@ -154,6 +137,11 @@ else if(startButton.getText().equals("Next")){ playerBidHistory.clear(); activeBidders.clear(); announceResult(); + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e) { + e.printStackTrace(); + } currentItem++; if(currentItem == itemArrList.size() - 1) { startButton.setText("Finish"); diff --git a/app/src/main/java/com/network/p2pauction/GroupJoin.java b/app/src/main/java/com/network/p2pauction/GroupJoin.java index 55a23e5..4cec70e 100644 --- a/app/src/main/java/com/network/p2pauction/GroupJoin.java +++ b/app/src/main/java/com/network/p2pauction/GroupJoin.java @@ -1,9 +1,5 @@ package com.network.p2pauction; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - import android.content.Context; import android.graphics.Color; import android.net.nsd.NsdManager; @@ -12,6 +8,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.text.LoginFilter; import android.text.format.Formatter; import android.util.Log; import android.view.View; @@ -22,6 +19,10 @@ import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import com.google.android.material.button.MaterialButton; import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; @@ -31,15 +32,13 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; -import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Timer; +import java.util.concurrent.TimeUnit; public class GroupJoin extends AppCompatActivity { String AUCTION_NAME; @@ -57,6 +56,7 @@ public class GroupJoin extends AppCompatActivity { ArrayList itemArrList; String ip, myip; RelativeLayout relativeLayout; + MaterialTextView txtResult; private int currentItem = 0; @Override protected void onCreate(Bundle savedInstanceState) { @@ -73,6 +73,7 @@ protected void onCreate(Bundle savedInstanceState) { txtBidAmount = (TextInputEditText) findViewById(R.id.BidAmount); textInputLayout = (TextInputLayout) findViewById(R.id.inputLayout); txtLeaderboardPosition = (MaterialTextView) findViewById(R.id.LeaderboardPosition); + txtResult = (MaterialTextView) findViewById(R.id.result); WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); myip = Formatter.formatIpAddress(wifiManager.getConnectionInfo().getIpAddress()); Thread myThread = new Thread(new MyServer()); @@ -294,8 +295,22 @@ public void run() { @Override public void run() { if(message.contains("result")) { - currentItem++; - updateItemInfo(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + currentItem++; + txtResult.setText(""); + Log.i("module6", "gone"); + updateItemInfo(); + } + }, 5000); + + if(txtLeaderboardPosition.getText().toString().equals("Your Leaderboard Position: 1")) { + txtResult.setText("You won this bid"); + Log.i("module6", "winner"); + } else { + Log.i("module6", "not a winner"); + } } else if(message.contains("update")) { Log.i("module4", "message: " + message + "status: received"); @@ -316,6 +331,8 @@ else if(message.contains("finish")) { btnSend.setVisibility(View.GONE); txtBidAmount.setVisibility(View.GONE); textInputLayout.setVisibility(View.GONE); + if(txtLeaderboardPosition.getText().toString().equals("Your Leaderboard Position: 1")) + txtResult.setText("You won this bid"); } } }); diff --git a/app/src/main/java/com/network/p2pauction/HomeScreen.java b/app/src/main/java/com/network/p2pauction/HomeScreen.java index d688453..ab13813 100644 --- a/app/src/main/java/com/network/p2pauction/HomeScreen.java +++ b/app/src/main/java/com/network/p2pauction/HomeScreen.java @@ -1,13 +1,12 @@ package com.network.p2pauction; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.app.AppCompatDelegate; - -import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatDelegate; + import com.google.android.material.button.MaterialButton; import com.google.android.material.textview.MaterialTextView; diff --git a/app/src/main/java/com/network/p2pauction/JoinActivity.java b/app/src/main/java/com/network/p2pauction/JoinActivity.java index 7b18479..4374e0c 100644 --- a/app/src/main/java/com/network/p2pauction/JoinActivity.java +++ b/app/src/main/java/com/network/p2pauction/JoinActivity.java @@ -1,7 +1,5 @@ package com.network.p2pauction; -import androidx.appcompat.app.AppCompatActivity; - import android.content.Intent; import android.os.Bundle; import android.view.View; diff --git a/app/src/main/java/com/network/p2pauction/createActivity.java b/app/src/main/java/com/network/p2pauction/createActivity.java index 59750ad..b24a2cf 100644 --- a/app/src/main/java/com/network/p2pauction/createActivity.java +++ b/app/src/main/java/com/network/p2pauction/createActivity.java @@ -1,44 +1,33 @@ package com.network.p2pauction; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; - -import android.Manifest; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.pm.PackageManager; import android.graphics.Color; -import android.graphics.Paint; -import android.net.wifi.WpsInfo; -import android.net.wifi.p2p.WifiP2pConfig; import android.net.wifi.p2p.WifiP2pDevice; import android.net.wifi.p2p.WifiP2pDeviceList; import android.net.wifi.p2p.WifiP2pInfo; import android.net.wifi.p2p.WifiP2pManager; -import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceInfo; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import com.google.android.material.button.MaterialButton; import java.net.InetAddress; -import java.nio.channels.Channel; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class createActivity extends AppCompatActivity implements WifiP2pManager.ChannelListener { WifiP2pManager manager; @@ -59,7 +48,6 @@ protected void onCreate(Bundle savedInstanceState) { P2PHandler(); P2PInfoReceiver(); service(); - } protected void P2PHandler() { manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); diff --git a/app/src/main/res/layout/activity_group_join.xml b/app/src/main/res/layout/activity_group_join.xml index 2f47b00..a923559 100644 --- a/app/src/main/res/layout/activity_group_join.xml +++ b/app/src/main/res/layout/activity_group_join.xml @@ -100,4 +100,14 @@ android:layout_marginTop="20dp" android:text="Join" android:layout_centerHorizontal="true" /> + \ No newline at end of file