Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onResponse(Call<PhotoItemCollectionDao> call, Response<PhotoItemCollectionDao> response) {
- if(response.isSuccessful()){
- PhotoItemCollectionDao dao = response.body();
- secondFragment.setDao(dao.getData());
- layout = (LinearLayout) rootView.findViewById(R.id.index);
- int childs = 0;
- int temp=0;
- int temp2=0;
- LinearLayout a = new LinearLayout(getContext());
- a.setOrientation(LinearLayout.HORIZONTAL);
- int count=0;
- for(int i=0; i<dao.getData().size();i++){
- temp2=i;
- if(count%2==0) {
- a = new LinearLayout(getContext());
- a.setOrientation(LinearLayout.HORIZONTAL);
- }
- if(dao.getData().get(i).getParent().equals("")) {
- childs = 0;
- while (true) {
- if ((dao.getData().get(i).getNode() + "").equals(dao.getData().get(childs).getpNode()) || dao.getData().get(i).getStep() != null) {
- childs = 1000;
- break;
- }
- else if(childs == dao.getData().size() - 1) {
- childs = -1000;
- break;
- }
- childs++;
- }
- count += 1;
- if (temp == 0) {
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(300, 100);
- lp.weight = 3;
- View view = new View(getContext());
- a.addView(view, lp);
- lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- lp.weight = 3;
- Button button = new Button(getContext());
- if(childs==1000){
- button.setTag("normal");
- }
- else if(childs==-1000){
- button.setTag("unNormal");
- }
- button.setText(dao.getData().get(i).getAlbumnName());
- button.setBackgroundResource(R.drawable.button_grid2);
- button.setTextColor(Color.BLACK);
- button.setTextSize(20);
- button.setOnClickListener(clickListener);
- a.addView(button, lp);
- temp = 1;
- } else {
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- lp.weight = 3;
- Button button = new Button(getContext());
- if(childs==1000){
- button.setTag("normal");
- }
- else if(childs==-1000){
- button.setTag("unNormal");
- }
- button.setText(dao.getData().get(i).getAlbumnName());
- button.setBackgroundResource(R.drawable.button_grid2);
- button.setTextSize(20);
- button.setTextColor(Color.BLACK);
- button.setOnClickListener(clickListener);
- a.addView(button, lp);
- layout.addView(a);
- temp = 0;
- }
- childs = 0;
- }
- }if(temp==1){
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- lp.setMargins(0,0,0,0);
- lp.weight = 3;
- Button button = new Button(getContext());
- button.setText("");
- button.setBackgroundResource(R.drawable.button_grid2);
- button.setTextColor(Color.BLACK);
- button.setTextSize(20);
- button.setOnClickListener(clickListener);
- button.setVisibility(View.INVISIBLE);
- a.addView(button,lp);
- lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- lp.setMargins(0,0,0,0);
- layout.addView(a, lp);
- }
- }else{
- //handle
- try {
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement