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
suspend fun <T : Any> executeApi(call: suspend () -> Response<T>): DataResult<T, DataError.Network> { | |
return try { | |
val response = call.invoke() | |
val body = response.body() | |
val errorBody = response.errorBody() | |
if (response.isSuccessful && body != null) { | |
DataResult.Success(body) | |
} else if (errorBody != null) { | |
val gson = Gson() | |
val errorResponse = gson.fromJson(String(errorBody.bytes()), ErrorResponse::class.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
// include package path here | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.FragmentTransaction; | |
import android.support.v7.app.AppCompatActivity; | |
import butterknife.ButterKnife; | |
public abstract class BaseActivity extends AppCompatActivity { |
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
// include package path here | |
import android.support.v4.app.FragmentManager; | |
import android.widget.Toast; | |
import br.com.intelize.onhome.presenter.R; | |
import br.com.intelize.onhome.presenter.components.CustomBottomNavigationView; | |
import br.com.intelize.onhome.presenter.view.base.BaseActivity; | |
import br.com.intelize.onhome.presenter.view.fragment.BillsFragment; | |
import br.com.intelize.onhome.presenter.view.fragment.SettingsFragment; |