Android Open Source - TheCompressYourFiles Drop Down Menu






From Project

Back to project page TheCompressYourFiles.

License

The source code is released under:

Apache License

If you think the Android project TheCompressYourFiles 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 com.mirrorlabs.ui.widgets;
//from   w  ww .  j a va2s  .  c o  m
import java.util.ArrayList;
import java.util.List;

import th.watsize.filebrowser.R;


import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.PopupWindow;
import android.widget.TextView;

public class DropDownMenu{
  
  private LayoutInflater mLayoutInflater;
  private Activity activity;
  private DropDownMenu menu;
  
   private Context mContext;
   private PopupWindow mPopup;
   private ListAdapter mAdapter;
    private View mDropDownAnchorView;

  
   public DropDownMenu(Activity activity) {
          this.activity = activity;
      }
  
  protected class DropDownListItem {
    public int icon;
    public String description;
    public Runnable action;

    public DropDownListItem(int icon, String description, Runnable action) {
      super();
      this.icon = icon;
      this.description = description;
      this.action = action;
    }

    @Override
    public String toString() {
      return description;
    }
  }

    public void setAnchorView(View anchor) {
          mDropDownAnchorView = anchor;
      }
  
  /**
   * You probably want to leave this method alone and implement
   * {@link #getDropDownItems(int)} instead. Only implement this method if you
   * want more control over the drop down menu.
   * 
   * <p>
   * Implement this method to set a custom drop down menu when the user clicks
   * on the icon of the window corresponding to the id. The icon is only shown
   * when {@link StandOutFlags#FLAG_DECORATION_SYSTEM} is set.
   * 
   * @param id
   *            The id of the window.
   * @return The drop down menu to be anchored to the icon, or null to have no
   *         dropdown menu.
   */
  protected PopupWindow getDropDown() {
    final List<DropDownListItem> items;

    List<DropDownListItem> dropDownListItems = getDropDownItems();
    if (dropDownListItems != null) {
      items = dropDownListItems;
    } else {
      items = new ArrayList<DropDownMenu.DropDownListItem>();
    }

    // add default drop down items
    

    // turn item list into views in PopupWindow
    LinearLayout list = new LinearLayout(activity);
    list.setOrientation(LinearLayout.VERTICAL);

    final PopupWindow dropDown = new PopupWindow(list,
        LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);

    for (final DropDownListItem item : items) {
      ViewGroup listItem = (ViewGroup) mLayoutInflater.inflate(
          R.layout.drop_down_list_item, null);
      list.addView(listItem);

      ImageView icon = (ImageView) listItem.findViewById(R.id.icon);
      icon.setImageResource(item.icon);

      TextView description = (TextView) listItem
          .findViewById(R.id.description);
      description.setText(item.description);

      listItem.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
          item.action.run();
          dropDown.dismiss();
        }
      });
    }

    Drawable background = activity.getResources().getDrawable(
        android.R.drawable.editbox_dropdown_dark_frame);
    dropDown.setBackgroundDrawable(background);
    return dropDown;
  }

  /**
   * Implement this method to populate the drop down menu when the user clicks
   * on the icon of the window corresponding to the id. The icon is only shown
   * when {@link StandOutFlags#FLAG_DECORATION_SYSTEM} is set.
   * 
   * @param id
   *            The id of the window.
   * @return The list of items to show in the drop down menu, or null or empty
   *         to have no dropdown menu.
   */
  protected List<DropDownListItem> getDropDownItems() {
    return null;
  }

  
}




Java Source Code List

com.android.gestures.CreateGestureActivity.java
com.android.gestures.GestureBuilderActivity.java
com.android.gestures.GestureMonitorActivity.java
com.markupartist.android.widget.ActionBar.java
com.markupartist.android.widget.ScrollingTextView.java
com.mirrorlabs.ui.widgets.ClickableSlidingDrawer.java
com.mirrorlabs.ui.widgets.DropDownMenu.java
com.mirrorlabs.ui.widgets.IcsListPopupWindow.java
com.mirrorlabs.ui.widgets.JavaYoutubeDownloader.java
com.mirrorlabs.ui.widgets.Panel.java
com.mirrorlabs.ui.widgets.ScrollPager.java
com.mirrorlabs.ui.widgets.SlidingFrameLayout.java
org.zeroxlab.widget.AnimationLayout.java
org.zeroxlab.widget.MyHorizontalScrollView.java
th.watsize.customcheckboxwidget.DontPressWithParentCheckBox.java
th.watsize.customtoast.Toaster.java
th.watsize.filebrowser.BackupManager.java
th.watsize.filebrowser.BaseActivity.java
th.watsize.filebrowser.BitmapManager.java
th.watsize.filebrowser.BookmarksProvider.java
th.watsize.filebrowser.CMDProcessor.java
th.watsize.filebrowser.CompressManager.java
th.watsize.filebrowser.DesEncrypter.java
th.watsize.filebrowser.DrawableManager.java
th.watsize.filebrowser.DrawableThreadLoader.java
th.watsize.filebrowser.DuplicatesManager.java
th.watsize.filebrowser.ExtractManager.java
th.watsize.filebrowser.FileUtils.java
th.watsize.filebrowser.FilebrowserULTRAActivity.java
th.watsize.filebrowser.ImageThreadLoader.java
th.watsize.filebrowser.LinuxShell.java
th.watsize.filebrowser.MimeTypes.java
th.watsize.filebrowser.MyApplication.java
th.watsize.filebrowser.PDFViewer.java
th.watsize.filebrowser.PreferenceActivity.java
th.watsize.filebrowser.ProcessManager.java
th.watsize.filebrowser.RootUtils.java
th.watsize.filebrowser.SearchFilesDialog.java
th.watsize.filebrowser.SearchFilesWidget.java
th.watsize.filebrowser.UltraBaseAdapter.java
th.watsize.imageviewer.EclairMotionEvent.java
th.watsize.imageviewer.ExpandImage.java
th.watsize.imageviewer.TouchImageView.java
th.watsize.imageviewer.WrapMotionEvent.java
th.watsize.menupopup.MenuItem.java
th.watsize.menupopup.PopupMenu.java
th.watsize.musicplayer.DBHelper.java
th.watsize.musicplayer.PlayerActivity.java
th.watsize.quickaction3D.ActionItem.java
th.watsize.quickaction3D.PopupWindows.java
th.watsize.quickaction3D.QuickAction.java
th.watsize.quickaction.ActionItem.java
th.watsize.quickaction.PopupWindows.java
th.watsize.quickaction.QuickAction.java
th.watsize.widgets.ExampleAppWidgetProvider1.java
th.watsize.widgets.ExampleAppWidgetProvider.java
th.watsize.widgets.UpdateWidgetService1.java
th.watsize.widgets.UpdateWidgetService.java