|
|
@ -19,31 +19,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.isoron.uhabits.ui.habits.list;
|
|
|
|
package org.isoron.uhabits.ui.habits.list;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.*;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.content.res.*;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.annotation.*;
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.*;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.*;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
import org.isoron.uhabits.*;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.models.*;
|
|
|
|
import org.isoron.uhabits.R;
|
|
|
|
import org.isoron.uhabits.ui.*;
|
|
|
|
import org.isoron.uhabits.models.ModelObservable;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.controllers.*;
|
|
|
|
import org.isoron.uhabits.ui.BaseRootView;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.model.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.controllers.HabitCardListController;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.views.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.model.HabitCardListAdapter;
|
|
|
|
import org.isoron.uhabits.utils.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.model.HintList;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.ui.habits.list.views.HabitCardListView;
|
|
|
|
import butterknife.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.views.HintView;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ListHabitsRootView extends BaseRootView
|
|
|
|
public class ListHabitsRootView extends BaseRootView
|
|
|
|
implements ModelObservable.Listener
|
|
|
|
implements ModelObservable.Listener
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public static final int MAX_CHECKMARK_COUNT = 21;
|
|
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.listView)
|
|
|
|
@BindView(R.id.listView)
|
|
|
|
HabitCardListView listView;
|
|
|
|
HabitCardListView listView;
|
|
|
|
|
|
|
|
|
|
|
@ -71,6 +68,15 @@ public class ListHabitsRootView extends BaseRootView
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int getCheckmarkCount(View v)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Resources res = v.getResources();
|
|
|
|
|
|
|
|
float labelWidth = res.getDimension(R.dimen.habitNameWidth);
|
|
|
|
|
|
|
|
float buttonWidth = res.getDimension(R.dimen.checkmarkWidth);
|
|
|
|
|
|
|
|
return Math.min(MAX_CHECKMARK_COUNT, Math.max(0,
|
|
|
|
|
|
|
|
(int) ((v.getMeasuredWidth() - labelWidth) / buttonWidth)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@NonNull
|
|
|
|
@NonNull
|
|
|
|
public ProgressBar getProgressBar()
|
|
|
|
public ProgressBar getProgressBar()
|
|
|
@ -80,10 +86,16 @@ public class ListHabitsRootView extends BaseRootView
|
|
|
|
|
|
|
|
|
|
|
|
public boolean getShowArchived()
|
|
|
|
public boolean getShowArchived()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(listAdapter == null) return false;
|
|
|
|
if (listAdapter == null) return false;
|
|
|
|
return listAdapter.getIncludeArchived();
|
|
|
|
return listAdapter.getIncludeArchived();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setShowArchived(boolean showArchived)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (listAdapter == null) return;
|
|
|
|
|
|
|
|
listAdapter.setShowArchived(showArchived);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Toolbar getToolbar()
|
|
|
|
public Toolbar getToolbar()
|
|
|
@ -103,19 +115,6 @@ public class ListHabitsRootView extends BaseRootView
|
|
|
|
updateEmptyView();
|
|
|
|
updateEmptyView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setShowArchived(boolean showArchived)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(listAdapter == null) return;
|
|
|
|
|
|
|
|
listAdapter.setShowArchived(showArchived);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateEmptyView()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (listAdapter == null) return;
|
|
|
|
|
|
|
|
llEmpty.setVisibility(
|
|
|
|
|
|
|
|
listAdapter.getCount() > 0 ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setController(@Nullable ListHabitsController controller,
|
|
|
|
public void setController(@Nullable ListHabitsController controller,
|
|
|
|
@Nullable ListHabitsSelectionMenu menu)
|
|
|
|
@Nullable ListHabitsSelectionMenu menu)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -139,20 +138,6 @@ public class ListHabitsRootView extends BaseRootView
|
|
|
|
listAdapter.setListView(listView);
|
|
|
|
listAdapter.setListView(listView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void init()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
addView(inflate(getContext(), R.layout.list_habits, null));
|
|
|
|
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvStarEmpty.setTypeface(InterfaceUtils.getFontAwesome(getContext()));
|
|
|
|
|
|
|
|
initToolbar();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String hints[] =
|
|
|
|
|
|
|
|
getContext().getResources().getStringArray(R.array.hints);
|
|
|
|
|
|
|
|
HintList hintList = new HintList(hints);
|
|
|
|
|
|
|
|
hintView.setHints(hintList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onAttachedToWindow()
|
|
|
|
protected void onAttachedToWindow()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -170,4 +155,25 @@ public class ListHabitsRootView extends BaseRootView
|
|
|
|
listAdapter.getObservable().removeListener(this);
|
|
|
|
listAdapter.getObservable().removeListener(this);
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void init()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
addView(inflate(getContext(), R.layout.list_habits, null));
|
|
|
|
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvStarEmpty.setTypeface(InterfaceUtils.getFontAwesome(getContext()));
|
|
|
|
|
|
|
|
initToolbar();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String hints[] =
|
|
|
|
|
|
|
|
getContext().getResources().getStringArray(R.array.hints);
|
|
|
|
|
|
|
|
HintList hintList = new HintList(hints);
|
|
|
|
|
|
|
|
hintView.setHints(hintList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateEmptyView()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (listAdapter == null) return;
|
|
|
|
|
|
|
|
llEmpty.setVisibility(
|
|
|
|
|
|
|
|
listAdapter.getCount() > 0 ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|