本文整理汇总了Java中net.danlew.android.joda.JodaTimeAndroid类的典型用法代码示例。如果您正苦于以下问题:Java JodaTimeAndroid类的具体用法?Java JodaTimeAndroid怎么用?Java JodaTimeAndroid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JodaTimeAndroid类属于net.danlew.android.joda包,在下文中一共展示了JodaTimeAndroid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAverageGlucoseReadingsByWeek
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
public List<Integer> getAverageGlucoseReadingsByWeek() {
JodaTimeAndroid.init(mContext);
DateTime maxDateTime = new DateTime(realm.where(GlucoseReading.class).maximumDate("created").getTime());
DateTime minDateTime = new DateTime(realm.where(GlucoseReading.class).minimumDate("created").getTime());
DateTime currentDateTime = minDateTime;
DateTime newDateTime = minDateTime;
ArrayList<Integer> averageReadings = new ArrayList<Integer>();
// The number of weeks is at least 1 since we do have average for the current week even if incomplete
int weeksNumber = Weeks.weeksBetween(minDateTime, maxDateTime).getWeeks() + 1;
for (int i = 0; i < weeksNumber; i++) {
newDateTime = currentDateTime.plusWeeks(1);
RealmResults<GlucoseReading> readings = realm.where(GlucoseReading.class)
.between("created", currentDateTime.toDate(), newDateTime.toDate())
.findAll();
averageReadings.add(((int) readings.average("reading")));
currentDateTime = newDateTime;
}
return averageReadings;
}
示例2: getGlucoseDatetimesByWeek
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
public List<String> getGlucoseDatetimesByWeek() {
JodaTimeAndroid.init(mContext);
DateTime maxDateTime = new DateTime(realm.where(GlucoseReading.class).maximumDate("created").getTime());
DateTime minDateTime = new DateTime(realm.where(GlucoseReading.class).minimumDate("created").getTime());
DateTime currentDateTime = minDateTime;
DateTime newDateTime = minDateTime;
ArrayList<String> finalWeeks = new ArrayList<String>();
// The number of weeks is at least 1 since we do have average for the current week even if incomplete
int weeksNumber = Weeks.weeksBetween(minDateTime, maxDateTime).getWeeks() + 1;
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
for (int i = 0; i < weeksNumber; i++) {
newDateTime = currentDateTime.plusWeeks(1);
finalWeeks.add(inputFormat.format(newDateTime.toDate()));
currentDateTime = newDateTime;
}
return finalWeeks;
}
示例3: getAverageGlucoseReadingsByMonth
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
public List<Integer> getAverageGlucoseReadingsByMonth() {
JodaTimeAndroid.init(mContext);
DateTime maxDateTime = new DateTime(realm.where(GlucoseReading.class).maximumDate("created").getTime());
DateTime minDateTime = new DateTime(realm.where(GlucoseReading.class).minimumDate("created").getTime());
DateTime currentDateTime = minDateTime;
DateTime newDateTime = minDateTime;
ArrayList<Integer> averageReadings = new ArrayList<Integer>();
// The number of months is at least 1 since we do have average for the current week even if incomplete
int monthsNumber = Months.monthsBetween(minDateTime, maxDateTime).getMonths() + 1;
for (int i = 0; i < monthsNumber; i++) {
newDateTime = currentDateTime.plusMonths(1);
RealmResults<GlucoseReading> readings = realm.where(GlucoseReading.class)
.between("created", currentDateTime.toDate(), newDateTime.toDate())
.findAll();
averageReadings.add(((int) readings.average("reading")));
currentDateTime = newDateTime;
}
return averageReadings;
}
示例4: getGlucoseDatetimesByMonth
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
public List<String> getGlucoseDatetimesByMonth() {
JodaTimeAndroid.init(mContext);
DateTime maxDateTime = new DateTime(realm.where(GlucoseReading.class).maximumDate("created").getTime());
DateTime minDateTime = new DateTime(realm.where(GlucoseReading.class).minimumDate("created").getTime());
DateTime currentDateTime = minDateTime;
DateTime newDateTime = minDateTime;
ArrayList<String> finalMonths = new ArrayList<String>();
// The number of months is at least 1 because current month is incomplete
int monthsNumber = Months.monthsBetween(minDateTime, maxDateTime).getMonths() + 1;
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
for (int i = 0; i < monthsNumber; i++) {
newDateTime = currentDateTime.plusMonths(1);
finalMonths.add(inputFormat.format(newDateTime.toDate()));
currentDateTime = newDateTime;
}
return finalMonths;
}
示例5: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
TallyStackerApplication.instance = this;
JodaTimeAndroid.init(this);
Fabric.with(this, new Crashlytics());
Fabric.with(this, new Answers());
Stetho.initializeWithDefaults(this);
// Setup handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable e) {
if (!(e instanceof ExpectedElementNotFound))
handleUncaughtException(e);
}
});
}
示例6: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
instance = this;
applicationComponent = DaggerApplicationComponent.builder()
.networkModule(new NetworkModule())
.presentersModule(new PresentersModule())
.sourceModule(new SourceModule(this))
.gatewaysModule(new GatewaysModule())
.managerModule(new ManagerModule(this))
.utilsModule(new UtilsModule(this))
.build();
JodaTimeAndroid.init(this);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath(getString(R.string.font_ubuntu))
.setFontAttrId(R.attr.fontPath)
.build()
);
}
示例7: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
JodaTimeAndroid.init(this);
Settings.initialize(this);
if (BuildConfig.DEBUG) {
StrictMode.enableDefaults();
ButterKnife.setDebug(true);
}
Dagger.initEagerSingletons(this);
// get the correct theme for the app!
ThemeHelperService.updateTheme(this);
}
示例8: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
JodaTimeAndroid.init(this);
//LeakCanary.install(this);
sAppContext = getApplicationContext();
// Create a singleton instance of the "DatabaseHandler" using the application context. This
// avoids memory leaks elsewhere and is more convenient. There is ABSOLUTELY NO NEED to
// close the database EVER. Closing it in an ad hoc fashion (as was done in fragments and
// activities) leads to all sorts of concurrency problems, race conditions, etc. SQLite
// handles all of the concurrency itself, so there is no problem there. Android/Linux will
// ensure that the database is closed if the application process exits.
//
// Note that the database is not opened here; it will not be opened until the first call to
// "getReadableDatabase" or "getWritableDatabase" and then the open database instance will
// be cached (by "SQLiteOpenHelper", which is the base class of "DatabaseHandler"). Those
// two methods should really only be called from a background task, though, as opening the
// database (particularly for the first time) can take some time.
sDBHandler = new DatabaseHandler();
LocaleUtils.onCreate();
}
示例9: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if(BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree(){
@Override
protected void log(int priority, String tag, String message, Throwable t) {
super.log(priority, Constants.LOGTAG, message, t);
}
});
}
JodaTimeAndroid.init(this);
appComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
}
示例10: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.CRASHLYTICS_ENABLED) {
Fabric.with(this, new Crashlytics());
}
JodaTimeAndroid.init(this);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
if (null == preferences.getString(PreferenceKeys.KEY_APP_ID, null)) {
String id = Base62.encode(TimeBasedRandomGenerator.generate());
SharedPreferences.Editor editor = preferences.edit();
editor.putString(PreferenceKeys.KEY_APP_ID, id);
editor.apply();
}
DailyReminderServiceHelper.setup(this, preferences);
DriveBackupServiceHelper.setup(this);
}
示例11: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
context = this;
// 初始化JodaTimeAndroid
JodaTimeAndroid.init(this);
// 配置全局异常捕获
if (!BuildConfig.DEBUG) {
Thread.setDefaultUncaughtExceptionHandler(this);
}
// 友盟设置调试模式
MobclickAgent.setDebugMode(BuildConfig.DEBUG);
}
示例12: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// Since this is app for developers we can log even in release build.
Timber.plant(new Timber.DebugTree());
JodaTimeAndroid.init(this);
FlowManager.init(this);
applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
.apiModule(new ApiModule("https://api.travis-ci.org/"))
.build();
applicationComponent.inject(this);
developerTools();
}
示例13: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
JodaTimeAndroid.init(this);
Funs.getInstance().setContext(getApplicationContext());
setContentView(R.layout.activity_main);
FunsPageAdapter adapter = new FunsPageAdapter();
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(Funs.getInstance().getViewPagerCurrentItem());
RecyclerTabLayout recyclerTabLayout = (RecyclerTabLayout)
findViewById(R.id.recycler_tab_layout);
recyclerTabLayout.setUpWithViewPager(viewPager);
}
示例14: initResources
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
/**
* Initializes all the resources for the application with Application Context.
*/
public void initResources() {
// initialize the ApiRequestHandler to get access token.
mApiRequestHandler = new ApiRequestHandler(mBus, this);
mUserRequestHandler = new UserRequestHandler(mBus, this);
mBus.register(mUserRequestHandler);
mActivityRequestHandler = new ActivityRequestHandler(mBus, this);
mBus.register(mActivityRequestHandler);
mObservationRequestHandler = new ObservationRequestHandler(mBus, this);
mBus.register(mObservationRequestHandler);
mLocationRequestHandler = new LocationRequestHandler(mBus, this);
mBus.register(mLocationRequestHandler);
mTickRequestHandler = new TickRequestHandler(mBus, this);
mBus.register(mTickRequestHandler);
mFileUploadHandler = new FileUploadHandler(mBus, this);
mBus.register(mFileUploadHandler);
JodaTimeAndroid.init(this);
}
示例15: onCreate
import net.danlew.android.joda.JodaTimeAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// Initalize JodaTime
JodaTimeAndroid.init(this);
// Get the RetrofitRestadapter reference
mGithubApiClient = new GithubApiClient();
// Initialize a MyDataStore to handle SharedPreferences
mMyDataStore = new DatastoreBuilder(PreferenceManager.getDefaultSharedPreferences(this))
.create(MyDataStore.class);
// Check if it is the first time the application runs
if (mMyDataStore.isFirstRun().get(true)) {
onFirstRun();
}
}