mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Fix previews in Layout Editor
This commit is contained in:
@@ -299,10 +299,18 @@ public class FrequencyChart extends ScrollableChart
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initDateFormats()
|
private void initDateFormats()
|
||||||
|
{
|
||||||
|
if (isInEditMode())
|
||||||
|
{
|
||||||
|
dfMonth = new SimpleDateFormat("MMM", Locale.getDefault());
|
||||||
|
dfYear = new SimpleDateFormat("yyyy", Locale.getDefault());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
dfMonth = AndroidDateFormats.fromSkeleton("MMM");
|
dfMonth = AndroidDateFormats.fromSkeleton("MMM");
|
||||||
dfYear = AndroidDateFormats.fromSkeleton("yyyy");
|
dfYear = AndroidDateFormats.fromSkeleton("yyyy");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initRects()
|
private void initRects()
|
||||||
{
|
{
|
||||||
@@ -326,5 +334,6 @@ public class FrequencyChart extends ScrollableChart
|
|||||||
frequency.put(new Timestamp(date), values);
|
frequency.put(new Timestamp(date), values);
|
||||||
date.add(Calendar.MONTH, -1);
|
date.add(Calendar.MONTH, -1);
|
||||||
}
|
}
|
||||||
|
maxFreq = getMaxFreq(frequency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,10 +427,18 @@ public class HistoryChart extends ScrollableChart
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initDateFormats()
|
private void initDateFormats()
|
||||||
|
{
|
||||||
|
if (isInEditMode())
|
||||||
|
{
|
||||||
|
dfMonth = new SimpleDateFormat("MMM", Locale.getDefault());
|
||||||
|
dfYear = new SimpleDateFormat("yyyy", Locale.getDefault());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
dfMonth = AndroidDateFormats.fromSkeleton("MMM");
|
dfMonth = AndroidDateFormats.fromSkeleton("MMM");
|
||||||
dfYear = AndroidDateFormats.fromSkeleton("yyyy");
|
dfYear = AndroidDateFormats.fromSkeleton("yyyy");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initRects()
|
private void initRects()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -410,10 +410,20 @@ public class ScoreChart extends ScrollableChart
|
|||||||
|
|
||||||
private void initDateFormats()
|
private void initDateFormats()
|
||||||
{
|
{
|
||||||
dfYear = AndroidDateFormats.fromSkeleton("yyyy");
|
if (isInEditMode())
|
||||||
|
{
|
||||||
|
dfMonth = new SimpleDateFormat("MMM", Locale.getDefault());
|
||||||
|
dfYear = new SimpleDateFormat("yyyy", Locale.getDefault());
|
||||||
|
dfDay = new SimpleDateFormat("d", Locale.getDefault());
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
dfMonth = AndroidDateFormats.fromSkeleton("MMM");
|
dfMonth = AndroidDateFormats.fromSkeleton("MMM");
|
||||||
|
dfYear = AndroidDateFormats.fromSkeleton("yyyy");
|
||||||
dfDay = AndroidDateFormats.fromSkeleton("d");
|
dfDay = AndroidDateFormats.fromSkeleton("d");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initPaints()
|
private void initPaints()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public class StreakChart extends View
|
|||||||
streaks = Collections.emptyList();
|
streaks = Collections.emptyList();
|
||||||
|
|
||||||
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
|
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
if (!isInEditMode()) dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
rect = new RectF();
|
rect = new RectF();
|
||||||
baseSize = getResources().getDimensionPixelSize(R.dimen.baseSize);
|
baseSize = getResources().getDimensionPixelSize(R.dimen.baseSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,16 @@ public class BarCard extends HabitCard
|
|||||||
HabitsApplication app = (HabitsApplication) appContext;
|
HabitsApplication app = (HabitsApplication) appContext;
|
||||||
taskRunner = app.getComponent().getTaskRunner();
|
taskRunner = app.getComponent().getTaskRunner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isInEditMode()) initEditMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initEditMode()
|
||||||
|
{
|
||||||
|
int color = PaletteUtils.getAndroidTestColor(1);
|
||||||
|
title.setTextColor(color);
|
||||||
|
chart.setColor(color);
|
||||||
|
chart.populateWithRandomData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RefreshTask implements Task
|
private class RefreshTask implements Task
|
||||||
|
|||||||
@@ -18,14 +18,14 @@
|
|||||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
android:orientation="vertical">
|
||||||
|
|
||||||
<org.isoron.uhabits.activities.habits.show.views.BarCard
|
<org.isoron.uhabits.activities.habits.show.views.ScoreCard
|
||||||
android:id="@+id/barCard"
|
|
||||||
style="@style/Card"
|
style="@style/Card"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:gravity="center" />
|
android:gravity="center" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user