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
package net.colaborativa.exampleapp.api.volley; | |
import java.io.UnsupportedEncodingException; | |
import java.util.Map; | |
import android.util.Log; | |
import com.android.volley.AuthFailureError; | |
import com.android.volley.NetworkResponse; | |
import com.android.volley.ParseError; |
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
package net.colaborativa.exampleapp.api; | |
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.util.Collections; | |
import java.util.HashMap; | |
import java.util.Map; |
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
package net.colaborativa.exampleapp.api.volley; | |
import java.io.UnsupportedEncodingException; | |
import com.android.volley.Cache; | |
import com.android.volley.DefaultRetryPolicy; | |
import com.android.volley.NetworkResponse; | |
import com.android.volley.ParseError; | |
import com.android.volley.Request; | |
import com.android.volley.Response; |
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
String baseUrl = | |
"http://www.webservicex.net/currencyconvertor.asmx/ConversionRate"; | |
// using the cached request | |
Request<String> request = new CachedStringGETRequest( | |
baseUrl + "?fromCurrencyCode=USD&toCurrencyCode=EUR", | |
new ErrorListener() { | |
@Override | |
public void onErrorResponse(VolleyError error) { | |
Log.w("exampleapp", "Exchange rate USD " + | |
"to EUR failed to update. " + error ); |
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
new Listener<String>() { | |
@Override | |
public void onResponse(String response) { | |
MyItem item = new MyItem(response); | |
display(item); | |
} |
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
package net.colaborativa.exampleapp; | |
import android.content.Context; | |
import com.android.volley.DefaultRetryPolicy; | |
import com.android.volley.Request; | |
import com.android.volley.RequestQueue; | |
import com.android.volley.Response.ErrorListener; | |
import com.android.volley.Response.Listener; | |
import com.android.volley.toolbox.Volley; |
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
// ... | |
/** | |
* Handles onClick event on the Submit button. Sends username/password to | |
* the server for authentication. | |
* | |
* @param view The Submit button for which this method is invoked | |
*/ | |
public void handleLogin(View view) { | |
if(((EditText) findViewById(R.id.username)).getText() == null || |
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
package net.colaborativa.exampleapp; | |
import android.accounts.Account; | |
import android.accounts.AccountManager; | |
import android.text.TextUtils; | |
import android.util.Log; | |
// This is the login activity of your app, only used | |
// here to retrieve the value of ACCOUNT_TYPE | |
import net.colaborativa.exampleapp.account.AuthenticatorActivity; |
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
package net.colaborativa.exampleapp; | |
// check your imports, this list may not be complete | |
import android.accounts.Account; | |
import android.accounts.AccountManager; | |
import android.accounts.AccountManagerCallback; | |
import android.accounts.AccountManagerFuture; | |
import android.accounts.OnAccountsUpdateListener; | |
import android.content.Intent; | |
import android.text.TextUtils; |
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
public Request<?> postImage( | |
String token, | |
long l, | |
File imageFile, | |
Listener<String> listener, | |
ErrorListener errorListener) { | |
String url = "http://yoururl.com/post-image"; | |
PhotoMultipartRequest<String> req = new PhotoMultipartRequest<String>( |
OlderNewer