Search in sources :

Example 1 with AppAdapter

use of com.kale.floatbar.adapter.AppAdapter in project Float-Bar by tianzhijiexian.

the class DrawService method updateUi.

/**
	 * 更新悬浮窗布局等
	 */
private void updateUi() {
    RIGHT_MODE = !prefs.getDrawMode();
    DRAW_COLOR = prefs.getDrawColor();
    ALPHA = prefs.getDrawAlpha();
    // 获取浮动窗口视图所在布局
    layout = (LinearLayout) inflater.inflate(RIGHT_MODE ? R.layout.draw_right : R.layout.draw_left, null);
    // 添加悬浮窗的视图
    mWindowManager.addView(layout, wmParams);
    /**
		 * 设置抽屉控件的打开方向和监听器
		 */
    mDrawerLayout = (DrawerLayout) layout.findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerListener(new MyDrawListener());
    mDrawerLayout.openDrawer(RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT);
    /**
		 * 设置上方的home键
		 */
    Button home = (Button) layout.findViewById(R.id.home_key);
    home.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Util.virtualHome(getBaseContext());
            stopSelf();
        }
    });
    /**
		 * 设置抽屉控件内的背景
		 */
    drawContent = (LinearLayout) layout.findViewById(R.id.drawer_content);
    drawContent.setBackgroundColor(DRAW_COLOR);
    drawContent.getBackground().setAlpha(ALPHA);
    /**
		 * 设置最近任务list中item的个数:20
		 */
    Util.reloadButtons(this, appInfos, 20);
    ListView listView = (ListView) layout.findViewById(R.id.drawer_list);
    listView.setAdapter(new AppAdapter(this, mWindowManager, layout, mDrawerLayout, appInfos));
    // 悬浮窗显示确定右上角为起始坐标
    wmParams.gravity = RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT | Gravity.TOP;
    // 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置
    // 添加动画。参考自:http://bbs.9ria.com/thread-242912-1-1.html
    wmParams.windowAnimations = (RIGHT_MODE) ? R.style.right_anim : R.style.left_anim;
    mWindowManager.updateViewLayout(layout, wmParams);
}
Also used : AppAdapter(com.kale.floatbar.adapter.AppAdapter) ListView(android.widget.ListView) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) View(android.view.View) ListView(android.widget.ListView)

Aggregations

View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 AppAdapter (com.kale.floatbar.adapter.AppAdapter)1