Commit b32b42f6 authored by Rahadi Jalu's avatar Rahadi Jalu

Current Changes

parent 2ee4e7a9
Pipeline #145 canceled with stages
...@@ -53,18 +53,6 @@ Secara umum, pengembangan aplikasi lebih lanjut dapat dilakukan dengan langkah-l ...@@ -53,18 +53,6 @@ Secara umum, pengembangan aplikasi lebih lanjut dapat dilakukan dengan langkah-l
7. Untuk melakukan run project, tekan tombol panah hijau di bagian atas dari Android Studio. 7. Untuk melakukan run project, tekan tombol panah hijau di bagian atas dari Android Studio.
> Note: Penggunaan emulator mungkin dapat mengakibatkan aplikasi berjalan lambat. Oleh karena itu, disarankan untuk menggunakan device selama memungkinkan. > Note: Penggunaan emulator mungkin dapat mengakibatkan aplikasi berjalan lambat. Oleh karena itu, disarankan untuk menggunakan device selama memungkinkan.
## Panduan & Dokumentasi
Berikut adalah *table of content* dari panduan yang tersedia:
1. Instalasi aplikasi
- Menggunakan APK
- Run project pada Android Studio
2. Penggunaan aplikasi
- Konfigurasi Server
- User Interface pemutakhiran
- Keterkaitan Kuesioner
## Credits ## Credits
Banyak pihak yang telah dilibatkan dalam melakukan pengembangan aplikasi ini. Oleh karena itu, pengembang mengucapkan terima kasih kepada: Banyak pihak yang telah dilibatkan dalam melakukan pengembangan aplikasi ini. Oleh karena itu, pengembang mengucapkan terima kasih kepada:
......
...@@ -313,7 +313,7 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -313,7 +313,7 @@ public class CapiInstanceActivity extends AppCompatActivity
HashMap<String, String> informations = new HashMap<>(); HashMap<String, String> informations = new HashMap<>();
File file = new File(instance.getInstanceFilePath()); File file = new File(instance.getInstanceFilePath());
InstanceValues values = XmlUtils.getInstanceValues(instance.getInstanceUuid(), file, labels); InstanceValues values = XmlUtils.getInstanceValues(instance.getInstanceUuid(), file, labels, InstanceValues.STATE_NEUTRAL);
Set<String> parsedXpaths = values.getXPaths(); Set<String> parsedXpaths = values.getXPaths();
for(String parsed : parsedXpaths) { for(String parsed : parsedXpaths) {
if(parsed.equals(titleSelected)) { if(parsed.equals(titleSelected)) {
......
...@@ -40,26 +40,12 @@ public class HierarchyAdapter extends RecyclerView.Adapter<HierarchyAdapter.View ...@@ -40,26 +40,12 @@ public class HierarchyAdapter extends RecyclerView.Adapter<HierarchyAdapter.View
@NonNull @NonNull
@Override @Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Timber.d("Creating with type %s", viewType);
// BaseHierarchy hierarchy = hierarchies.get(viewType);
// if (hierarchy instanceof PromptHierarchy) {
// ((PromptHierarchy) hierarchy).setOnChangeListener(onChangeListener);
// return new PromptViewHolder(hierarchy.getView());
// } else if (hierarchy instanceof CaptionHierarchy) {
// return new CaptionViewHolder(hierarchy.getView());
// } else {
// // Should not be happening
// return new ViewHolder(hierarchy.getView());
// }
return new ViewHolder(new LinearLayout(parent.getContext())); return new ViewHolder(new LinearLayout(parent.getContext()));
} }
@Override @Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
// if (holder instanceof PromptViewHolder) {
// PromptHierarchy hierarchy = (PromptHierarchy) hierarchies.get(position);
// }
holder.bind(hierarchies.get(position)); holder.bind(hierarchies.get(position));
} }
......
...@@ -60,6 +60,9 @@ public class NodeViewFactory extends BaseNodeViewFactory { ...@@ -60,6 +60,9 @@ public class NodeViewFactory extends BaseNodeViewFactory {
case ModeTreeNode.QUEUED: case ModeTreeNode.QUEUED:
imageStatus.setImageResource(R.drawable.ic_download); imageStatus.setImageResource(R.drawable.ic_download);
break; break;
case ModeTreeNode.FAILED:
imageStatus.setImageResource(R.drawable.ic_cancel);
break;
} }
} else { } else {
secondaryText.setVisibility(View.GONE); secondaryText.setVisibility(View.GONE);
......
...@@ -29,7 +29,7 @@ import id.ac.stis.capi.odk.dto.Form; ...@@ -29,7 +29,7 @@ import id.ac.stis.capi.odk.dto.Form;
public class InstancePreferenceFragment extends BasePreferenceFragment { public class InstancePreferenceFragment extends BasePreferenceFragment {
private PreferencesManager manager; private PreferencesManager manager;
private ListPreference viewModePref, titlePref, constraintPref; private ListPreference viewModePref, titlePref, constraintPref, filterPref;
private MultiSelectListPreference subtitlePref; private MultiSelectListPreference subtitlePref;
private String formId; private String formId;
private FormLabels formLabels; private FormLabels formLabels;
...@@ -53,7 +53,8 @@ public class InstancePreferenceFragment extends BasePreferenceFragment { ...@@ -53,7 +53,8 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
List<Form> forms = formsDao.getFormsFromCursor(formsDao.getFormsCursorForFormId(formId)); List<Form> forms = formsDao.getFormsFromCursor(formsDao.getFormsCursorForFormId(formId));
File file = new File(forms.get(0).getFormFilePath()); File file = new File(forms.get(0).getFormFilePath());
List<String> xPaths = XmlUtils.getInstanceXPathList(file); List<String> xPaths = XmlUtils.getInstanceXPathList(file, false);
formLabels = XmlUtils.getFormLabels(formId, file, xPaths); formLabels = XmlUtils.getFormLabels(formId, file, xPaths);
entries = new LinkedList<>(); entries = new LinkedList<>();
...@@ -87,11 +88,14 @@ public class InstancePreferenceFragment extends BasePreferenceFragment { ...@@ -87,11 +88,14 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
} }
if (titlePref != null) { if (titlePref != null) {
entries.addFirst("Default Title"); LinkedList<String> titleEntries = new LinkedList<>(entries);
entryValues.addFirst(PreferencesAPI.TITLE_DEFAULT); titleEntries.addFirst("Default Title");
LinkedList<String> titleEntryValues = new LinkedList<>(entryValues);
titleEntryValues.addFirst(PreferencesAPI.TITLE_DEFAULT);
titlePref.setEntries(entries.toArray(new CharSequence[entries.size()])); titlePref.setEntries(titleEntries.toArray(new CharSequence[titleEntries.size()]));
titlePref.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()])); titlePref.setEntryValues(titleEntryValues.toArray(new CharSequence[titleEntryValues.size()]));
} }
String value = (String) manager.getByFormId(PreferencesAPI.KEY_VIEW_MODE, formId); String value = (String) manager.getByFormId(PreferencesAPI.KEY_VIEW_MODE, formId);
...@@ -141,6 +145,22 @@ public class InstancePreferenceFragment extends BasePreferenceFragment { ...@@ -141,6 +145,22 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
break; break;
} }
} }
filterPref = (ListPreference) findPreference(PreferencesAPI.KEY_FILTER);
if (filterPref != null) {
LinkedList<String> filterEntries = new LinkedList<>(entries);
filterEntries.addFirst("None");
LinkedList<String> filterEntryValues = new LinkedList<>(entryValues);
filterEntryValues.addFirst(PreferencesAPI.FILTER_NONE);
filterPref.setEntries(filterEntries.toArray(new CharSequence[filterEntries.size()]));
filterPref.setEntryValues(filterEntryValues.toArray(new CharSequence[filterEntryValues.size()]));
String val = (String) manager.getByFormId(PreferencesAPI.KEY_FILTER, formId);
setSelectSummary(filterPref, val);
filterPref.setValue(val);
}
} }
private void setListeners() { private void setListeners() {
...@@ -228,6 +248,19 @@ public class InstancePreferenceFragment extends BasePreferenceFragment { ...@@ -228,6 +248,19 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
} }
}); });
} }
if (filterPref != null) {
setSelectSummary(filterPref, (String) manager.getByFormId(PreferencesAPI.KEY_FILTER, formId));
filterPref.setKey(manager.getKey(filterPref.getKey(), formId));
filterPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
setSelectSummary(filterPref, newValue.toString());
return true;
}
});
}
} }
private String getViewModeValue(String entryValue) { private String getViewModeValue(String entryValue) {
...@@ -253,8 +286,13 @@ public class InstancePreferenceFragment extends BasePreferenceFragment { ...@@ -253,8 +286,13 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
} }
private void setSelectSummary(ListPreference preference, String entryValue) { private void setSelectSummary(ListPreference preference, String entryValue) {
if(entryValue.isEmpty() || entryValue.trim().length() == 0 || entryValue.equals(PreferencesAPI.TITLE_DEFAULT)) { if (entryValue == null
|| entryValue.isEmpty()
|| entryValue.trim().length() == 0
|| entryValue.equals(PreferencesAPI.TITLE_DEFAULT)) {
preference.setSummary("Default Title"); preference.setSummary("Default Title");
} else if (entryValue.equals(PreferencesAPI.FILTER_NONE)) {
preference.setSummary("None");
} else { } else {
preference.setSummary(formLabels.getFormLabel(entryValue)); preference.setSummary(formLabels.getFormLabel(entryValue));
} }
...@@ -263,7 +301,7 @@ public class InstancePreferenceFragment extends BasePreferenceFragment { ...@@ -263,7 +301,7 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
private void setMultiSelectSummary(MultiSelectListPreference preference, HashSet<String> set) { private void setMultiSelectSummary(MultiSelectListPreference preference, HashSet<String> set) {
boolean first = true; boolean first = true;
if(!set.isEmpty()) { if (!set.isEmpty()) {
StringBuilder values = new StringBuilder(); StringBuilder values = new StringBuilder();
for (String v : set) { for (String v : set) {
if (!first) { if (!first) {
......
...@@ -11,14 +11,23 @@ import java.util.Set; ...@@ -11,14 +11,23 @@ import java.util.Set;
*/ */
public class InstanceValues implements Serializable { public class InstanceValues implements Serializable {
// TODO: parsing instance value dobel ning instance karo group activity
public static int STATE_NEUTRAL = 0;
public static int STATE_ACTIVE = 1;
public static int STATE_COMPLETED = 2;
private String instanceId; private String instanceId;
private String formId; private String formId;
private int state;
private Map<String, String> instanceValue; private Map<String, String> instanceValue;
public InstanceValues(String instanceId, String formId, Map<String, String> instanceValue) { public InstanceValues(String instanceId, String formId, Map<String, String> instanceValue,
int state) {
this.instanceId = instanceId; this.instanceId = instanceId;
this.formId = formId; this.formId = formId;
this.instanceValue = instanceValue; this.instanceValue = instanceValue;
this.state = state;
} }
public InstanceValues putInstanceValue(String xPath, String value) { public InstanceValues putInstanceValue(String xPath, String value) {
...@@ -46,4 +55,7 @@ public class InstanceValues implements Serializable { ...@@ -46,4 +55,7 @@ public class InstanceValues implements Serializable {
return instanceValue.get(xPath); return instanceValue.get(xPath);
} }
public int getState() {
return state;
}
} }
...@@ -11,6 +11,7 @@ public class ModeTreeNode extends TreeNode { ...@@ -11,6 +11,7 @@ public class ModeTreeNode extends TreeNode {
public static final int DOWNLOADED = 0; public static final int DOWNLOADED = 0;
public static final int QUEUED = 1; public static final int QUEUED = 1;
public static final int FAILED = 2;
private int mode; private int mode;
private String valueId; private String valueId;
......
...@@ -9,10 +9,6 @@ import java.util.HashSet; ...@@ -9,10 +9,6 @@ import java.util.HashSet;
* Company: Politeknik Statistika STIS * Company: Politeknik Statistika STIS
*/ */
public class PreferencesAPI { public class PreferencesAPI {
public static final String KEY_CATEGORY_APPEARANCE = "appearance_category";
public static final String KEY_RESPONSE_APPEARANCE = "response_category";
public static final String KEY_CONSTRAINT_APPEARANCE = "constraint_category";
public static final String KEY_VIEW_MODE = "view_mode"; public static final String KEY_VIEW_MODE = "view_mode";
public static final String KEY_TITLE = "title"; public static final String KEY_TITLE = "title";
...@@ -20,8 +16,12 @@ public class PreferencesAPI { ...@@ -20,8 +16,12 @@ public class PreferencesAPI {
public static final String KEY_CONSTRAINT = "constraint"; public static final String KEY_CONSTRAINT = "constraint";
public static final String KEY_FILTER = "filter";
public static final String TITLE_DEFAULT = "default"; public static final String TITLE_DEFAULT = "default";
public static final String FILTER_NONE = "none";
public static final String VIEW_MODE_ROSTER = "roster"; public static final String VIEW_MODE_ROSTER = "roster";
public static final String VIEW_MODE_CARDS = "cards"; public static final String VIEW_MODE_CARDS = "cards";
......
...@@ -6,6 +6,7 @@ import android.graphics.PorterDuff; ...@@ -6,6 +6,7 @@ import android.graphics.PorterDuff;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -23,10 +24,12 @@ import id.ac.stis.capi.lessthink.listeners.OnFooterNavigationListener; ...@@ -23,10 +24,12 @@ import id.ac.stis.capi.lessthink.listeners.OnFooterNavigationListener;
* Email : 14.8325@stis.ac.id * Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS * Company: Politeknik Statistika STIS
*/ */
public class TableFooterView extends RelativeLayout implements View.OnClickListener { public class TableFooterView extends LinearLayout implements View.OnClickListener {
private View shadowView;
private ImageView addButton; private ImageView addButton;
private TextView currPage; private TextView currPage;
private RelativeLayout container;
private LinearLayout pageIndicator, navigationWrapper; private LinearLayout pageIndicator, navigationWrapper;
private int textSize, componentColor, footerColor, currentPage, pageCount; private int textSize, componentColor, footerColor, currentPage, pageCount;
private OnFooterNavigationListener onFooterNavigationListener; private OnFooterNavigationListener onFooterNavigationListener;
...@@ -35,6 +38,8 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -35,6 +38,8 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
public TableFooterView(Context context, AttributeSet attrs) { public TableFooterView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
setOrientation(VERTICAL);
this.textSize = 12; this.textSize = 12;
this.componentColor = ContextCompat.getColor(getContext(), R.color.white); this.componentColor = ContextCompat.getColor(getContext(), R.color.white);
this.footerColor = ContextCompat.getColor(getContext(), R.color.accent); this.footerColor = ContextCompat.getColor(getContext(), R.color.accent);
...@@ -55,10 +60,25 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -55,10 +60,25 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
a.recycle(); a.recycle();
} }
setBackgroundColor(getFooterColor());
this.shadowView = LayoutInflater.from(getContext()).inflate(R.layout.toolbar_action_bar_shadow_inverted, null, false);
LinearLayout.LayoutParams shadowViewParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
shadowView.setLayoutParams(shadowViewParams);
addView(shadowView);
this.container = new RelativeLayout(getContext());
LinearLayout.LayoutParams containerParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
container.setLayoutParams(containerParams);
addView(container);
container.setBackgroundColor(getFooterColor());
this.pageIndicator = new LinearLayout(getContext()); this.pageIndicator = new LinearLayout(getContext());
RelativeLayout.LayoutParams pageIndicatorParams = new LayoutParams( RelativeLayout.LayoutParams pageIndicatorParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
pageIndicatorParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); pageIndicatorParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
...@@ -71,7 +91,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -71,7 +91,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
pageIndicator.setPadding(15, 15, 15, 15); pageIndicator.setPadding(15, 15, 15, 15);
pageIndicator.setOrientation(LinearLayout.VERTICAL); pageIndicator.setOrientation(LinearLayout.VERTICAL);
addView(pageIndicator); container.addView(pageIndicator);
TextView page = new TextView(getContext()); TextView page = new TextView(getContext());
page.setTextColor(getComponentColor()); page.setTextColor(getComponentColor());
...@@ -90,7 +110,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -90,7 +110,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
pageIndicator.addView(currPage); pageIndicator.addView(currPage);
this.navigationWrapper = new LinearLayout(getContext()); this.navigationWrapper = new LinearLayout(getContext());
RelativeLayout.LayoutParams navigationWrapperParams = new LayoutParams( RelativeLayout.LayoutParams navigationWrapperParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
navigationWrapperParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); navigationWrapperParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
...@@ -98,7 +118,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -98,7 +118,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
navigationWrapper.setLayoutParams(navigationWrapperParams); navigationWrapper.setLayoutParams(navigationWrapperParams);
addView(navigationWrapper); container.addView(navigationWrapper);
int sizeForButtons = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, int sizeForButtons = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
40, getResources().getDisplayMetrics())); 40, getResources().getDisplayMetrics()));
...@@ -148,7 +168,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -148,7 +168,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
this.addButton = new ImageView(getContext(), null, 0); this.addButton = new ImageView(getContext(), null, 0);
addButton.setId(R.id.footer_view_add_button); addButton.setId(R.id.footer_view_add_button);
RelativeLayout.LayoutParams addButtonParams = new LayoutParams(sizeForButtons, sizeForButtons); RelativeLayout.LayoutParams addButtonParams = new RelativeLayout.LayoutParams(sizeForButtons, sizeForButtons);
addButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); addButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
addButtonParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); addButtonParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
...@@ -164,7 +184,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe ...@@ -164,7 +184,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
addButton.setOnClickListener(this); addButton.setOnClickListener(this);
addView(addButton); container.addView(addButton);
} }
public void setPageCountInfo(int pageCount) { public void setPageCountInfo(int pageCount) {
......
...@@ -17,7 +17,6 @@ import android.widget.RelativeLayout; ...@@ -17,7 +17,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import java.util.Set; import java.util.Set;
import id.ac.stis.capi.R; import id.ac.stis.capi.R;
...@@ -85,6 +84,14 @@ public class TableHeaderView extends HorizontalScrollView { ...@@ -85,6 +84,14 @@ public class TableHeaderView extends HorizontalScrollView {
header.setLayoutParams(headerParams); header.setLayoutParams(headerParams);
this.handler = new RelativeLayout(getContext());
RelativeLayout.LayoutParams handlerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
handlerParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
handler.setLayoutParams(handlerParams);
addView(container); addView(container);
} }
...@@ -135,6 +142,10 @@ public class TableHeaderView extends HorizontalScrollView { ...@@ -135,6 +142,10 @@ public class TableHeaderView extends HorizontalScrollView {
public void setColumns(FormLabels columns) { public void setColumns(FormLabels columns) {
this.columns = columns; this.columns = columns;
header.removeAllViews();
handler.removeAllViews();
container.removeAllViews();
Set<String> columnsKeySet = columns.getXPaths(); Set<String> columnsKeySet = columns.getXPaths();
for (String columnsKey : columnsKeySet) { for (String columnsKey : columnsKeySet) {
TextView col = new TextView(getContext()); TextView col = new TextView(getContext());
...@@ -158,14 +169,6 @@ public class TableHeaderView extends HorizontalScrollView { ...@@ -158,14 +169,6 @@ public class TableHeaderView extends HorizontalScrollView {
container.addView(header); container.addView(header);
this.handler = new RelativeLayout(getContext());
RelativeLayout.LayoutParams handlerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
handlerParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
handler.setLayoutParams(handlerParams);
ArrayList<View> headerViews = new ArrayList<>(); ArrayList<View> headerViews = new ArrayList<>();
header.findViewsWithText(headerViews, "column", FIND_VIEWS_WITH_CONTENT_DESCRIPTION); header.findViewsWithText(headerViews, "column", FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
for (View headerView : headerViews) { for (View headerView : headerViews) {
......
...@@ -16,7 +16,6 @@ import android.widget.TextView; ...@@ -16,7 +16,6 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import id.ac.stis.capi.R; import id.ac.stis.capi.R;
...@@ -38,7 +37,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -38,7 +37,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
private LinearLayout row; private LinearLayout row;
private List<InstanceValues> rows; private List<InstanceValues> rows;
private RelativeLayout separator, container; private RelativeLayout separator, container;
private int headerViewRef, footerViewRef, rowPadding, textSize, rowCount, pageCount, currentPage; private int headerViewRef, footerViewRef, rowPadding, textSize, rowCount, pageCount,
currentPage;
private TableHeaderView headerView; private TableHeaderView headerView;
private TableFooterView footerView; private TableFooterView footerView;
private OnClickListener onClickListener; private OnClickListener onClickListener;
...@@ -54,10 +54,14 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -54,10 +54,14 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TableRowView, TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TableRowView,
0, 0); 0, 0);
try { try {
setHeaderViewRef(a.getResourceId(R.styleable.TableRowView_tableHeaderView, getHeaderViewRef())); setHeaderViewRef(
setFooterViewRef(a.getResourceId(R.styleable.TableRowView_tableFooterView, getFooterViewRef())); a.getResourceId(R.styleable.TableRowView_tableHeaderView, getHeaderViewRef()));
setRowPadding(a.getDimensionPixelSize(R.styleable.TableRowView_rowPadding, getRowPadding())); setFooterViewRef(
setTextSize(a.getDimensionPixelSize(R.styleable.TableRowView_rowTextSize, getTextSize())); a.getResourceId(R.styleable.TableRowView_tableFooterView, getFooterViewRef()));
setRowPadding(
a.getDimensionPixelSize(R.styleable.TableRowView_rowPadding, getRowPadding()));
setTextSize(
a.getDimensionPixelSize(R.styleable.TableRowView_rowTextSize, getTextSize()));
} finally { } finally {
a.recycle(); a.recycle();
} }
...@@ -112,9 +116,9 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -112,9 +116,9 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
return currentPage; return currentPage;
} }
public void initView(List<InstanceValues> rows) { public void initView() {
this.rows = rows;
this.currentPage = 1; this.currentPage = 1;
this.rows = new ArrayList<>();
if (headerViewRef != 0) { if (headerViewRef != 0) {
headerView = getRootView().findViewById(headerViewRef); headerView = getRootView().findViewById(headerViewRef);
...@@ -199,11 +203,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -199,11 +203,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
row.removeAllViews(); row.removeAllViews();
int rowHeight = 0; int rowHeight = 0;
int availableHeight = container.getHeight(); int availableHeight =
container.getHeight() != 0 ? container.getHeight() : measureViewHeight(container);
int currIdx = this.rowCount * page - this.rowCount; int currIdx = this.rowCount * page - this.rowCount;
int maxIdx; int maxIdx;
if(this.rowCount != 0 && this.rowCount * page < rows.size()) { if (this.rowCount != 0 && this.rowCount * page < rows.size()) {
maxIdx = this.rowCount * page; maxIdx = this.rowCount * page;
} else { } else {
maxIdx = rows.size(); maxIdx = rows.size();
...@@ -234,7 +239,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -234,7 +239,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
LinearLayout.LayoutParams colParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams colParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
col.setPadding(18, 12 + getRowPadding(), 18, 12 + getRowPadding()); col.setPadding(18, 12 + getRowPadding(),
18, 12 + getRowPadding());
col.setEllipsize(TextUtils.TruncateAt.END); col.setEllipsize(TextUtils.TruncateAt.END);
col.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextSize()); col.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextSize());
col.setText(rowValue.getInstanceValue(rowValueKey)); col.setText(rowValue.getInstanceValue(rowValueKey));
...@@ -257,7 +263,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -257,7 +263,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
if (currIdx % 2 == 0) { if (currIdx % 2 == 0) {
column.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.white)); column.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.white));
} else { } else {
column.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.smoother_gray)); column.setBackgroundColor(
ContextCompat.getColor(getContext(), R.color.smoother_gray));
} }
final FrameLayout columnWrapper = new FrameLayout(getContext()); final FrameLayout columnWrapper = new FrameLayout(getContext());
...@@ -266,10 +273,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved ...@@ -266,10 +273,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
columnWrapper.setLayoutParams(columnWrapperParams); columnWrapper.setLayoutParams(columnWrapperParams);