I hereby claim:
- I am daniloleemes on github.
- I am daniloleemes (https://keybase.io/daniloleemes) on keybase.
- I have a public key whose fingerprint is 035D 6B79 2812 192E A600 BCB6 F612 2279 1ED6 DD7E
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
```java | |
package br.com.firstsoft.escolasbrasil.activitiy; | |
import android.content.Intent; | |
import android.support.annotation.NonNull; | |
import android.support.v4.widget.DrawerLayout; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; |
public class BaseActivity extends AppCompatActivity { | |
public void setupViews(Toolbar toolbar, String title) { | |
setTitle(title); | |
setSupportActionBar(toolbar); | |
try { | |
getSupportActionBar().setElevation(0); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
getSupportActionBar().setHomeButtonEnabled(true); | |
getSupportActionBar().setDisplayShowTitleEnabled(false); |
dependencies { | |
... | |
compile 'com.google.code.gson:gson:2.8.1' | |
compile 'com.squareup.retrofit2:retrofit:2.3.0' | |
compile 'com.squareup.retrofit2:converter-gson:2.3.0' | |
... | |
} |
public class AppBaseService { | |
private static final AppBaseService ourInstance = new AppBaseService(); | |
private static String BASE_URL = "https://en.wikipedia.org/"; | |
private Retrofit retrofit; | |
private final static OkHttpClient okHttpClient = new OkHttpClient.Builder() | |
.readTimeout(2, TimeUnit.MINUTES) | |
.connectTimeout(2, TimeUnit.MINUTES) |
public interface WikipediaService { | |
@GET("w/api.php?action=query&utf8=true&list=search&format=json") | |
Call<ResponseBody> search(@QueryMap(encoded=false) Map<String, String> options); | |
} |
public class MainActivity extends AppCompatActivity { | |
private WikipediaService wikipediaService; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
wikipediaService = BaseService.getInstance().getWikiService(); |
exports.facebook = async (access_token) => { | |
const fields = 'id, name, email, picture'; | |
const url = 'https://graph.facebook.com/me'; | |
const params = { access_token, fields }; | |
const response = await axios.get(url, { params }); | |
const { id, name, email, picture } = response.data; | |
return { | |
service: 'facebook', | |
picture: picture.data.url, | |
id, |
fun <T> callback(success: (Response<T>) -> Unit, failure: (t: Throwable) -> Unit): Callback<T>? { | |
return object : Callback<T> { | |
override fun onResponse(call: Call<T>, response: retrofit2.Response<T>) = success(response) | |
override fun onFailure(call: Call<T>, t: Throwable) = failure(t) | |
} | |
} | |
fun parseResponse(listener: (AppResponse?, Throwable?) -> Unit): Callback<AppResponse>? { | |
return callback( | |
{ response -> if (response.body() != null) listener(response.body(), null) else listener(null, Throwable(response.errorBody().toString())) }, |
doAsync { | |
val imagem = Glide.with(this@BookActivity).downloadOnly().load(book.LargeImage).submit().get() | |
if (imagem != null) { | |
val uri = getUriForFile(this@BookActivity, this@BookActivity.getPackageName() + ".util.ImageFileProvider", imagem) | |
val intent = Intent(Intent.ACTION_SEND) | |
intent.type = "image/jpeg" | |
intent.putExtra(Intent.EXTRA_SUBJECT, "Compartilhar") | |
intent.putExtra(Intent.EXTRA_TEXT, "${it.ItemAttributes.Title} - ${it.ItemAttributes.Author} por ${it.ItemAttributes.ListPrice[0].price} em ${it.ItemAttributes.ListPrice[0].store}") | |
intent.putExtra(Intent.EXTRA_STREAM, uri) | |
startActivity(Intent.createChooser(intent, "Compartilhar")) |