-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added an alarm manager for background Friend activity checks and prob…
…ably fixed the challenge feature, and fixed the Friend addition and request bug incl the Notificatin service
- Loading branch information
Natanel Rudyuklakir
committed
May 2, 2023
1 parent
8569a1b
commit 771a284
Showing
13 changed files
with
359 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>app</name> | ||
<comment>Project app created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
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,13 @@ | ||
arguments= | ||
auto.sync=false | ||
build.scans.enabled=false | ||
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1)) | ||
connection.project.dir= | ||
eclipse.preferences.version=1 | ||
gradle.user.home= | ||
java.home=/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home | ||
jvm.arguments= | ||
offline.mode=false | ||
override.workspace.settings=true | ||
show.console.view=true | ||
show.executions.view=true |
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
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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/example/chessfirebase/alarmManager/AlarmHandler.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,34 @@ | ||
package com.example.chessfirebase.alarmManager; | ||
|
||
import android.app.AlarmManager; | ||
import android.app.PendingIntent; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
|
||
import com.example.chessfirebase.broadcastRecievers.CheckFriends; | ||
|
||
public class AlarmHandler { | ||
private Context context; | ||
|
||
public AlarmHandler(Context context) { | ||
this.context = context; | ||
Log.d("ALARM HANDLER","Started alarm managert"); | ||
} | ||
|
||
public void SetAlarmManager(){ | ||
Intent i = new Intent(context, CheckFriends.class); | ||
PendingIntent pi = PendingIntent.getBroadcast(context, 2, i, 0); | ||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); | ||
long startAfter = 1000 * 20;//we want it to start immidiately | ||
long repeatEvery = 1000 * 20;//every 30 seconds | ||
if(alarmManager != null) alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, startAfter, repeatEvery, pi); | ||
} | ||
|
||
public void cancelAlarmManager(){ | ||
Intent i = new Intent(context, CheckFriends.class); | ||
PendingIntent pi = PendingIntent.getBroadcast(context, 2, i, 0); | ||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); | ||
if(alarmManager != null) alarmManager.cancel(pi); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/chessfirebase/broadcastRecievers/CheckFriends.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.example.chessfirebase.broadcastRecievers; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
|
||
import com.example.chessfirebase.helpers.FriendHandler; | ||
|
||
public class CheckFriends extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
//we check the friend status including the friend requests and challanges | ||
Log.e("CHECKING FRIENDS", "START OF CHECK"); | ||
new FriendHandler().checkFriends(context); | ||
Log.d("CHECKING FRIENDS", "-------------------------------"); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ public void oppMove(int r, int c) { | |
move(r, c); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.