Fix tracedroid, accept json as responses from api
This commit is contained in:
parent
d6fb67357c
commit
2cb2ecdb72
|
@ -39,6 +39,7 @@ import com.mikepenz.materialdrawer.model.interfaces.*
|
||||||
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
|
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
|
||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
||||||
import com.mikepenz.materialdrawer.widget.AccountHeaderView
|
import com.mikepenz.materialdrawer.widget.AccountHeaderView
|
||||||
|
import org.ligi.tracedroid.sending.sendTraceDroidStackTracesIfExist
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -68,6 +69,8 @@ class MainActivity : BaseActivity() {
|
||||||
launchActivity(LoginActivity(), firstTime = true)
|
launchActivity(LoginActivity(), firstTime = true)
|
||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
|
sendTraceDroidStackTracesIfExist("contact@pixeldroid.org", this)
|
||||||
|
|
||||||
setupDrawer()
|
setupDrawer()
|
||||||
|
|
||||||
val tabs: List<() -> Fragment> = listOf(
|
val tabs: List<() -> Fragment> = listOf(
|
||||||
|
|
|
@ -16,7 +16,6 @@ class PixelDroidApplication: Application() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|
||||||
TraceDroid.init(this)
|
TraceDroid.init(this)
|
||||||
sendTraceDroidStackTracesIfExist("contact@pixeldroid.org", this)
|
|
||||||
|
|
||||||
val sharedPreferences =
|
val sharedPreferences =
|
||||||
PreferenceManager.getDefaultSharedPreferences(this)
|
PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.h.pixeldroid.utils.api.objects
|
||||||
|
|
||||||
|
data class Error(
|
||||||
|
val error: String?
|
||||||
|
)
|
|
@ -2,7 +2,6 @@ package com.h.pixeldroid.utils.di
|
||||||
|
|
||||||
import com.h.pixeldroid.utils.api.PixelfedAPI
|
import com.h.pixeldroid.utils.api.PixelfedAPI
|
||||||
import com.h.pixeldroid.utils.db.AppDatabase
|
import com.h.pixeldroid.utils.db.AppDatabase
|
||||||
import com.h.pixeldroid.utils.db.addUser
|
|
||||||
import com.h.pixeldroid.utils.db.entities.UserDatabaseEntity
|
import com.h.pixeldroid.utils.db.entities.UserDatabaseEntity
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
|
@ -11,7 +10,6 @@ import okhttp3.*
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
import java.lang.Exception
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
|
@ -74,9 +72,18 @@ class PixelfedAPIHolder(db: AppDatabase?){
|
||||||
): PixelfedAPI {
|
): PixelfedAPI {
|
||||||
val newAPI = intermediate
|
val newAPI = intermediate
|
||||||
.baseUrl(user.instance_uri)
|
.baseUrl(user.instance_uri)
|
||||||
.client(OkHttpClient().newBuilder().authenticator(TokenAuthenticator(user, db)).build())
|
.client(
|
||||||
|
OkHttpClient().newBuilder().authenticator(TokenAuthenticator(user, db))
|
||||||
|
.addInterceptor {
|
||||||
|
it.request().newBuilder().run {
|
||||||
|
header("Accept", "application/json")
|
||||||
|
it.proceed(build())
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
.build().create(PixelfedAPI::class.java)
|
.build().create(PixelfedAPI::class.java)
|
||||||
api = newAPI
|
api = newAPI
|
||||||
return newAPI
|
return newAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue