Commit 0dc7f21c authored by rahadi's avatar rahadi

Added tree view on dependencies resolving

parent d03bb2de
package id.ac.stis.capi.lessthink.binders;
import android.view.View;
import android.widget.TextView;
import id.ac.stis.capi.R;
import me.texy.treeview.TreeNode;
import me.texy.treeview.base.BaseNodeViewBinder;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
private TextView mainText;
public FirstLevelNodeViewBinder(View itemView) {
super(itemView);
mainText = itemView.findViewById(R.id.text_main);
}
@Override
public int getLayoutId() {
return R.layout.item_node_first;
}
@Override
public void bindView(TreeNode treeNode) {
mainText.setText(treeNode.getValue().toString());
}
}
package id.ac.stis.capi.lessthink.binders;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.models.ModeTreeNode;
import me.texy.treeview.TreeNode;
import me.texy.treeview.base.BaseNodeViewBinder;
import me.texy.treeview.base.BaseNodeViewFactory;
......@@ -13,13 +19,51 @@ import me.texy.treeview.base.BaseNodeViewFactory;
public class NodeViewFactory extends BaseNodeViewFactory {
@Override
public BaseNodeViewBinder getNodeViewBinder(View view, int level) {
switch (level) {
case 0:
return new FirstLevelNodeViewBinder(view);
case 1:
return new FirstLevelNodeViewBinder(view);
default:
return null;
return new NodeViewBinder(view, level);
}
public class NodeViewBinder extends BaseNodeViewBinder {
private int level;
private TextView mainText, secondaryText;
private ImageView imageStatus;
public NodeViewBinder(View itemView, int level) {
super(itemView);
this.level = level;
this.mainText = itemView.findViewById(R.id.text_main);
this.secondaryText = itemView.findViewById(R.id.text_secondary);
this.imageStatus = itemView.findViewById(R.id.image_status);
}
@Override
public int getLayoutId() {
return R.layout.item_node_first;
}
@Override
public void bindView(TreeNode treeNode) {
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) itemView.getLayoutParams();
params.leftMargin = 64 * (level + 1);
params.rightMargin = 64 * (level + 1);
itemView.setLayoutParams(params);
mainText.setText(treeNode.getValue().toString());
if (treeNode instanceof ModeTreeNode) {
secondaryText.setText(((ModeTreeNode) treeNode).getValueId());
switch (((ModeTreeNode) treeNode).getMode()) {
case ModeTreeNode.DOWNLOADED:
imageStatus.setImageResource(R.drawable.ic_check_circle);
break;
case ModeTreeNode.QUEUED:
imageStatus.setImageResource(R.drawable.ic_download);
break;
}
} else {
secondaryText.setVisibility(View.GONE);
}
}
}
}
package id.ac.stis.capi.lessthink.models;
import me.texy.treeview.TreeNode;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class ModeTreeNode extends TreeNode {
public static final int DOWNLOADED = 0;
public static final int QUEUED = 1;
private int mode;
private String valueId;
public ModeTreeNode(String value, String valueId, int mode) {
super(value);
this.valueId = valueId;
this.mode = mode;
}
public String getValueId() {
return valueId;
}
public int getMode() {
return mode;
}
public void setMode(int mode) {
this.mode = mode;
}
}
......@@ -56,9 +56,9 @@ public class DependenciesResolverTask extends AsyncTask<List<FormDetails>, Strin
// Process the forms supplied by the execute() parameter
for (FormDetails fd : toResolve) {
List<DependencyDetails> details = processOneForm(fd, total, count++);
if (details.size() > 0) {
// if (details.size() > 0) {
result.put(fd, details);
}
// }
}
return result;
......@@ -171,9 +171,9 @@ public class DependenciesResolverTask extends AsyncTask<List<FormDetails>, Strin
List<FormDetails> evaluated = evaluateOneFormDependencies(evaluateMe,
k.formName, total, count++);
if (evaluated.size() > 0) {
// if (evaluated.size() > 0) {
result.put(k, evaluated);
}
// }
}
if (listener != null) {
......
......@@ -48,6 +48,11 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
private Fragment fragment;
private ArrayList<HashMap<String, String>> dataSet;
private ArrayList<HashMap<String, String>> dataSetOri;
private OnFormDeletedListener onFormDeletedListener;
public void setOnFormDeletedListener(OnFormDeletedListener onFormDeletedListener) {
this.onFormDeletedListener = onFormDeletedListener;
}
public CapiFormAdapter(Activity activity, Fragment fragment) {
this.context = activity;
......@@ -204,13 +209,17 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
deletedItems.put(HAS_BEEN_DOWNLOADED, "false");
dataSet.add(deletedItems);
notifyDataSetChanged();
if (onFormDeletedListener != null) {
onFormDeletedListener.onFormDelete(formIdKey);
}
}
private void showConfirmDelete(final int position) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Delete Form");
builder.setMessage("Are you sure to delete \"" + dataSet.get(position).get(FORMNAME) + "form?");
builder.setMessage("Are you sure to delete \"" + dataSet.get(position).get(FORMNAME) + "\" form?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
......@@ -290,4 +299,8 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
imgPattern = (ImageView) itemView.findViewById(R.id.image_pattern);
}
}
public interface OnFormDeletedListener {
void onFormDelete(String formId);
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
android:layout_height="match_parent"
android:background="@color/background">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!--<TextView-->
<!--android:id="@android:id/empty"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:gravity="center"-->
<!--android:text="@string/no_items_display"-->
<!--android:textSize="21sp" />-->
android:layout_height="wrap_content"
tools:listitem="@layout/collectiva_item_form" />
<ProgressBar
android:id="@+id/holder_progress_bar"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_centerInParent="true"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/recycler_view"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:layout_centerVertical="false"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp" />
<LinearLayout
android:id="@+id/holder_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@color/background"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp"
android:visibility="gone">
<ImageView
android:id="@+id/icon_message"
android:layout_width="50dp"
android:layout_height="70dp"
android:tint="@android:color/darker_gray"
app:srcCompat="@drawable/ic_sad_sorry"/>
app:srcCompat="@drawable/ic_sad_sorry" />
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sorry, internal error."/>
android:text="Sorry, internal error." />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<!--<TextView-->
<!--android:id="@android:id/empty"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:gravity="center"-->
<!--android:text="@string/no_items_display"-->
<!--android:textSize="21sp" />-->
</RelativeLayout>
\ No newline at end of file
......@@ -3,31 +3,49 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/image_icon"
android:id="@+id/image_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_folder" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/text_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="TextView"
android:textAllCaps="false"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/text_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="TextView"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
<ImageView
android:id="@+id/image_status"
android:id="@+id/image_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:srcCompat="@drawable/ic_download" />
</LinearLayout>
\ 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