org.androidannotations.annotations.Background Java Examples

The following examples show how to use org.androidannotations.annotations.Background. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VmDetailPresenter.java    From moVirt with Apache License 2.0 6 votes vote down vote up
@Override
@Background
public void openConsole(final ConsoleProtocol protocol) {
    Console console = consoles.blockingFirst().get(protocol);
    if (console != null) {
        try {
            environmentStore.getEnvironment(account).getVvClient()
                    .getConsoleConnectionDetails(vmId, console.getId(), new ProgressBarResponse<ConsoleConnectionDetails>(this) {
                        @Override
                        public void onResponse(ConsoleConnectionDetails details) throws RemoteException {
                            connectToConsole(details);
                        }
                    });
        } catch (RestCallException e) {
            commonMessageHelper.showToast(resources.getNoConsoleFileError(e.getCallResult().name()));
        } catch (AccountDeletedException ignore) {
        }
    }
}
 
Example #2
Source File: FlickrWebAuthActivity.java    From flickr-uploader with GNU General Public License v2.0 6 votes vote down vote up
@Background
void doDataCallback() {
    Utils.clearProperty(STR.lastBrowserOpenForAuth);
    setLoading("Almost done…");
    try {
        AppInstall appInstall = RPC.getRpcService().ensureInstall(Utils.createAndroidDevice());
        if (ToolString.isBlank(appInstall.getFlickrToken())) {
            setError(new Exception("app not in sync with server"));
        } else {
            Utils.setStringProperty(STR.accessToken, appInstall.getFlickrToken());
            Utils.setStringProperty(STR.accessTokenSecret, appInstall.getFlickrTokenSecret());
            Utils.setStringProperty(STR.userId, appInstall.getFlickrUserId());
            Utils.setStringProperty(STR.userName, appInstall.getFlickrUserName());
            FlickrApi.reset();
            FlickrApi.syncMedia();
            setResult(RESULT_CODE_AUTH);
            finish();
        }
    } catch (Throwable e) {
        setError(e);
    }
}
 
Example #3
Source File: Card.java    From iSCAU-Android with GNU General Public License v3.0 6 votes vote down vote up
@Background( id = UIHelper.CANCEL_FLAG )
void loadData(Object... params) {
    try{

        ArrayList<String> param = (ArrayList<String>)params[0];
        CardRecordModel.RecordList records;
        if( param == null){
            records = api.getToday(AppContext.userName, app.getEncodeCardPassword());
        }else{
            records = api.getHistory(AppContext.userName, app.getEncodeCardPassword(), param.get(0), param.get(1), page);
        }
        showSuccessResult(records);
    }catch (HttpStatusCodeException e){
        showErrorResult(ctx, e.getStatusCode().value());
    }
}
 
Example #4
Source File: SyncableActivity.java    From moVirt with Apache License 2.0 6 votes vote down vote up
@OptionsItem(R.id.action_refresh)
@Background
public void onRefresh() {
    boolean networkAvailable = connectivityHelper.isNetworkAvailable();
    if (!networkAvailable) {
        // show toast but allow system to notice refresh
        commonMessageHelper.showToast(getString(R.string.rest_no_network));
    }

    final ActiveSelection activeSelection = rxStore.getActiveSelection();

    if (activeSelection.isAllAccounts()) {
        notifySyncing(networkAvailable, null);
        for (MovirtAccount account : rxStore.getAllAccounts()) {
            accountManagerHelper.triggerRefresh(account);
        }
    } else if (accountManagerHelper.isSyncable(activeSelection.getAccount())) {
        notifySyncing(networkAvailable, activeSelection.getAccount());
        accountManagerHelper.triggerRefresh(activeSelection.getAccount());
    }
}
 
Example #5
Source File: UpdateDatabaseFragment.java    From Local-GSM-Backend with Apache License 2.0 6 votes vote down vote up
@Background
protected void updateLastDatabaseUpdate() {
    if (isAdded()) {
        long time = Settings.with(this).databaseLastModified();

        if (time != 0) {
            setLastUpdateString(getString(
                    R.string.fragment_update_database_last_update,
                    DateUtils.getRelativeTimeSpanString(time, System.currentTimeMillis(), DateUtils.DAY_IN_MILLIS)
            ), true);
        } else if (Settings.with(this).databaseFile() != null) {
            // exists but not readable
            setLastUpdateString(getString(
                    R.string.fragment_update_database_no_permission, Settings.with(this).databaseFile()
            ), true);
        } else {
            // not found
            setLastUpdateString(getString(R.string.fragment_update_database_no_database_found), false);
        }
    }
}
 
Example #6
Source File: CertificateManagementPresenter.java    From moVirt with Apache License 2.0 6 votes vote down vote up
@Override
@Background
public void onCertificateLocationChangeAttempt(CertLocation certLocation) {
    try {
        if (propertiesManager.getCertificateChain().length > 0) {
            final CertLocation oldLocation = propertiesManager.getCertificateLocation();
            if (certLocation != oldLocation) {
                revertCheckFromUiThread(oldLocation, certLocation); // many issues with radio buttons so we call UiThread from Background
            }
        } else {
            propertiesManager.setCertificateLocation(certLocation);
        }
    } catch (AccountDeletedException e) {
        finishSafe();
    }
}
 
Example #7
Source File: MultipleFacadeBaseListFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@Background
public void onRefresh() {
    if (isSingle()) {
        super.onRefresh();
    } else {
        try {
            Collection<AccountEnvironment> environments;

            ActiveSelection activeSelection = rxStore.getActiveSelection();
            if (activeSelection.isAllAccounts()) {
                environments = environmentStore.getAllEnvironments();
            } else {
                environments = Collections.singletonList(environmentStore.getEnvironment(activeSelection.getAccount()));
            }

            List<AccountEnvironment> filtered = new ArrayList<>();
            for (AccountEnvironment env : environments) {
                if (!env.getAccountPropertiesManager().isFirstLogin()) {
                    filtered.add(env);
                }
            }

            for (int i = 0; i < filtered.size(); i++) {
                if (i == filtered.size() - 1) {
                    filtered.get(i).getFacade(entityClass).syncAll(new ProgressBarResponse<>(this));
                } else {
                    filtered.get(i).getFacade(entityClass).syncAll();
                }
            }
        } catch (AccountDeletedException ignore) {
        }
    }
}
 
Example #8
Source File: Bus.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * load the bus location information;
 * @param params
 */
@Background( id = UIHelper.CANCEL_FLAG )
void loadData(Object... params) {
    try{
        stateList = api.getBusState((String) params[0], (String) params[1]).getStates();
        showSiteAndBus();
    }catch (HttpStatusCodeException e){
        showErrorResult(getSherlockActivity(), e.getStatusCode().value());
    }
}
 
Example #9
Source File: GetCitiesImp.java    From MVPAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
@Override
@Background
@DebugLog
public void getCities(Double latitude, Double longitude, Integer count, Callback callback) {
    this.callback = callback;
    try {
        List<City> cityList = cleanRepository.getCities(latitude, longitude, count);
        onItemsLoaded(cityList);
    } catch (GetCitiesException getCitiesException) {
        onError(getCitiesException);
    }
}
 
Example #10
Source File: CertificateManagementPresenter.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
void deleteAllCertsInBackground() {
    try {
        backgroundOperationStatus(true);
        CertHelper.deleteAllCerts(propertiesManager);
        messageHelper.showToast(resources.deletedCertsChainMessage());
    } catch (AccountDeletedException e) {
        finishSafe();
    } finally {
        backgroundOperationStatus(false);
    }
}
 
Example #11
Source File: CertificateManagementPresenter.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
@Override
public void toggleCustomCertificateLocation(CertLocation certLocation) {
    try {
        backgroundOperationStatus(true);
        CertHelper.deleteAllCerts(propertiesManager); // before cert location
        messageHelper.showToast(resources.deletedCertsChainMessage());
        propertiesManager.setCertificateLocation(certLocation);
    } catch (AccountDeletedException e) {
        finishSafe();
    } finally {
        backgroundOperationStatus(false);
    }
}
 
Example #12
Source File: Bus.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * loading line informations
 */
@Background( id = UIHelper.CANCEL_FLAG )
void loadLine(){
    loadCacheLineList();
    if (lineList == null){
        try{
            lineList = api.getLine().getLines();
            saveCacheLineList();
            showLine();
        }catch (HttpStatusCodeException e){
            showErrorResult(getSherlockActivity(), e.getStatusCode().value());
        }
    }
}
 
Example #13
Source File: Introduction.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
@Background
void loadData(Object... params) {
    String fileName = "introduction/" + target + ".json";
    String context  = textUtil.getFromAssets(fileName);
    List<IntroductionModel> introList = IntroductionModel.parse(context);
    buildListViewAdapter(introList);
    showContent();

}
 
Example #14
Source File: InventoryTransferActivity.java    From moserp with Apache License 2.0 5 votes vote down vote up
@Background
void saveClicked() {
    Log.v("InventoryTransfer", "Save called. " + binding.getInventoryTransferViewModel());
    ResponseEntity<InventoryTransfer> re = inventoryTransferRestService.post(binding.getInventoryTransferViewModel().toInventoryTransfer());
    if (re != null) {
        Log.v("InventoryTransfer", "InventoryTransfer saved. URI: " + re.getHeaders().getLocation());
        returnToParentActivity();
    }
}
 
Example #15
Source File: IncomingDeliveryActivity.java    From moserp with Apache License 2.0 5 votes vote down vote up
@Background
void saveClicked() {
    Log.v("IncomingDelivery", "Save called. " + binding.getIncomingDeliveryViewModel());
    ResponseEntity<IncomingDelivery> re = incomingDeliveryRestService.post(binding.getIncomingDeliveryViewModel().toIncomingDelivery());
    if (re != null) {
        Log.v("IncomingDelivery", "IncomingDelivery saved. URI: " + re.getHeaders().getLocation());
        returnToParentActivity();
    }
}
 
Example #16
Source File: MapPoiHandler.java    From overpasser with Apache License 2.0 5 votes vote down vote up
@Background
void fetchPois(LatLngBounds bounds) {
    OverpassQueryResult result = overApiAdapter.search(bounds);

    if (result != null) {
        for (Element poi : result.elements) {
            if (!alreadyStored(poi)) {
                fixTitle(poi);
                storePoi(poi);
                showPoi(poi);
            }
        }
    }
}
 
Example #17
Source File: AccountFacadeBaseListFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@Background
public void onRefresh() {
    if (isSingle()) {
        environmentStore.safeEntityFacadeCall(account, entityClass,
                facade -> facade.syncAll(new ProgressBarResponse<>(this)));
    }
}
 
Example #18
Source File: VmDetailPresenter.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@Background
public void createSnapshot(org.ovirt.mobile.movirt.rest.dto.Snapshot snapshot) {
    environmentStore.safeOvirtClientCall(account,
            client -> client.createSnapshot(snapshot, vmId, new SimpleResponse<Void>() {
                @Override
                public void onResponse(Void aVoid) throws RemoteException {
                    // refresh snapshots
                    environmentStore.safeEntityFacadeCall(account, Snapshot.class,
                            facade -> facade.syncAll(vmId));
                }
            }));
}
 
Example #19
Source File: VmDisksFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
@Override
public void onRefresh() {
    environmentStore.safeEnvironmentCall(account, environment -> {
        Version version = environment.getVersion();

        if (VersionSupport.VM_DISKS.isSupported(version)) {
            environment.getFacade(Disk.class).syncAll(new ProgressBarResponse<>(this), getVmId());
        } else if (VersionSupport.DISK_ATTACHMENTS.isSupported(version)) {
            environment.getFacade(DiskAttachment.class).syncAll(new ProgressBarResponse<>(this), getVmId());
        }
    });
}
 
Example #20
Source File: VmDetailGeneralFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@Background
public void onRefresh() {
    if (vm != null) {
        vmFacade.syncOne(new ProgressBarResponse<>(this), vmId);
        consoleFacade.syncAll(new ProgressBarResponse<>(this), vmId);
    }
}
 
Example #21
Source File: EditTriggerActivity.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
public void updateTrigger(Trigger trigger) {
    if (findSimilarTrigger(trigger) != null) {
        commonMessageHelper.showToast(resources.getUpdateDuplicateTriggerError());
    }
    provider.update(trigger);
}
 
Example #22
Source File: AddTriggerActivity.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
public void addTrigger(Trigger trigger) {
    if (findSimilarTrigger(trigger) != null) {
        commonMessageHelper.showToast(resources.getCreatedDuplicateTriggerError());
    }
    provider.insert(trigger);
}
 
Example #23
Source File: SnapshotVmDetailGeneralFragment.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@Background
public void onRefresh() {
    if (vmId != null && snapshotId != null) {
        snapshotFacade.syncOne(new ProgressBarResponse<>(this), snapshotId, vmId);
    }
}
 
Example #24
Source File: SnapshotDetailPresenter.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
@Override
public void previewSnapshot(boolean restoreMemory) {
    SnapshotAction action = new SnapshotAction(snapshotId, restoreMemory);
    environmentStore.safeOvirtClientCall(account,
            client -> client.previewSnapshot(action, vmId, new SyncSnapshotsResponse()));
}
 
Example #25
Source File: SnapshotDetailPresenter.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Background
@Override
public void restoreSnapshot(boolean restoreMemory) {
    SnapshotAction action = new SnapshotAction(snapshotId, restoreMemory);
    environmentStore.safeOvirtClientCall(account,
            client -> client.restoreSnapshot(action, vmId, new SyncSnapshotsResponse()));
}
 
Example #26
Source File: SnapshotDetailPresenter.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
@Background
public void deleteSnapshot() {
    environmentStore.safeOvirtClientCall(account,
            client -> client.deleteSnapshot(vmId, snapshotId, new SimpleResponse<Void>() {
                @Override
                public void onResponse(Void aVoid) throws RemoteException {
                    finishSafe();
                    syncSnapshots();
                }
            }));
}
 
Example #27
Source File: CommonMessageHelper.java    From moVirt with Apache License 2.0 5 votes vote down vote up
/**
 * @see Message for default values to understand behaviour of overloaded methods
 * broadcasts error and logs it
 */
@Background
public void showError(MovirtAccount account, Message message) {
    ErrorType errorType = message.getType();
    Integer logPriority = message.getLogPriority();

    if (logPriority == null) {
        logPriority = errorType.getDefaultLogPriority();
    }

    showError(account, logPriority, messageToString(message));
}
 
Example #28
Source File: FlickrWebAuthActivity.java    From flickr-uploader with GNU General Public License v2.0 5 votes vote down vote up
@Background
void loadAuthorizationUrl() {
    try {
        Utils.saveAndroidDevice();
        String url = "http://ra-fa-li.appspot.com/flickr?oauth_redirect=true&device_id=" + Utils.getDeviceId();
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
        setLoading("Waiting for browser info…");
        Utils.setLongProperty(STR.lastBrowserOpenForAuth, System.currentTimeMillis());
    } catch (Throwable e) {
        setError(e);
    }
}
 
Example #29
Source File: AutoUploadFoldersActivity.java    From flickr-uploader with GNU General Public License v2.0 5 votes vote down vote up
@Background
void load() {
    folders = new ArrayList<Folder>(Utils.getFolders(true).values());
    Collections.sort(folders, new Comparator<Folder>() {
        @Override
        public int compare(Folder lhs, Folder rhs) {
            return rhs.getSize() - lhs.getSize();
        }
    });
    render();
    cachedPhotoSets = FlickrApi.getPhotoSets(true);
    refresh();
}
 
Example #30
Source File: FlickrUploaderActivity.java    From flickr-uploader with GNU General Public License v2.0 5 votes vote down vote up
@Background
void enqueue(Collection<Media> images, String photoSetTitle) {
    int enqueued = UploadService.enqueue(false, images, photoSetTitle);
    if (slidingDrawer != null && enqueued > 0) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (Utils.getBooleanProperty(STR.show_sliding_demo, true)) {
                    slidingDrawer.demo();
                }
                drawerContentView.setCurrentTab(DrawerContentView.TAB_QUEUED_INDEX);
            }
        });
    }
}