This commit is contained in:
ScorpioMiku
2018-09-02 16:26:44 +08:00
parent 02ff5ecc97
commit 750d0bfabc
14 changed files with 59 additions and 11 deletions

View File

@@ -1,6 +1,8 @@
package com.example.ninefourone.nutritionmaster.adapter;
import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@@ -18,6 +20,16 @@ import java.util.ArrayList;
public class CardAdapter extends RecyclerView.Adapter<CardHolder> {
private Context context;
private ArrayList<String> mList;
private int[] picList = new int[]{
R.drawable.monday,
R.drawable.tuesday,
R.drawable.wednesday,
R.drawable.thursday,
R.drawable.friday,
R.drawable.saturday,
R.drawable.sunday
};
public CardAdapter(Context context, ArrayList<String> mList) {
this.context = context;
@@ -32,9 +44,10 @@ public class CardAdapter extends RecyclerView.Adapter<CardHolder> {
return cardHolder;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onBindViewHolder(CardHolder holder, int position) {
holder.bindView(mList.get(position));
holder.bindView(picList[position], mList.get(position), context);
}
@Override

View File

@@ -1,5 +1,8 @@
package com.example.ninefourone.nutritionmaster.adapter;
import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
@@ -7,6 +10,8 @@ import android.widget.TextView;
import com.example.ninefourone.nutritionmaster.R;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -23,13 +28,16 @@ public class CardHolder extends RecyclerView.ViewHolder {
TextView tvSign;
public CardHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
public void bindView(String text) {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void bindView(int picId, String text, Context context) {
tvName.setText(text);
ivPhoto.setImageDrawable(context.getDrawable(picId));
}
}

View File

@@ -14,6 +14,7 @@ import com.example.ninefourone.nutritionmaster.base.BaseFragment;
import com.example.ninefourone.nutritionmaster.cardconfig.CardConfig;
import com.example.ninefourone.nutritionmaster.cardconfig.CardItemTouchCallBack;
import com.example.ninefourone.nutritionmaster.cardconfig.SwipeCardLayoutManager;
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
import java.util.ArrayList;
@@ -68,8 +69,8 @@ public class CustomizationFragment extends BaseFragment {
@Override
protected void loadData() {
super.loadData();
for (int i = 0; i < 10; i++) {
mDataList.add(i + "");
for (int i = 1; i <= 7; i++) {
mDataList.add("" + ConstantUtils.arab2Chinese(i) + "美食普");
}
}

View File

@@ -1,8 +1,31 @@
package com.example.ninefourone.nutritionmaster.utils;
import java.util.ArrayList;
/**
* Created by ScorpioMiku on 2018/8/26.
*/
public class ConstantUtils {
public static String arab2Chinese(int number) {
switch (number) {
case 1:
return "";
case 2:
return "";
case 3:
return "";
case 4:
return "";
case 5:
return "";
case 6:
return "";
case 7:
return "";
default:
return "";
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

View File

@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="420dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
@@ -16,16 +17,17 @@
android:id="@+id/iv_photo"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="@drawable/foods" />
/>
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/iv_photo"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Rachel"
android:textColor="#000000"
android:textSize="18sp"
@@ -33,11 +35,12 @@
<TextView
android:id="@+id/tv_sign"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="其他"
android:textSize="10sp" />

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:gravity="center">
<android.support.v7.widget.RecyclerView
android:id="@+id/card_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_record">
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>