本文整理匯總了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();
}
}