public void init() {
    tb_title = (TextView) findViewById(R.id.tb_title);
    tb_back = (TextView) findViewById(R.id.tb_back);
    tv_empty = (TextView) findViewById(R.id.tv_empty);
    progress_bar = (LinearLayout) findViewById(R.id.progress_bar);
    progress_bar.setVisibility(View.VISIBLE);

    tb_back.setText("我的");
    tb_title.setText("我的助人");
    tb_back.setOnClickListener(this);

    swipeRefresh = (SwipeRefreshX) findViewById(R.id.swipeRefresh);

    swipeRefresh.setColorSchemeResources(
        android.R.color.holo_blue_bright,
        android.R.color.holo_green_light,
        android.R.color.holo_orange_light,
        android.R.color.holo_red_light);
    listView = (ListView) findViewById(R.id.lv_mymission);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent();
            intent.setClass(MyMissionActivity.this, OrderDetailsActivity.class);

            OrderDetails orderDetails = (OrderDetails) parent.getAdapter().getItem(position);
            Bundle bundle = new Bundle();
            bundle.putSerializable("OrderDetails", orderDetails);
            bundle.putString("From", "MyOrder");
            intent.putExtras(bundle);

            startActivity(intent);
          }
        });
  }
  private void init() {
    et_search = (EditText) findViewById(R.id.et_search);
    tb_back = (TextView) findViewById(R.id.tb_back);
    lv_mysearch = (ListView) findViewById(R.id.lv_mysearch);
    tb_back.setText("添加好友");
    tb_back.setOnClickListener(this);
    swipeRefresh = (SwipeRefreshX) findViewById(R.id.swipeRefresh);

    swipeRefresh.setColorSchemeResources(
        android.R.color.holo_blue_bright,
        android.R.color.holo_green_light,
        android.R.color.holo_orange_light,
        android.R.color.holo_red_light);
    lv_mysearch.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent();
            intent.setClass(SearchFriendsActivity.this, FriendsInfoActivity.class);
            UserDetail userDetail = (UserDetail) parent.getAdapter().getItem(position);
            Bundle bundle = new Bundle();
            bundle.putSerializable("UserDetail", userDetail);
            bundle.putBoolean("AddFriend", true);
            intent.putExtras(bundle);
            startActivity(intent);
          }
        });
    et_search.addTextChangedListener(textWatcher);

    // 下拉刷新监听器
    swipeRefresh.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {

          @Override
          public void onRefresh() {

            Map<String, String> map = new HashMap<String, String>();
            map.put("Page", "1");
            map.put("Size", String.valueOf(AppConfig.ORDER_SIZE));
            map.put("KeyWord", URLEncoder.encode(et_search.getText().toString()));
            Http.request(
                SearchFriendsActivity.this,
                API.SEARCH_USER,
                new Object[] {Http.getURL(map)},
                new Http.RequestListener<List<UserDetail>>() {
                  @Override
                  public void onSuccess(final List<UserDetail> result) {
                    super.onSuccess(result);
                    page = 1;
                    swipeRefresh.setRefreshing(false);
                    swipeRefreshXUser = new SwipeRefreshXUser(SearchFriendsActivity.this, result);
                    lv_mysearch.setAdapter(swipeRefreshXUser);
                  }

                  @Override
                  public void onFail(String code) {
                    super.onFail(code);
                    swipeRefresh.setRefreshing(false);
                  }
                });
          }
        });
    // 加载监听器
    swipeRefresh.setOnLoadListener(
        new SwipeRefreshX.OnLoadListener() {

          @Override
          public void onLoad() {

            page++;
            Map<String, String> map = new HashMap<String, String>();
            map.put("Page", String.valueOf(page));
            map.put("Size", String.valueOf(AppConfig.ORDER_SIZE));
            map.put("KeyWord", URLEncoder.encode(et_search.getText().toString()));
            Http.request(
                SearchFriendsActivity.this,
                API.SEARCH_USER,
                new Object[] {Http.getURL(map)},
                new Http.RequestListener<List<UserDetail>>() {
                  @Override
                  public void onSuccess(final List<UserDetail> result) {
                    super.onSuccess(result);
                    if (result != null) {

                      loadMore(swipeRefreshXUser, result);
                    }
                    swipeRefresh.setLoading(false);
                  }

                  @Override
                  public void onFail(String code) {
                    super.onFail(code);
                    swipeRefresh.setLoading(false);
                  }
                });
          }
        });
  }
  public void initdata() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("Page", "1");
    map.put("Size", String.valueOf(AppConfig.ORDER_SIZE));
    map.put("Type", String.valueOf("1"));
    Http.request(
        MyMissionActivity.this,
        API.GET_SELFORDER,
        new Object[] {Http.getURL(map)},
        new Http.RequestListener<List<OrderDetails>>() {
          @Override
          public void onSuccess(List<OrderDetails> result) {
            super.onSuccess(result);
            progress_bar.setVisibility(View.GONE);
            swipeRefreshXMyMissionAdapater =
                new SwipeRefreshXMyMissionAdapater(MyMissionActivity.this, result);
            listView.setAdapter(swipeRefreshXMyMissionAdapater);
            if (result != null && result.size() != 0) {
              tv_empty.setVisibility(View.GONE);
            } else {
              tv_empty.setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void onFail(String code) {
            super.onFail(code);
            progress_bar.setVisibility(View.GONE);
          }
        });

    // 下拉刷新监听器
    swipeRefresh.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {

          @Override
          public void onRefresh() {

            Map<String, String> map = new HashMap<String, String>();
            map.put("Page", "1");
            map.put("Size", String.valueOf(AppConfig.ORDER_SIZE));
            map.put("Type", String.valueOf("1"));
            Http.request(
                MyMissionActivity.this,
                API.GET_SELFORDER,
                new Object[] {Http.getURL(map)},
                new Http.RequestListener<List<OrderDetails>>() {
                  @Override
                  public void onSuccess(List<OrderDetails> result) {
                    super.onSuccess(result);
                    page = 1;
                    swipeRefresh.setRefreshing(false);
                    swipeRefreshXMyMissionAdapater =
                        new SwipeRefreshXMyMissionAdapater(MyMissionActivity.this, result);
                    listView.setAdapter(swipeRefreshXMyMissionAdapater);
                    if (result != null && result.size() != 0) {
                      tv_empty.setVisibility(View.GONE);
                    } else {
                      tv_empty.setVisibility(View.VISIBLE);
                    }
                  }

                  @Override
                  public void onFail(String code) {
                    super.onFail(code);
                    swipeRefresh.setRefreshing(false);
                  }
                });
          }
        });
    // 加载监听器
    swipeRefresh.setOnLoadListener(
        new SwipeRefreshX.OnLoadListener() {

          @Override
          public void onLoad() {

            page++;
            Map<String, String> map = new HashMap<String, String>();
            map.put("Page", String.valueOf(page));
            map.put("Size", String.valueOf(AppConfig.ORDER_SIZE));
            map.put("Type", String.valueOf("1"));
            Http.request(
                MyMissionActivity.this,
                API.GET_SELFORDER,
                new Object[] {Http.getURL(map)},
                new Http.RequestListener<List<OrderDetails>>() {
                  @Override
                  public void onSuccess(List<OrderDetails> result) {
                    super.onSuccess(result);
                    if (result != null) {

                      loadMore(swipeRefreshXMyMissionAdapater, result);
                    }
                    swipeRefresh.setLoading(false);
                  }

                  @Override
                  public void onFail(String code) {
                    super.onFail(code);
                    swipeRefresh.setLoading(false);
                  }
                });
          }
        });
  }
Пример #4
0
  public View onLoadView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.fragment_order, null);

    //        // 模拟一些数据
    //        final List<String> datas = new ArrayList<String>();
    //        for (int i = 0; i < 20; i++) {
    //            datas.add("item - " + i);
    //        }
    //
    //        // 构造适配器
    //        final BaseAdapter adapter = new ArrayAdapter<String>(getActivity(),
    //                android.R.layout.simple_list_item_1,
    //                datas);
    //        // 获取listview实例
    //        listView = (ListView) root.findViewById(R.id.lv_order);
    //        listView.setAdapter(adapter);
    //
    //        // 获取RefreshLayout实例
    //        final SwipeRefreshX myRefreshListView = (SwipeRefreshX)
    //                root.findViewById(R.id.swipeRefresh);
    //        // 设置下拉刷新时的颜色值,颜色值需要定义在xml中
    //        myRefreshListView.setColorSchemeResources(android.R.color.holo_blue_bright,
    // android.R.color.holo_green_light,
    //                android.R.color.holo_orange_light, android.R.color.holo_red_light);
    //        // 设置下拉刷新监听器
    //        myRefreshListView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    //
    //            @Override
    //            public void onRefresh() {
    //
    //                Toast.makeText(getActivity(), "refresh", Toast.LENGTH_SHORT).show();
    //
    //                myRefreshListView.postDelayed(new Runnable() {
    //
    //                    @Override
    //                    public void run() {
    //                        // 更新数据
    //                        datas.add(new Date().toGMTString());
    //                        adapter.notifyDataSetChanged();
    //                        // 更新完后调用该方法结束刷新
    //                        myRefreshListView.setRefreshing(false);
    //                    }
    //                }, 1000);
    //            }
    //        });
    //        // 加载监听器
    //        myRefreshListView.setOnLoadListener(new SwipeRefreshX.OnLoadListener() {
    //
    //            @Override
    //            public void onLoad() {
    //
    //                Toast.makeText(getActivity(), "load", Toast.LENGTH_SHORT).show();
    //
    //                myRefreshListView.postDelayed(new Runnable() {
    //
    //                    @Override
    //                    public void run() {
    //                        datas.add(new Date().toGMTString());
    //                        adapter.notifyDataSetChanged();
    //                        // 加载完后调用该方法
    //                        myRefreshListView.setLoading(false);
    //                    }
    //                }, 1500);
    //
    //            }
    //        });

    swipeRefresh = (SwipeRefreshX) root.findViewById(R.id.swipeRefresh);
    //        swipeRefresh.setOnRefreshListener(this);
    swipeRefresh.setColorSchemeResources(
        android.R.color.holo_blue_bright,
        android.R.color.holo_green_light,
        android.R.color.holo_orange_light,
        android.R.color.holo_red_light);
    listView = (ListView) root.findViewById(R.id.lv_order);
    //        //ArrayAdapter mAdapter = new ArrayAdapter<String>(getActivity(),
    // android.R.layout.simple_list_item_1, mDatas);
    //        //listView.setAdapter(mAdapter);
    listView.setAdapter(new SwipeRefreshListViewAdapater(getActivity()));
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Toast.makeText(getActivity(), "df", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(getActivity(), OrderDetailsActivity.class));
          }
        });

    // 设置下拉刷新监听器
    swipeRefresh.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {

          @Override
          public void onRefresh() {

            Toast.makeText(getActivity(), "refresh", Toast.LENGTH_SHORT).show();

            //                myRefreshListView.postDelayed(new Runnable() {
            //
            //                    @Override
            //                    public void run() {
            //                        // 更新数据
            //                        datas.add(new Date().toGMTString());
            //                        adapter.notifyDataSetChanged();
            //                        // 更新完后调用该方法结束刷新
            //                        myRefreshListView.setRefreshing(false);
            //                    }
            //                }, 1000);
          }
        });
    // 加载监听器
    swipeRefresh.setOnLoadListener(
        new SwipeRefreshX.OnLoadListener() {

          @Override
          public void onLoad() {

            Toast.makeText(getActivity(), "load", Toast.LENGTH_SHORT).show();
          }
        });

    mask = root.findViewById(R.id.mask);
    chooseType = (DropdownButton) root.findViewById(R.id.chooseType);
    chooseMulti = (DropdownButton) root.findViewById(R.id.chooseMulti);
    chooseMoney = (DropdownButton) root.findViewById(R.id.chooseMoney);
    chooseSelect = (DropdownButton) root.findViewById(R.id.chooseSelect);
    dropdownType = (DropdownListView) root.findViewById(R.id.dropdownType);
    dropdownMulti = (DropdownListView) root.findViewById(R.id.dropdownMulti);
    dropdownMoney = (DropdownListView) root.findViewById(R.id.dropdownMoney);
    dropdownSelect = (DropdownListView) root.findViewById(R.id.dropdownSelect);

    dropdown_in = AnimationUtils.loadAnimation(getActivity(), R.anim.dropdown_in);
    dropdown_out = AnimationUtils.loadAnimation(getActivity(), R.anim.dropdown_out);
    dropdown_mask_out = AnimationUtils.loadAnimation(getActivity(), R.anim.dropdown_mask_out);

    dropdownButtonsController.init();

    // id count name
    //        TopicLabelObject topicLabelObject1 =  new TopicLabelObject(1,1,"Fragment");
    //        labels.add(topicLabelObject1);
    //        TopicLabelObject topicLabelObject2 =new TopicLabelObject(2,1,"CustomView");
    //        labels.add(topicLabelObject2);
    //        TopicLabelObject topicLabelObject3 =new TopicLabelObject(2,1,"Service");
    //        labels.add(topicLabelObject3);
    //        TopicLabelObject topicLabelObject4 =new TopicLabelObject(2,1,"BroadcastReceiver");
    //        labels.add(topicLabelObject4);
    //        TopicLabelObject topicLabelObject5 =new TopicLabelObject(2,1,"Activity");
    //        labels.add(topicLabelObject5);

    mask.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            dropdownButtonsController.hide();
          }
        });

    //        dropdownButtonsController.flushCounts();
    //        dropdownButtonsController.flushAllLabels();
    //        dropdownButtonsController.flushMyLabels();

    //        View root = inflater.inflate(R.layout.fragment_order, null);
    //        test_button = root.findViewById(R.id.test_button);
    //        UploadContact_button = root.findViewById(R.id.UploadContact_button);
    //        test_button.setOnClickListener(new View.OnClickListener(){
    //
    //            @Override
    //            public void onClick(View v) {
    //                UriHandler.openWebActivity(getActivity(), "/public/js/webframe-test.html");
    //            }
    //        });
    //        UploadContact_button.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                //Cursor cursor = null;
    //                List<UserContact> contactsList = new ArrayList<UserContact>();
    //                try {
    //                    //Get Contacts
    //                    Cursor cursor =
    // getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null,
    // null, null);
    //                    while (cursor.moveToNext()) {
    //                        //At least one phone number
    //
    // if(cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))>0)
    //                        {
    //                            int ContactID =
    // cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts._ID));
    //                            String ContactName =
    // cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
    //                            Cursor cursorPhone =
    // getActivity().getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
    // null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + ContactID, null, null);
    //                            while(cursorPhone.moveToNext())
    //                            {
    //                                String ContactMobile =
    // cursorPhone.getString(cursorPhone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
    //                                Pattern pattern = Pattern.compile("^\\d{11}$");
    //                                Matcher matcher = pattern.matcher(ContactMobile);
    //                                if(matcher.matches()) {
    //                                    UserContact userContact = new UserContact(ContactName,
    // ContactMobile);
    //                                    contactsList.add(userContact);
    //                                }
    //                            }
    //                            cursorPhone.close();
    //                        }
    //
    //                    }
    //                    cursor.close();
    //                }
    //                catch (Exception e)
    //                {
    //                    e.printStackTrace();
    //                }
    //                /*finally {
    //                    if (cursor != null) {
    //                        cursor.close();
    //                    }
    //                    if (cursorPhone != null) {
    //                        cursorPhone.close();
    //                    }
    //                }*/
    //                //SharedPreferences sp = getActivity().getSharedPreferences("Auth",
    // getActivity().MODE_PRIVATE);
    //
    //                Http.request(getActivity(), API.USER_CONTACT_UPLOAD, Http.map(
    //                        "Mobile", String.valueOf(Auth.getCurrentUserMobile()),
    //                        "UserContact", GsonHelper.getGson().toJson(contactsList)
    //                ), new Http.RequestListener<AuthResult>() {
    //                    @Override
    //                    public void onSuccess(AuthResult result) {
    //                        super.onSuccess(result);
    //                        //
    //
    //
    //                    }
    //                });
    //            }
    //        });
    return root;
  }