Browse Source

Recyclerview layout changes

pull/24/head
Ezerous 8 years ago
parent
commit
603c761ebe
  1. 18
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java
  2. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
  3. 16
      app/src/main/res/layout/fragment_forum_board_row.xml
  4. 30
      app/src/main/res/layout/fragment_forum_category_row.xml
  5. 15
      app/src/main/res/layout/fragment_recent_row.xml
  6. 3
      app/src/main/res/values/colors.xml

18
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java

@ -69,34 +69,16 @@ class ForumAdapter extends ExpandableRecyclerAdapter<Category, Board, ForumAdapt
class CategoryViewHolder extends ParentViewHolder { class CategoryViewHolder extends ParentViewHolder {
private TextView categoryTextview; private TextView categoryTextview;
private ImageView arrowImageView;
CategoryViewHolder(View itemView) { CategoryViewHolder(View itemView) {
super(itemView); super(itemView);
categoryTextview = (TextView) itemView.findViewById(R.id.category); categoryTextview = (TextView) itemView.findViewById(R.id.category);
arrowImageView = (ImageView) itemView.findViewById(R.id.arrow); //todo animated arrow up/down
arrowImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isExpanded()) {
collapseView();
} else {
expandView();
}
}
});
} }
void bind(Category category) { void bind(Category category) {
categoryTextview.setText(category.getName()); categoryTextview.setText(category.getName());
} }
@Override
public boolean shouldItemViewClickToggleExpansion() {
return false;
}
} }
class BoardViewHolder extends ChildViewHolder { class BoardViewHolder extends ChildViewHolder {

7
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java

@ -2,6 +2,7 @@ package gr.thmmy.mthmmy.activities.main.forum;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -129,7 +130,11 @@ public class ForumFragment extends BaseFragment
}); });
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.list); RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(rootView.findViewById(R.id.list).getContext())); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
linearLayoutManager.getOrientation());
recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setAdapter(forumAdapter); recyclerView.setAdapter(forumAdapter);
} }

16
app/src/main/res/layout/fragment_forum_board_row.xml

@ -1,16 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingEnd="4dp" android:background="@color/primary_lighter">
android:paddingStart="4dp">
<TextView <TextView
android:id="@+id/board" android:id="@+id/board"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceListItem" android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/primary_text"/> android:textColor="@color/accent"
android:textSize="16sp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:gravity="center_horizontal"
android:padding="8dp"/>
</LinearLayout> </LinearLayout>

30
app/src/main/res/layout/fragment_forum_category_row.xml

@ -1,27 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingEnd="4dp" android:orientation="vertical"
android:paddingStart="4dp"> android:background="@color/primary_light">
<TextView <TextView
android:id="@+id/category" android:id="@+id/category"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:textAppearance="?attr/textAppearanceListItem" android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/accent"/> android:textColor="@color/primary_text"
android:textSize="20sp"
android:background="?attr/selectableItemBackground"
android:gravity="center_horizontal"
android:padding="8dp"/>
<ImageView </LinearLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
app:srcCompat="@android:drawable/arrow_down_float"
android:id="@+id/arrow"
android:contentDescription="arrow" />
</RelativeLayout>

15
app/src/main/res/layout/fragment_recent_row.xml

@ -5,21 +5,10 @@
android:orientation="vertical" android:orientation="vertical"
> >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="0dp"
card_view:cardBackgroundColor="?attr/cardBackgroundColor">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:background="@color/primary_light"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:paddingBottom="6dp" android:paddingBottom="6dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
@ -61,5 +50,5 @@
android:textColor="@color/secondary_text" android:textColor="@color/secondary_text"
android:textStyle="italic"/> android:textStyle="italic"/>
</RelativeLayout> </RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout> </LinearLayout>

3
app/src/main/res/values/colors.xml

@ -26,7 +26,8 @@
<!--Dark--> <!--Dark-->
<color name="primary">#2B2B2B</color> <color name="primary">#2B2B2B</color>
<color name="primary_dark">#333333</color> <color name="primary_dark">#333333</color>
<color name="primary_light">#3C3F41</color> <color name="primary_light">#3C3C3C</color>
<color name="primary_lighter">#454545</color>
<color name="accent">#26A69A</color> <color name="accent">#26A69A</color>
<color name="primary_text">#E7E7E7</color> <color name="primary_text">#E7E7E7</color>
<color name="secondary_text">#757575</color> <color name="secondary_text">#757575</color>

Loading…
Cancel
Save