本文整理汇总了Java中com.qiniu.android.utils.AsyncRun.runInMain方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncRun.runInMain方法的具体用法?Java AsyncRun.runInMain怎么用?Java AsyncRun.runInMain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.qiniu.android.utils.AsyncRun
的用法示例。
在下文中一共展示了AsyncRun.runInMain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateStatus
import com.qiniu.android.utils.AsyncRun; //导入方法依赖的package包/类
private void updateStatus(final double percentage) {
long now = System.currentTimeMillis();
long deltaTime = now - uploadLastTimePoint;
long currentOffset = (long) (percentage * uploadFileLength);
long deltaSize = currentOffset - uploadLastOffset;
if (deltaTime <= 100) {
return;
}
final String speed = Tools.formatSpeed(deltaSize, deltaTime);
// update
uploadLastTimePoint = now;
uploadLastOffset = currentOffset;
AsyncRun.runInMain(new Runnable() {
@Override
public void run() {
int progress = (int) (percentage * 100);
uploadProgressBar.setProgress(progress);
uploadPercentageTextView.setText(progress + " %");
uploadSpeedTextView.setText(speed);
}
});
}
示例2: writeLog
import com.qiniu.android.utils.AsyncRun; //导入方法依赖的package包/类
private void writeLog(final String msg) {
AsyncRun.runInMain(new Runnable() {
@Override
public void run() {
uploadLogTextView.append(msg);
uploadLogTextView.append("\r\n");
}
});
}
示例3: writeLog
import com.qiniu.android.utils.AsyncRun; //导入方法依赖的package包/类
private void writeLog(final String msg) {
AsyncRun.runInMain(new Runnable() {
@Override
public void run() {
uploadLogTextView.append(msg);
uploadLogTextView.append("\r\n");
}
});
}
示例4: writeLog
import com.qiniu.android.utils.AsyncRun; //导入方法依赖的package包/类
private void writeLog(final String msg) {
AsyncRun.runInMain(new Runnable() {
@Override
public void run() {
uploadLogTextView.append(msg);
uploadLogTextView.append("\r\n");
}
});
}
示例5: loadPlaylist
import com.qiniu.android.utils.AsyncRun; //导入方法依赖的package包/类
private void loadPlaylist() {
final OkHttpClient httpClient = new OkHttpClient();
Request req = new Request.Builder().url(QiniuLabConfig.makeUrl(
QiniuLabConfig.REMOTE_SERVICE_SERVER,
QiniuLabConfig.PUBLIC_VIDEO_PLAY_LIST_PATH)).method("GET", null).build();
Response resp = null;
try {
resp = httpClient.newCall(req).execute();
JSONObject jsonObject = new JSONObject(resp.body().string());
JSONArray playlistArray = jsonObject.getJSONArray("playlist");
List<Map<String, String>> playlistDataList = new ArrayList<Map<String, String>>();
for (int i = 0; i < playlistArray.length(); i++) {
JSONObject videoObj = playlistArray.getJSONObject(i);
String name = videoObj.getString("name");
String adsUrl = videoObj.getString("ads_url");
String videoUrl = videoObj.getString("video_url");
Map<String, String> playlistData = new HashMap<String, String>();
playlistData.put("NAME", name);
playlistData.put("ADS_URL", adsUrl);
playlistData.put("VIDEO_URL", videoUrl);
playlistDataList.add(playlistData);
}
// pack playlist
final SimpleAdapter playlistAdapter = new SimpleAdapter(
context,
playlistDataList,
R.layout.simple_video_play_list_item,
new String[]{"NAME", "ADS_URL", "VIDEO_URL"},
new int[]{
R.id.simple_video_play_list_item_name_textview,
R.id.simple_video_play_list_item_ads_url_textview,
R.id.simple_video_play_list_item_video_url_textview});
AsyncRun.runInMain(new Runnable() {
@Override
public void run() {
playlistView.setAdapter(playlistAdapter);
}
});
} catch (Exception e1) {
Toast.makeText(
context,
context.getString(R.string.qiniu_get_public_video_playlist_failed),
Toast.LENGTH_LONG).show();
} finally {
if (resp != null) {
resp.body().close();
}
}
}