mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-15 06:40:58 +00:00
show notes in card view
This commit is contained in:
@@ -30,7 +30,7 @@ import org.houxg.leamonax.service.NoteService;
|
||||
import org.houxg.leamonax.utils.DisplayUtils;
|
||||
import org.houxg.leamonax.utils.NetworkUtils;
|
||||
import org.houxg.leamonax.utils.ToastUtils;
|
||||
import org.houxg.leamonax.widget.DashDividerDecoration;
|
||||
import org.houxg.leamonax.widget.DividerDecoration;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -79,11 +79,7 @@ public class NoteFragment extends Fragment implements NoteAdapter.NoteAdapterLis
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(container.getContext());
|
||||
mNoteListView.setLayoutManager(layoutManager);
|
||||
mNoteListView.setItemAnimator(new DefaultItemAnimator());
|
||||
|
||||
int dashGap = DisplayUtils.dp2px(container.getContext(), 4);
|
||||
int dashWidth = DisplayUtils.dp2px(container.getContext(), 8);
|
||||
int height = DisplayUtils.dp2px(container.getContext(), 1);
|
||||
mNoteListView.addItemDecoration(new DashDividerDecoration(0xffa0a0a0, dashGap, dashWidth, height));
|
||||
mNoteListView.addItemDecoration(new DividerDecoration(DisplayUtils.dp2px(container.getContext(), 8)));
|
||||
mAdapter = new NoteAdapter(this);
|
||||
mNoteListView.setAdapter(mAdapter);
|
||||
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package org.houxg.leamonax.widget;
|
||||
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
public class DividerDecoration extends RecyclerView.ItemDecoration {
|
||||
private int mDividerSize;
|
||||
|
||||
public DividerDecoration(int dividerSize) {
|
||||
mDividerSize = dividerSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int pos = parent.getChildAdapterPosition(view);
|
||||
int top = pos == 0 ? mDividerSize : 0;
|
||||
outRect.set(mDividerSize, top, mDividerSize, mDividerSize);
|
||||
}
|
||||
}
|
5
app/src/main/res/drawable/shape_changed.xml
Normal file
5
app/src/main/res/drawable/shape_changed.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="6dp" />
|
||||
<solid android:color="#FFB74D" />
|
||||
</shape>
|
@@ -1,11 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
@@ -16,43 +28,6 @@
|
||||
android:textSize="20sp"
|
||||
tools:text="Leanote API" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dirty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/changed"
|
||||
android:textColor="#FFA726"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_update_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:textColor="@color/hint_text_light"
|
||||
android:textSize="12sp"
|
||||
tools:text="9-18 23:23" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_notebook"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/hint_text_light"
|
||||
android:textSize="12sp"
|
||||
tools:text="Gradle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="match_parent"
|
||||
@@ -64,4 +39,63 @@
|
||||
android:textColor="#9E9E9E"
|
||||
android:textSize="14sp"
|
||||
tools:text="Enim consequat enim pariatur id anim Ut Excepteur dolor in laborum incididunt veniam quis proident. in consequat aliquip in minim adipisicing exercitation sunt sed qui pariatur consequat commodo ea do." />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="#BDBDBD" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dirty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/shape_changed"
|
||||
android:fontFamily="sans-serif"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingTop="2dp"
|
||||
android:text="@string/changed"
|
||||
android:textColor="#fff"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_update_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:textColor="@color/hint_text_light"
|
||||
android:textSize="12sp"
|
||||
tools:text="9-18 23:23" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_notebook"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/hint_text_light"
|
||||
android:textSize="12sp"
|
||||
tools:text="Gradle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</android.support.v7.widget.CardView>
|
Reference in New Issue
Block a user