1
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Illness;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/10/6.
|
||||
*/
|
||||
|
||||
public class IllAdapter extends RecyclerView.Adapter<IllnessHolder> {
|
||||
private List<String> mList;
|
||||
private Context context;
|
||||
|
||||
public IllAdapter(List<String> mList, Context context) {
|
||||
this.mList = mList;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IllnessHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.ill_item, parent, false);
|
||||
return new IllnessHolder(v, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(IllnessHolder holder, int position) {
|
||||
holder.bindView(mList.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public void deleteItem(int position) {
|
||||
mList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.bean.Illness;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -17,8 +21,39 @@ public class IllnessHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.text)
|
||||
TextView text;
|
||||
|
||||
public IllnessHolder(View itemView) {
|
||||
private IllAdapter adapter;
|
||||
|
||||
public IllnessHolder(View itemView, IllAdapter adapter) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
public void bindView(String illness, final int position) {
|
||||
text.setText(illness);
|
||||
text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(itemView.getContext())
|
||||
.setTitle("删除").setMessage("确定删除该项?");
|
||||
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
adapter.deleteItem(position);
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setCancelable(true);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -19,10 +21,14 @@ import android.widget.TextView;
|
||||
|
||||
import com.ToxicBakery.viewpager.transforms.CubeOutTransformer;
|
||||
import com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar;
|
||||
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
|
||||
import com.bigkoo.pickerview.view.OptionsPickerView;
|
||||
import com.cb.ratingbar.CBRatingBar;
|
||||
import com.example.ninefourone.nutritionmaster.NutritionMaster;
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.HomePagerAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.adapter.IllAdapter;
|
||||
import com.example.ninefourone.nutritionmaster.base.BaseActivity;
|
||||
import com.example.ninefourone.nutritionmaster.camera.ClassifierCamera;
|
||||
import com.example.ninefourone.nutritionmaster.modules.addinformation.AddInformationActivity;
|
||||
@@ -111,6 +117,16 @@ public class MainActivity extends BaseActivity {
|
||||
RoundCornerProgressBar weightBar;
|
||||
@BindView(R.id.tool_bar_nickname)
|
||||
TextView toolBarNickname;
|
||||
@BindView(R.id.ill_recycler_view)
|
||||
RecyclerView illRecyclerView;
|
||||
@BindView(R.id.ill_button)
|
||||
LinearLayout illButton;
|
||||
|
||||
|
||||
private OptionsPickerView illPicker;
|
||||
private ArrayList<String> illness = ConstantUtils.getIllness();
|
||||
private ArrayList<String> userIllness = new ArrayList<>();
|
||||
private IllAdapter illAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -142,6 +158,7 @@ public class MainActivity extends BaseActivity {
|
||||
initViewPager();
|
||||
initSearchView();
|
||||
initBMB();
|
||||
initIllnessRecycler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -497,4 +514,32 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化用户疾病list
|
||||
*/
|
||||
private void initIllnessRecycler() {
|
||||
illAdapter = new IllAdapter(userIllness, MainActivity.this);
|
||||
illRecyclerView.setLayoutManager(new GridLayoutManager(MainActivity.this, 2));
|
||||
illRecyclerView.setAdapter(illAdapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 疾病list点击事件
|
||||
*/
|
||||
@OnClick(R.id.ill_button)
|
||||
public void onViewClicked() {
|
||||
illPicker = new OptionsPickerBuilder(MainActivity.this, new OnOptionsSelectListener() {
|
||||
@Override
|
||||
public void onOptionsSelect(int options1, int options2, int options3, View v) {
|
||||
userIllness.add(illness.get(options1));
|
||||
illAdapter.notifyDataSetChanged();
|
||||
illButton.setBackgroundResource(0);
|
||||
}
|
||||
}).build();
|
||||
MessageUtils.MakeToast("dianjile");
|
||||
illPicker.setPicker(illness);
|
||||
illPicker.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,17 +140,10 @@ public class RecommendFragment extends BaseFragment {
|
||||
* 加载新数据
|
||||
*/
|
||||
private void addData() {
|
||||
// Logger.d("加载数据");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int flag = indexs[i % 4];
|
||||
RecommendFood recommendFood = new RecommendFood(1, "烧肉", "好吃", flag);
|
||||
adapter.getData().add(recommendFood);
|
||||
// if (flag == 2) {
|
||||
//
|
||||
// } else {
|
||||
// RecommendFood recommendFood = new RecommendFood(1, "烧肉", "好吃", flag);
|
||||
// adapter.getData().add(recommendFood);
|
||||
// }
|
||||
}
|
||||
adapter.loadMoreComplete();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.example.ninefourone.nutritionmaster.utils;
|
||||
import com.example.ninefourone.nutritionmaster.bean.ClassifyResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/26.
|
||||
@@ -298,4 +300,45 @@ public class ConstantUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<String, String> illnessMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
illnessMap.put("补肾", "肾调养食谱");
|
||||
illnessMap.put("糖尿病", "糖尿病食谱");
|
||||
illnessMap.put("结核病", "结核病食谱");
|
||||
illnessMap.put("骨质酥松症", "骨质疏松食谱");
|
||||
illnessMap.put("营养不良", "营养不良食谱");
|
||||
illnessMap.put("便秘", "便秘食谱");
|
||||
illnessMap.put("高血压", "高血压食谱");
|
||||
illnessMap.put("消化不良", "消化不良食谱");
|
||||
illnessMap.put("神经衰弱", "神经衰弱食谱");
|
||||
illnessMap.put("肾炎", "肾炎食谱");
|
||||
illnessMap.put("月经不调", "月经不调食谱");
|
||||
illnessMap.put("上火", "清热解毒食谱");
|
||||
illnessMap.put("贫血", "贫血食谱");
|
||||
illnessMap.put("多汗", "自汗盗汗食谱");
|
||||
illnessMap.put("咳嗽", "咳喘食谱");
|
||||
illnessMap.put("防暑", "防暑食谱");
|
||||
illnessMap.put("健忘", "健忘食谱");
|
||||
illnessMap.put("耳鸣", "耳鸣食谱");
|
||||
illnessMap.put("肺病", "肺调养食谱");
|
||||
illnessMap.put("冻疮", "冻疮食谱");
|
||||
illnessMap.put("利尿", "利尿食谱");
|
||||
illnessMap.put("头疼", "头痛食谱");
|
||||
illnessMap.put("口腔溃疡", "口腔溃疡食谱");
|
||||
illnessMap.put("祛痱", "祛痱食谱");
|
||||
illnessMap.put("感冒", "感冒食谱");
|
||||
illnessMap.put("前内腺疾病", "前列腺疾病食谱");
|
||||
illnessMap.put("鼻炎", "鼻炎食谱");
|
||||
illnessMap.put("跌打骨折", "跌打骨折食谱");
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIllness() {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
for (String key : illnessMap.keySet()) {
|
||||
arrayList.add(key);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
||||
12
app/src/main/res/drawable/ic_ill.xml
Normal file
12
app/src/main/res/drawable/ic_ill.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<vector android:height="24dp" android:viewportHeight="1024.0"
|
||||
android:viewportWidth="1025.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#CAF0F3" android:pathData="M1016.3,565.8l-2.6,-2.6c-20.5,-35.8 -67.8,-48.6 -103.7,-28.2l-147.2,85.8c-37.1,21.8 -84.5,9 -106.2,-28.2L514.6,345.6c-21.8,-37.1 -9,-84.5 28.2,-105l134.4,-78.1c35.8,-20.5 48.6,-67.8 28.2,-103.7C684.8,23 637.4,10.2 601.6,30.7L37.1,357.1c-34.6,19.2 -46.1,64 -26.9,98.6l2.6,2.6c20.5,35.8 67.8,48.6 103.7,28.2l162.6,-93.4c37.1,-21.8 83.2,-9 105,28.2l143.4,248.3c21.8,37.1 9,84.5 -28.2,105l-148.5,85.8c-35.8,20.5 -48.6,67.8 -28.2,103.7l1.3,2.6c19.2,34.6 64,46.1 98.6,26.9L989.4,665.6c34.6,-20.5 46.1,-65.3 26.9,-99.8z"/>
|
||||
<path android:fillColor="#F6B5B8" android:pathData="M906.2,564.5l-21.8,-12.8c-3.8,-2.6 -7.7,-7.7 -7.7,-12.8v-25.6c0,-5.1 2.6,-10.2 7.7,-12.8l21.8,-12.8c3.8,-2.6 10.2,-2.6 14.1,0l21.8,12.8c3.8,2.6 7.7,7.7 7.7,12.8v25.6c0,5.1 -2.6,10.2 -7.7,12.8l-21.8,12.8c-3.8,2.6 -9,2.6 -14.1,0zM139.5,529.9l-24.3,5.1c-5.1,1.3 -10.2,0 -14.1,-3.8L84.5,512c-3.8,-3.8 -5.1,-9 -2.6,-14.1L89.6,473.6c1.3,-5.1 5.1,-9 10.2,-10.2l24.3,-5.1c5.1,-1.3 10.2,0 14.1,3.8l16.6,19.2c3.8,3.8 5.1,9 2.6,14.1l-7.7,24.3c0,5.1 -5.1,9 -10.2,10.2z"/>
|
||||
<path android:fillColor="#39BDC9" android:pathData="M311,879.4l-17.9,-7.7c-2.6,-1.3 -3.8,-3.8 -3.8,-6.4l-2.6,-19.2c0,-2.6 1.3,-5.1 2.6,-6.4l15.4,-11.5c2.6,-1.3 5.1,-1.3 7.7,-1.3l17.9,7.7c2.6,1.3 3.8,3.8 3.8,6.4l2.6,19.2c0,2.6 -1.3,5.1 -2.6,6.4l-15.4,11.5c-2.6,2.6 -5.1,2.6 -7.7,1.3z"/>
|
||||
<path android:fillColor="#F6777A" android:pathData="M802.6,561.9s0,1.3 0,0z"/>
|
||||
<path android:fillColor="#C3D2D9" android:pathData="M94.7,389.1m-14.1,0a14.1,14.1 0,1 0,28.2 0,14.1 14.1,0 1,0 -28.2,0Z"/>
|
||||
<path android:fillColor="#C3D2D9" android:pathData="M705.3,290.6L175.4,290.6c-41,0 -75.5,-34.6 -75.5,-75.5v-3.8c0,-41 34.6,-75.5 75.5,-75.5h529.9c41,0 75.5,34.6 75.5,75.5v3.8c0,42.2 -33.3,75.5 -75.5,75.5zM755.2,213.8c0,-28.2 -23,-51.2 -51.2,-51.2L176.6,162.6c-28.2,0 -51.2,23 -51.2,51.2s23,51.2 51.2,51.2L704,265c28.2,0 51.2,-23 51.2,-51.2zM354.6,409.6c-32,0 -58.9,26.9 -58.9,58.9 0,32 26.9,58.9 58.9,58.9 32,0 58.9,-26.9 58.9,-58.9 0,-33.3 -25.6,-58.9 -58.9,-58.9zM354.6,501.8c-17.9,0 -33.3,-15.4 -33.3,-33.3 0,-17.9 15.4,-33.3 33.3,-33.3 17.9,0 33.3,15.4 33.3,33.3 0,17.9 -15.4,33.3 -33.3,33.3zM641.3,409.6c-32,0 -58.9,26.9 -58.9,58.9 0,32 26.9,58.9 58.9,58.9 32,0 58.9,-26.9 58.9,-58.9 0,-33.3 -26.9,-58.9 -58.9,-58.9zM641.3,501.8c-17.9,0 -33.3,-15.4 -33.3,-33.3 0,-17.9 15.4,-33.3 33.3,-33.3 17.9,0 33.3,15.4 33.3,33.3 0,17.9 -15.4,33.3 -33.3,33.3z"/>
|
||||
<path android:fillColor="#C3D2D9" android:pathData="M716.8,285.4c56.3,67.8 87,156.2 80.6,253.4 -12.8,174.1 -154.9,314.9 -329,325.1C261.1,876.8 89.6,714.2 89.6,510.7c0,-26.9 2.6,-53.8 9,-79.4 2.6,-9 -6.4,-17.9 -15.4,-15.4 -5.1,1.3 -9,5.1 -10.2,10.2 -9,37.1 -11.5,76.8 -9,116.5C79.4,729.6 234.2,879.4 421.1,890.9c220.2,12.8 401.9,-162.6 401.9,-378.9 0,-87 -29.4,-167.7 -79.4,-231.7l-26.9,5.1z"/>
|
||||
<path android:fillColor="#C3D2D9" android:pathData="M444.2,700.2h2.6c33.3,-7.7 67.8,-11.5 102.4,-11.5 35.8,0 69.1,3.8 102.4,11.5h6.4c16.6,0 19.2,-23 2.6,-26.9 -35.8,-7.7 -71.7,-11.5 -110.1,-11.5 -37.1,0 -74.2,3.8 -110.1,11.5 -14.1,3.8 -11.5,26.9 3.8,26.9z"/>
|
||||
<path android:fillColor="#64D5BD" android:pathData="M610.6,683.5c-19.2,-19.2 -19.2,-49.9 0,-69.1l253.4,-253.4c19.2,-19.2 49.9,-19.2 69.1,0 19.2,19.2 19.2,49.9 0,69.1L679.7,683.5c-19.2,19.2 -49.9,19.2 -69.1,0z"/>
|
||||
</vector>
|
||||
@@ -202,10 +202,24 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="25dp"
|
||||
android:background="#dc4444">
|
||||
>
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ill_button"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginRight="35dp"
|
||||
android:alpha="0.3"
|
||||
android:background="@drawable/ic_ill"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -2,21 +2,22 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:alpha="0.9"
|
||||
android:background="#f44f2a"
|
||||
android:gravity="center"
|
||||
android:padding="3dp">
|
||||
android:padding="1dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="18dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorPrimary"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textSize="11sp"
|
||||
android:textSize="8sp"
|
||||
tools:text="感冒" />
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user