Пример #1
0
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    SwipeMenuCreator creator =
        new SwipeMenuCreator() {

          @Override
          public void create(SwipeMenu menu) {
            createMenu(menu);
          }
        };
    // set creator
    mSwipeMenuListView.setMenuCreator(creator);
    mSwipeMenuListView.setOnItemClickListener(this);
    mSwipeMenuListView.setOnMenuItemClickListener(this);
    mSwipeMenuListView.setOnScrollListener(this);

    /** 获取本地数据 */
    getNewsListDataFromLocal(todayTime);

    /** 获取网上数据 */
    getNewsListGsonDataFromNet(false, todayTime);

    hideFootView();

    super.onActivityCreated(savedInstanceState);
  }
Пример #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_bookmark, container, false);

    // Set the adapter
    mListView = (SwipeMenuListView) view.findViewById(android.R.id.list);
    mListView.setAdapter(mAdapter);
    mListView.setMenuCreator(creator);
    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(this);
    mListView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          int mLastFirstVisibleItem = 0;

          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {}

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (view.getId() == mListView.getId()) {
              final int currentFirstVisibleItem = mListView.getFirstVisiblePosition();

              if (currentFirstVisibleItem > mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().hide();
                ((ActionBarActivity) getActivity()).getSupportActionBar().hide();
              } else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
                // getSherlockActivity().getSupportActionBar().show();
                ((ActionBarActivity) getActivity()).getSupportActionBar().show();
              }
              mLastFirstVisibleItem = currentFirstVisibleItem;
            }
          }
        });
    mListView.setOnMenuItemClickListener(
        new SwipeMenuListView.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
            switch (index) {
              case 0:
                // delete
                DB.delOne(data.get(position));
                // Update Home screen product list.
                MyApp.getInstance().updateProductFromWishlist(false, data.get(position).objectId);
                // Update wishlist view
                data = DB.getAllProduct();
                mAdapter = new FavoriteAdapter(getActivity(), data);
                mListView.setAdapter(mAdapter);
                break;
            }
            // false : close the menu; true : not close the menu
            return false;
          }
        });
    mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
    return view;
  }
Пример #3
0
  @Override
  protected View getContentView(LayoutInflater inflater, ViewGroup container) {
    final View view = inflater.inflate(R.layout.fragment_xiu_layout, container, false);

    setLeftContentIcon(R.drawable.back_icon_selector);
    setCenterText(getString(R.string.tab_xiu_tip));
    mXiuInfos = GlobalDataHolder.getInstance(getActivity()).getXiuInfo();

    // set mAdapter
    mAdapter = new XiuPageAdapter(getActivity());
    mAdapter.setItems(mXiuInfos);

    mSwipeMenuListView = (SwipeMenuListView) view.findViewById(R.id.swipeListView);

    // set creator
    mSwipeMenuListView.setMenuCreator(this);
    mSwipeMenuListView.setOnMenuItemClickListener(this);
    mSwipeMenuListView.setOnItemClickListener(this);

    // add headerview and footerview
    final RelativeLayout headerView = new RelativeLayout(getActivity());
    headerView.setLayoutParams(
        new SwipeMenuListView.LayoutParams(
            SwipeMenuListView.LayoutParams.MATCH_PARENT,
            getResources().getDimensionPixelSize(R.dimen.xiu_list_header)));
    headerView.setBackgroundColor(0xffefeff4);
    mSwipeMenuListView.addHeaderView(headerView);

    final View footerView = inflater.inflate(R.layout.xiu_footer_view, container, false);
    footerView.setLayoutParams(
        new SwipeMenuListView.LayoutParams(
            SwipeMenuListView.LayoutParams.MATCH_PARENT,
            SwipeMenuListView.LayoutParams.WRAP_CONTENT));
    mSwipeMenuListView.addFooterView(footerView);
    footerView.findViewById(R.id.add_wrapper).setOnClickListener(this);

    mSwipeMenuListView.setAdapter(mAdapter);

    return view;
  }
  private void initviews() {
    conversationList.addAll(loadConversationsWithRecentChat());
    chatallhis_no = (TextView) view.findViewById(R.id.chatallhis_no);
    chatallhis_no.setVisibility(View.GONE);
    chatallhis_listview = (SwipeMenuListView) view.findViewById(R.id.chatallhis_listview);
    adapter = new ChatAllHistoryAdapter(getActivity(), conversationList);
    chatallhis_listview.setAdapter(adapter);
    chatallhis_listview.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EMConversation conversation = conversationList.get(position);
            String username = conversation.getUserName();
            if (!username.equals(currentUserName)) {
              // 进入聊天页面
              Intent intent = new Intent(getActivity(), MessageActivity.class);
              Bundle bundle = new Bundle();
              if (conversation.isGroup()) {
                bundle.putInt("chatType", MessageActivity.CHATTYPE_GROUP);
                bundle.putString("groupId", username);
                EMGroup group = EMGroupManager.getInstance().getGroup(username);
                bundle.putString("groupName", group != null ? group.getGroupName() : username);
              } else {
                bundle.putInt("chatType", MessageActivity.CHATTYPE_SINGLE);
                bundle.putString("userId", username);
              }
              intent.putExtras(bundle);
              startActivity(intent);
            }
          }
        });
    SwipeMenuCreator creator =
        new SwipeMenuCreator() {
          @Override
          public void create(SwipeMenu menu) {
            SwipeMenuItem item = new SwipeMenuItem(getActivity());
            item.setBackground(new ColorDrawable(Color.RED));
            item.setWidth(CommonUtils.dip2px(getActivity(), 90));
            item.setTitle("删除");
            item.setTitleColor(Color.WHITE);
            item.setTitleSize(CommonUtils.sp2px(getActivity(), 5));
            menu.addMenuItem(item);
          }
        };
    chatallhis_listview.setMenuCreator(creator);
    chatallhis_listview.setOnMenuItemClickListener(
        new SwipeMenuListView.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
            if (index == 0) {
              boolean deleteMessage = false;
              EMConversation tobeDeleteCons = conversationList.get(position);
              // 删除此会话
              EMChatManager.getInstance()
                  .deleteConversation(
                      tobeDeleteCons.getUserName(), tobeDeleteCons.isGroup(), deleteMessage);
              InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
              inviteMessgeDao.deleteMessage(tobeDeleteCons.getUserName());
              conversationList.remove(tobeDeleteCons);
              adapter.notifyDataSetChanged();
              if (conversationList.size() == 0) {
                chatallhis_no.setVisibility(View.VISIBLE);
              } else {
                chatallhis_no.setVisibility(View.GONE);
              }
            }
            return false;
          }
        });
    if (conversationList.size() == 0) {
      chatallhis_no.setVisibility(View.VISIBLE);
    } else {
      chatallhis_no.setVisibility(View.GONE);
    }
  }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    carDB = CarDB.getInstance(this);
    if (carDB.loadCityDetailBoolean()) {
      System.out.print("123456");
    } else {
      new ProvinceTask().execute(this);
      Log.v("1223", "____________________________________________________");
    }

    mListView = (SwipeMenuListView) findViewById(R.id.listView);
    View emptyView = findViewById(android.R.id.empty);
    mListView.setEmptyView(emptyView);

    //        CarDetail car1 = new CarDetail();
    //        car1.setCarNumberString("sdfasd");
    //        car1.setShortProvince("sdfs");
    //        car1.setCarNumberString("sdfas");
    //        list.add(car1);
    //        list = new ArrayList<String>();
    //        for (int i = 0; i < city.length; i++) {
    //            list.add(city[i]);
    //        }
    addFloatingActionButton = (AddFloatingActionButton) findViewById(R.id.normal_plus);
    if (carDB.loadCarDetail() != null) {
      list = carDB.loadCarDetail();
      //
      //            adapter.notifyDataSetChanged();
    } else {
      list = new ArrayList<CarDetail>();
      //
    }
    adapter = new mAdapter();
    mListView.setAdapter(adapter);
    addFloatingActionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent i = new Intent(MainActivity.this, Car.class);
            startActivityForResult(i, 1);
            //                list.add("122455");
            //                adapter.notifyDataSetChanged();
          }
        });

    SwipeMenuCreator creator =
        new SwipeMenuCreator() {
          @Override
          public void create(SwipeMenu swipeMenu) {
            SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext());
            deleteItem.setBackground(new ColorDrawable(Color.rgb(0xf9, 0x3f, 0x25)));
            deleteItem.setWidth(dp2px(90));
            deleteItem.setIcon(R.drawable.abc_ic_menu_selectall_mtrl_alpha);
            swipeMenu.addMenuItem(deleteItem);
          }
        };
    mListView.setMenuCreator(creator);
    mListView.setOnMenuItemClickListener(
        new SwipeMenuListView.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(int position, SwipeMenu swipeMenu, int index) {
            switch (index) {
              case 0:
                CarDetail car = new CarDetail();
                car = list.get(position);
                carDB.removelist(
                    car.getShortProvince(), car.getCharCity(), car.getCarNumberString());
                //                        list = new ArrayList<CarDetail>();
                list = carDB.loadCarDetail();
                adapter.notifyDataSetChanged();
            }
            return false;
          }
        });
    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(MainActivity.this, CarReason.class);
            CarDetail car = new CarDetail();
            CarDetail car1 = new CarDetail();
            car = list.get(position);
            car1 =
                carDB.queryCarDetail(
                    car.getShortProvince(), car.getCharCity(), car.getCarNumberString());
            Bundle bundle = new Bundle();
            bundle.putSerializable("car", car1);
            String hphm =
                new StringBuffer(car.getShortProvince())
                    .append(car.getCharCity())
                    .append(car.getCarNumberString())
                    .toString();
            i.putExtra("hphm", hphm);
            i.putExtra("bundle", bundle);
            startActivity(i);
          }
        });
  }