Created
March 29, 2018 11:04
-
-
Save pask23/1154f8bd4015542e70387beabe53e0c2 to your computer and use it in GitHub Desktop.
Android UI bullets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tutored.tutored.ui.userprofile.academicsQualification; | |
import android.view.View; | |
import com.pask.data.model.AcademicQualification; | |
import com.pask.data.model.dto.MessageEventDTO; | |
import com.pask.ui.userprofile.ExperienceFragment; | |
import com.pask.ui.userprofile.ExperienceRecyclerViewAdapter; | |
import com.pask.utils.TextUtils; | |
import org.greenrobot.eventbus.EventBus; | |
import java.util.List; | |
/** | |
* Created by pasquale on 23/05/2017. | |
*/ | |
public class AcademicQualificationAdapter extends ExperienceRecyclerViewAdapter<AcademicQualification> { | |
public AcademicQualificationAdapter(List<AcademicQualification> items) { | |
super(items); | |
} | |
@Override | |
public void onBindViewHolder(final ExperienceRecyclerViewAdapter.VH holder, int position) { | |
AcademicQualification academicQualification = super.getItem(position); | |
holder.mItem = academicQualification; | |
holder.mTitleView.setText(academicQualification.getUniversityName()); | |
holder.mContentView.setText(academicQualification.getFacultyName()+" - "+academicQualification.getCourseName()); | |
holder.mSubContentView.setText(TextUtils.getIntervalFromDate(academicQualification.getStartedAt(),academicQualification.getFinishedAt())); | |
if (holder instanceof ExperienceRecyclerViewAdapter.VHItem){ | |
((ExperienceRecyclerViewAdapter.VHItem)holder).mDownSegment.setVisibility(View.VISIBLE); | |
((ExperienceRecyclerViewAdapter.VHItem)holder).mNode.setVisibility(View.VISIBLE); | |
((ExperienceRecyclerViewAdapter.VHItem)holder).mUpSegment.setVisibility(View.VISIBLE); | |
if(position == mValues.size()-1) | |
((ExperienceRecyclerViewAdapter.VHItem)holder).mDownSegment.setVisibility(View.GONE); | |
} | |
else{ | |
((ExperienceRecyclerViewAdapter.VHHeader)holder).mNodePrimary.setVisibility(View.VISIBLE); | |
if(mValues.size()>1) | |
((ExperienceRecyclerViewAdapter.VHHeader)holder).mDownSegment.setVisibility(View.VISIBLE); | |
} | |
holder.mView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
EventBus.getDefault().post(new MessageEventDTO<AcademicQualification>().withTopic(ExperienceFragment.REQ_ACADEMIC).withItem((AcademicQualification)holder.mItem)); | |
} | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.TextView; | |
import com.pask.R; | |
import java.util.List; | |
import butterknife.BindView; | |
import butterknife.ButterKnife; | |
public abstract class ExperienceRecyclerViewAdapter<T> extends RecyclerView.Adapter<ExperienceRecyclerViewAdapter.VH> { | |
private static final int TYPE_HEADER = 0; | |
private static final int TYPE_ITEM = 1; | |
protected final List<T> mValues; | |
protected Context mContext; | |
public ExperienceRecyclerViewAdapter(List items) { | |
mValues = items; | |
} | |
@Override | |
public ExperienceRecyclerViewAdapter.VH onCreateViewHolder(ViewGroup parent, int viewType) { | |
View view = LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.fragment_experience, parent, false); | |
mContext = parent.getContext(); | |
if (viewType == TYPE_ITEM) { | |
return new VHItem(view); | |
} else { | |
return new VHHeader(view); | |
} | |
} | |
@Override | |
public int getItemCount() { | |
return mValues.size(); | |
} | |
@Override | |
public int getItemViewType(int position) { | |
if (isPositionHeader(position)) | |
return TYPE_HEADER; | |
return TYPE_ITEM; | |
} | |
private boolean isPositionHeader(int position) { | |
return position == 0; | |
} | |
protected T getItem(int position) { | |
return mValues.get(position); | |
} | |
public class VHItem extends VH { | |
@BindView(R.id.up_segment) | |
public View mUpSegment; | |
@BindView(R.id.node) | |
public View mNode; | |
public T mItem; | |
public VHItem(View view) { | |
super(view); | |
ButterKnife.bind(this,view); | |
} | |
@Override | |
public String toString() { | |
return super.toString() + " '" + mContentView.getText() + "'"; | |
} | |
} | |
public class VH extends RecyclerView.ViewHolder{ | |
public final View mView; | |
@BindView(R.id.title) | |
public TextView mTitleView; | |
@BindView(R.id.content) | |
public TextView mContentView; | |
@BindView(R.id.sub_content) | |
public TextView mSubContentView; | |
@BindView(R.id.down_segment) | |
public View mDownSegment; | |
public T mItem; | |
public VH(View view) { | |
super(view); | |
mView = view; | |
ButterKnife.bind(this,view); | |
} | |
} | |
public class VHHeader extends VH { | |
@BindView(R.id.node_primary) | |
public View mNodePrimary; | |
@BindView(R.id.node) | |
public View mNode; | |
public T mItem; | |
public VHHeader(View view) { | |
super(view); | |
ButterKnife.bind(this,view); | |
} | |
@Override | |
public String toString() { | |
return super.toString() + " '" + mContentView.getText() + "'"; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
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="80dp" | |
android:background="?android:attr/selectableItemBackground"> | |
<TextView | |
android:id="@+id/title" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginStart="@dimen/text_margin" | |
android:layout_marginEnd="8dp" | |
android:layout_marginTop="8dp" | |
android:textSize="12sp" | |
app:layout_constraintBottom_toTopOf="@id/content" | |
app:layout_constraintTop_toTopOf="parent" | |
tools:text="Sapienza Università di Roma" | |
app:layout_constraintLeft_toRightOf="@+id/guideline_vertical" /> | |
<TextView | |
android:id="@+id/content" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="@dimen/text_margin" | |
android:textAppearance="?attr/textAppearanceListItem" | |
app:layout_constraintBottom_toTopOf="@+id/sub_content" | |
app:layout_constraintLeft_toLeftOf="@+id/title" | |
app:layout_constraintTop_toBottomOf="@+id/title" | |
app:layout_constraintRight_toRightOf="parent" | |
android:maxLines="2" | |
android:ellipsize="end" | |
tools:text="Laurea Magistrale in Architettura indirizzo Architettura del paesaggio" /> | |
<TextView | |
android:id="@+id/sub_content" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="8dp" | |
android:layout_marginEnd="@dimen/text_margin" | |
android:textSize="12sp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintLeft_toLeftOf="@+id/title" | |
app:layout_constraintTop_toBottomOf="@+id/content" | |
tools:text="Mar 2014 - Dic 2015" /> | |
<View | |
android:id="@+id/up_segment" | |
android:layout_width="2dp" | |
android:layout_height="40dp" | |
android:layout_alignParentTop="true" | |
android:layout_marginStart="@dimen/text_margin" | |
android:background="@color/mediumGray" | |
app:layout_constraintLeft_toLeftOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintBottom_toTopOf="@+id/guideline_horizontal" | |
android:visibility="invisible"/> | |
<View | |
android:id="@+id/down_segment" | |
android:layout_width="2dp" | |
android:layout_height="40dp" | |
android:layout_alignParentBottom="true" | |
android:layout_centerHorizontal="true" | |
android:background="@color/mediumGray" | |
app:layout_goneMarginStart="@dimen/text_margin" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintLeft_toLeftOf="@+id/up_segment" | |
app:layout_constraintTop_toBottomOf="@+id/guideline_horizontal" | |
android:visibility="invisible"/> | |
<View | |
android:id="@+id/node_primary" | |
android:layout_width="20dp" | |
android:layout_height="20dp" | |
android:background="@drawable/double_point" | |
app:layout_goneMarginStart="@dimen/text_margin" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintBottom_toBottomOf="parent" | |
android:layout_marginStart="7dp" | |
app:layout_constraintLeft_toLeftOf="parent" | |
android:visibility="gone" | |
/> | |
<android.support.constraint.Guideline | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:id="@+id/guideline_vertical" | |
app:layout_constraintGuide_begin="16dp" | |
android:orientation="vertical" /> | |
<android.support.constraint.Guideline | |
android:id="@+id/guideline_horizontal" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal" | |
app:layout_constraintGuide_begin="40dp" /> | |
<View | |
android:id="@+id/node" | |
android:layout_width="12dp" | |
android:layout_height="12dp" | |
android:background="@drawable/point" | |
app:layout_goneMarginStart="@dimen/text_margin" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintBottom_toBottomOf="parent" | |
android:layout_marginStart="11dp" | |
app:layout_constraintLeft_toLeftOf="parent" | |
android:visibility="invisible"/> | |
</android.support.constraint.ConstraintLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment