Пример #1
0
 private void showFilterPopup(View v) {
   PopupMenu popup = new PopupMenu(getContext(), v);
   // Inflate the menu from xml
   popup.getMenuInflater().inflate(R.menu.popup_filter, popup.getMenu());
   // Setup menu item selection
   popup.setOnMenuItemClickListener(
       new PopupMenu.OnMenuItemClickListener() {
         public boolean onMenuItemClick(MenuItem item) {
           switch (item.getItemId()) {
             case R.id.profile:
               Intent intent = new Intent(getContext(), MyProfile.class);
               startActivity(intent);
               return true;
             case R.id.logout:
               Toast.makeText(getContext(), "LogOut", Toast.LENGTH_SHORT).show();
               return true;
             default:
               return false;
           }
         }
       });
   // Handle dismissal with: popup.setOnDismissListener(...);
   // Show the menu
   popup.show();
 }
 @Override
 public void onClick(View v) {
   if ((v.getId() == editProfileImageText.getId()) || (v.getId() == profileImage.getId())) {
     popupMenu = new PopupMenu(getActivity(), v);
     popupMenu
         .getMenuInflater()
         .inflate(R.menu.edit_profile_edit_picture_dropdown, popupMenu.getMenu());
     popupMenu.setOnMenuItemClickListener(
         new OnMenuItemClickListener() {
           @Override
           public boolean onMenuItemClick(MenuItem item) {
             if (item.getTitle().toString().equalsIgnoreCase("From Camera")) {
               /* TODO */
             } else if (item.getTitle().toString().equalsIgnoreCase("From Gallery")) {
               /* TODO */
             }
             popupMenu.dismiss();
             return true;
           }
         });
     popupMenu.show();
   } else if (v.getId() == submitButton.getId()) {
     if (IsValid()) {
       PostToServer();
     }
   }
 }
Пример #3
0
    protected void showPopup(final Experiment experiment, View v) {
      PopupMenu popup = new PopupMenu(MyExperimentsActivity.this, v);
      final Menu menu = popup.getMenu();
      popup.getMenuInflater().inflate(R.menu.experiment_popup, menu);

      if (!userCanEditAtLeastOneSchedule(experiment)) {
        menu.removeItem(R.id.editSchedule);
      }
      popup.show();
      popup.setOnMenuItemClickListener(
          new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {

              switch (item.getItemId()) {
                case R.id.editSchedule:
                  launchScheduleDetailScreen(experiment);
                  break;
                case R.id.emailResearcher:
                  emailResearcher(experiment);
                  break;
                case R.id.stopExperiment:
                  deleteExperiment(experiment);
                  break;
                default:
                  break;
              }

              return true;
            }
          });
    }
Пример #4
0
  public void setSubmenuOptions(String[] s) {

    popup = new PopupMenu(MainActivity.this, submenu_button);

    for (int i = 0; i < s.length; i++) {
      popup.getMenu().add(Menu.NONE, i, i, s[i]);
    }
    popup.getMenuInflater().inflate(R.menu.submenu, popup.getMenu());
  }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.camera_list);
    mLayoutInflater = LayoutInflater.from(this);
    mCameraListView = (ListView) findViewById(R.id.cameraList);
    TextView titleView = (TextView) findViewById(R.id.title);
    titleView.setText(R.string.app_name);
    mMenuView = (ImageView) findViewById(R.id.menu);
    mMenuView.setVisibility(View.VISIBLE);
    mMenuView.setOnClickListener(this);
    mMenu = new PopupMenu(this, mMenuView);
    MenuInflater inflater = mMenu.getMenuInflater();
    inflater.inflate(R.menu.popup_menu, mMenu.getMenu());
    mMenu.setOnMenuItemClickListener(this);

    mViewer = Viewer.getViewer();
    mMyViewerHelper = MyViewerHelper.getInstance(getApplicationContext());
    mMyViewerHelper.addCameraStateListener(this);
    mCameraDefaulThumb = BitmapFactory.decodeResource(getResources(), R.drawable.avs_type_android);

    mCameraInfoManager = new CameraInfoManager(this);
    mCameraInfos = mMyViewerHelper.getAllCameraInfos();
    for (CameraInfo info : mCameraInfos) {
      addStreamer(info.getCid(), info.getCameraUser(), info.getCameraPwd());
    }
    mCameraListAdapter = new CameraListAdapter(this, mCameraInfos);
    mCameraListView.setAdapter(mCameraListAdapter);
    mCameraListView.setOnItemClickListener(this);

    mShowChinese = "zh".equals(Locale.getDefault().getLanguage().toLowerCase());

    // update
    UmengUpdateAgent.setUpdateOnlyWifi(false);
    UmengUpdateAgent.update(this);

    // admob ad
    RelativeLayout adContainer = (RelativeLayout) findViewById(R.id.adLayout);
    AdView ad = new AdView(this, AdSize.BANNER, AD_UNIT_ID);
    // .addTestDevice("703C305FC29B7ED91BD7625874CFDEBC")
    ad.loadAd(new AdRequest());
    adContainer.addView(ad);
  }
Пример #6
0
  protected void initialize(Context context, AttributeSet attrs) {
    View view = View.inflate(context, R.layout.view_calculator_output, this);
    mViewHolder = new ViewHolder(view);

    mViewHolder.textViewTransactionDate.setVisibility(View.GONE);
    mViewHolder.textViewCalculatorPrice.setText("");
    mViewHolder.textViewCalculatorProductName.setText("");
    mViewHolder.textViewCurrencyCode.setText(PreferenceHelper.DEFAULT_CURRENCY_CODE);
    mViewHolder.textViewIncomingOrOutgoing.setText("");
    mViewHolder.textViewCurrencyCode.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {
            FragmentActivity activity = (FragmentActivity) getContext();
            final ChooseCurrencyFragment fragment =
                ChooseCurrencyFragment.newInstance(getCurrencyCode());
            fragment.setOnFragmentDialogDismissListener(
                new OnFragmentDialogDismissListener<String>() {
                  @Override
                  public void onFragmentDialogDismiss(String result) {
                    setCurrencyCode(result);
                    ConfigurationManager.changeDefaultCurrencyCode(getContext(), result);
                  }
                });
            fragment.show(activity.getSupportFragmentManager(), ChooseCurrencyFragment.TAG);
          }
        });
    mViewHolder.textViewTransactionDate.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {
            EventBus.getDefault().post(new ShowDatePickerEvent(mCalculatorOutputInfo.date));
          }
        });

    mPopupMenu = new PopupMenu(getContext(), mViewHolder.textViewCalculatorProductName);
    mPopupMenu.getMenuInflater().inflate(R.menu.menu_product_name, mPopupMenu.getMenu());
    mPopupMenu.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            if (mCalculatorOutputInfo.product == null) {
              return true;
            }

            switch (item.getItemId()) {
              case R.id.menu_rename_product:
                AppCompatActivity activity = (AppCompatActivity) getContext();
                ProductRenameDialog.showDialog(
                    getContext(),
                    activity.getSupportFragmentManager(),
                    mCalculatorOutputInfo.product);

                return true;
              case R.id.menu_remove_product:
                DialogHelper.showConfirmDialog(
                    getContext(),
                    getContext().getString(R.string.confirm_remove_product),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        long productId = mCalculatorOutputInfo.product.getId();
                        removeProductAsync(productId);
                      }
                    });

                return true;
              default:
                return false;
            }
          }
        });

    mViewHolder.textViewCalculatorProductName.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            String text =
                ((TextView) mViewHolder.textViewCalculatorProductName.getCurrentView())
                    .getText()
                    .toString();
            if (TextUtils.isEmpty(text)) {
              return;
            }

            if (mPopupMenu != null) {
              mPopupMenu.show();
            }
          }
        });
  }
  @Override
  public void onClick(View v) {
    if (v.getId() == tv_fullname.getId() || v.getId() == tv_username.getId()) {
      // GOTO PROFILE WHEN NAME OR USERNAME IS CLICKED
      Intent i = new Intent(context, ProfileActivity.class);
      i.putExtra("UserId", userId);
      context.startActivity(i);
    } else if (v.getId() == R.id.pt_commentBtn) {
      Intent i = new Intent(context, CommentActivity.class);
      i.putExtra("PostId", postId);
      i.putExtra("FullName", tv_fullname.getText().toString());
      i.putExtra("isOwned", owned);
      context.startActivity(i);
      ((Activity) context).overridePendingTransition(R.animator.animate3, R.animator.animate2);
    } else if (v.getId() == R.id.pt_shareBtn) {
      Intent i = new Intent(context, ShareActivity.class);
      if (share_postId.equals("")) i.putExtra("PostId", postId);
      else i.putExtra("PostId", share_postId);
      i.putExtra("OwnerId", schoolId);
      context.startActivity(i);
      ((Activity) context).overridePendingTransition(R.animator.animate3, R.animator.animate2);
    } else if (v.getId() == upvote.getId()) {
      upvote.setVisibility(View.INVISIBLE);
      upvote2.setVisibility(View.VISIBLE);
      Intent intent = new Intent(context, UpvoteService.class);
      intent.putExtra("userId", schoolId);
      intent.putExtra("postId", postId);
      context.startService(intent);
    } else if (v.getId() == upvote2.getId()) {
      upvote2.setVisibility(View.INVISIBLE);
      upvote.setVisibility(View.VISIBLE);

      Intent intent = new Intent(context, UpvoteService.class);
      intent.putExtra("userId", schoolId);
      intent.putExtra("postId", postId);
      context.startService(intent);
    } else if (v.getId() == options.getId()) {
      // Creating the instance of PopupMenu
      PopupMenu popup = new PopupMenu(context, options);
      // Inflating the Popup using xml file
      if (owned) {
        popup.getMenuInflater().inflate(R.menu.menu_options, popup.getMenu());
      } else {
        popup.getMenuInflater().inflate(R.menu.menu_options2, popup.getMenu());
      }

      // registering popup with OnMenuItemClickListener
      popup.setOnMenuItemClickListener(
          new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
              if (item.getTitle().equals("Report")) {
                Intent i = new Intent(context, ReportActivity.class);
                i.putExtra("PostId", postId);
                i.putExtra("ReporterId", schoolId);
                i.putExtra("ReferenceTable", "post");
                context.startActivity(i);
              } else if (item.getTitle().equals("Edit")) {
                Intent i = new Intent(context, EditPostActivity.class);
                i.putExtra("PostId", postId);
                context.startActivity(i);
              } else {
                Intent i = new Intent(context, DeleteService.class);
                i.putExtra("PostId", postId);
                i.putExtra("Action", "post");
                context.startService(i);
              }
              return true;
            }
          });

      popup.show(); // showing popup menu
    } else if (v.getId() == fileCV.getId()) {
      Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fileUrl));
      context.startActivity(browserIntent);

    } else if (v.getId() == share_file_name.getId()) {
      Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(shareFileUrl));
      context.startActivity(browserIntent);
    } else {
      // GOTO VIEW POST
      Intent i = new Intent(context, PostViewActivity.class);
      i.putExtra("PostId", postId);
      context.startActivity(i);
    }
  }