Android Open Source - dttv-android Pop Window Compnent






From Project

Back to project page dttv-android.

License

The source code is released under:

GNU General Public License

If you think the Android project dttv-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dttv.app.compnent;
//from  w  ww.ja  v a2 s. c om
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import dttv.app.R;
import dttv.app.impl.ICallBack;
import dttv.app.impl.I_PopWindow;
import dttv.app.utils.Constant;

public class PopWindowCompnent extends Compnent implements I_PopWindow {
  String TAG = "PopWindowCompnent";
  private PopupWindow effectWindow;
  private ListView mListView;
  private Activity mActivity;
  
  public PopWindowCompnent(Activity activity,Context context) {
    super(activity);
    mActivity = activity;
    // TODO Auto-generated constructor stub
    Log.i(TAG, "enter PopWindowCompnent");
    initialize();
  }
  
  @Override
  public void initialize() {
    // TODO Auto-generated method stub
    super.initialize();
    View view = LayoutInflater.from(mActivity).inflate(R.layout.effect_popwindow, null);
    mListView = (ListView)view.findViewById(R.id.pop_listview);
    fillData();
    effectWindow = new PopupWindow(view,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    effectWindow.setAnimationStyle(R.style.pop_win_style);
    ColorDrawable dw = new ColorDrawable(0xb0ffffff);
    effectWindow.setBackgroundDrawable(dw);
    mListView.setOnItemClickListener(new ItemClickListener());
  }
  
  private class  ItemClickListener implements OnItemClickListener{
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position,
        long id) {
      // TODO Auto-generated method stub
      callback.doItemClickListener(parent, view, position, id);
      effectWindow.dismiss();
    }
  }
   
  private void fillData(){
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity, 
        android.R.layout.simple_list_item_1, Constant.gEqulizerPresets);
    mListView.setAdapter(adapter);
  }

  @Override
  public void onItemClick(View v) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void onProgressChanged(int widgetId) {
    // TODO Auto-generated method stub
    
  }
  
  public void show(View v,boolean isShowing){
    if(isShowing){
      int location[] = new int[2];
      v.getLocationOnScreen(location);
      int _x = location[0];
      int height = mListView.getMeasuredHeight();
      int _y = location[1] - height;// effectWindow.getHeight();
      Log.i(TAG, "_x is:"+_x+"--height is:"+height+"---_y is:"+_y);
      effectWindow.showAtLocation(v, Gravity.NO_GRAVITY, _x, _y);
    }
    else
      effectWindow.dismiss();
  }
  
  @Override
  protected void setContentView(View contentView) {
    // TODO Auto-generated method stub
    super.setContentView(contentView);
  }
  
  private ICallBack callback;
  public void setCallback(ICallBack callback){
    this.callback = callback;
  }
}




Java Source Code List

dttv.app.DtPlayer.java
dttv.app.FileBrowserActivity.java
dttv.app.FileShowActivity.java
dttv.app.IndexActivity.java
dttv.app.MainActivity.java
dttv.app.SettingActivity.java
dttv.app.VideoPlayerActivity.java
dttv.app.adapter.FileAdapter.java
dttv.app.compnent.Compnent.java
dttv.app.compnent.MethodPlayerCompnent.java
dttv.app.compnent.PopWindowCompnent.java
dttv.app.impl.ICallBack.java
dttv.app.impl.I_Async.java
dttv.app.impl.I_KeyIntercept.java
dttv.app.impl.I_OnMyKey.java
dttv.app.impl.I_PopWindow.java
dttv.app.model.Item.java
dttv.app.multithread.DataAsyncTask.java
dttv.app.utils.Constant.java
dttv.app.utils.ControlLightness.java
dttv.app.utils.FileUtil.java
dttv.app.utils.Log.java
dttv.app.utils.MultiMediaTypeUtil.java
dttv.app.utils.MusicUtils.java
dttv.app.utils.PlayerUtil.java
dttv.app.utils.SettingUtil.java
dttv.app.utils.TimesUtil.java
dttv.app.utils.VolumeUtil.java
dttv.app.view.SimpleDialog.java
dttv.app.widget.AudioUIFragment.java
dttv.app.widget.EffectWindow.java
dttv.app.widget.FilesUIFragment.java
dttv.app.widget.GlVideoView.java
dttv.app.widget.OnTouchMoveListener.java
dttv.app.widget.SlideTabsFragment.java
dttv.app.widget.VideoUIFragment.java