MenuItemImpl.java 14.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
package android.support.v7.view.menu;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.support.annotation.RestrictTo;
import android.support.v4.internal.view.SupportMenuItem;
import android.support.v4.view.ActionProvider.VisibilityListener;
import android.support.v4.view.MenuItemCompat.OnActionExpandListener;
import android.support.v7.content.res.AppCompatResources;
import android.util.Log;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MenuItem.OnActionExpandListener;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewDebug.CapturedViewProperty;
import android.widget.LinearLayout;
import java.util.ArrayList;

@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public final class MenuItemImpl
  implements SupportMenuItem
{
  static String c;
  static String d;
  static String e;
  static String f;
  MenuBuilder a;
  ContextMenu.ContextMenuInfo b;
  private final int g;
  private final int h;
  private final int i;
  private final int j;
  private CharSequence k;
  private CharSequence l;
  private Intent m;
  private char n;
  private char o;
  private Drawable p;
  private int q = 0;
  private SubMenuBuilder r;
  private Runnable s;
  private MenuItem.OnMenuItemClickListener t;
  private int u = 16;
  private int v = 0;
  private View w;
  private android.support.v4.view.ActionProvider x;
  private MenuItemCompat.OnActionExpandListener y;
  private boolean z = false;
  
  MenuItemImpl(MenuBuilder paramMenuBuilder, int paramInt1, int paramInt2, int paramInt3, int paramInt4, CharSequence paramCharSequence, int paramInt5)
  {
    this.a = paramMenuBuilder;
    this.g = paramInt2;
    this.h = paramInt1;
    this.i = paramInt3;
    this.j = paramInt4;
    this.k = paramCharSequence;
    this.v = paramInt5;
  }
  
  private void b(boolean paramBoolean)
  {
    int i2 = this.u;
    int i3 = this.u;
    if (paramBoolean) {}
    for (int i1 = 2;; i1 = 0)
    {
      this.u = (i1 | i3 & 0xFFFFFFFD);
      if (i2 != this.u) {
        this.a.onItemsChanged(false);
      }
      return;
    }
  }
  
  final char a()
  {
    if (this.a.isQwertyMode()) {
      return this.o;
    }
    return this.n;
  }
  
  final CharSequence a(MenuView.ItemView paramItemView)
  {
    if ((paramItemView != null) && (paramItemView.prefersCondensedTitle())) {
      return getTitleCondensed();
    }
    return getTitle();
  }
  
  final boolean a(boolean paramBoolean)
  {
    boolean bool = false;
    int i2 = this.u;
    int i3 = this.u;
    if (paramBoolean) {}
    for (int i1 = 0;; i1 = 8)
    {
      this.u = (i1 | i3 & 0xFFFFFFF7);
      paramBoolean = bool;
      if (i2 != this.u) {
        paramBoolean = true;
      }
      return paramBoolean;
    }
  }
  
  public final void actionFormatChanged()
  {
    this.a.b();
  }
  
  final boolean b()
  {
    return (this.a.isShortcutsVisible()) && (a() != 0);
  }
  
  public final boolean collapseActionView()
  {
    if ((this.v & 0x8) == 0) {}
    do
    {
      return false;
      if (this.w == null) {
        return true;
      }
    } while ((this.y != null) && (!this.y.onMenuItemActionCollapse(this)));
    return this.a.collapseItemActionView(this);
  }
  
  public final boolean expandActionView()
  {
    if (!hasCollapsibleActionView()) {}
    while ((this.y != null) && (!this.y.onMenuItemActionExpand(this))) {
      return false;
    }
    return this.a.expandItemActionView(this);
  }
  
  public final android.view.ActionProvider getActionProvider()
  {
    throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.getActionProvider()");
  }
  
  public final View getActionView()
  {
    if (this.w != null) {
      return this.w;
    }
    if (this.x != null)
    {
      this.w = this.x.onCreateActionView(this);
      return this.w;
    }
    return null;
  }
  
  public final char getAlphabeticShortcut()
  {
    return this.o;
  }
  
  public final int getGroupId()
  {
    return this.h;
  }
  
  public final Drawable getIcon()
  {
    if (this.p != null) {
      return this.p;
    }
    if (this.q != 0)
    {
      Drawable localDrawable = AppCompatResources.getDrawable(this.a.getContext(), this.q);
      this.q = 0;
      this.p = localDrawable;
      return localDrawable;
    }
    return null;
  }
  
  public final Intent getIntent()
  {
    return this.m;
  }
  
  @ViewDebug.CapturedViewProperty
  public final int getItemId()
  {
    return this.g;
  }
  
  public final ContextMenu.ContextMenuInfo getMenuInfo()
  {
    return this.b;
  }
  
  public final char getNumericShortcut()
  {
    return this.n;
  }
  
  public final int getOrder()
  {
    return this.i;
  }
  
  public final int getOrdering()
  {
    return this.j;
  }
  
  public final SubMenu getSubMenu()
  {
    return this.r;
  }
  
  public final android.support.v4.view.ActionProvider getSupportActionProvider()
  {
    return this.x;
  }
  
  @ViewDebug.CapturedViewProperty
  public final CharSequence getTitle()
  {
    return this.k;
  }
  
  public final CharSequence getTitleCondensed()
  {
    if (this.l != null) {}
    for (CharSequence localCharSequence = this.l;; localCharSequence = this.k)
    {
      Object localObject = localCharSequence;
      if (Build.VERSION.SDK_INT < 18)
      {
        localObject = localCharSequence;
        if (localCharSequence != null)
        {
          localObject = localCharSequence;
          if (!(localCharSequence instanceof String)) {
            localObject = localCharSequence.toString();
          }
        }
      }
      return (CharSequence)localObject;
    }
  }
  
  public final boolean hasCollapsibleActionView()
  {
    boolean bool2 = false;
    boolean bool1 = bool2;
    if ((this.v & 0x8) != 0)
    {
      if ((this.w == null) && (this.x != null)) {
        this.w = this.x.onCreateActionView(this);
      }
      bool1 = bool2;
      if (this.w != null) {
        bool1 = true;
      }
    }
    return bool1;
  }
  
  public final boolean hasSubMenu()
  {
    return this.r != null;
  }
  
  public final boolean invoke()
  {
    if ((this.t != null) && (this.t.onMenuItemClick(this))) {}
    do
    {
      do
      {
        return true;
      } while (this.a.a(this.a.getRootMenu(), this));
      if (this.s != null)
      {
        this.s.run();
        return true;
      }
      if (this.m != null) {
        try
        {
          this.a.getContext().startActivity(this.m);
          return true;
        }
        catch (ActivityNotFoundException localActivityNotFoundException)
        {
          Log.e("MenuItemImpl", "Can't find activity to handle intent; ignoring", localActivityNotFoundException);
        }
      }
    } while ((this.x != null) && (this.x.onPerformDefaultAction()));
    return false;
  }
  
  public final boolean isActionButton()
  {
    return (this.u & 0x20) == 32;
  }
  
  public final boolean isActionViewExpanded()
  {
    return this.z;
  }
  
  public final boolean isCheckable()
  {
    return (this.u & 0x1) == 1;
  }
  
  public final boolean isChecked()
  {
    return (this.u & 0x2) == 2;
  }
  
  public final boolean isEnabled()
  {
    return (this.u & 0x10) != 0;
  }
  
  public final boolean isExclusiveCheckable()
  {
    return (this.u & 0x4) != 0;
  }
  
  public final boolean isVisible()
  {
    if ((this.x != null) && (this.x.overridesItemVisibility())) {
      if (((this.u & 0x8) != 0) || (!this.x.isVisible())) {}
    }
    while ((this.u & 0x8) == 0)
    {
      return true;
      return false;
    }
    return false;
  }
  
  public final boolean requestsActionButton()
  {
    return (this.v & 0x1) == 1;
  }
  
  public final boolean requiresActionButton()
  {
    return (this.v & 0x2) == 2;
  }
  
  public final MenuItem setActionProvider(android.view.ActionProvider paramActionProvider)
  {
    throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()");
  }
  
  public final SupportMenuItem setActionView(int paramInt)
  {
    Context localContext = this.a.getContext();
    setActionView(LayoutInflater.from(localContext).inflate(paramInt, new LinearLayout(localContext), false));
    return this;
  }
  
  public final SupportMenuItem setActionView(View paramView)
  {
    this.w = paramView;
    this.x = null;
    if ((paramView != null) && (paramView.getId() == -1) && (this.g > 0)) {
      paramView.setId(this.g);
    }
    this.a.b();
    return this;
  }
  
  public final void setActionViewExpanded(boolean paramBoolean)
  {
    this.z = paramBoolean;
    this.a.onItemsChanged(false);
  }
  
  public final MenuItem setAlphabeticShortcut(char paramChar)
  {
    if (this.o == paramChar) {
      return this;
    }
    this.o = Character.toLowerCase(paramChar);
    this.a.onItemsChanged(false);
    return this;
  }
  
  public final MenuItem setCallback(Runnable paramRunnable)
  {
    this.s = paramRunnable;
    return this;
  }
  
  public final MenuItem setCheckable(boolean paramBoolean)
  {
    int i2 = this.u;
    int i3 = this.u;
    if (paramBoolean) {}
    for (int i1 = 1;; i1 = 0)
    {
      this.u = (i1 | i3 & 0xFFFFFFFE);
      if (i2 != this.u) {
        this.a.onItemsChanged(false);
      }
      return this;
    }
  }
  
  public final MenuItem setChecked(boolean paramBoolean)
  {
    if ((this.u & 0x4) != 0)
    {
      MenuBuilder localMenuBuilder = this.a;
      int i2 = getGroupId();
      int i3 = localMenuBuilder.a.size();
      localMenuBuilder.stopDispatchingItemsChanged();
      int i1 = 0;
      if (i1 < i3)
      {
        MenuItemImpl localMenuItemImpl = (MenuItemImpl)localMenuBuilder.a.get(i1);
        if ((localMenuItemImpl.getGroupId() == i2) && (localMenuItemImpl.isExclusiveCheckable()) && (localMenuItemImpl.isCheckable())) {
          if (localMenuItemImpl != this) {
            break label105;
          }
        }
        label105:
        for (paramBoolean = true;; paramBoolean = false)
        {
          localMenuItemImpl.b(paramBoolean);
          i1 += 1;
          break;
        }
      }
      localMenuBuilder.startDispatchingItemsChanged();
      return this;
    }
    b(paramBoolean);
    return this;
  }
  
  public final MenuItem setEnabled(boolean paramBoolean)
  {
    if (paramBoolean) {}
    for (this.u |= 0x10;; this.u &= 0xFFFFFFEF)
    {
      this.a.onItemsChanged(false);
      return this;
    }
  }
  
  public final void setExclusiveCheckable(boolean paramBoolean)
  {
    int i2 = this.u;
    if (paramBoolean) {}
    for (int i1 = 4;; i1 = 0)
    {
      this.u = (i1 | i2 & 0xFFFFFFFB);
      return;
    }
  }
  
  public final MenuItem setIcon(int paramInt)
  {
    this.p = null;
    this.q = paramInt;
    this.a.onItemsChanged(false);
    return this;
  }
  
  public final MenuItem setIcon(Drawable paramDrawable)
  {
    this.q = 0;
    this.p = paramDrawable;
    this.a.onItemsChanged(false);
    return this;
  }
  
  public final MenuItem setIntent(Intent paramIntent)
  {
    this.m = paramIntent;
    return this;
  }
  
  public final void setIsActionButton(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      this.u |= 0x20;
      return;
    }
    this.u &= 0xFFFFFFDF;
  }
  
  public final MenuItem setNumericShortcut(char paramChar)
  {
    if (this.n == paramChar) {
      return this;
    }
    this.n = paramChar;
    this.a.onItemsChanged(false);
    return this;
  }
  
  public final MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener paramOnActionExpandListener)
  {
    throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setOnActionExpandListener()");
  }
  
  public final MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener paramOnMenuItemClickListener)
  {
    this.t = paramOnMenuItemClickListener;
    return this;
  }
  
  public final MenuItem setShortcut(char paramChar1, char paramChar2)
  {
    this.n = paramChar1;
    this.o = Character.toLowerCase(paramChar2);
    this.a.onItemsChanged(false);
    return this;
  }
  
  public final void setShowAsAction(int paramInt)
  {
    switch (paramInt & 0x3)
    {
    default: 
      throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, and SHOW_AS_ACTION_NEVER are mutually exclusive.");
    }
    this.v = paramInt;
    this.a.b();
  }
  
  public final SupportMenuItem setShowAsActionFlags(int paramInt)
  {
    setShowAsAction(paramInt);
    return this;
  }
  
  public final void setSubMenu(SubMenuBuilder paramSubMenuBuilder)
  {
    this.r = paramSubMenuBuilder;
    paramSubMenuBuilder.setHeaderTitle(getTitle());
  }
  
  public final SupportMenuItem setSupportActionProvider(android.support.v4.view.ActionProvider paramActionProvider)
  {
    if (this.x != null) {
      this.x.reset();
    }
    this.w = null;
    this.x = paramActionProvider;
    this.a.onItemsChanged(true);
    if (this.x != null) {
      this.x.setVisibilityListener(new ActionProvider.VisibilityListener()
      {
        public final void onActionProviderVisibilityChanged(boolean paramAnonymousBoolean)
        {
          MenuItemImpl.this.a.a();
        }
      });
    }
    return this;
  }
  
  public final SupportMenuItem setSupportOnActionExpandListener(MenuItemCompat.OnActionExpandListener paramOnActionExpandListener)
  {
    this.y = paramOnActionExpandListener;
    return this;
  }
  
  public final MenuItem setTitle(int paramInt)
  {
    return setTitle(this.a.getContext().getString(paramInt));
  }
  
  public final MenuItem setTitle(CharSequence paramCharSequence)
  {
    this.k = paramCharSequence;
    this.a.onItemsChanged(false);
    if (this.r != null) {
      this.r.setHeaderTitle(paramCharSequence);
    }
    return this;
  }
  
  public final MenuItem setTitleCondensed(CharSequence paramCharSequence)
  {
    this.l = paramCharSequence;
    this.a.onItemsChanged(false);
    return this;
  }
  
  public final MenuItem setVisible(boolean paramBoolean)
  {
    if (a(paramBoolean)) {
      this.a.a();
    }
    return this;
  }
  
  public final boolean shouldShowIcon()
  {
    return this.a.e;
  }
  
  public final boolean showsTextAsAction()
  {
    return (this.v & 0x4) == 4;
  }
  
  public final String toString()
  {
    if (this.k != null) {
      return this.k.toString();
    }
    return null;
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/view/menu/MenuItemImpl.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */