package com.jone.app.ui.floatview; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.jone.app.R; import com.jone.app.services.JoneShowFloatLayoutService; import com.jone.app.utils.MyWindowManager; /** * Created by jone_admin on 2014/3/27. */ public class FloatWindowBigView extends LinearLayout { /** * 记录大悬浮窗的宽度 */ public static int viewWidth; /** * 记录大悬浮窗的高度 */ public static int viewHeight; public FloatWindowBigView(final Context context) { super(context); LayoutInflater.from(context).inflate(R.layout.layout_float_big, this); View view = findViewById(R.id.big_window_layout); viewWidth = view.getLayoutParams().width; viewHeight = view.getLayoutParams().height; Button close = (Button) findViewById(R.id.close); Button back = (Button) findViewById(R.id.back); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // 点击关闭悬浮窗的时候,移除所有悬浮窗,并停止Service MyWindowManager.removeBigWindow(context); MyWindowManager.removeSmallWindow(context); Intent intent = new Intent(getContext(), JoneShowFloatLayoutService.class); context.stopService(intent); //设置悬浮窗的当前状态 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean("chP_open_float_window", false).commit(); } }); back.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // 点击返回的时候,移除大悬浮窗,创建小悬浮窗 MyWindowManager.removeBigWindow(context); MyWindowManager.createSmallWindow(context); } }); } }