Beispiel #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);
  }
 public void onEvent(SameTabClickEvent event) {
   final String className = event.getClassName();
   if (className.equals(((Object) this).getClass().getSimpleName())
       && mSwipeMenuListView != null
       && mSwipeMenuListView.getFirstVisiblePosition() != 0) {
     mSwipeMenuListView.smoothScrollToPosition(0);
   }
 }
 public void onEvent(TabChangeEvent event) {
   final String className = event.getClassName();
   if (className.equals(((Object) this).getClass().getSimpleName())
       && mSwipeMenuListView != null
       && mSwipeMenuListView.isOpen()) {
     mSwipeMenuListView.closeMenu();
   }
 }
 public void testSayHiToJane() {
   assertTrue(getSolo().waitForView(getSolo().getView(R.id.swipe_menu_list_view)));
   SwipeMenuListView listView = (SwipeMenuListView) getSolo().getView(R.id.swipe_menu_list_view);
   View listItem1 = listView.getChildAt(1);
   int[] location = new int[2];
   listItem1.getLocationOnScreen(location);
   float x = (float) location[0] + (listItem1.getWidth() / 2);
   float y = (float) location[1] + (listItem1.getHeight() / 2);
   getSolo().drag(x, x - 150, y, y, 10);
   assertTrue(getSolo().waitForText(getSolo().getString(R.string.say_hi)));
   getSolo().clickOnText(getSolo().getString(R.string.say_hi));
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_left) {
      mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
      return true;
    }
    if (id == R.id.action_right) {
      mListView.setSwipeDirection(SwipeMenuListView.DIRECTION_RIGHT);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
 // Refresh data here.
 @Override
 public void onResume() {
   super.onResume();
   data = DB.getAllProduct();
   mAdapter = new FavoriteAdapter(getActivity(), data);
   mListView.setAdapter(mAdapter);
 }
  /**
   * The default content for this Fragment has a TextView that is shown when the list is empty. If
   * you would like to change the text, call this method to supply the text it should use.
   */
  public void setEmptyText(CharSequence emptyText) {
    View emptyView = mListView.getEmptyView();

    if (emptyView instanceof TextView) {
      ((TextView) emptyView).setText(emptyText);
    }
  }
Beispiel #8
0
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mSwipeMenuListView = (SwipeMenuListView) view.findViewById(R.id.swipe_list_view);
    // Close Interpolator
    mSwipeMenuListView.setCloseInterpolator(new BounceInterpolator());
    mSwipeMenuListView.addFooterView(loadmoreView);

    mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    mSwipeLayout.setOnRefreshListener(this);
    mSwipeLayout.setColorSchemeResources(
        android.R.color.holo_red_light,
        android.R.color.holo_green_light,
        android.R.color.holo_orange_light,
        android.R.color.holo_blue_bright);
    super.onViewCreated(view, savedInstanceState);
  }
  @Override
  protected void doHandler() {
    listData = new ArrayList<DataModel>();
    adapter = new CollectionAdapter();
    mListView.setAdapter(adapter);

    SwipeMenuCreator creator =
        new SwipeMenuCreator() {
          @Override
          public void create(SwipeMenu menu) {
            menu.addMenuItem(getMenuItem());
          }
        };
    ((SwipeMenuListView) mListView).setMenuCreator(creator);
    ((SwipeMenuListView) mListView)
        .setOnMenuItemClickListener(
            new OnMenuItemClickListener() {
              @Override
              public void onMenuItemClick(final int position, SwipeMenu menu, int index) {
                JSONObject params = new JSONObject();
                params.put("order_id", listData.get(position).order_id);
                AsyncTaskUtil.postData(
                    getActivity(),
                    "delOrderMsg",
                    params,
                    new Callback() {
                      @Override
                      public void onSuccess(JSONObject result) {
                        listData.remove(position);
                        adapter.notifyDataSetChanged();
                      }

                      @Override
                      public void onFail(String msg) {}
                    });
              }
            });
  }
Beispiel #10
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;
  }
  @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);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("E-care");
    setSupportActionBar(toolbar);

    db = new SQLiteHandler(getApplicationContext());
    session = new SessionManager(getApplicationContext());

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    view.getMenu().getItem(1).setChecked(true);
    view.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {
            Toast.makeText(
                    ShowAppointmentList.this, menuItem.getItemId() + " pressed", Toast.LENGTH_LONG)
                .show();
            Intent intent = new Intent();
            Log.d(R.id.nav_1 + "", menuItem.getItemId() + " ");
            switch (menuItem.getItemId()) {
              case R.id.nav_1:
                intent.setClass(ShowAppointmentList.this, Case_history_review.class);
                startActivity(intent);
                break;
              case R.id.nav_2:
                intent.setClass(ShowAppointmentList.this, ShowAppointmentList.class);
                // intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
              case R.id.nav_3:
                intent.setClass(ShowAppointmentList.this, Appointmentcreate.class);
                // intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
              case R.id.nav_4:
                intent.setClass(ShowAppointmentList.this, AlarmActivity.class);
                // intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
              case R.id.nav_5:
                intent.setClass(ShowAppointmentList.this, PatientReport.class);
                // intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
              case R.id.nav_6:
                // logout
                AlertDialog.Builder builder = new AlertDialog.Builder(ShowAppointmentList.this);
                // Uncomment the below code to Set the message and title from the strings.xml file
                // builder.setMessage(R.string.dialog_message) .setTitle(R.string.dialog_title);

                // Setting message manually and performing action on button click
                builder
                    .setMessage("Do you want to close this application ?")
                    .setCancelable(false)
                    .setPositiveButton(
                        "Yes",
                        new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int id) {
                            session.setLogin(false);
                            db.deleteUsers();
                            final Intent intent_logout =
                                new Intent(ShowAppointmentList.this, LoginActivity.class);
                            startActivity(intent_logout);
                            finish();
                          }
                        })
                    .setNegativeButton(
                        "No",
                        new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int id) {
                            //  Action for 'NO' Button
                            dialog.cancel();
                          }
                        });

                // Creating dialog box
                AlertDialog alert = builder.create();
                // Setting the title manually
                alert.setTitle("AlertDialogExample");
                alert.show();

                break;
            }
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            return true;
          }
        });

    ActionBarDrawerToggle actionBarDrawerToggle =
        new ActionBarDrawerToggle(
            this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
          }

          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
          }
        };

    db = new SQLiteHandler(getApplicationContext());
    dbuser = db.getUserDetails();
    View header = view.getHeaderView(0);
    TextView headerName = (TextView) header.findViewById(R.id.drawer_name);
    username = dbuser.get("name");
    uid = dbuser.get("uid");
    headerName.setText(username);
    ImageLoader imageLoader = AppController.getInstance().getImageLoader();
    com.example.yuen.e_carei_doctor.customlistviewvolley.CirculaireNetworkImageView headerphoto =
        (com.example.yuen.e_carei_doctor.customlistviewvolley.CirculaireNetworkImageView)
            header.findViewById(R.id.drawer_thumbnail);
    headerphoto.setImageUrl("http://10.89.133.147/test/" + dbuser.get("image"), imageLoader);
    drawerLayout.setDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();

    mListView = (SwipeMenuListView) findViewById(R.id.listView);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);

    swipeRefreshLayout.setOnRefreshListener(this);

    /**
     * Showing Swipe Refresh animation on activity create As animation won't start on onCreate, post
     * runnable is used
     */
    swipeRefreshLayout.post(
        new Runnable() {
          @Override
          public void run() {

            swipeRefreshLayout.setRefreshing(true);
            fetchPatients();
          }
        });

    PD = new ProgressDialog(this);
    // Showing progress dialog before making http request
    PD.setMessage("Loading...");
    PD.show();
    mAdapter = new AppointmentListAdapter(this, appointmentList);
    mListView.setAdapter(mAdapter);
    // fetchPatients();
    // step 1. create a MenuCreator
    SwipeMenuCreator creator =
        new SwipeMenuCreator() {

          @Override
          public void create(SwipeMenu menu) {

            // create "delete" item
            SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext());
            // set item background
            deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
            // set item width
            deleteItem.setWidth(dp2px(90));
            // set a icon
            deleteItem.setIcon(R.drawable.ic_delete);
            // add to menu
            menu.addMenuItem(deleteItem);
          }
        };
    // set creator
    mListView.setMenuCreator(creator);

    // step 2. listener item click event
    mListView.setOnMenuItemClickListener(
        new SwipeMenuListView.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
            AppointmentList item = appointmentList.get(position);
            switch (index) {
              case 0:
                // delete
                // delete(item);
                final String row_aid = aidlist.get(position).toString();
                AlertDialog.Builder builder = new AlertDialog.Builder(ShowAppointmentList.this);

                // Setting message manually and performing action on button click
                builder
                    .setMessage("Do you want to delete this row ?")
                    .setCancelable(false)
                    .setPositiveButton(
                        "Yes",
                        new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int id) {
                            delete(uid, row_aid);
                            fetchPatients();
                          }
                        })
                    .setNegativeButton(
                        "No",
                        new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int id) {
                            //  Action for 'NO' Button
                            dialog.cancel();
                          }
                        });

                // Creating dialog box
                AlertDialog alert = builder.create();
                // Setting the title manually
                alert.setTitle("AlertDialogExample");
                alert.show();
                break;
            }
            return false;
          }
        });

    // set SwipeListener
    mListView.setOnSwipeListener(
        new SwipeMenuListView.OnSwipeListener() {

          @Override
          public void onSwipeStart(int position) {
            // swipe start
          }

          @Override
          public void onSwipeEnd(int position) {
            // swipe end
          }
        });

    // set MenuStateChangeListener
    mListView.setOnMenuStateChangeListener(
        new SwipeMenuListView.OnMenuStateChangeListener() {
          @Override
          public void onMenuOpen(int position) {}

          @Override
          public void onMenuClose(int position) {}
        });

    // other setting
    //		listView.setCloseInterpolator(new BounceInterpolator());

    // test item long click
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getApplicationContext(), position + " long click", Toast.LENGTH_SHORT)
                .show();
            return false;
          }
        });
  }
  @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);
          }
        });
  }