@Background public void performVote(VoteDirection voteDirection) { if (this.currentlyVoting) { return; } this.currentlyVoting = true; VoteDirection oldDirection = this.currentVoteDirection; if (voteDirection == oldDirection) { voteDirection = VoteDirection.NO_VOTE; } // update vote on ui instantly, reverting if it fails this.setVoteDirection(voteDirection); try { this.manager.getAccountManager().vote(this.upvotable, voteDirection); } catch (ApiException ex) { Log.e("vote", ex.toString()); this.setVoteDirection(oldDirection); } this.currentlyVoting = false; }
@Background(serial = "serial") @Override public void getTimeFramesList(final ILoadCallback<List<DataTimeFrame>> pLoadCallback) { ensureConferenceLoaded(); if (mMemCacheTimeFrame != null) { this.onUiThreadCallOnSuccessCallback(pLoadCallback, mMemCacheTimeFrame); return; } this.mLocalSnappyDataSource.getTimeFramesList(new ILoadCallback<List<DataTimeFrame>>() { @Override public void onSuccess(List<DataTimeFrame> pObject) { if (pObject == null) { this.onFailure(new DataNotFoundException()); return; } mMemCacheTimeFrame = pObject; onUiThreadCallOnSuccessCallback(pLoadCallback, pObject); } @Override public void onFailure(Exception pException) { } }); }
@Background(serial = "serial") @Override public void getCodecampersList(final ILoadCallback<List<DataCodecamper>> pLoadCallback) { ensureConferenceLoaded(); if (mMemCacheDataCodecampers != null) { this.onUiThreadCallOnSuccessCallback(pLoadCallback, mMemCacheDataCodecampers); return; } this.mLocalSnappyDataSource.getCodecampersList(new ILoadCallback<List<DataCodecamper>>() { @Override public void onSuccess(List<DataCodecamper> pObject) { if (pObject == null) { this.onFailure(new DataNotFoundException()); return; } mMemCacheDataCodecampers = pObject; onUiThreadCallOnSuccessCallback(pLoadCallback, pObject); } @Override public void onFailure(Exception pException) { } }); }
@Background @Override void createChannelSMS(){ if (hcPhoneNo1 != null && !hcPhoneNo1.trim().equals("")) { log.info("create channel and send sms..."); Channel channel = createChannel(); String command = SMSCommandUtil.getH2CExchange(channel.qh, channel.channelId); SMSUtil.sendSMS(hcPhoneNo1, command, sendIntent, backIntent); }else { String msg = "Please configure the phone number of open platform first"; log.info(msg); showMsg(msg); } }
@Override @Background public void onRefresh() { adapter.setLoading(true); List<AddressHistory> addressHistories = null; try { if(isHot) { addressHistories = Api.apiService(ChainCloudHotSendService.class) .addressHistory(GlobalParams.coinCode, path.value(), null); }else { addressHistories = Api.apiService(ChainCloudColdReceiveService.class) .addressHistory(GlobalParams.coinCode, path.value(), null); } apiDataListGot(true, addressHistories); } catch (RetrofitError e) { apiDataListGot(true, null); refresher.post(new Runnable() { @Override public void run() { adapter.setLoading(false); refresher.setRefreshing(false); } }); } }
@Override @Background public void onPageAutoLoad() { if (addresses.size() == 0) { apiDataListGot(false, null); return; } List<AddressHistory> addressHistories = null; try { if(isHot) { addressHistories = Api.apiService(ChainCloudHotSendService.class) .addressHistory(GlobalParams.coinCode, path.value(), addresses.get(addresses.size() - 1).address); }else { addressHistories = Api.apiService(ChainCloudColdReceiveService.class) .addressHistory(GlobalParams.coinCode, path.value(), addresses.get(addresses.size() - 1).address); } apiDataListGot(false, addressHistories); } catch (RetrofitError e) { e.printStackTrace(); apiDataListGot(false, null); } }
@Background void loadUser() { try{ if (isHot) { user = chainCloudHotSendService.currentUser(GlobalParams.coinCode); }else { user = chainCloudColdReceiveService.currentUser(GlobalParams.coinCode); } showUser(user); }catch (RetrofitError error){ showNetException(error); return; }finally { closeRefresh(); closeProgress(); } }
@Background void getDataFromServer() { try { Tx detail = null; if (isHot) { detail = Api.apiService(ChainCloudHotSendService.class).getDetail(GlobalParams.coinCode, tx.getTxHash()); }else { detail = Api.apiService(ChainCloudColdReceiveService.class).getDetail(GlobalParams.coinCode, tx.getTxHash()); } tx = detail; showtx(); } catch (RetrofitError ex) { ex.printStackTrace(); } refresher.post(new Runnable() { @Override public void run() { refresher.setRefreshing(false); } }); }
@Background // because it involves network void doMusicScan() { try { ChannelSftp channelSftp = sftpManager.connectAndGetSftpChannel(); musicScanner.setProgressListener(new MusicScanner.ProgressListener() { @Override public void onNewDir(String path) { setStatus(path); } }); musicScanner.doMusicScan(channelSftp); setStatus("finished!"); } catch(Exception e) { setStatus(e.toString()); Log.e(TAG, Log.getStackTraceString(e)); } }
@Background void getData() { try { int userId = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); mAwardRequest.setUserId(userId); //1 出租 2 出售 (目前默认1) type if (mType.equals("rent")) { mAwardRequest.setType(1); } else { mAwardRequest.setType(2); } mAwardResponse = mMonthawardService.getMonthAward(mAwardRequest); setView(); } catch (Exception e) { throw e; } }
@Background @Override public void getData(boolean b) { showBottomOnHasMoreData(); mReq.setStart(0); mReq.setMax(25); try { if (b) { mRes = mHousereSourceService.findSellByPage(mReq); } else { mRes = mHousereSourceService.findSellByPage2(mReq); } setCatchLayoutVisible(View.GONE); } catch (final Exception e) { catchSet(e); mCurrentFlag = FLAG_GETDATA; throw e; } finally { upData(); } }
@Background @Override public void loadByConditions() { showBottomOnHasMoreData(); mReq.setStart(0); mReq.setMax(25); try { mRes = mHousereSourceService.findSellByPage(mReq); setCatchLayoutVisible(View.GONE); } catch (final Exception e) { catchSet(e); mCurrentFlag = FLAG_CONDITION; throw e; } finally { upData(); } }
@Background public void recordInfoRequest() { try { if (releaseTypeId == Constants.RECORD_INFO_RENT) { recordInfoRequest.setHistoryId(historyId); mReleaseRecordInfoResponse = mRentService.rentRecordInfo(recordInfoRequest); } else if (releaseTypeId == Constants.RECORD_INFO_SELL) { recordInfoRequest.setHistoryId(historyId); mReleaseRecordInfoResponse = mSellService.sellRecordInfo(recordInfoRequest); } recordGetInfo(); } catch (Exception e) { onRecordInfoRequestError(e.getMessage()); } }
@Background @Override public void loadMore() { mReq.setStart(mRes.getHouseList().size()); mReq.setMax(25); try { List<HouseInfo> list = mHousereSourceService.findRentByPage2(mReq).getHouseList(); mRes.getHouseList().addAll(list); if (list.size() == 0 || list.size() < 25) { showBottomOnDataEnd(); } setCatchLayoutVisible(View.GONE); } catch (final Exception e) { catchSet(e); mCurrentFlag = FLAG_LOADMORE; throw e; } finally { upData(); } }
@Background @Override public void getData(boolean b) { showBottomOnHasMoreData(); mReq.setStart(0); mReq.setMax(25); try { if (b) { mRes = mHousereSourceService.findRentByPage(mReq); } else { mRes = mHousereSourceService.findRentByPage2(mReq); } setCatchLayoutVisible(View.GONE); } catch (final Exception e) { catchSet(e); catchSet(e); mCurrentFlag = FLAG_CONDITION; mCurrentFlag = FLAG_GETDATA; } finally { upData(); } }
@Background @Override public void loadByConditions() { showBottomOnHasMoreData(); mReq.setStart(0); mReq.setMax(25); try { mRes = mHousereSourceService.findRentByPage(mReq); setCatchLayoutVisible(View.GONE); } catch (final Exception e) { mCurrentFlag = FLAG_CONDITION; catchSet(e); throw e; } finally { upData(); } }
@Trace @Background public void getForumPart(String forumName, ForumType type, AsyncHttpResponseHandler cb) { try { forumName = URLEncoder.encode(forumName, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String url; if (type == ForumType.Tag) { url = "/tag/"; } else if (type == ForumType.Room) { url = "/forum/"; } else { url = "/club/"; type = ForumType.Club; } get(url + forumName, null, cb); Log.d(TAG, "get forum part - " + forumName); }
@Background public void getAdvertData() { try { int uid = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); AdvertRequest request = new AdvertRequest(); request.setUserId(uid); request.setCityId(cityId); AdvertResponse response = mAdvertService.getAdvertList(request); if (response != null && response.getErrorCode() == 0) { mDataList = response.getList(); } notifyAdvert(); } catch (RestException e) { // TODO Auto-generated catch block showDialog(e.getMessage()); } }
/** * 请求服务器 */ @Background public void onUserTaskCount() { try { uid = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); UserTaskCountRequest countRequest = new UserTaskCountRequest(); countRequest.setUid(uid); countResponse = mTaskService.userTaskCount(countRequest); TaskCountResponseUtil.getInstance().setResponse(countResponse);// 缓存数据 // onUserTaskCountSet(); onUserTaskReleaseCountSet(); setTitle(); } catch (Exception e) { // TODO Auto-generated catch block } }
@Background void quest() { try { BindPaypalRequest req = new BindPaypalRequest(); req.setPaypalAccount(mBingDingEmail.getText().toString()); int uid = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); req.setUid(uid); mService.bindPaypal(req); sucess(); } catch (RestException e) { showToast(e.getMessage()); } }
@Background void quest() { try { BindPaypalRequest req = new BindPaypalRequest(); req.setPaypalAccount(mBingdingEmail.getText().toString()); int uid = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); req.setUid(uid); mService.bindPaypal(req); SharedPreferences sharedPreferences = getBackOpActivity().getSharedPreferences(Constants.LOGIN_TIMES, Context.MODE_PRIVATE + Context.MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.putBoolean("isSkip", true); editor.commit(); ManyiUtils.closeKeyBoard(getActivity(), mBingdingEmail); initMainActivity2(); } catch (RestException e) { showtoast(e.getMessage()); } }
@Background void quest() { try { int uid = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); ChangePaypalRequest alipayRequst = new ChangePaypalRequest(); alipayRequst.setPaypalAccount(mEmailPhone.getText().toString()); alipayRequst.setPassword(mPasswordModificationa.getText().toString()); alipayRequst.setUid(uid); mService.changePaypal(alipayRequst); sucess(); } catch (RestException e) { showToast(e.getMessage()); } }
@Background void getdata(Boolean b) { showBottomOnHasMoreData(); try { int uid = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("uid", 0); mReq.setUid(uid); mReq.setPayTime(payTime); mReq.setStart(indexPage); mReq.setMaxResult(maxResult); mReq.setMarkTime(null); if (b) { mRes = mService.awardDetail(mReq); } else { mRes = mService.awardDetail2(mReq); } if (mRes == null || mRes.getAwardList().toArray().length == 0) { noData(); } upData(); } catch (Exception e) { mDetailList.onRefreshComplete(); throw e; } }
@SuppressWarnings("unchecked") @Background void getdata() { if (bundle != null) { subEstateResponses = (List<SubEstateResponse>) bundle.getSerializable(Constants.SELECTED_ESTATE_DATA); if (subEstateResponses == null) { SubRequest subRequest = new SubRequest(); subRequest.setEstateId(estateId); SubResponse subResponse = mCommonService.subResponse(subRequest); subEstateResponses = subResponse.getSubEstateList(); } } if (subEstateResponses == null) { return; } mDialogListViewList.clear(); for (int i = 0; i < subEstateResponses.size(); i++) { Map<String, String> map = new HashMap<String, String>(); map.put("name", subEstateResponses.get(i).getSubEstateName()); mDialogListViewList.add(map); } notifyDialogListViewAdapter(); }
@Background public void reloadRemoteData() { try { String searchKey = mSearchKey.getText().toString().trim(); int cityId = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("cityId", 0); SearchRequest searchRequest = new SearchRequest(); searchRequest.setName(searchKey); searchRequest.setCityId(cityId); SearchRespose searchRespose = commonService.search(searchRequest); updateDataFromRemote(searchRespose.getEstateList()); } catch (Exception e) { e.printStackTrace(); } finally { setSearchVisibility(View.GONE); } }
@Background public void loadDate() { try { if (mSearchEdtext.getText().toString().length() != 0) { int cityId = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("cityId", 0); SearchRequest searchRequest = new SearchRequest(); searchRequest.setName(mSearchEdtext.getText().toString()); searchRequest.setCityId(cityId); SearchRespose searchRespose = commonService.search(searchRequest); mSearchList.clear(); mSearchList.addAll((ArrayList<Estate>) searchRespose.getEstateList()); refresh(); } } catch (Exception e) { e.printStackTrace(); } }
@Background public void reloadRemoteData() { String searchKey = mSearchKey.getText().toString().trim(); if (searchKey == null || searchKey.length() == 0) { updateDateFromLocal(); return; } try { int cityId = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("cityId", 0); SearchRequest searchRequest = new SearchRequest(); searchRequest.setName(searchKey); searchRequest.setCityId(cityId); SearchRespose searchRespose = mCommonService.search(searchRequest); updateDataFromRemote(searchRespose.getEstateList()); } catch (Exception e) { e.printStackTrace(); } }
@Background void getAreas() { try { AreaRequest req = new AreaRequest(); int cityId = getActivity().getSharedPreferences(Constants.LOGIN_TIMES, 0).getInt("cityId", 0); req.setAreaId(cityId); req.setNotHasAll(true); mAreasResponse = commonService.getDistrict(req); adapter(); } catch (Exception e) { throw e; } }
@Background void getdate() { AreaRequest req = new AreaRequest(); if (areaId <= 0) { areaId = Constants.ID_CITY_SHANGHAI; } req.setAreaId(areaId); req.setNotHasAll(true); res = commonService.getArea(req); res.getAreaList().addAll(data); data = res.getAreaList(); adapter(); }
@Trace @Background void prepareForumPart() { if (!isPantipPick() && !isPantipTrend()) { Log.i("loadData " + forumPagerItem.title, "prepareForumPart start"); forumPart = RESTUtils.parseForumPart(new String(tmpForumPartBytes)); if (forumType == ForumType.Room && forumPart.getRecommendTopic().get(0) == null) { Log.e("forumPath", "CANT PARSE FORUMPATH\n" + new String(tmpForumPartBytes)); } Log.d( "forumPart", "prepareForumPart recommend size : " + forumPart.getRecommendUrl() .size() + " - " + forumPart.getRecommendTopic().size() ); for (String s : forumPart.getRecommendTopic()) { Log.d("recommend", forumPagerItem.title + " " + s); } Log.i("loadData " + forumPagerItem.title, "prepareForumPart finish"); prepareRecommendCard(); } else { prepareRecommendDone = true; joinForum(); } }
@Background public void prepareRecommendCard() { Log.i("loadData " + forumPagerItem.title, "prepareRecommendCard starts"); int numPreview = forumPart.getRecommendTopic().size() > 3 ? 3 : forumPart.getRecommendTopic().size(); if (recommendTopicTitle == null) { // Do just first load recommendTopicTitle = new String[numPreview]; recommendTopicUrl = new String[numPreview]; // // Add Recommend Topic for (int i = 0; i < numPreview; i++) { Log.d("recommend", "prepareRecommendCard " + i + " : " + forumPart.getRecommendTopic().get(i)); recommendTopicTitle[i] = forumPart.getRecommendTopic().get(i); recommendTopicUrl[i] = forumPart.getRecommendUrl().get(i); } } tmpForumPartBytes = null; prepareRecommendDone = true; Log.i("loadData " + forumPagerItem.title, "prepareRecommendCard finish"); joinForum(); }
@Background protected void replyWith(T thing, String message) { try { String result = this.manager.getAccountManager().reply(thing, message); this.replyListener.onSuccess(result); } catch (Exception ex) { this.replyListener.onFailure(ex); } }
@AfterViews @Background protected void init() { this.submission = this.manager.getClient().getSubmission(this.submissionId); this.treeNode = this.adapter.fromSubmission(submission); this.setAdapter(); }
@AfterViews @Background protected void authenticateIfRequired() { this.manager.authenticateIfRequired(new AuthenticationCallback() { @Override public void onSuccessfulAuthentication() { SubredditActivity.this.fetchPosts(); } @Override public void onFailedAuthentication(Exception e) { Log.e("subreddit-error", e.toString()); } }); }
@Background protected void handleOAuthSuccess(String url) { try { OAuthData resp = this.helper.onUserChallenge(url, this.credentials); this.manager.getClient().authenticate(resp); this.handleSuccess(); } catch (OAuthException ex) { this.handleError(ex.getMessage()); } }
@Background protected void doFaceSwap(String[] pathArray) { showDialog(); final String result = JNIUtils.doFaceSwap(pathArray); if (result != null) { final File file = new File(result); if (file.exists()) { OBJUtils.createTexture(BuildMaskActivity.this, result, mCurrentImgPath); runOnUiThread(new Runnable() { @Override public void run() { ivFace.setImageBitmap(BitmapUtils.decodeSampledBitmapFromFilePath(result, 1024, 1024)); } }); } else { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(BuildMaskActivity.this, "cannot do face swap!", Toast.LENGTH_SHORT).show(); } }); } } else { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(BuildMaskActivity.this, "cannot do face swap!", Toast.LENGTH_SHORT).show(); } }); } dismissDialog(); }
@Background public void stopDiscovery() { synchronized(this) { //try //{ if (!isDiscovering || jmdns == null) return; if (multicastLock.isHeld()) { multicastLock.release(); } else { Log.i(TAG, "Multicast lock already released"); } jmdns.closeState(); jmdns.cancelState(); jmdns.unregisterAllServices(); jmdns.cancelTimer(); jmdns.cancelState(); jmdns.cancelStateTimer(); jmdns.purgeStateTimer(); jmdns.purgeTimer(); jmdns.recover(); jmdns.close(); jmdns = null; try { Thread.sleep(6000); } catch (InterruptedException e) { } isDiscovering = false; Log.w(TAG, "MDNS discovery stopped"); //} catch (IOException e) { // e.printStackTrace(); //} } }
@Background void updateCacheSize() { File[] cacheDir = getAllCacheDir(); long size = 0; for (File dir : cacheDir) { size += getFileSize(dir); } String sizeString = String.format("%.2f MB", (double) size / 1024 /1024); dispayCacheSize(sizeString); }
@Background void setImageData(int page) { // UrlList = JsoupClass.getDuowanListJson("http://tu.duowan.com/m/meinv?offset=" // + page * 30 + "&order=created&math=0.6211543285753578"); try { UrlList = JsoupClass.getDuowanListHtml("http://tu.duowan.com/m/meinv?offset=" + page * 30); ShowImageData(); } catch (IOException e) { errorHadler(); e.printStackTrace(); } }
@Background public void getInstalledAppsAsync( final Context context, final GenericCallback<List<InstalledApp>> callback ) { List<InstalledApp> items = getInstalledApps(context); callback.onResult(items); }