本文整理汇总了Java中org.jraf.android.util.async.TaskFragment类的典型用法代码示例。如果您正苦于以下问题:Java TaskFragment类的具体用法?Java TaskFragment怎么用?Java TaskFragment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TaskFragment类属于org.jraf.android.util.async包,在下文中一共展示了TaskFragment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateViews
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void populateViews() {
Uri rideUri = getIntent().getData();
if (rideUri == null) return;
new TaskFragment(new Task<RideEditActivity>() {
private String mRideName;
@Override
protected void doInBackground() throws Throwable {
mRideName = RideManager.get().getName(rideUri);
}
@Override
protected void onPostExecuteOk() {
if (mRideName != null) mEdtName.append(mRideName);
}
}).execute(getSupportFragmentManager());
}
示例2: quickStart
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void quickStart() {
new TaskFragment(new Task<RideEditActivity>() {
private Uri mCreatedRideUri;
@Override
protected void doInBackground() throws Throwable {
mCreatedRideUri = RideManager.get().create(null);
}
@Override
protected void onPostExecuteOk() {
startService(new Intent(LogCollectorService.ACTION_START_COLLECTING, mCreatedRideUri, thiz, LogCollectorService.class));
startActivity(new Intent(null, mCreatedRideUri, thiz, DisplayActivity.class));
}
}).execute(getSupportFragmentManager());
}
示例3: startExport
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void startExport() {
new TaskFragment(new Task<RideListActivity>() {
@Override
protected void doInBackground() throws Throwable {
getActivity().mState.mExporter.export();
}
@Override
protected void onPostExecuteOk() {
File exportedFile = getActivity().mState.mExporter.getExportFile();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_subject));
String messageBody = getString(R.string.export_body);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + exportedFile.getAbsolutePath()));
sendIntent.setType("application/bikey");
sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.ride_list_action_share)));
}
}.toastFail(R.string.export_failToast)).execute(getSupportFragmentManager());
}
示例4: startExport
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void startExport() {
new TaskFragment(new Task<RideDetailActivity>() {
@Override
protected void doInBackground() throws Throwable {
getActivity().mState.mExporter.export();
}
@Override
protected void onPostExecuteOk() {
File exportedFile = getActivity().mState.mExporter.getExportFile();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_subject));
String messageBody = getString(R.string.export_body);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + exportedFile.getAbsolutePath()));
sendIntent.setType("application/bikey");
sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.ride_list_action_share)));
}
}.toastFail(R.string.export_failToast)).execute(getSupportFragmentManager());
}
示例5: copyFile
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void copyFile(File destDir) {
String fileName = mSourceFileUri.getLastPathSegment();
File src = new File(mSourceFileUri.getPath());
File dest = new File(destDir, fileName);
String successToast = getString(R.string.saveToStorage_successToast, dest);
new TaskFragment(new Task<SaveToStorageActivity>() {
@Override
protected void doInBackground() throws Throwable {
FileUtil.copy(src, dest);
}
@Override
protected void onPostExecuteFail() {
super.onPostExecuteFail();
finish();
}
@Override
protected void onPostExecuteOk() {
super.onPostExecuteOk();
finish();
}
}.toastFail(R.string.saveToStorage_failedToast).toastOk(successToast)).execute(getSupportFragmentManager());
}
示例6: startExport
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
@Override
public void startExport() {
new TaskFragment(new Task<PreferenceActivity>() {
DbExporter mExporter = new DbExporter();
@Override
protected void doInBackground() throws Throwable {
mExporter.export();
}
@Override
protected void onPostExecuteOk() {
File exportedFile = mExporter.getExportFile();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_subject));
String messageBody = getString(R.string.export_body);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + exportedFile.getAbsolutePath()));
sendIntent.setType("application/bikey");
sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.preference_export_title)));
}
}.toastFail(R.string.export_failToast)).execute(getSupportFragmentManager());
}
示例7: delete
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void delete() {
new TaskFragment(new Task<AddressInfoEditActivity>() {
@Override
protected void doInBackground() throws Throwable {
AddressInfoEditActivity a = getActivity();
a.mAddressInfo.delete(a);
}
@Override
protected void onPostExecuteOk() {
getActivity().finish();
}
}).execute(getSupportFragmentManager());
}
示例8: saveRide
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void saveRide() {
new TaskFragment(new Task<RideEditActivity>() {
private Uri mRideUri;
@Override
protected void doInBackground() throws Throwable {
String name = getActivity().mEdtName.getText().toString().trim();
Uri rideUri = getIntent().getData();
if (rideUri == null) {
// Create
mRideUri = RideManager.get().create(name);
// Save the new ride as the current one
RideManager.get().setCurrentRide(mRideUri);
} else {
mRideUri = rideUri;
RideManager.get().updateName(rideUri, name);
}
}
@Override
protected void onPostExecuteOk() {
setResult(RESULT_OK, new Intent(null, mRideUri));
getActivity().finish();
}
}).execute(getSupportFragmentManager());
}
示例9: delete
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void delete(long[] ids) {
new TaskFragment(new Task<RideListActivity>() {
@Override
protected void doInBackground() throws Throwable {
RideManager.get().delete(ids);
}
}).execute(getSupportFragmentManager());
}
示例10: merge
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void merge(long[] ids) {
new TaskFragment(new Task<RideListActivity>() {
@Override
protected void doInBackground() throws Throwable {
RideManager.get().merge(ids);
}
}).execute(getSupportFragmentManager());
}
示例11: delete
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void delete() {
long[] ids = {ContentUris.parseId(mRideUri)};
new TaskFragment(new Task<RideDetailActivity>() {
@Override
protected void doInBackground() throws Throwable {
RideManager.get().delete(ids);
}
@Override
protected void onPostExecuteOk() {
finish();
}
}).execute(getSupportFragmentManager());
}
示例12: startGoogleDriveSyncTask
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
public void startGoogleDriveSyncTask() {
mSyncOnGoing = true;
new TaskFragment(new Task<GoogleDriveSyncActivity>() {
@Override
protected void doInBackground() throws Throwable {
GoogleDriveSyncManager.get(GoogleDriveSyncActivity.this).sync(getGoogleApiClient(), GoogleDriveSyncActivity.this);
mSyncOnGoing = false;
}
}).execute(getSupportFragmentManager(), false);
}
示例13: importRides
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void importRides(Uri ridesFile) {
new TaskFragment(new Task<PreferenceActivity>() {
@Override
protected void doInBackground() throws Throwable {
DatabaseImporter.importDatabase(thiz, ridesFile);
}
}.toastFail(R.string.preference_import_failToast).toastOk(R.string.preference_import_successToast)).execute(getSupportFragmentManager());
}
示例14: loadData
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void loadData() {
new TaskFragment(new Task<AddressInfoEditActivity>() {
@Override
protected void doInBackground() throws Throwable {
AddressInfoEditActivity a = getActivity();
Uri addressUri = a.mAddressUri;
String[] projection = {ContactsContract.Data.CONTACT_ID, // 0
ContactsContract.Contacts.DISPLAY_NAME, // 1
ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS, // 2
ContactsContract.Contacts.LOOKUP_KEY, // 3
};
Cursor c = a.getContentResolver().query(addressUri, projection, null, null, null);
try {
if (c.moveToNext()) {
String formattedAddress = c.getString(2);
AddressInfo addressInfo;
if (AddressInfo.isAugmented(formattedAddress)) {
// Augmented (existing AddressInfo)
addressInfo = AddressInfo.parseAugmented(formattedAddress);
} else {
// New AddressInfo
addressInfo = new AddressInfo();
addressInfo.formattedAddress = formattedAddress;
}
addressInfo.uri = addressUri;
addressInfo.contactInfo.uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, c.getLong(0));
addressInfo.contactInfo.contentLookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, c.getString(3));
addressInfo.contactInfo.displayName = c.getString(1);
a.mAddressInfo = addressInfo;
} else {
// Should not normally happen
throw new Exception("Could not find uri " + addressUri);
}
} finally {
c.close();
}
}
@Override
protected void onPostExecuteFail() {
super.onPostExecuteFail();
getActivity().finish();
}
@Override
protected void onPostExecuteOk() {
getActivity().onDataLoaded();
}
}.toastFail(R.string.addressInfo_edit_loadError)).execute(getSupportFragmentManager());
}
示例15: loadData
import org.jraf.android.util.async.TaskFragment; //导入依赖的package包/类
private void loadData() {
new TaskFragment(new Task<RideMapActivity>() {
private String mName;
private List<LatLng> mLatLngArray;
@Override
protected void doInBackground() throws Throwable {
RideManager rideManager = RideManager.get();
Uri rideUri = getActivity().mRideUri;
RideCursor rideCursor = rideManager.query(rideUri);
mName = rideCursor.getName();
rideCursor.close();
LogManager logManager = LogManager.get();
mLatLngArray = logManager.getLatLngArray(rideUri, 100);
// Make sure the map is actually available
getMap();
}
@Override
protected void onPostExecuteOk() {
RideMapActivity a = getActivity();
if (mName != null) a.setTitle(mName);
// Map
// Add a padding since the map is below the action bar (+ status bar + nav bar if >= kitkat)
int statusBarHeight = 0;
int navigationBarHeight = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
statusBarHeight = a.getStatusBarHeight();
navigationBarHeight = a.getNavigationBarHeight();
}
a.getMap().setPadding(0, getActionBarHeight() + statusBarHeight, 0, navigationBarHeight);
a.updateMapType();
if (mLatLngArray.size() > 0) {
// Polyline
PolylineOptions polylineOptions = new PolylineOptions().addAll(mLatLngArray);
polylineOptions.color(getResources().getColor(R.color.map_polyline));
a.getMap().addPolyline(polylineOptions);
// Start / finish markers
a.getMap().addMarker(new MarkerOptions()
.position(mLatLngArray.get(0)).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
a.getMap().addMarker(new MarkerOptions()
.position(mLatLngArray.get(mLatLngArray.size() - 1)).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
// Calculate bounds
LatLngBounds bounds = new LatLngBounds(mLatLngArray.get(0), mLatLngArray.get(0));
for (LatLng latLng : mLatLngArray) {
bounds = bounds.including(latLng);
}
int padding = getResources().getDimensionPixelSize(R.dimen.ride_detail_map_padding);
a.getMap().moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
a.mBinding.conMap.setVisibility(View.VISIBLE);
}
}
}).execute(getSupportFragmentManager());
}