Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy2626 committed May 23, 2019
1 parent fddf08a commit 7f851e3
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 179 deletions.
74 changes: 27 additions & 47 deletions app/src/main/java/com/lzy/flowlayoutdemo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.lzy.flowlayoutdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.lzy.flowlayout.CateBean;
import com.lzy.flowlayout.FlowLayoutDialog;
import com.lzy.flowlayout.Product;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {
Expand All @@ -17,50 +17,30 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

List<Product.Classify> classifies = new ArrayList<>();
classifies.add(new Product.Classify("年级", Arrays.asList(
new Product.Classify.Des("一年级"),
new Product.Classify.Des("二年级"),
new Product.Classify.Des("三年级"),
new Product.Classify.Des("四年级"),
new Product.Classify.Des("五年级"),
new Product.Classify.Des("六年级"))));
classifies.add(new Product.Classify("科目", Arrays.asList(new Product.Classify.Des("180"),
new Product.Classify.Des("175"),
new Product.Classify.Des("170"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("160"),
new Product.Classify.Des("155"),
new Product.Classify.Des("150"))));
classifies.add(new Product.Classify("科目", Arrays.asList(new Product.Classify.Des("180"),
new Product.Classify.Des("175"),
new Product.Classify.Des("170"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("160"),
new Product.Classify.Des("155"),
new Product.Classify.Des("150"))));
classifies.add(new Product.Classify("科目", Arrays.asList(new Product.Classify.Des("180"),
new Product.Classify.Des("175"),
new Product.Classify.Des("170"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("165"),
new Product.Classify.Des("160"),
new Product.Classify.Des("155"),
new Product.Classify.Des("150"))));
classifies.add(new Product.Classify("款式",
Arrays.asList(new Product.Classify.Des("男款"), new Product.Classify.Des("语文"),
new Product.Classify.Des("数学"),
new Product.Classify.Des("英语"))));

FlowLayoutDialog flowLayoutDialog = new FlowLayoutDialog(this, classifies);
List<CateBean> cateBeanList = new ArrayList<>();
CateBean cateBean = new CateBean();
cateBean.setCcid(1);
cateBean.setIdx(1);
cateBean.setName("年级");

List<CateBean.ChildcatelistBean> childcatelist = new ArrayList<>();
CateBean.ChildcatelistBean childcatelistBean = new CateBean.ChildcatelistBean();
childcatelistBean.setCccid(1);
childcatelistBean.setIdx(1);
childcatelistBean.setName("一年级");
childcatelist.add(childcatelistBean);

cateBean.setChildcatelist(childcatelist);
cateBeanList.add(cateBean);


FlowLayoutDialog flowLayoutDialog = new FlowLayoutDialog(this, cateBeanList);
flowLayoutDialog.setChooseResultListenner(new FlowLayoutDialog.ChooseResultListenner() {
@Override
public void onChooseResult(String cateids) {
Log.e("cateids", cateids);
}
});
flowLayoutDialog.show();


Expand Down
98 changes: 98 additions & 0 deletions flowlayout/src/main/java/com/lzy/flowlayout/CateBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.lzy.flowlayout;

import java.util.List;

/**
* Created by xiangcheng on 17/9/26.
*/

public class CateBean {
/**
* ccid : 1
* name : 颜色
* childcatelist : [{"name":"红","idx":1,"cccid":1},{"name":"黄","idx":2,"cccid":2}]
* idx : 1
*/

private int ccid;
private String name;
private int idx;
private List<ChildcatelistBean> childcatelist;

public int getCcid() {
return ccid;
}

public void setCcid(int ccid) {
this.ccid = ccid;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getIdx() {
return idx;
}

public void setIdx(int idx) {
this.idx = idx;
}

public List<ChildcatelistBean> getChildcatelist() {
return childcatelist;
}

public void setChildcatelist(List<ChildcatelistBean> childcatelist) {
this.childcatelist = childcatelist;
}

public static class ChildcatelistBean {
/**
* name : 红
* idx : 1
* cccid : 1
*/

private String name;
private int idx;
private int cccid;
private boolean isSelect;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getIdx() {
return idx;
}

public void setIdx(int idx) {
this.idx = idx;
}

public int getCccid() {
return cccid;
}

public void setCccid(int cccid) {
this.cccid = cccid;
}

public boolean isSelect() {
return isSelect;
}

public void setSelect(boolean select) {
isSelect = select;
}
}
}
24 changes: 19 additions & 5 deletions flowlayout/src/main/java/com/lzy/flowlayout/FlowLayoutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
Expand All @@ -16,12 +17,14 @@

public class FlowLayoutDialog extends AlertDialog {
private Context context;
private List<Product.Classify> classifies;
private List<CateBean> cateBeanList;
private ProductAdapter productAdapter;
private ChooseResultListenner chooseResultListenner;

public FlowLayoutDialog(Context context, List<Product.Classify> classifies) {
public FlowLayoutDialog(Context context, List<CateBean> cateBeanList) {
super(context);
this.context = context;
this.classifies = classifies;
this.cateBeanList = cateBeanList;
}

protected FlowLayoutDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
Expand All @@ -44,7 +47,8 @@ protected void onCreate(Bundle savedInstanceState) {
view.findViewById(R.id.ll_buttom).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
String cateIds = productAdapter.getSelectedCateIds();
chooseResultListenner.onChooseResult(cateIds);
}
});

Expand All @@ -58,10 +62,20 @@ public void onClick(View v) {

RecyclerView productView = (RecyclerView) findViewById(R.id.product_view);
productView.setLayoutManager(new LinearLayoutManager(context));
productView.setAdapter(new ProductAdapter(context, classifies));
productAdapter = new ProductAdapter(context, cateBeanList);
productView.setAdapter(productAdapter);

}

private int dp2px(float value) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics());
}

public void setChooseResultListenner(ChooseResultListenner chooseResultListenner) {
this.chooseResultListenner = chooseResultListenner;
}

public interface ChooseResultListenner {
void onChooseResult(String cateids);
}
}
31 changes: 0 additions & 31 deletions flowlayout/src/main/java/com/lzy/flowlayout/Product.java

This file was deleted.

75 changes: 0 additions & 75 deletions flowlayout/src/main/java/com/lzy/flowlayout/ProductActivity.java

This file was deleted.

Loading

0 comments on commit 7f851e3

Please sign in to comment.