Skip to content

Commit

Permalink
project
Browse files Browse the repository at this point in the history
  • Loading branch information
YaminMahdi committed Jun 24, 2022
1 parent b9b5864 commit 57d4a1d
Show file tree
Hide file tree
Showing 53 changed files with 12,266 additions and 212 deletions.
29 changes: 23 additions & 6 deletions .idea/misc.xml

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

3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
Expand Down Expand Up @@ -33,6 +34,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-database:20.0.5'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
40 changes: 40 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"project_info": {
"project_number": "351530286669",
"firebase_url": "https://line2box-default-rtdb.firebaseio.com",
"project_id": "line2box",
"storage_bucket": "line2box.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:351530286669:android:a700619cf2442f12d2e604",
"android_client_info": {
"package_name": "com.diu.yk_games.line2box"
}
},
"oauth_client": [
{
"client_id": "351530286669-1d57184u3fvkl8vaim4gdh1n4g970ps7.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBr_tXEA3by1QmimDncUSay9NdrUG8uXDw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "351530286669-1d57184u3fvkl8vaim4gdh1n4g970ps7.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions app/src/main/java/com/diu/yk_games/line2box/BlankFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.diu.yk_games.line2box;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
* A simple {@link Fragment} subclass.
* Use the {@link BlankFragment#newInstance} factory method to
* create an instance of this fragment.
*
*/
public class BlankFragment extends Fragment {

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";

// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;

/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment BlankFragment.
*/
// TODO: Rename and change types and number of parameters
public static BlankFragment newInstance(String param1, String param2) {
BlankFragment fragment = new BlankFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}

public BlankFragment() {
// Required empty public constructor
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank, container, false);
}
}
20 changes: 20 additions & 0 deletions app/src/main/java/com/diu/yk_games/line2box/DataStore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.diu.yk_games.line2box;

import android.util.Log;

public class DataStore
{
public String timeData="";
public String redData="Red";
public String blueData="Blue";
public String starData="★";

public DataStore(){}
public DataStore(String redData, String blueData, String starData)
{
this.redData = redData;
this.blueData = blueData;
this.starData = starData;
}

}
122 changes: 122 additions & 0 deletions app/src/main/java/com/diu/yk_games/line2box/DisplayFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.diu.yk_games.line2box;

import android.annotation.SuppressLint;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;


public class DisplayFragment extends Fragment
{


private final String TAG="frag";
ArrayList<DataStore> dsList;
String bestScore="\n\n\nNetwork Error";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Initialize dataset, this data would usually come from a local content provider or
// remote server.
dsList = new ArrayList<>();
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("ScoreBoard");

myRef.child("Last Best Player").addValueEventListener(new ValueEventListener() {
@SuppressLint("SetTextI18n")
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
// This method is called once with the initial value and again
// whenever data at this location is updated.
bestScore = dataSnapshot.getValue(String.class);
//Log.d(TAG, "Last Value is: " + bestScore);

}
@Override
public void onCancelled(@NonNull DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});
myRef.child("allScore").addChildEventListener(new ChildEventListener()
{
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, String s)
{
DataStore ds = dataSnapshot.getValue(DataStore.class);
assert ds != null;
ds.timeData = dataSnapshot.getKey();
dsList.add(ds);
//Log.i(TAG,"key data = " + ds.timeData);

}
@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

}
@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {

}
@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

Log.w(TAG, "Failed to read value.", databaseError.toException());

}

});
}


@SuppressLint("SetTextI18n")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{

View v=inflater.inflate(R.layout.fragment_display, container, false);
TextView lbs= v.findViewById(R.id.lastBestScore);

Handler handler = new Handler();
handler.postDelayed(() ->
{
lbs.setText("Last Best Score is from: "+bestScore);
//Log.d(TAG, "Last Value is: " + bestScore);
MyListAdapter adapter=new MyListAdapter(getActivity(),dsList); //
ListView list = v.findViewById(R.id.showNotesList);
list.setAdapter(adapter);
}, 1420);

return v;
}

}
Loading

0 comments on commit 57d4a1d

Please sign in to comment.