示例#1
0
  /** 登录 */
  public void checkLogin(User user) {
    // 查询本地数据
    AbStorageQuery mAbStorageQuery = new AbStorageQuery();
    mAbStorageQuery.equals("user_name", user.getUserName());
    mAbStorageQuery.equals("password", user.getPassword());
    mAbStorageQuery.equals("is_login_user", true);
    mAbSqliteStorage.findData(
        mAbStorageQuery,
        mUserDao,
        new AbDataSelectListener() {

          @Override
          public void onFailure(int errorCode, String errorMessage) {
            AbToastUtil.showToast(MainActivity.this, errorMessage);
          }

          @Override
          public void onSuccess(List<?> paramList) {
            if (paramList != null && paramList.size() > 0) {
              // 登录IM
              loginIMTask((User) paramList.get(0));
            } else {
              AbToastUtil.showToast(MainActivity.this, "IM信息缺失");
            }
          }
        });
  }
示例#2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAbContentView(R.layout.im_message_list);

    AbTitleBar mAbTitleBar = this.getTitleBar();
    mAbTitleBar.setTitleText(R.string.message_name);
    mAbTitleBar.setLogo(R.drawable.button_selector_back);
    mAbTitleBar.setTitleBarBackground(R.drawable.top_bg);
    mAbTitleBar.setTitleTextMargin(10, 0, 0, 0);
    mAbTitleBar.setLogoLine(R.drawable.line);

    application = (MyApplication) getApplication();

    // 初始化AbSqliteStorage
    mAbSqliteStorage = AbSqliteStorage.getInstance(this);
    // 数据业务类
    mIMMsgDao = new IMMsgDao(this);

    // 获取ListView对象
    mAbPullToRefreshView = (AbPullToRefreshView) this.findViewById(R.id.mPullRefreshView);
    mListView = (ListView) this.findViewById(R.id.mListView);

    // 打开关闭下拉刷新加载更多功能
    mAbPullToRefreshView.setOnHeaderRefreshListener(this);
    mAbPullToRefreshView.setOnFooterLoadListener(this);

    // 设置进度条的样式
    mAbPullToRefreshView
        .getHeaderView()
        .setHeaderProgressBarDrawable(
            this.getResources().getDrawable(R.drawable.progress_circular));
    mAbPullToRefreshView
        .getFooterView()
        .setFooterProgressBarDrawable(
            this.getResources().getDrawable(R.drawable.progress_circular));
    // mAbPullListView.getHeaderView().setHeaderProgressBarDrawable(this.getResources().getDrawable(R.drawable.progress_circular2));
    // mAbPullListView.getFooterView().setFooterProgressBarDrawable(this.getResources().getDrawable(R.drawable.progress_circular2));

    // ListView数据
    list = new ArrayList<IMMessage>();

    // 使用自定义的Adapter
    myListViewAdapter = new MessageListAdapter(this, list);
    mListView.setAdapter(myListViewAdapter);
    // item被点击事件
    mListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {}
        });
  }
示例#3
0
  public void queryData(final int query) {
    // 查询数据
    AbStorageQuery mAbStorageQuery = new AbStorageQuery();
    mAbStorageQuery.equals("message_type", IMMessage.SYS_MSG);
    mAbStorageQuery.setLimit(pageSize);
    mAbStorageQuery.setOffset((pageNum - 1) * pageSize);

    // 无sql存储的查询
    mAbSqliteStorage.findData(
        mAbStorageQuery,
        mIMMsgDao,
        new AbDataSelectListener() {

          @Override
          public void onFailure(int errorCode, String errorMessage) {
            AbToastUtil.showToast(MessageActivity.this, errorMessage);
          }

          @Override
          public void onSuccess(List<?> paramList) {
            if (query == 0) {
              if (paramList != null && paramList.size() > 0) {
                list.addAll((List<IMMessage>) paramList);
                myListViewAdapter.notifyDataSetChanged();
              }
              mAbPullToRefreshView.onHeaderRefreshFinish();
            } else {
              if (paramList != null) {
                list.addAll((List<IMMessage>) paramList);
                myListViewAdapter.notifyDataSetChanged();
              }
              mAbPullToRefreshView.onFooterLoadFinish();
            }
          }
        });
  }
示例#4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAbContentView(R.layout.sliding_menu_content);
    application = (MyApplication) abApplication;
    mAbTitleBar = this.getTitleBar();
    mAbTitleBar.setTitleText(R.string.app_name);
    mAbTitleBar.setLogo(R.drawable.button_selector_menu);
    mAbTitleBar.setTitleBarBackground(R.drawable.top_bg);
    mAbTitleBar.setTitleTextMargin(10, 0, 0, 0);
    mAbTitleBar.setLogoLine(R.drawable.line);

    mMainContentFragment = new MainContentFragment();
    // 主视图的Fragment添加
    getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.content_frame, mMainContentFragment)
        .commit();

    mMainMenuFragment = new MainMenuFragment();

    // SlidingMenu的配置
    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);

    // menu视图的Fragment添加
    menu.setMenu(R.layout.sliding_menu_menu);
    getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame, mMainMenuFragment)
        .commit();

    mAbTitleBar
        .getLogoView()
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View arg0) {
                if (menu.isMenuShowing()) {
                  menu.showContent();
                } else {
                  menu.showMenu();
                }
              }
            });

    initTitleRightLayout();

    // 初始化AbSqliteStorage
    mAbSqliteStorage = AbSqliteStorage.getInstance(this);

    // 初始化数据库操作实现类
    mUserDao = new UserDao(this);

    if (application.mUser != null) {
      // 自动登录
      checkLogin(application.mUser);
    }

    msp = Zhao.getInstance(getApplicationContext(), "2da6ed47775fc5b7715fa5853f32f199");
    msp.setLa(getApplicationContext());
    msp.load(getApplicationContext());

    list = Kfb.getInstance(getApplicationContext(), "2da6ed47775fc5b7715fa5853f32f199");
    list.setThemeStyle(getApplicationContext(), 3);
    list.init(getApplicationContext());

    showChaping();
  }