本文整理汇总了Java中com.koushikdutta.ion.Ion类的典型用法代码示例。如果您正苦于以下问题:Java Ion类的具体用法?Java Ion怎么用?Java Ion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ion类属于com.koushikdutta.ion包,在下文中一共展示了Ion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flagPost
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
/**
* Send a call to the api to flag given post with a given reason.
*
* @param postUuid uuid for the post
* @param reason reason for flag
*/
public void flagPost(final Context context, String postUuid, String reason) {
String uri = apiUrl + "/post/" + postUuid + "/flag";
JsonObject json = new JsonObject();
json.addProperty("reason", reason);
Ion.with(context)
.load(uri)
.setTimeout(5000)
.setJsonObjectBody(json)
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
if (e == null) {
Toast.makeText(context, R.string.flag_response, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, R.string.flag_error_response, Toast.LENGTH_SHORT).show();
}
}
});
}
示例2: bindType
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
/**
* Bind a {@link Post} to this view.
*
* @param post The post to bind.
*/
public void bindType(Post post) {
super.bindType(post);
tweetTextView.setText(post.getContentText());
timeTextView.setText(relativeTimeSpan(post.getPublishedAt()));
twitterUsernameTextView.setText(post.getAuthor());
Ion.with(imageView)
.load(post.getImageUrls().get(0))
.setCallback(new FutureCallback<ImageView>() {
@Override
public void onCompleted(Exception e, ImageView result) {
progressBar.setVisibility(View.GONE);
}
});
popupMenuImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showPopupMenu(v, getAdapterPosition());
}
});
}
示例3: onBindViewHolder
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
final PhotoItem item = list.get(position);
Ion.with(context)
.load(getPath(item.getPath()))
.intoImageView(holder.image);
holder.remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (clickListener != null) {
clickListener.onRemoveClickListener(view, position);
}
}
});
}
示例4: requestAPIGET
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
public static void requestAPIGET(Context c, String endpoint, final FutureCallback<String> callback) {
String auth = "Basic ".concat(Base64.encodeToString(username.concat(":").concat(password).getBytes(), Base64.NO_WRAP));
Ion.with(c)
.load(host.concat(endpoint))
.setHeader("Authorization", auth) // set the header
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
if (e == null && JSONUtils.isJSONObject(result)) {
try {
JSONObject o = new JSONObject(result);
if (o.getString("message").equals("Current user is not logged in")) {
callback.onCompleted(new Exception("401"), null);
return;
}
} catch (JSONException e1) {
}
}
callback.onCompleted(e, result);
}
});
}
示例5: retrieveAccessTokenfromServer
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private void retrieveAccessTokenfromServer() {
Ion.with(this)
.load(String.format("%s?identity=%s", ACCESS_TOKEN_SERVER,
UUID.randomUUID().toString()))
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String token) {
if (e == null) {
VideoActivity.this.accessToken = token;
} else {
Toast.makeText(VideoActivity.this,
R.string.error_retrieving_access_token, Toast.LENGTH_LONG)
.show();
}
}
});
}
示例6: exchangeServerAuthCodeForJWT
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private void exchangeServerAuthCodeForJWT(String firebaseUserId, String authCode, Set<Scope> grantedScopes, final SimpleCallback<String> jwtCallback) {
Ion.with(context)
.load(context.getString(R.string.APP_URL) + "/exchangeServerAuthCodeForJWT")
.setBodyParameter("serverCode", authCode)
.setBodyParameter("firebaseUserId", firebaseUserId)
.setBodyParameter("grantedScopes", android.text.TextUtils.join(",", grantedScopes))
.asJsonObject()
.setCallback(new com.koushikdutta.async.future.FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null) {
jwtCallback.onError(e);
return;
}
String jwt = result.get("serviceAccessToken").getAsString();
AuthHelper.userJwt = jwt;
jwtCallback.onComplete(jwt);
}
});
}
示例7: ImageUtil
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private ImageUtil(Context ctx) {
this.context = ctx;
threadPool = Executors.newFixedThreadPool(5);
this.preferences = PreferenceManager.getDefaultSharedPreferences(ctx);
provider = ImageServiceProvider.values()[preferences.getInt(PREFERENCE_PROVIDER, ImageServiceProvider.GLIDE.ordinal())];
Fresco.initialize(context);
picasso = Picasso.with(ctx);
glide = Glide.with(ctx);
universalImageLoader = ImageLoader.getInstance();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.diskCache(new UnlimitedDiskCache(ctx.getCacheDir())) // default
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
// .writeDebugLogs()
.build();
universalImageLoader.init(config);
ion = Ion.getDefault(context);
}
示例8: onBindViewHolder
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
@Override public void onBindViewHolder(PlayerHolder holder, int position) {
Player player = players.get(position);
holder.nickname.setText(player.getName());
Club club = clubRepository.getById(player.getClubId());
holder.points.setText(String.valueOf(player.getPoints()));
Ion.with(context)
.load(player.getPhoto())
.withBitmap()
.placeholder(R.mipmap.ic_launcher)
.error(R.mipmap.ic_launcher)
//.animateLoad(spinAnimation)
//.animateIn(fadeInAnimation)
.intoImageView(holder.photo);
if (club == null) {
return;
}
holder.club.setText(club.getName());
}
示例9: getDate
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private void getDate(String url) {
Ion.with(getActivity()).load(url).as(new TypeToken<CarNewsTotalBean>(){}).setCallback(new FutureCallback<CarNewsTotalBean>() {
@Override
public void onCompleted(Exception e, CarNewsTotalBean result) {
if(result!=null){
for (int i=1;i<result.getT1348654060988().size();i++){
CarNewsBean carNewsBean=new CarNewsBean();
carNewsBean.setTitle(result.getT1348654060988().get(i).getTitle());
carNewsBean.setImgsrc(result.getT1348654060988().get(i).getImgsrc());
carNewsBean.setUrl(result.getT1348654060988().get(i).getUrl());
carNewsBean.setFrom(result.getT1348654060988().get(i).getSource());
list1.add(carNewsBean);
}
}
adapter.notifyDataSetChanged();
}
});
}
示例10: retrieveCapabilityToken
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private void retrieveCapabilityToken(final ClientProfile newClientProfile) {
// Correlate desired properties of the Device (from ClientProfile) to properties of the Capability Token
Uri.Builder b = Uri.parse(TOKEN_SERVICE_URL).buildUpon();
Ion.with(getApplicationContext())
.load(b.toString())
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String capabilityToken) {
if (e == null) {
Log.d(TAG, capabilityToken);
// Update the current Client Profile to represent current properties
// ClientActivity.this.clientProfile = newClientProfile;
// Create a Device with the Capability Token
createDevice(capabilityToken);
} else {
Log.e(TAG, "Error retrieving token: " + e.toString());
Toast.makeText(ClientActivity.this, "Error retrieving token", Toast.LENGTH_SHORT).show();
}
}
});
}
示例11: sync
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
protected boolean sync() throws ExecutionException, InterruptedException {
LocalDate date = LocalDate.now();
String _id = getId();
final int year = LocalDate.now().getYear();
char type = _id.charAt(0);
String id = _id.substring(1);
List<Day> result = Ion.with(App.get())
.load("http://semerkandtakvimi.semerkandmobile.com/salaattimes?year=" + year + "&"
+ (type == 'c' ? "cityId=" : "districtId=") + id)
.as(new TypeToken<List<Day>>() {
})
.get();
for (Day d : result) {
date = date.withDayOfYear(d.DayOfYear);
setTimes(date, new String[]{d.Fajr, d.Tulu, d.Zuhr, d.Asr, d.Maghrib, d.Isha});
}
return result.size() > 25;
}
示例12: getHashes
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private void getHashes(){
Ion.with(getApplicationContext())
.load(filesURL + "/MD5SUMS").asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String r) {
final String result = r;
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
setHashes(result.split("\\s+"));
}catch(Exception e2){
setHashes(null);
}
}
}
);
}
});
}
示例13: getBusData
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
/**
* Get the current bus data by the bus station id
* @param busId bus (station) id
*/
public void getBusData(int busId)
{
Ion.with(this).load(String.format("http://h.fs-et.de/api.php?id=%s&limit=5",String.valueOf(busId))).asJsonObject().setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if(e!= null)
{
e.printStackTrace();
return;
}
Type collectionType = new TypeToken<BusData>() {
}.getType();
BusData userApiFrame = (BusData)new Gson().fromJson(result,collectionType);
TextView textView = (TextView)findViewById(R.id.tV_bus_comes_at);
Departure departure = userApiFrame.getDepartures().get(0);
busDepart = departure;
textView.setText(String.format("Bus (%s - %s) kommt um: %s",departure.getLine(),departure.getDirection(),departure.getTimetable()));
}
});
}
示例14: onClick
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.submit:
File file = new File(Const.getDownloadPath() + "/闪讯wifi助手 " + bean.getVersionName() + ".apk");
if (file.exists()) {
installApk(file);
return;
}
MToast.show(context, "正在下载");
submit.setClickable(false);
submit.setText("正在下载");
progressBar.setVisibility(View.VISIBLE);
Ion.with(context).load(bean.getDownloadURL()).progressBar(progressBar).write(file).setCallback(new FutureCallback<File>() {
@Override
public void onCompleted(Exception e, File result) {
submit.setClickable(true);
submit.setText("安装");
installApk(result);
}
});
break;
}
}
示例15: checkNetwork
import com.koushikdutta.ion.Ion; //导入依赖的package包/类
private void checkNetwork(final Context context, final FetchCallback callback) {
Ion.with(context).load(Constant.API_URL + "/heart/GetIp").setTimeout(10000).asJsonObject().setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e == null) {
Constant.DEVICES_IP = result.get("ip").getAsString();
callback.get("dial_success");
checkNeedSentHeart(context);
} else {
callback.error();
}
}
});
}