Browse Source

Improve CallNotificationController ncapi usage

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 years ago
parent
commit
d5476f83ec

+ 3 - 11
app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java

@@ -76,6 +76,7 @@ import com.nextcloud.talk.utils.MagicFlipView;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.glide.GlideApp;
 import com.nextcloud.talk.utils.glide.GlideApp;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
+import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
 import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder;
 import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder;
 
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.EventBus;
@@ -96,15 +97,13 @@ import io.reactivex.Observer;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.disposables.Disposable;
 import io.reactivex.disposables.Disposable;
 import io.reactivex.schedulers.Schedulers;
 import io.reactivex.schedulers.Schedulers;
-import okhttp3.Cache;
 
 
 @AutoInjector(NextcloudTalkApplication.class)
 @AutoInjector(NextcloudTalkApplication.class)
 public class CallNotificationController extends BaseController {
 public class CallNotificationController extends BaseController {
 
 
     private static final String TAG = "CallNotificationController";
     private static final String TAG = "CallNotificationController";
 
 
-    @Inject
-    NcApi ncApi;
+    private NcApi ncApi;
 
 
     @Inject
     @Inject
     AppPreferences appPreferences;
     AppPreferences appPreferences;
@@ -130,9 +129,6 @@ public class CallNotificationController extends BaseController {
     @BindView(R.id.incomingTextRelativeLayout)
     @BindView(R.id.incomingTextRelativeLayout)
     RelativeLayout incomingTextRelativeLayout;
     RelativeLayout incomingTextRelativeLayout;
 
 
-    @Inject
-    Cache cache;
-
     private List<Disposable> disposablesList = new ArrayList<>();
     private List<Disposable> disposablesList = new ArrayList<>();
     private Bundle originalBundle;
     private Bundle originalBundle;
     private String roomId;
     private String roomId;
@@ -302,11 +298,7 @@ public class CallNotificationController extends BaseController {
         if (handler == null) {
         if (handler == null) {
             handler = new Handler();
             handler = new Handler();
 
 
-            try {
-                cache.evictAll();
-            } catch (IOException e) {
-                Log.e(TAG, "Failed to evict cache");
-            }
+            ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userBeingCalled.getId(), null);
         }
         }
 
 
         if (currentConversation == null) {
         if (currentConversation == null) {