mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 12:12:20 +00:00
Move directory refresh from a service over to a job.
// FREEBIE
This commit is contained in:
@@ -13,6 +13,7 @@ import org.whispersystems.textsecure.api.TextSecureAccountManager;
|
||||
import org.whispersystems.textsecure.api.push.ContactTokenDetails;
|
||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -20,10 +21,6 @@ import java.util.Set;
|
||||
public class DirectoryHelper {
|
||||
private static final String TAG = DirectoryHelper.class.getSimpleName();
|
||||
|
||||
public static void refreshDirectoryWithProgressDialog(final Context context) {
|
||||
refreshDirectoryWithProgressDialog(context, null);
|
||||
}
|
||||
|
||||
public static void refreshDirectoryWithProgressDialog(final Context context, final DirectoryUpdateFinishedListener listener) {
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) {
|
||||
Toast.makeText(context.getApplicationContext(),
|
||||
@@ -38,7 +35,11 @@ public class DirectoryHelper {
|
||||
{
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
DirectoryHelper.refreshDirectory(context.getApplicationContext());
|
||||
try {
|
||||
DirectoryHelper.refreshDirectory(context.getApplicationContext());
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,15 +52,19 @@ public class DirectoryHelper {
|
||||
|
||||
}
|
||||
|
||||
public static void refreshDirectory(final Context context) {
|
||||
public static void refreshDirectory(final Context context) throws IOException {
|
||||
refreshDirectory(context, TextSecureCommunicationFactory.createManager(context));
|
||||
}
|
||||
|
||||
public static void refreshDirectory(final Context context, final TextSecureAccountManager accountManager) {
|
||||
public static void refreshDirectory(final Context context, final TextSecureAccountManager accountManager)
|
||||
throws IOException
|
||||
{
|
||||
refreshDirectory(context, accountManager, TextSecurePreferences.getLocalNumber(context));
|
||||
}
|
||||
|
||||
public static void refreshDirectory(final Context context, final TextSecureAccountManager accountManager, final String localNumber) {
|
||||
public static void refreshDirectory(final Context context, final TextSecureAccountManager accountManager, final String localNumber)
|
||||
throws IOException
|
||||
{
|
||||
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
|
||||
Set<String> eligibleContactNumbers = directory.getPushEligibleContactNumbers(localNumber);
|
||||
Map<String, String> tokenMap = DirectoryUtil.getDirectoryServerTokenMap(eligibleContactNumbers);
|
||||
|
||||
Reference in New Issue
Block a user