Commit abd3d572 authored by rahadi's avatar rahadi

WIP: added pagination to TableView

parent 840cfb84
......@@ -41,7 +41,7 @@ public class ListingInstanceActivity extends AppCompatActivity {
tableHeaderView.setColumns(headerList);
Map<String, Map<String, String>> rowData = new LinkedHashMap<>();
for (int i = 0; i < 15; i++) {
for (int i = 0; i < 31; i++) {
Map<String, String> row = new LinkedHashMap<>();
row.put("no_sls", (i < 9 ? "00" : "0") + (i + 1));
row.put("no_bs", (i < 9 ? "00" : "0") + (i + 1));
......
package id.ac.stis.capi.lessthink.listeners;
import android.view.View;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface OnFooterNavigationListener {
int onGoToNextPage(View v);
int onGoToPrevPage(View v);
}
......@@ -10,7 +10,7 @@ import java.util.List;
import java.util.Set;
import id.ac.stis.capi.lessthink.listeners.DependenciesResolverListener;
import id.ac.stis.capi.lessthink.logics.DependencyDetails;
import id.ac.stis.capi.lessthink.models.DependencyDetails;
import id.ac.stis.capi.odk.application.Collect;
import id.ac.stis.capi.odk.dao.FormsDao;
import id.ac.stis.capi.odk.dto.Form;
......
......@@ -6,7 +6,6 @@ import android.graphics.PorterDuff;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
......@@ -16,6 +15,7 @@ import android.widget.TextView;
import android.widget.Toast;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.listeners.OnFooterNavigationListener;
/**
* Author : Rahadi Jalu
......@@ -25,8 +25,10 @@ import id.ac.stis.capi.R;
public class TableFooterView extends RelativeLayout implements View.OnClickListener {
private ImageView addButton;
private TextView currPage;
private LinearLayout pageIndicator, navigationWrapper;
private int textSize, componentColor, footerColor;
private int textSize, componentColor, footerColor, currentPage, pageCount;
private OnFooterNavigationListener onFooterNavigationListener;
public TableFooterView(Context context, AttributeSet attrs) {
super(context, attrs);
......@@ -34,6 +36,12 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
this.textSize = 12;
this.componentColor = ContextCompat.getColor(getContext(), R.color.white);
this.footerColor = ContextCompat.getColor(getContext(), R.color.accent);
this.currentPage = 1;
this.pageCount = 1;
if (getId() == NO_ID) {
setId(R.id.row_view_footer_id);
}
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TableFooterView,
0, 0);
......@@ -69,11 +77,11 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
pageIndicator.addView(page);
TextView currPage = new TextView(getContext());
currPage = new TextView(getContext());
currPage.setTextColor(getComponentColor());
currPage.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextSize());
currPage.setText("1 of 3");
currPage.setText("1 of 1");
pageIndicator.addView(currPage);
......@@ -147,6 +155,15 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
addView(addButton);
}
public void setPageCountInfo(int pageCount) {
this.pageCount = pageCount;
currPage.setText(currentPage + " of " + pageCount);
}
public void setOnFooterNavigationListener(OnFooterNavigationListener onFooterNavigationListener) {
this.onFooterNavigationListener = onFooterNavigationListener;
}
public int getTextSize() {
return textSize;
}
......@@ -184,10 +201,22 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
Toast.makeText(getContext(), "ADD", Toast.LENGTH_LONG).show();
break;
case R.id.footer_view_prev_button:
Toast.makeText(getContext(), "PREV", Toast.LENGTH_LONG).show();
// Toast.makeText(getContext(), "PREV", Toast.LENGTH_LONG).show();
if (onFooterNavigationListener != null) {
this.currentPage = onFooterNavigationListener.onGoToPrevPage(view);
}
currPage.setText(currentPage + " of " + pageCount);
break;
case R.id.footer_view_next_button:
Toast.makeText(getContext(), "NEXT", Toast.LENGTH_LONG).show();
// Toast.makeText(getContext(), "NEXT", Toast.LENGTH_LONG).show();
if (onFooterNavigationListener != null) {
this.currentPage = onFooterNavigationListener.onGoToNextPage(view);
}
currPage.setText(currentPage + " of " + pageCount);
break;
}
}
......
......@@ -179,14 +179,14 @@ public class TableHeaderView extends HorizontalScrollView {
getHandleSize(), getHandleSize());
hand.setLayoutParams(handParams);
hand.setPadding(10, 10, 10, 10);
hand.setPadding(15, 15, 15, 15);
hand.setImageResource(R.drawable.ic_dot);
hand.setColorFilter(getComponentColor(), PorterDuff.Mode.MULTIPLY);
handler.addView(hand);
setHandlerPosition();
setDragBehaviour(key);
setDragBehavior(key);
}
container.addView(handler);
......@@ -195,7 +195,7 @@ public class TableHeaderView extends HorizontalScrollView {
requestLayout();
}
private void setDragBehaviour(final String key) {
private void setDragBehavior(final String key) {
final View handler = this.handler.findViewWithTag(key);
final TextView column = this.header.findViewWithTag(key);
......
......@@ -23,7 +23,7 @@ import org.kxml2.kdom.Document;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.logics.DependencyDetails;
import id.ac.stis.capi.lessthink.models.DependencyDetails;
import id.ac.stis.capi.odk.application.Collect;
import java.io.File;
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
......@@ -10,11 +10,9 @@
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:theme="@style/AppTheme.NoActionBar.AppBarOverlay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
android:theme="@style/AppTheme.NoActionBar.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
......@@ -32,26 +30,21 @@
<id.ac.stis.capi.lessthink.views.TableRowView
android:id="@+id/row_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/footer_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/footer_view"
android:layout_below="@+id/appBarLayout"
app:rowPadding="4dp"
app:tableFooterView="@+id/footer_view"
app:tableHeaderView="@+id/header_view">
</id.ac.stis.capi.lessthink.views.TableRowView>
<id.ac.stis.capi.lessthink.views.TableFooterView
android:id="@+id/footer_view"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/row_view"
app:tableRowView="@+id/row_view" />
android:layout_alignParentBottom="true" />
<!--<id.ac.stis.capi.lessthink.views.ListingTableView-->
<!--android:id="@+id/listingTableView"-->
......@@ -60,10 +53,6 @@
<!--app:header_color="@color/colorPrimary"-->
<!--app:header_text_color="@color/white"-->
<!--app:header_padding="10dp"-->
<!--app:layout_constraintBottom_toBottomOf="parent"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toBottomOf="@+id/appBarLayout"-->
<!--app:row_padding="10dp" />-->
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
</RelativeLayout>
\ No newline at end of file
......@@ -10,13 +10,13 @@
<declare-styleable name="TableRowView">
<attr name="rowTextSize" format="dimension" />
<attr name="tableHeaderView" format="reference" />
<attr name="tableFooterView" format="reference" />
<attr name="rowPadding" format="dimension" />
</declare-styleable>
<declare-styleable name="TableFooterView">
<attr name="footerComponentColor" format="color" />
<attr name="footerColor" format="color" />
<attr name="tableRowView" format="reference" />
<attr name="footerTextSize" format="dimension" />
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -5,5 +5,5 @@
<item name="footer_view_next_button" type="id"/>
<item name="footer_view_add_button" type="id"/>
<item name="row_view_header_id" type="id"/>
<item name="footer_view_row_id" type="id"/>
<item name="row_view_footer_id" type="id"/>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment