mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,78 @@
|
|||
package com.adins.mss.base.scheme;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.dao.QuestionSet;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.foundation.db.dataaccess.QuestionSetDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.scheme.sync.SyncQuestionSet;
|
||||
import com.adins.mss.foundation.scheme.sync.SyncQuestionSetListener;
|
||||
import com.adins.mss.foundation.scheme.sync.SyncQuestionSetRequest;
|
||||
import com.adins.mss.foundation.scheme.sync.SyncQuestionSetResponse;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 28/12/2016.
|
||||
*/
|
||||
|
||||
public class SyncQuestionSetTask {
|
||||
|
||||
public static void syncQuestionSetInBackground(final Context activity) {
|
||||
List<VersionSchemeTaskBean> listVersionScheme = TaskHDataAccess.getAllVersionSchemeTask(activity);
|
||||
if(listVersionScheme != null){
|
||||
for (VersionSchemeTaskBean requestScehemeVersion : listVersionScheme){
|
||||
SyncQuestionSetRequest request = new SyncQuestionSetRequest();
|
||||
request.setForm_version(requestScehemeVersion.getFormVersion());
|
||||
request.setUuid_scheme(requestScehemeVersion.getUuidScheme());
|
||||
|
||||
SyncQuestionSet task = new SyncQuestionSet(activity, request, new SyncQuestionSetListener() {
|
||||
@Override
|
||||
public void onProgress() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(SyncQuestionSetResponse response) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SyncQuestionSetResponse response, String uuidScheme) {
|
||||
List<QuestionSet> questionSets = response.getListQuestionSet();
|
||||
List<QuestionSet> newquestionSets = new ArrayList<QuestionSet>();
|
||||
Scheme scheme = SchemeDataAccess.getOne(activity, uuidScheme);
|
||||
try {
|
||||
for (QuestionSet questionSet : questionSets) {
|
||||
questionSet
|
||||
.setUuid_question_set(Tool.getUUID());
|
||||
questionSet.setScheme(scheme);
|
||||
newquestionSets.add(questionSet);
|
||||
}
|
||||
List<String> listVersionScheme = TaskHDataAccess.getAllVersionSchemeTaskByUuidScheme(activity, scheme.getUuid_scheme());
|
||||
listVersionScheme.add(scheme.getForm_version());
|
||||
QuestionSetDataAccess.deleteBySchemeVersion(activity,
|
||||
scheme.getUuid_scheme(), listVersionScheme);
|
||||
QuestionSetDataAccess.addOrReplace(activity,
|
||||
scheme.getUuid_scheme(), newquestionSets);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
ACRA.getErrorReporter().putCustomData("errorSyncQuestionSetTask", e.getMessage());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Error: Insert Question Set. " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/taskListLayout">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/timelineItem">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="4">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/taskHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="5dp"
|
||||
app:cardElevation="5dp"
|
||||
android:layout_margin="3dp"
|
||||
app:cardBackgroundColor="@color/fontColorWhite">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
<ImageView
|
||||
android:id="@+id/initialIcon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/task_highpriority"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mmaLayout"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
android:id="@+id/accountName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Account"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_person_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/lastStatus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Status"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_info"
|
||||
android:drawablePadding="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/productName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Product"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_product"
|
||||
android:drawablePadding="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
<ImageView
|
||||
android:id="@+id/callIcon"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_phone_color"
|
||||
android:padding="2dp"
|
||||
android:layout_marginTop="10dp"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/taskLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:id="@+id/taskName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Name"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_person_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/taskAddress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Address"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_location_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/taskPhone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="Phone"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_phone_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/taskForm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Form"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:drawableLeft="@drawable/ic_form_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/collectionInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
<TextView
|
||||
android:id="@+id/taskAgreement"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/lblAgreementNo"
|
||||
android:textSize="12dp"
|
||||
android:drawableLeft="@drawable/ic_form_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/taskAmount"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="Amount Due"
|
||||
android:textSize="12dp"
|
||||
android:drawableLeft="@drawable/ic_cash_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/taskOverdue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="Overdue"
|
||||
android:textSize="12dp"
|
||||
android:drawableLeft="@drawable/ic_date_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
<TextView
|
||||
android:id="@+id/taskInst"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="Installment No"
|
||||
android:textSize="12dp"
|
||||
android:drawableLeft="@drawable/ic_no_color"
|
||||
android:drawablePadding="5dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/txtslatime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="TOM 11.45"
|
||||
android:textSize="11dp"
|
||||
android:drawableLeft="@drawable/ic_sla"
|
||||
android:drawablePadding="5dp"
|
||||
android:padding="5dp"
|
||||
android:background="@color/slaGreen"
|
||||
android:visibility="gone"/>
|
||||
<TextView
|
||||
android:id="@+id/txtSaveDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="end"
|
||||
android:text="11.45"
|
||||
android:textSize="11dp"
|
||||
android:paddingRight="5dp"
|
||||
android:drawableLeft="@drawable/ic_save_color"
|
||||
android:drawablePadding="5dp"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,51 @@
|
|||
package com.adins.mss.odr.accounts.adapter;
|
||||
|
||||
/**
|
||||
* Created by muhammad.aap on 11/30/2018.
|
||||
*/
|
||||
|
||||
public class LeadHistoryDetail {
|
||||
private String leadHistoryDate;
|
||||
private String leadHistoryProduct;
|
||||
private String leadCommVia;
|
||||
private String leadHistoryNotes;
|
||||
|
||||
public LeadHistoryDetail(String leadHistoryDate, String leadHistoryProduct, String leadCommVia, String leadHistoryNotes) {
|
||||
this.leadHistoryDate = leadHistoryDate;
|
||||
this.leadHistoryProduct = leadHistoryProduct;
|
||||
this.leadCommVia = leadCommVia;
|
||||
this.leadHistoryNotes = leadHistoryNotes;
|
||||
}
|
||||
|
||||
public String getLeadHistoryDate() {
|
||||
return leadHistoryDate;
|
||||
}
|
||||
|
||||
public void setLeadHistoryDate(String leadHistoryDate) {
|
||||
this.leadHistoryDate = leadHistoryDate;
|
||||
}
|
||||
|
||||
public String getLeadHistoryProduct() {
|
||||
return leadHistoryProduct;
|
||||
}
|
||||
|
||||
public void setLeadHistoryProduct(String leadHistoryProduct) {
|
||||
this.leadHistoryProduct = leadHistoryProduct;
|
||||
}
|
||||
|
||||
public String getLeadCommVia() {
|
||||
return leadCommVia;
|
||||
}
|
||||
|
||||
public void setLeadCommVia(String leadCommVia) {
|
||||
this.leadCommVia = leadCommVia;
|
||||
}
|
||||
|
||||
public String getLeadHistoryNotes() {
|
||||
return leadHistoryNotes;
|
||||
}
|
||||
|
||||
public void setLeadHistoryNotes(String leadHistoryNotes) {
|
||||
this.leadHistoryNotes = leadHistoryNotes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.adins.mss.coll.dashboardcollection.view;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.dashboardcollection.model.CollResultDetail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DashCollResultItemAdapter extends RecyclerView.Adapter<DashCollResultItemAdapter.DashboardCollResultVH> {
|
||||
|
||||
private Context context;
|
||||
private List<CollResultDetail> dataset;
|
||||
|
||||
public DashCollResultItemAdapter(Context context,List<CollResultDetail> dataset) {
|
||||
this.dataset = dataset;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DashboardCollResultVH onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dash_coll_result_item,viewGroup,false);
|
||||
DashboardCollResultVH viewHolder = new DashboardCollResultVH(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DashboardCollResultVH dashboardCollResultVH, int i) {
|
||||
dashboardCollResultVH.bind(dataset.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataset.size();
|
||||
}
|
||||
|
||||
public void notifyDataChange(List<CollResultDetail> dataset){
|
||||
this.dataset = dataset;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public class DashboardCollResultVH extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView agrNoTv;
|
||||
private TextView custNoTv;
|
||||
private TextView resultTv;
|
||||
|
||||
public DashboardCollResultVH(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
agrNoTv = itemView.findViewById(R.id.dashResultAgrNo);
|
||||
custNoTv = itemView.findViewById(R.id.dashResultCustNo);
|
||||
resultTv = itemView.findViewById(R.id.dashResult);
|
||||
}
|
||||
|
||||
public void bind(CollResultDetail item){
|
||||
if(item == null)
|
||||
return;
|
||||
agrNoTv.setText(item.getAgrNo());
|
||||
custNoTv.setText(item.getCustName());
|
||||
resultTv.setText(item.getResult());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.manuelpeinado.fadingactionbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public class Utils {
|
||||
public static int getDisplayHeight(Context context) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
@SuppressWarnings("deprecation")
|
||||
int displayHeight = wm.getDefaultDisplay().getHeight();
|
||||
return displayHeight;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,407 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions.viewholder;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.libs.nineoldandroids.view.ViewHelper;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 03/09/2016.
|
||||
*/
|
||||
public class ExpandableRecyclerView extends androidx.recyclerview.widget.RecyclerView {
|
||||
|
||||
public ExpandableRecyclerView(Context context) {
|
||||
super(context, null);
|
||||
initRecycler();
|
||||
}
|
||||
|
||||
public ExpandableRecyclerView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initRecycler();
|
||||
}
|
||||
|
||||
public ExpandableRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initRecycler();
|
||||
}
|
||||
|
||||
private void initRecycler() {
|
||||
setClipToPadding(false);
|
||||
setItemAnimator(new DefaultItemAnimator());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelable onSaveInstanceState() {
|
||||
//begin boilerplate code that allows parent classes to save state
|
||||
Parcelable superState = super.onSaveInstanceState();
|
||||
|
||||
SavedState ss = new SavedState(superState);
|
||||
//end
|
||||
|
||||
if (getAdapter() != null)
|
||||
ss.stateToSave = ((Adapter) this.getAdapter()).getExpandedGroups();
|
||||
|
||||
return ss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestoreInstanceState(Parcelable state) {
|
||||
//begin boilerplate code so parent classes can restore state
|
||||
if (!(state instanceof SavedState)) // if state is not instance of out SaveState just restore in reg way
|
||||
{
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
// else if cast him to SavedState
|
||||
|
||||
SavedState ss = (SavedState) state;
|
||||
super.onRestoreInstanceState(ss.getSuperState());
|
||||
//end
|
||||
|
||||
if (getAdapter() != null)
|
||||
((Adapter) getAdapter()).setExpandedGroups(ss.stateToSave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdapter(androidx.recyclerview.widget.RecyclerView.Adapter adapter) {
|
||||
if (!(adapter instanceof Adapter))
|
||||
throw new IllegalArgumentException("adapter has to be of type ExpandableRecyclerView.Adapter");
|
||||
super.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
public interface OnChildItemClickedListener {
|
||||
void onChildItemClicked(int group, int position);
|
||||
}
|
||||
|
||||
static class SavedState implements Parcelable {
|
||||
public static final SavedState EMPTY_STATE = new SavedState() {
|
||||
};
|
||||
//required field that makes Parcelables from a Parcel
|
||||
public static final Creator<SavedState> CREATOR =
|
||||
new Creator<SavedState>() {
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
SparseBooleanArray stateToSave;
|
||||
Parcelable superState;
|
||||
|
||||
SavedState() {
|
||||
superState = null;
|
||||
}
|
||||
|
||||
SavedState(Parcelable superState) {
|
||||
this.superState = superState != EMPTY_STATE ? superState : null;
|
||||
}
|
||||
|
||||
private SavedState(Parcel in) {
|
||||
Parcelable superState = in.readParcelable(ExpandableRecyclerView.class.getClassLoader());
|
||||
this.superState = superState != null ? superState : EMPTY_STATE;
|
||||
this.stateToSave = in.readSparseBooleanArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
out.writeParcelable(superState, flags);
|
||||
out.writeSparseBooleanArray(this.stateToSave);
|
||||
}
|
||||
|
||||
public Parcelable getSuperState() {
|
||||
return superState;
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class Adapter<CVH extends ViewHolder, GVH extends ViewHolder, C, G> extends RecyclerView.Adapter<ViewHolder> {
|
||||
|
||||
private static final int TYPE_HEADER = 0;
|
||||
SparseBooleanArray expanded = new SparseBooleanArray();
|
||||
private OnChildItemClickedListener onChildItemClickedListener;
|
||||
|
||||
public Adapter() {
|
||||
}
|
||||
|
||||
public boolean isExpanded(int group) {
|
||||
return expanded.get(group);
|
||||
}
|
||||
|
||||
SparseBooleanArray getExpandedGroups() {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
public void setExpandedGroups(SparseBooleanArray expanded) {
|
||||
this.expanded = expanded;
|
||||
}
|
||||
|
||||
public void expand(int group) {
|
||||
Utility.freeMemory();
|
||||
if (isExpanded(group))
|
||||
return;
|
||||
|
||||
// this lines of code calculate number of shown item in recycler view. also group is counting .
|
||||
int position = 0;
|
||||
for (int i = 0; i < group; i++) {
|
||||
position++;
|
||||
if (isExpanded(i))
|
||||
position += getChildItemCount(i);
|
||||
}
|
||||
position++; // this for percent group
|
||||
|
||||
notifyItemRangeInserted(position, getChildItemCount(group)); // notify recycler view for expanding
|
||||
expanded.put(group, true); // save expanding in sparce array
|
||||
}
|
||||
|
||||
public void collapse(int group) {
|
||||
Utility.freeMemory();
|
||||
if (!isExpanded(group)) // if is not expanded . so nothing to collapse.
|
||||
return;
|
||||
|
||||
int position = 0;
|
||||
for (int i = 0; i < group; i++) {
|
||||
position++;
|
||||
if (isExpanded(i))
|
||||
position += getChildItemCount(i); // item
|
||||
}
|
||||
position++;
|
||||
notifyItemRangeRemoved(position, getChildItemCount(group));
|
||||
expanded.put(group, false);
|
||||
}
|
||||
|
||||
public abstract int getGroupItemCount();
|
||||
|
||||
public abstract int getChildItemCount(int group);
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int count = 0;
|
||||
for (int i = 0; i <= getGroupItemCount(); i++) {
|
||||
count += isExpanded(i) ? getChildItemCount(i) + 1 : 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public abstract G getGroupItem(int position);
|
||||
|
||||
public abstract C getChildItem(int group, int position);
|
||||
|
||||
public Object getItem(int i) {
|
||||
int group = 0;
|
||||
while (group <= getGroupItemCount()) {
|
||||
if (i > 0 && !isExpanded(group)) {
|
||||
i--;
|
||||
group++;
|
||||
continue;
|
||||
}
|
||||
if (i > 0 && isExpanded(group)) {
|
||||
i--;
|
||||
if (i < getChildItemCount(group))
|
||||
return getChildItem(group, i);
|
||||
i -= getChildItemCount(group);
|
||||
group++;
|
||||
continue;
|
||||
}
|
||||
if (i == 0)
|
||||
return getGroupItem(group);
|
||||
}
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int i) {
|
||||
int group = 0;
|
||||
while (group <= getGroupItemCount()) {
|
||||
if (i > 0 && !isExpanded(group)) {
|
||||
i--;
|
||||
group++;
|
||||
continue;
|
||||
}
|
||||
if (i > 0 && isExpanded(group)) {
|
||||
i--;
|
||||
if (i < getChildItemCount(group)) {
|
||||
onBindChildViewHolder((CVH) holder, group, i);
|
||||
return;
|
||||
}
|
||||
i -= getChildItemCount(group);
|
||||
group++;
|
||||
continue;
|
||||
}
|
||||
if (i == 0) {
|
||||
onBindGroupViewHolder((GVH) holder, group);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return viewType == TYPE_HEADER ? onCreateGroupViewHolder(parent) : onCreateChildViewHolder(parent, viewType);
|
||||
}
|
||||
|
||||
protected abstract GVH onCreateGroupViewHolder(ViewGroup parent);
|
||||
|
||||
protected abstract CVH onCreateChildViewHolder(ViewGroup parent, int viewType);
|
||||
|
||||
public abstract int getChildItemViewType(int group, int position);
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
int group = 0;
|
||||
while (group <= getGroupItemCount()) {
|
||||
if (i > 0 && !isExpanded(group)) {
|
||||
i--;
|
||||
group++;
|
||||
continue;
|
||||
}
|
||||
if (i > 0 && isExpanded(group)) {
|
||||
i--;
|
||||
if (i < getChildItemCount(group))
|
||||
return getChildItemViewType(group, i);
|
||||
i -= getChildItemCount(group);
|
||||
group++;
|
||||
continue;
|
||||
}
|
||||
if (i == 0)
|
||||
return TYPE_HEADER;
|
||||
}
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
public void setOnChildItemClickedListener(OnChildItemClickedListener onItemClickedListener) {
|
||||
this.onChildItemClickedListener = onItemClickedListener;
|
||||
}
|
||||
|
||||
public void onBindChildViewHolder(CVH holder, final int group, final int position) {
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (Adapter.this.onChildItemClickedListener != null) {
|
||||
Adapter.this.onChildItemClickedListener.onChildItemClicked(group, position);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onBindGroupViewHolder(final GVH holder, final int group) {
|
||||
if (holder instanceof GroupViewHolder)
|
||||
((GroupViewHolder) holder).setExpanded(isExpanded(group));
|
||||
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isExpanded(group)) {
|
||||
collapse(group);
|
||||
if (holder instanceof GroupViewHolder)
|
||||
((GroupViewHolder) holder).collapse();
|
||||
} else {
|
||||
expand(group);
|
||||
if (holder instanceof GroupViewHolder)
|
||||
((GroupViewHolder) holder).expand();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class GroupViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public GroupViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public abstract void expand();
|
||||
|
||||
public abstract void collapse();
|
||||
|
||||
public abstract boolean isExpanded();
|
||||
|
||||
public abstract void setExpanded(boolean expanded);
|
||||
}
|
||||
|
||||
public static class SimpleGroupViewHolder extends GroupViewHolder {
|
||||
ImageView expandedIndicator;
|
||||
TextView text;
|
||||
private boolean expanded;
|
||||
|
||||
public SimpleGroupViewHolder(Context context) {
|
||||
super(View.inflate(context, R.layout.question_group_layout, null));
|
||||
|
||||
itemView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
expandedIndicator = (ImageView) itemView.findViewById(R.id.questionGroupExpandedIndicator);
|
||||
text = (TextView) itemView.findViewById(R.id.txtQuestionGroup);
|
||||
}
|
||||
|
||||
public void expand() {
|
||||
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
|
||||
animator.setInterpolator(new DecelerateInterpolator());
|
||||
animator.setDuration(200);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
ViewHelper.setRotation(expandedIndicator, 180 * (float) (animation.getAnimatedValue()));
|
||||
expandedIndicator.postInvalidate();
|
||||
}
|
||||
});
|
||||
animator.start();
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
public void collapse() {
|
||||
ValueAnimator animator = ValueAnimator.ofFloat(1, 0);
|
||||
animator.setInterpolator(new DecelerateInterpolator());
|
||||
animator.setDuration(200);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
ViewHelper.setRotation(expandedIndicator, 180 * (float) (animation.getAnimatedValue()));
|
||||
expandedIndicator.postInvalidate();
|
||||
}
|
||||
});
|
||||
animator.start();
|
||||
expanded = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpanded() {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
public void setExpanded(boolean expanded) {
|
||||
ViewHelper.setRotation(expandedIndicator, expanded ? 180 : 0);
|
||||
this.expanded = expanded;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text.getText().toString();
|
||||
}
|
||||
|
||||
public void setText(String t) {
|
||||
text.setText(t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,342 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions.viewholder;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.questiongenerator.OptionAnswerBean;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
import com.adins.mss.foundation.questiongenerator.form.QuestionView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 31/08/2016.
|
||||
*/
|
||||
public class DropdownQuestionViewHolder extends RecyclerView.ViewHolder implements TextWatcher, AdapterView.OnItemSelectedListener {
|
||||
public QuestionView mView;
|
||||
public TextView mQuestionLabel;
|
||||
public TextView mLookupEmpty;
|
||||
public AppCompatSpinner mSpinnLookup;
|
||||
public EditText mDescription;
|
||||
public QuestionBean bean;
|
||||
public FragmentActivity mActivity;
|
||||
public ImageView img;
|
||||
protected List<OptionAnswerBean> options;
|
||||
private LookupAdapter adapter;
|
||||
|
||||
@Deprecated
|
||||
public DropdownQuestionViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionDropdownLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionDropdownLabel);
|
||||
mLookupEmpty = (TextView) itemView.findViewById(R.id.questionDropdownEmpty);
|
||||
mSpinnLookup = (AppCompatSpinner) itemView.findViewById(R.id.spinnerQuestionList);
|
||||
mDescription = (EditText) itemView.findViewById(R.id.questionDropdownDescription);
|
||||
img = (ImageView) itemView.findViewById(R.id.img1);
|
||||
}
|
||||
|
||||
public DropdownQuestionViewHolder(View itemView, FragmentActivity activity) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionDropdownLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionDropdownLabel);
|
||||
mLookupEmpty = (TextView) itemView.findViewById(R.id.questionDropdownEmpty);
|
||||
mSpinnLookup = (AppCompatSpinner) itemView.findViewById(R.id.spinnerQuestionList);
|
||||
mDescription = (EditText) itemView.findViewById(R.id.questionDropdownDescription);
|
||||
img = (ImageView) itemView.findViewById(R.id.img1);
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
public void bind(final QuestionBean item, int number) {
|
||||
bean = item;
|
||||
options = bean.getOptionAnswers();
|
||||
String answerType = bean.getAnswer_type();
|
||||
String qLabel = number + ". " + bean.getQuestion_label();
|
||||
mQuestionLabel.setText(qLabel);
|
||||
if (bean.isReadOnly()) {
|
||||
mSpinnLookup.setClickable(false);
|
||||
mSpinnLookup.setEnabled(false);
|
||||
} else {
|
||||
mSpinnLookup.setClickable(true);
|
||||
mSpinnLookup.setEnabled(true);
|
||||
}
|
||||
int nextOptionIndex = -1;
|
||||
try {
|
||||
if (bean.getSelectedOptionAnswers() == null || bean.getSelectedOptionAnswers().size() == 0) {
|
||||
if (bean.isReadOnly()) {
|
||||
bean.setOptionAnswers(null);
|
||||
options = new ArrayList<>();
|
||||
img.setVisibility(View.GONE);
|
||||
} else {
|
||||
img.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
if (bean.isReadOnly())
|
||||
img.setVisibility(View.GONE);
|
||||
else
|
||||
img.setVisibility(View.VISIBLE);
|
||||
|
||||
String optionSelectedIdStr = QuestionBean.getAnswer(bean);
|
||||
OptionAnswerBean optionAnswerBean = new OptionAnswerBean();
|
||||
optionAnswerBean.setCode(mActivity.getString(R.string.promptChooseOne));
|
||||
optionAnswerBean.setLov_group(bean.getLov_group());
|
||||
optionAnswerBean.setValue(mActivity.getString(R.string.promptChooseOne));
|
||||
if (optionSelectedIdStr == null)
|
||||
optionSelectedIdStr = bean.getLovCode();
|
||||
if (options != null && options.size() > 0) {
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
OptionAnswerBean option = options.get(i);
|
||||
if (options.get(i).getValue().equals(mActivity.getString(R.string.promptChooseOne))){
|
||||
options.remove(i);
|
||||
options = bean.getOptionAnswers();
|
||||
}
|
||||
if (option.getCode().equalsIgnoreCase(optionSelectedIdStr)) { //this is the same option (based on id)
|
||||
nextOptionIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
options.add(0,optionAnswerBean);
|
||||
mLookupEmpty.setVisibility(View.GONE);
|
||||
} else {
|
||||
mLookupEmpty.setVisibility(View.VISIBLE);
|
||||
if (bean.isReadOnly()) {
|
||||
mLookupEmpty.setText(mActivity.getString(R.string.no_answer_found));
|
||||
} else {
|
||||
mLookupEmpty.setText(mActivity.getString(R.string.lookup_not_found));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
adapter = new LookupAdapter(mActivity, R.layout.spinner_style2, R.id.text_spin, options);
|
||||
adapter.setDropDownViewResource(R.layout.spinner_style);
|
||||
mSpinnLookup.setAdapter(adapter);
|
||||
|
||||
if (nextOptionIndex >= 0 && nextOptionIndex < options.size()) {
|
||||
mSpinnLookup.setSelection(nextOptionIndex);
|
||||
}
|
||||
|
||||
mSpinnLookup.setOnItemSelectedListener(this);
|
||||
|
||||
if (Global.AT_DROPDOWN_W_DESCRIPTION.equals(answerType)) {
|
||||
enableDescription(true);
|
||||
mDescription.addTextChangedListener(this);
|
||||
} else {
|
||||
enableDescription(false);
|
||||
}
|
||||
selectSavedOptionsFromBeans(bean.getSelectedOptionAnswers());
|
||||
mSpinnLookup.setFocusableInTouchMode(true);
|
||||
}
|
||||
|
||||
private void setSelectedOptionAnswer(OptionAnswerBean option) {
|
||||
List<OptionAnswerBean> selectedOptionAnswers = new ArrayList<OptionAnswerBean>();
|
||||
if (option != null) {
|
||||
option.setSelected(true);
|
||||
selectedOptionAnswers.add(option);
|
||||
bean.setLovCode(option.getCode());
|
||||
bean.setLookupId(option.getUuid_lookup());
|
||||
} else {
|
||||
bean.setLovCode(null);
|
||||
bean.setLookupId(null);
|
||||
}
|
||||
bean.setSelectedOptionAnswers(selectedOptionAnswers);
|
||||
}
|
||||
|
||||
private void selectSavedOptionsFromBeans(List<OptionAnswerBean> beans) {
|
||||
|
||||
if (beans != null) {
|
||||
for (OptionAnswerBean optAnsBean : beans) {
|
||||
String lovCode = optAnsBean.getCode();
|
||||
String description = null;
|
||||
if (Global.AT_DROPDOWN_W_DESCRIPTION.equals(bean.getAnswer_type()) ||
|
||||
Global.AT_RADIO_W_DESCRIPTION.equals(bean.getAnswer_type()) ||
|
||||
Global.AT_MULTIPLE_W_DESCRIPTION.equals(bean.getAnswer_type())) {
|
||||
description = bean.getAnswer();
|
||||
}
|
||||
if (lovCode==null){
|
||||
selectOption("",description);
|
||||
}else {
|
||||
selectOption(lovCode, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSelectedOptionToBean() {
|
||||
OptionAnswerBean selected = (OptionAnswerBean) mSpinnLookup.getSelectedItem();
|
||||
if (mDescription.getVisibility() == View.VISIBLE && !mDescription.getText().toString().trim().isEmpty()) {
|
||||
bean.setAnswer(mDescription.getText().toString().trim());
|
||||
} else {
|
||||
bean.setAnswer("");
|
||||
}
|
||||
setSelectedOptionAnswer(selected);
|
||||
}
|
||||
|
||||
private void selectOption(String lovCode, String desc) {
|
||||
int indexOfOption = -1;
|
||||
int i = 0;
|
||||
for (OptionAnswerBean optAnsBean : options) {
|
||||
if ("".equals(optAnsBean.getCode())){
|
||||
indexOfOption = -1;
|
||||
break;
|
||||
}else if (lovCode.equals(optAnsBean.getCode())) {
|
||||
indexOfOption = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (indexOfOption > -1) {
|
||||
if (mSpinnLookup != null) {
|
||||
mSpinnLookup.setSelection(i);
|
||||
}
|
||||
|
||||
if (desc != null) {
|
||||
enableDescription(true);
|
||||
mDescription.setText(bean.getAnswer());
|
||||
} else {
|
||||
enableDescription(false);
|
||||
}
|
||||
}else if (indexOfOption == -1){
|
||||
if (mSpinnLookup!=null){
|
||||
mSpinnLookup.setSelection(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableDescription(boolean enable) {
|
||||
if (enable) {
|
||||
if (null != bean.getMax_length() ) {
|
||||
InputFilter[] inputFilters = {new InputFilter.LengthFilter(
|
||||
bean.getMax_length() == 0 ? Global.DEFAULT_MAX_LENGTH : bean.getMax_length())};
|
||||
mDescription.setFilters(inputFilters);
|
||||
}
|
||||
mDescription.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!bean.isReadOnly())
|
||||
saveSelectedOptionToBean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (parent != null && view.getId() != 0) {
|
||||
//do your code here to avoid callback twice
|
||||
if (!bean.isReadOnly()) {
|
||||
List<OptionAnswerBean> tempSelectedItems = bean.getSelectedOptionAnswers();
|
||||
OptionAnswerBean newSelectedItem = (OptionAnswerBean) mSpinnLookup.getSelectedItem();
|
||||
if (tempSelectedItems != null && tempSelectedItems.size() > 0) {
|
||||
// if (!tempSelectedItems.get(0).getUuid_lookup().equals(newSelectedItem.getUuid_lookup())) {
|
||||
// mView.setChanged(true);
|
||||
// bean.setChange(true);
|
||||
// } else {
|
||||
// bean.setChange(false);
|
||||
if(!bean.isChange()) {
|
||||
if (tempSelectedItems.get(0).getUuid_lookup()==null||!tempSelectedItems.get(0).getUuid_lookup().equals(newSelectedItem.getUuid_lookup())) {
|
||||
mView.setChanged(true);
|
||||
bean.setChange(true);
|
||||
} else {
|
||||
bean.setChange(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bean.setChange(false);
|
||||
}
|
||||
saveSelectedOptionToBean();
|
||||
} else {
|
||||
bean.setChange(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
|
||||
public class LookupAdapter extends ArrayAdapter<OptionAnswerBean> {
|
||||
private Context context;
|
||||
private List<OptionAnswerBean> values;
|
||||
|
||||
public LookupAdapter(Context context, int resource, int textViewResourceId, List<OptionAnswerBean> objects) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
this.context = context;
|
||||
this.values = objects;
|
||||
}
|
||||
public class ViewHolder {
|
||||
public TextView nameTextView;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return values.size();
|
||||
}
|
||||
|
||||
public OptionAnswerBean getItem(int position) {
|
||||
return values.get(position);
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return getViewInternal(position, convertView, parent);
|
||||
// LayoutInflater inflater = mActivity.getLayoutInflater();
|
||||
// View view = inflater.inflate(R.layout.spinner_style2, parent, false);
|
||||
// TextView label = (TextView) view.findViewById(R.id.text_spin);
|
||||
// label.setText(values.get(position).getValue());
|
||||
// return label;
|
||||
}
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
return getViewInternal(position, convertView, parent);
|
||||
}
|
||||
// fungsi untuk wrap text opsi dropdown pada LOV
|
||||
private View getViewInternal(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
if (view == null) {
|
||||
LayoutInflater inflater = mActivity.getLayoutInflater();
|
||||
view = inflater.inflate(R.layout.spinner_style2, parent,false);
|
||||
ViewHolder viewHolder = new ViewHolder();
|
||||
viewHolder.nameTextView = (TextView) view.findViewById(R.id.text_spin);
|
||||
view.setTag(viewHolder);
|
||||
}
|
||||
ViewHolder holder = (ViewHolder) view.getTag();
|
||||
holder.nameTextView.setText(values.get(position).getValue());
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:visibility="visible"
|
||||
android:background="@color/bgColor">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:background="@drawable/header"
|
||||
app:titleTextAppearance="?android:attr/textAppearanceSmall"
|
||||
android:titleTextColor="@color/fontColorWhite"
|
||||
app:popupTheme="@style/AppTheme" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/toolbar"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
app:contentPadding="10dp"
|
||||
app:cardCornerRadius="5dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lblServerLinkId"
|
||||
android:textColor="@color/gradient_end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold"
|
||||
android:drawableLeft="@drawable/ic_globe"
|
||||
android:drawablePadding="5dp">
|
||||
</TextView>
|
||||
<EditText
|
||||
android:id="@+id/txtServerLink"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:hint="@string/lblServerLinkId"
|
||||
android:padding="10dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall">
|
||||
</EditText>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSaveLink"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="@string/btnSaveLink"
|
||||
android:textColor="@color/fontColorWhite"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:background="@drawable/button_background"
|
||||
android:layout_margin="5dp">
|
||||
</Button>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Add table
Add a link
Reference in a new issue