@ -18,6 +18,7 @@ import android.support.v7.widget.RecyclerView;
import android.text.Editable ;
import android.text.TextUtils ;
import android.text.TextWatcher ;
import android.util.Log ;
import android.view.LayoutInflater ;
import android.view.MotionEvent ;
import android.view.View ;
@ -198,15 +199,18 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder . postNum . setText ( "" ) ;
holder . subject . setText ( currentPost . getSubject ( ) ) ;
holder . post . loadDataWithBaseURL ( "file:///android_asset/" , currentPost . getContent ( ) , "text/html" , "UTF-8" , null ) ;
if ( currentPost . getAttachedFiles ( ) ! = null & & currentPost . getAttachedFiles ( ) . size ( ) ! = 0 ) {
if ( ( currentPost . getAttachedFiles ( ) ! = null & & currentPost . getAttachedFiles ( ) . size ( ) ! = 0 )
| | ( currentPost . getLastEdit ( ) ! = null ) ) {
holder . bodyFooterDivider . setVisibility ( View . VISIBLE ) ;
holder . postFooter . removeAllViews ( ) ;
if ( currentPost . getAttachedFiles ( ) ! = null & & currentPost . getAttachedFiles ( ) . size ( ) ! = 0 ) {
int filesTextColor ;
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . M ) {
filesTextColor = context . getResources ( ) . getColor ( R . color . accent , null ) ;
} else //noinspection deprecation
filesTextColor = context . getResources ( ) . getColor ( R . color . accent ) ;
holder . postFooter . removeAllViews ( ) ;
for ( final ThmmyFile attachedFile : currentPost . getAttachedFiles ( ) ) {
final TextView attached = new TextView ( context ) ;
attached . setTextSize ( 10f ) ;
@ -227,6 +231,21 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder . postFooter . addView ( attached ) ;
}
}
if ( currentPost . getLastEdit ( ) ! = null & & currentPost . getLastEdit ( ) . length ( ) > 0 ) {
int lastEditTextColor ;
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . M ) {
lastEditTextColor = context . getResources ( ) . getColor ( R . color . white , null ) ;
} else //noinspection deprecation
lastEditTextColor = context . getResources ( ) . getColor ( R . color . white ) ;
final TextView lastEdit = new TextView ( context ) ;
lastEdit . setTextSize ( 12f ) ;
lastEdit . setText ( currentPost . getLastEdit ( ) ) ;
lastEdit . setTextColor ( lastEditTextColor ) ;
lastEdit . setPadding ( 0 , 3 , 0 , 3 ) ;
holder . postFooter . addView ( lastEdit ) ;
}
} else {
holder . bodyFooterDivider . setVisibility ( View . GONE ) ;
holder . postFooter . removeAllViews ( ) ;
@ -312,11 +331,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}
if ( ! currentPost . isDeleted ( ) ) {
//Sets graphics behavior
holder . header . setOnClickListener ( new View . OnClickListener ( ) {
holder . thumbnail . setOnClickListener ( new View . OnClickListener ( ) {
@Override
public void onClick ( View v ) {
//Clicking an expanded header starts profile activity
if ( viewProperties . get ( holder . getAdapterPosition ( ) ) [ isUserExtraInfoVisibile ] ) {
public void onClick ( View view ) {
//Clicking the thumbnail opens user's profile
Intent intent = new Intent ( context , ProfileActivity . class ) ;
Bundle extras = new Bundle ( ) ;
extras . putString ( BUNDLE_PROFILE_URL , currentPost . getProfileURL ( ) ) ;
@ -329,7 +347,11 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
intent . setFlags ( FLAG_ACTIVITY_NEW_TASK ) ;
context . startActivity ( intent ) ;
}
} ) ;
holder . header . setOnClickListener ( new View . OnClickListener ( ) {
@Override
public void onClick ( View v ) {
//Clicking the header makes it expand/collapse
boolean [ ] tmp = viewProperties . get ( holder . getAdapterPosition ( ) ) ;
tmp [ isUserExtraInfoVisibile ] = ! tmp [ isUserExtraInfoVisibile ] ;
viewProperties . set ( holder . getAdapterPosition ( ) , tmp ) ;
@ -341,7 +363,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@Override
public void onClick ( View v ) {
boolean [ ] tmp = viewProperties . get ( holder . getAdapterPosition ( ) ) ;
tmp [ 1 ] = false ;
tmp [ isUserExtraInfoVisibile ] = false ;
viewProperties . set ( holder . getAdapterPosition ( ) , tmp ) ;
TopicAnimations . animateUserExtraInfoVisibility ( v ) ;