Fix retrofit magic

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-08-18 09:57:05 +02:00
parent 5948aaec0a
commit f9af8dc2a4
6 changed files with 14 additions and 16 deletions

View File

@ -15,8 +15,8 @@ android {
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 58
versionName "3.0.0beta7"
versionCode 59
versionName "3.0.0beta8"
flavorDimensions "default"
renderscriptTargetApi 19

View File

@ -80,6 +80,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.glide.GlideApp;
import com.nextcloud.talk.utils.preferences.AppPreferences;
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
import com.nextcloud.talk.webrtc.MagicAudioManager;
import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper;
@ -182,7 +183,6 @@ public class CallController extends BaseController {
@BindView(R.id.conversationRelativeLayoutView)
RelativeLayout conversationView;
@Inject
NcApi ncApi;
@Inject
EventBus eventBus;
@ -302,6 +302,8 @@ public class CallController extends BaseController {
.setRepeatMode(PulseAnimation.REVERSE);
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(conversationUser.getId(), baseUrl);
try {
cache.evictAll();
} catch (IOException e) {

View File

@ -83,6 +83,7 @@ import com.nextcloud.talk.utils.NotificationUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.glide.GlideApp;
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
import com.otaliastudios.autocomplete.Autocomplete;
import com.otaliastudios.autocomplete.AutocompleteCallback;
@ -99,7 +100,6 @@ import com.webianks.library.PopupBubble;
import org.parceler.Parcels;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
@ -117,7 +117,6 @@ import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.Cache;
import retrofit2.HttpException;
import retrofit2.Response;
@ -125,12 +124,9 @@ import retrofit2.Response;
public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener,
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener, MessageHolders.ContentChecker {
private static final String TAG = "ChatController";
@Inject
NcApi ncApi;
@Inject
UserUtils userUtils;
@Inject
Cache cache;
@BindView(R.id.messagesListView)
MessagesList messagesListView;
@BindView(R.id.messageInputView)
@ -300,16 +296,12 @@ public class ChatController extends BaseController implements MessagesListAdapte
sendHiTextView.setText(String.format(getResources().getString(R.string.nc_chat_empty), getResources()
.getString(R.string.nc_hello)));
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(conversationUser.getId(), baseUrl);
if (adapter == null) {
loadingProgressBar.setVisibility(View.VISIBLE);
try {
cache.evictAll();
} catch (IOException e) {
Log.e(TAG, "Failed to evict cache");
}
adapterWasNull = true;
MessageHolders messageHolders = new MessageHolders();

View File

@ -56,6 +56,7 @@ import com.nextcloud.talk.models.json.participants.AddParticipantOverall;
import com.nextcloud.talk.models.json.rooms.Conversation;
import com.nextcloud.talk.models.json.rooms.RoomOverall;
import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
import com.nextcloud.talk.utils.DisplayUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys;
@ -95,7 +96,6 @@ public class OperationsMenuController extends BaseController {
@BindView(R.id.web_button)
Button webButton;
@Inject
NcApi ncApi;
@Inject
@ -156,6 +156,8 @@ public class OperationsMenuController extends BaseController {
super.onViewBound(view);
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userUtils.getCurrentUser().getId
(), null);
processOperation();
}

View File

@ -69,6 +69,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
super(context);
this.context = context;
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
setupNcApi();
}
public MentionAutocompletePresenter(Context context, String roomToken) {
@ -76,6 +77,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
this.roomToken = roomToken;
this.context = context;
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
setupNcApi();
}
private void setupNcApi() {

View File

@ -66,7 +66,7 @@ public class ApplicationWideApiHolder {
if (!ncApiHashMap.containsKey(accountId)) {
UserEntity userAccount = userUtils.getUserWithId(accountId);
if (userAccount == null || !TextUtils.isEmpty(baseUrl)) {
if (userAccount == null || (userAccount.getId() == -1 && !TextUtils.isEmpty(baseUrl))) {
retrofit = retrofit.newBuilder().baseUrl(baseUrl).build();
return retrofit.create(NcApi.class);
} else {