Ejemplo n.º 1
1
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_sketch_properties);

    // StackOverflow: http://stackoverflow.com/a/27455330/1628609
    LinearLayout root =
        (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
    toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
    root.addView(toolbar, 0);

    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    initOptionsMenu(toolbar.getMenu());
    toolbar.setOnMenuItemClickListener(this);

    toolbar.setTitle(getGlobalState().getSketchName());

    getGlobalState().setProperties(this);

    getWindow()
        .getDecorView()
        .setBackgroundColor(getResources().getColor(R.color.activity_background));
  }
Ejemplo n.º 2
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    MenuInflater inflater = getMenuInflater();
    Menu toolbar_menu = toolbar.getMenu();
    toolbar_menu.clear();
    inflater.inflate(R.menu.log_menu, toolbar_menu);
    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                // Respond to the action bar's Up/Home button

              case R.id.menu_share:
                sendLog();
                return true;
            }
            return true;
          }
        });
    return true;
  }
 private void initToolBar() {
   toolbar = (Toolbar) findViewById(R.id.toolbar);
   setSupportActionBar(toolbar);
   toolbar.setTitle("关于驱动器");
   toolbar.setTitleTextColor(getResources().getColor(R.color.white));
   if (typeNum == AboutQudongActivity.PRODUCT_NOTEBOOK) {
     toolbar.setSubtitle("产品手册");
   } else if (typeNum == AboutQudongActivity.ORDER_NOTEBOOK) {
     toolbar.setSubtitle("指令手册");
   } else if (typeNum == AboutQudongActivity.TEST_NOTEBOOK) {
     toolbar.setSubtitle("调试软件手册");
   } else if (typeNum == AboutQudongActivity.QAA_NOTEBOOK) {
     toolbar.setSubtitle("常见问题");
   }
   toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_48dp);
   toolbar.setNavigationOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent = new Intent(NoteBookActivity.this, AboutQudongActivity.class); // 方法1
           startActivity(intent);
           finish();
         }
       });
   toolbar.setOnMenuItemClickListener(onMenuItemClick);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the toolbar.
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Welcome");
    setSupportActionBar(toolbar);
    toolbar.setOnMenuItemClickListener(onToolbarMenuItemClickListener);
    ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
      setupDrawerContent(navigationView);
    }

    fragContainerId = R.id.main_content;

    if (savedInstanceState == null) {
      transitionTo(DemoHomePageFragment.newInstance());
    }

    // Uncomment me for iovation suppoort
    // start(getApplicationContext());
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   ButterKnife.bind(this);
   mToolbar.setTitle("ElasticDragDismissLayout");
   mToolbar.inflateMenu(R.menu.main);
   mToolbar.setOnMenuItemClickListener(
       new Toolbar.OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           switch (item.getItemId()) {
             case R.id.action_recyclerview:
               Intent intent = DetailRecyclerViewActivity.newIntent(MainActivity.this);
               startActivity(intent);
               return true;
           }
           return false;
         }
       });
   mCheeseAdapter = new CheeseAdapter(MainActivity.this, mCheeseAdapterListener);
   mRecyclerView.setAdapter(mCheeseAdapter);
   mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
   load();
 }
Ejemplo n.º 6
0
  /** {@inheritDoc} from Fragment */
  @Override
  public View onCreateView(
      final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.contact_picker_fragment, container, false);
    mRecipientTextView =
        (ContactRecipientAutoCompleteView) view.findViewById(R.id.recipient_text_view);
    mRecipientTextView.setThreshold(0);
    mRecipientTextView.setDropDownAnchor(R.id.compose_contact_divider);

    mRecipientTextView.setContactChipsListener(this);
    mRecipientTextView.setDropdownChipLayouter(
        new ContactDropdownLayouter(inflater, getActivity(), this));
    mRecipientTextView.setAdapter(new ContactRecipientAdapter(getActivity(), this));
    mRecipientTextView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(
              final CharSequence s, final int start, final int before, final int count) {}

          @Override
          public void beforeTextChanged(
              final CharSequence s, final int start, final int count, final int after) {}

          @Override
          public void afterTextChanged(final Editable s) {
            updateTextInputButtonsVisibility();
          }
        });

    final CustomHeaderPagerViewHolder[] viewHolders = {
      mFrequentContactsListViewHolder, mAllContactsListViewHolder
    };

    mCustomHeaderViewPager = (CustomHeaderViewPager) view.findViewById(R.id.contact_pager);
    mCustomHeaderViewPager.setViewHolders(viewHolders);
    mCustomHeaderViewPager.setViewPagerTabHeight(CustomHeaderViewPager.DEFAULT_TAB_STRIP_SIZE);
    mCustomHeaderViewPager.setBackgroundColor(
        getResources().getColor(R.color.contact_picker_background));

    // The view pager defaults to the frequent contacts page.
    mCustomHeaderViewPager.setCurrentItem(0);

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_light);
    mToolbar.setNavigationContentDescription(R.string.back);
    mToolbar.setNavigationOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(final View v) {
            mHost.onBackButtonPressed();
          }
        });

    mToolbar.inflateMenu(R.menu.compose_menu);
    mToolbar.setOnMenuItemClickListener(this);

    mComposeDivider = view.findViewById(R.id.compose_contact_divider);
    mRootView = view;
    return view;
  }
  private void createBottomToolbar() {

    Toolbar bottomToolbar = (Toolbar) findViewById(R.id.bottomToolbar);
    bottomToolbar.inflateMenu(R.menu.menu_main);

    bottomToolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            // Handle action bar item clicks
            int itemId = item.getItemId();
            // if statement is used because this sample is used elsewhere as a Library module
            if (itemId == R.id.action_def_exp) {
              // check the state of the menu item
              if (!applyActive) {
                applyDefinitionExpression();
                // change the text to reset
                applyActive = true;
                item.setTitle(R.string.action_reset);
              } else {
                resetDefinitionExpression();
                // change the text to apply
                applyActive = false;
                item.setTitle(R.string.action_def_exp);
              }
            }
            return true;
          }
        });
  }
Ejemplo n.º 8
0
  // toolbar
  private void initToolbar() {
    toolbar.findViewById(R.id.toolbar);
    if (toolbar != null) {
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      getSupportActionBar().setHomeButtonEnabled(true);
    }
    toolbar.setNavigationIcon(R.drawable.keyboard_backspace);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed();
            onclick(v);
          }
        });

    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem menuItem) {
            return false;
          }
        });
  }
  @Override
  protected void initEvents() {
    mToolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("https://realm.io"));
            startActivity(i);

            return true;
          }
        });

    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
            Intent i;
            switch (pos) {
              case 0:
                i = new Intent(mContext, RealmDatabaseActivityLine.class);
                break;
              case 1:
                i = new Intent(mContext, RealmDatabaseActivityBar.class);
                break;
              case 2:
                i = new Intent(mContext, RealmDatabaseActivityHorizontalBar.class);
                break;
              case 3:
                i = new Intent(mContext, RealmDatabaseActivityScatter.class);
                break;
              case 4:
                i = new Intent(mContext, RealmDatabaseActivityCandle.class);
                break;
              case 5:
                i = new Intent(mContext, RealmDatabaseActivityBubble.class);
                break;
              case 6:
                i = new Intent(mContext, RealmDatabaseActivityPie.class);
                break;
              case 7:
                i = new Intent(mContext, RealmDatabaseActivityRadar.class);
                break;
              case 8:
                i = new Intent(mContext, RealmWikiExample.class);
                break;
              default:
                i = null;
                break;
            }
            if (i != null) {
              startActivity(i);
              overridePendingTransition(
                  R.anim.move_right_in_activity, R.anim.move_left_out_activity);
            }
          }
        });
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (activity instanceof FragmentStatusInterface) {
      fragmentStatusInterface = (FragmentStatusInterface) activity;
    }

    adapter =
        new SeriesRecordingListAdapter(activity, new ArrayList<SeriesRecording>(), adapterLayout);
    listView.setAdapter(adapter);

    // Set the listener to show the recording details activity when the user
    // has selected a recording
    listView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SeriesRecording srec = (SeriesRecording) adapter.getItem(position);
            if (fragmentStatusInterface != null) {
              fragmentStatusInterface.onListItemSelected(position, srec, TAG);
            }
            adapter.setPosition(position);
            adapter.notifyDataSetChanged();
          }
        });

    registerForContextMenu(listView);

    if (toolbar != null) {
      toolbar.setOnMenuItemClickListener(
          new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
              return onToolbarItemSelected(item);
            }
          });
      // Inflate a menu to be displayed in the toolbar
      toolbar.inflateMenu(R.menu.recording_menu);

      toolbar.setNavigationIcon(R.drawable.ic_launcher);
      if (!isDualPane) {
        // Allow clicking on the navigation icon, if available. The icon is
        // set in the populateTagList method
        toolbar.setNavigationOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                activity.onBackPressed();
              }
            });
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_topic);
    ButterKnife.bind(this);

    topicId = getIntent().getStringExtra("topicId");

    toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
    toolbar.inflateMenu(R.menu.topic);
    toolbar.setOnMenuItemClickListener(this);

    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    adapter = new TopicAdapter(this, this);
    recyclerView.setAdapter(adapter);

    fabReply.attachToRecyclerView(recyclerView);

    // 创建回复窗口
    LayoutInflater inflater = LayoutInflater.from(this);
    View view = inflater.inflate(R.layout.activity_reply_window, layoutRoot, false);
    replyHandler = new ReplyHandler(view);

    replyWindow =
        new PopupWindow(
            view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    replyWindow.setBackgroundDrawable(new ColorDrawable(0x01000000));
    replyWindow.setFocusable(true);
    replyWindow.setOutsideTouchable(true);
    replyWindow.setAnimationStyle(R.style.AppTheme_ReplyWindowAnim);
    // - END -

    dialog =
        new MaterialDialog.Builder(this)
            .content("正在发布中...")
            .progress(true, 0)
            .cancelable(false)
            .build();

    refreshLayout.setColorSchemeResources(
        R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
    refreshLayout.setOnRefreshListener(this);

    HandlerUtils.postDelayed(
        new Runnable() {

          @Override
          public void run() {
            refreshLayout.setRefreshing(true);
            onRefresh();
          }
        },
        100); // refreshLayout无法直接在onCreate中设置刷新状态
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (Intent.ACTION_VIEW.equals(getIntent().getAction())
        || Intent.ACTION_SEND.equals(getIntent().getAction())
        || Intent.ACTION_SENDTO.equals(getIntent().getAction())
        || Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
      ActivityManager.getInstance().startNewTask(this);
    }
    super.onCreate(savedInstanceState);

    if (isFinishing()) {
      return;
    }

    setContentView(R.layout.contact_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setOnClickListener(this);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerToggle =
        new ActionBarDrawerToggle(
            this,
            drawerLayout,
            toolbar,
            R.string.application_title_short,
            R.string.application_title_short);
    drawerLayout.setDrawerListener(drawerToggle);

    toolbar.inflateMenu(R.menu.contact_list);
    optionsMenu = toolbar.getMenu();
    setUpSearchView(optionsMenu);
    toolbar.setOnMenuItemClickListener(this);

    barPainter = new BarPainter(this, toolbar);
    barPainter.setDefaultColor();

    toolbar.setTitle(R.string.application_title_full);

    if (savedInstanceState != null) {
      sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
      action = savedInstanceState.getString(SAVED_ACTION);
    } else {
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.container, new ContactListFragment(), CONTACT_LIST_TAG)
          .commit();

      sendText = null;
      action = getIntent().getAction();
    }
    getIntent().setAction(null);
  }
Ejemplo n.º 13
0
 private void initToolbar() {
   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   toolbar.setTitle(R.string.app_name);
   toolbar.setSubtitle("Добавить новый цветок");
   toolbar.setOnMenuItemClickListener(
       new Toolbar.OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           return false;
         }
       });
   toolbar.inflateMenu(R.menu.menu_main);
 }
Ejemplo n.º 14
0
 @Override
 public void initToolbar() {
   setSupportActionBar(toolbar);
   toolbar.setTitleTextColor(Color.WHITE);
   toolbar.setOnMenuItemClickListener(this);
   toolbar.setNavigationOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           close();
         }
       });
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nfc);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    deviceOptions.put(getString(R.string.device_cat), UnityActivity.MARKER_CAT);
    deviceOptions.put(getString(R.string.device_dog), UnityActivity.MARKER_DOG);
    deviceOptions.put(getString(R.string.device_snail), UnityActivity.MARKER_SNAIL);

    optionsDialogFragment =
        OptionsDialogFragment.newInstance(deviceOptions.keySet().toArray(new String[] {}));

    txtUsername = (TextView) findViewById(R.id.txt_username);

    user = (User) getIntent().getExtras().getSerializable(EXTRA_USER);
    presentation = (Presentation) getIntent().getExtras().getSerializable(EXTRA_PRESENTATION);

    txtUsername.setText(getString(R.string.welcome) + "\n" + user.getName());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(user.getName());

    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    toolbar.inflateMenu(R.menu.nfc);
    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.action_log_out:
                RestClient.getInstance().setUser(null, null);
                finish();
                break;
              case R.id.action_join:
                optionsDialogFragment.show(getSupportFragmentManager(), DIALOG_TAG_OPTIONS_DIALOG);
                break;
            }
            return false;
          }
        });

    requestPermissionsInit();
  }
Ejemplo n.º 16
0
  private void initToolbar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {

          @Override
          public boolean onMenuItemClick(MenuItem item) {
            return false;
          }
        });

    toolbar.inflateMenu(R.menu.menu);
  }
 private void initToorbar() {
   toolbar = (Toolbar) findViewById(R.id.toolbar2);
   toolbar.setTitle("");
   toolbar.setVisibility(View.GONE);
   setSupportActionBar(toolbar);
   // Menu item click 的監聽事件一樣要設定在 setSupportActionBar 才有作用
   toolbar.setOnMenuItemClickListener(onMenuItemClick);
   toolbar.setNavigationIcon(R.drawable.adward_navigationbar_icon_back);
   toolbar.setNavigationOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           ComicImageViewActivity.this.finish();
           overridePendingTransition(R.anim.hold, R.anim.left);
         }
       });
 }
Ejemplo n.º 18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing()) {
      return;
    }

    setContentView(R.layout.activity_with_toolbar_and_container);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
    toolbar.inflateMenu(R.menu.add_conference);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    toolbar.setOnMenuItemClickListener(this);

    BarPainter barPainter = new BarPainter(this, toolbar);
    barPainter.setDefaultColor();

    Intent intent = getIntent();

    if (savedInstanceState != null) {
      account = savedInstanceState.getString(SAVED_ACCOUNT);
      room = savedInstanceState.getString(SAVED_ROOM);
    } else {
      account = getAccount(intent);
      room = getUser(intent);
    }

    barPainter.updateWithAccountName(account);

    if (savedInstanceState == null) {
      getFragmentManager()
          .beginTransaction()
          .add(R.id.fragment_container, ConferenceAddFragment.newInstance(account, room))
          .commit();
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
  }
Ejemplo n.º 19
0
 private void setupToolbar(View rootView) {
   mToolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
   if (mToolbarContainer != null) {
     mToolbarContainer.setBackgroundColor(C.ThemedColors[C.colorPrimary]);
   }
   mToolbar.inflateMenu(R.menu.menu_edit);
   mToolbar
       .getMenu()
       .getItem(0)
       .getIcon()
       .setColorFilter(C.ThemedColors[C.colorTextNormal], PorterDuff.Mode.SRC_ATOP);
   mToolbar.setOnMenuItemClickListener(this);
   if (rootView.findViewById(R.id.frame_box) == null) {
     MainActivity ma = (MainActivity) getActivity();
     ma.setStatusBarColor(0, 0, true);
   }
   ImageButton close = (ImageButton) rootView.findViewById(R.id.close);
   close.setOnClickListener(this);
   mElevation = (int) (getResources().getDimension(R.dimen.toolbar_elevation) + 0.5f);
 }
Ejemplo n.º 20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);

    addFragmentContent();

    findViews();

    toolbar.inflateMenu(R.menu.menu_main);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed();
          }
        });

    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            BaseFragment currentFragment =
                (BaseFragment) getFragmentManager().findFragmentById(R.id.container);
            /*
                            switch (item.getItemId()) {
                                case R.id.doTest:
                                    currentFragment.onToolbarItemClick(DO_TEST);
                                    break;
                                case R.id.selectAll:
                                    currentFragment.onToolbarItemClick(SELECT_ALL);
                                    break;
                                case R.id.cancelAll:
                                    currentFragment.onToolbarItemClick(CANCEL_ALL);
                                    break;
                            }
            */
            return true;
          }
        });
  }
Ejemplo n.º 21
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    setTheme(MyApplication.theme_int);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nwsmosaic);

    toolbar = (Toolbar) findViewById(R.id.toolbar_top);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toolbar_bottom = (Toolbar) findViewById(R.id.toolbar_bottom);

    if (MyApplication.icons_even_spaced)
      UtilityToolbar.setupEvenlyDistributedToolbar(this, toolbar_bottom, R.menu.nwsmosaic);
    else toolbar_bottom.inflateMenu(R.menu.nwsmosaic);

    toolbar_bottom.setOnMenuItemClickListener(this);
    UtilityToolbar.FullScreenMode(toolbar, toolbar_bottom);

    img = (TouchImageView2) findViewById(R.id.iv);
    img.setOnClickListener(this);
    img.setMaxZoom(max_zoom);

    turl = getIntent().getStringArrayExtra(URL);
    img_url = turl[1];

    nws_radar_mosaic_sector_label_current =
        MyApplication.preferences.getString(
            "NWS_RADAR_MOSAIC_SECTOR_CURRENT", "Central Great Lakes");

    spinner1 = (Spinner) findViewById(R.id.spinner1);
    dataAdapter =
        new ArrayAdapter<>(
            this, android.R.layout.simple_spinner_item, UtilityUSImgNWSMosaic.nws_sectors_labels);
    dataAdapter.setDropDownViewResource(MyApplication.spinner_layout);
    spinner1.setAdapter(dataAdapter);
    spinner1.setOnItemSelectedListener(this);
    spinner1.setSelection(findPosition(nws_radar_mosaic_sector_label_current));
  }
Ejemplo n.º 22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    role = intent.getStringExtra("userRole");
    session = intent.getStringExtra("Session");
    at = (Login) Registry.getInstance().get("login.atr");
    if (session.isEmpty()) {
    } else {
      try {
        djObject = bundle.getParcelable("Twitter object");
        Registry.getInstance().set("djObject", djObject);
      } catch (Exception e) {
        Log.d("Show", e.getMessage());
      }
    }
    context = getApplicationContext();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            SocialAuth at = (SocialAuth) Registry.getInstance().get("authManager");
            at.logout();
            logout();
            return true;
          }
        });

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
      setupViewPager(viewPager);
    }
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
  }
Ejemplo n.º 23
0
  private void initToolbar() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    // toolbar.setLogo(R.drawable.ic_launcher);
    mToolbar.setTitleTextColor(getResources().getColor(R.color.white));
    mToolbar.setTitle("诺笔记");
    // toolbar.setSubtitle("副标题");
    setSupportActionBar(mToolbar);
    mToolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.ab_setting:
                AtySetting.launch(mActivity);

                break;
              default:
                break;
            }
            return true;
          }
        });
  }
 private void setUpToolbar() {
   setSupportActionBar(mToolbar);
   mToolbar.setOnMenuItemClickListener(
       new Toolbar.OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           switch (item.getItemId()) {
             case R.id.toolbar_demo_item_collect:
               SnackbarUtil.show(mCoordinatorLayout, item.getTitle());
               break;
             case R.id.toolbar_demo_item_feedback:
               SnackbarUtil.show(mCoordinatorLayout, item.getTitle());
               break;
             case R.id.toolbar_demo_item_help:
               SnackbarUtil.show(mCoordinatorLayout, item.getTitle());
               break;
             default:
               break;
           }
           return true;
         }
       });
 }
 private void initsToolbar() {
   Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
   setSupportActionBar(toolbar);
   toolbar.setOnMenuItemClickListener(onMenuItemClick);
 }
Ejemplo n.º 26
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    setTheme(MyApplication.theme_int);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_uswxoglv2);

    loc_x_current =
        MyApplication.preferences.getString("LOC" + MyApplication.current_loc_fragment + "_X", "");
    loc_y_current =
        MyApplication.preferences.getString("LOC" + MyApplication.current_loc_fragment + "_Y", "");

    turl = getIntent().getStringArrayExtra(RID);

    // for L2 archive called from storm reports
    if (turl.length > 5) {
      url_str = turl[3];
      loc_x_current = turl[4];
      loc_y_current = turl[5];
      archive_mode = true;
    }

    toolbar = (Toolbar) findViewById(R.id.toolbar_top);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_36px));
    // toolbar.setNavigationIcon(android.R.drawable.);

    toolbar_bottom = (Toolbar) findViewById(R.id.toolbar_bottom);

    if (MyApplication.icons_even_spaced)
      UtilityToolbar.setupEvenlyDistributedToolbar(this, toolbar_bottom, R.menu.uswxoglradar);
    else toolbar_bottom.inflateMenu(R.menu.uswxoglradar);

    toolbar_bottom.setOnMenuItemClickListener(this);

    if (archive_mode) toolbar_bottom.setVisibility(View.GONE);

    Menu menu = toolbar_bottom.getMenu();

    star_icon = R.drawable.star;
    star_outline_icon = R.drawable.star_outline;
    map_icon = R.drawable.map;
    star = menu.findItem(R.id.action_fav);
    map = menu.findItem(R.id.action_ridmap);
    map.setIcon(map_icon);

    tv0 = menu.findItem(R.id.action_tv0);
    tdwr = menu.findItem(R.id.action_tdwr);

    anim = menu.findItem(R.id.action_a6);
    tilt_menu = menu.findItem(R.id.action_tilt);

    // if ( ! MyApplication.loaded )
    //	MyApplication.Init(this);

    mImageMap = (ImageMap) findViewById(R.id.map);
    mImageMap.setVisibility(View.GONE);

    delay = UtilityImg.GetAnimInterval();

    img = (TouchImageView2) findViewById(R.id.iv);
    img.setMaxZoom(max_zoom);

    prod = "N0Q";

    glview = (WXGLSurfaceView) findViewById(R.id.glsurfaceview);
    InitGLVIEW();

    ogl_in_view = true;

    rid1 = turl[0];
    state = turl[1];
    if (turl.length > 2) {
      prod = turl[2];
      if (prod.equals("N0R")) {
        prod = "N0Q";
      }
    }

    if (MyApplication.wxogl_remember_location && !archive_mode) {

      OGLR.setZoom(MyApplication.wxogl_zoom);
      glview.mScaleFactor = (MyApplication.wxogl_zoom);
      if (!MyApplication.wxogl_rid.equals("")) rid1 = MyApplication.wxogl_rid;
      prod = MyApplication.wxogl_prod;
      OGLR.mPositionX = MyApplication.wxogl_x;
      OGLR.mPositionY = MyApplication.wxogl_y;
    }

    setTitle(prod);
    rid_arr_loc = UtilityFavorites.SetupFavMenu(MyApplication.rid_fav, rid1, pref_token_location);

    spinner1 = (Spinner) findViewById(R.id.spinner1);
    dataAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, rid_arr_loc);
    dataAdapter.setDropDownViewResource(MyApplication.spinner_layout);
    spinner1.setAdapter(dataAdapter);
    spinner1.setOnItemSelectedListener(this);

    if (MyApplication.wxogl_radar_autorefresh) {
      // 180000 is 3 min
      mInterval = 60000 * MyApplication.preferences.getInt("RADAR_REFRESH_INTERVAL", 3);

      getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      mHandler = new Handler();
      startRepeatingTask();
    }
  }
Ejemplo n.º 27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mKaaChatManager = EventsDemoApp.app(this).getKaaChatManager();

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    mToolbar.setTitle(EventsDemoApp.app(this).username());

    mToolbar.inflateMenu(R.menu.menu_main_activity);
    mToolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {

            switch (item.getItemId()) {
              case R.id.edit_nickname:
                showDialog(
                    MainActivity.this,
                    R.string.activity_main_edit_nickname_hint,
                    new OnTextInputListener() {
                      @Override
                      public void onTextInput(String text) {
                        EventsDemoApp.app(MainActivity.this).newUsername(text);
                        mToolbar.setTitle(text);
                      }
                    });
                break;
              default:
                return false;
            }

            return true;
          }
        });

    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
    mFloatingActionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            showDialog(
                MainActivity.this,
                R.string.activity_main_new_chat_hint,
                new OnTextInputListener() {
                  @Override
                  public void onTextInput(String text) {
                    mKaaChatManager.createChatRoom(text);
                    mChatAdapter.notifyDataSetChanged();
                  }
                });
          }
        });

    mRecyclerView = (RecyclerView) findViewById(R.id.chats);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mChatAdapter = new ChatAdapter(mKaaChatManager);
    mRecyclerView.setAdapter(mChatAdapter);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    View view = inflater.inflate(R.layout.chat_viewer_fragment, container, false);

    contactTitleView = view.findViewById(R.id.contact_title);

    abstractContact = RosterManager.getInstance().getBestContact(account, user);
    contactTitleView.findViewById(R.id.avatar).setOnClickListener(this);

    toolbar = (Toolbar) view.findViewById(R.id.toolbar_default);
    toolbar.inflateMenu(R.menu.chat);
    toolbar.setOnMenuItemClickListener(this);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(getActivity());
          }
        });

    setHasOptionsMenu(true);

    accountPainter = new AccountPainter(getActivity());

    sendButton = (ImageButton) view.findViewById(R.id.button_send_message);
    sendButton.setImageResource(R.drawable.ic_button_send_inactive_24dp);

    AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);

    securityButton = (ImageButton) view.findViewById(R.id.button_security);

    if (abstractChat instanceof RegularChat) {
      securityButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              showSecurityMenu();
            }
          });
    } else {
      securityButton.setVisibility(View.GONE);
    }

    chatMessageAdapter = new ChatMessageAdapter(getActivity(), account, user, this, this);

    recyclerView = (RecyclerView) view.findViewById(R.id.chat_messages_recycler_view);
    recyclerView.setAdapter(chatMessageAdapter);

    layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setStackFromEnd(true);
    recyclerView.setLayoutManager(layoutManager);

    inputView = (EditText) view.findViewById(R.id.chat_input);

    view.findViewById(R.id.button_send_message)
        .setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                sendMessage();
              }
            });

    inputView.setOnKeyListener(
        new View.OnKeyListener() {
          @Override
          public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (SettingsManager.chatsSendByEnter()
                && event.getAction() == KeyEvent.ACTION_DOWN
                && keyCode == KeyEvent.KEYCODE_ENTER) {
              sendMessage();
              return true;
            }
            return false;
          }
        });

    inputView.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!skipOnTextChanges && stopTypingTimer != null) {
              stopTypingTimer.cancel();
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable text) {
            setUpInputViewButtons();

            if (skipOnTextChanges) {
              return;
            }

            ChatStateManager.getInstance().onComposing(account, user, text);

            stopTypingTimer = new Timer();
            stopTypingTimer.schedule(
                new TimerTask() {
                  @Override
                  public void run() {
                    Application.getInstance()
                        .runOnUiThread(
                            new Runnable() {
                              @Override
                              public void run() {
                                ChatStateManager.getInstance().onPaused(account, user);
                              }
                            });
                  }
                },
                STOP_TYPING_DELAY);
          }
        });

    final ImageButton emojiButton = (ImageButton) view.findViewById(R.id.button_emoticon);
    final View rootView = view.findViewById(R.id.root_view);

    // Give the topmost view of your activity layout hierarchy. This will be used to measure soft
    // keyboard height
    final EmojiconsPopup popup = new EmojiconsPopup(rootView, getActivity());

    // Will automatically set size according to the soft keyboard size
    popup.setSizeForSoftKeyboard();

    // If the emoji popup is dismissed, change emojiButton to smiley icon
    popup.setOnDismissListener(
        new PopupWindow.OnDismissListener() {

          @Override
          public void onDismiss() {
            changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_emoticon_grey600_24dp);
          }
        });

    // If the text keyboard closes, also dismiss the emoji popup
    popup.setOnSoftKeyboardOpenCloseListener(
        new EmojiconsPopup.OnSoftKeyboardOpenCloseListener() {

          @Override
          public void onKeyboardOpen(int keyBoardHeight) {}

          @Override
          public void onKeyboardClose() {
            if (popup.isShowing()) popup.dismiss();
          }
        });

    // On emoji clicked, add it to edittext
    popup.setOnEmojiconClickedListener(
        new EmojiconGridView.OnEmojiconClickedListener() {

          @Override
          public void onEmojiconClicked(Emojicon emojicon) {
            if (inputView == null || emojicon == null) {
              return;
            }

            int start = inputView.getSelectionStart();
            int end = inputView.getSelectionEnd();
            if (start < 0) {
              inputView.append(emojicon.getEmoji());
            } else {
              inputView
                  .getText()
                  .replace(
                      Math.min(start, end),
                      Math.max(start, end),
                      emojicon.getEmoji(),
                      0,
                      emojicon.getEmoji().length());
            }
          }
        });

    // On backspace clicked, emulate the KEYCODE_DEL key event
    popup.setOnEmojiconBackspaceClickedListener(
        new EmojiconsPopup.OnEmojiconBackspaceClickedListener() {

          @Override
          public void onEmojiconBackspaceClicked(View v) {
            KeyEvent event =
                new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
            inputView.dispatchKeyEvent(event);
          }
        });

    // To toggle between text keyboard and emoji keyboard keyboard(Popup)
    emojiButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            // If popup is not showing => emoji keyboard is not visible, we need to show it
            if (!popup.isShowing()) {

              // If keyboard is visible, simply show the emoji popup
              if (popup.isKeyBoardOpen()) {
                popup.showAtBottom();
                changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_keyboard_variant_grey600_24dp);
              }

              // else, open the text keyboard first and immediately after that show the emoji popup
              else {
                inputView.setFocusableInTouchMode(true);
                inputView.requestFocus();
                popup.showAtBottomPending();
                final InputMethodManager inputMethodManager =
                    (InputMethodManager)
                        getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                inputMethodManager.showSoftInput(inputView, InputMethodManager.SHOW_IMPLICIT);
                changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_keyboard_variant_grey600_24dp);
              }
            }

            // If popup is showing, simply dismiss it to show the undelying text keyboard
            else {
              popup.dismiss();
            }
          }
        });

    attachButton = (ImageButton) view.findViewById(R.id.button_attach);
    attachButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onAttachButtonPressed();
          }
        });

    return view;
  }
Ejemplo n.º 29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    activity = this;
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    adapter_lock = false;
    if (toolbar != null) {
      toolbar.inflateMenu(R.menu.tool_bar_items);
      toolbar.setOnMenuItemClickListener(
          new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
              Log.i(TAG, "onMenuItemClickListener.");
              int menuItemId = item.getItemId();
              if (menuItemId == R.id.action_sort_by_rssi) {
                lock_list();
                mDevices.sortDevices(BeaconDeviceListAdapter.SortType.BEACON_DEVICE_SORT_BY_RSSI);
                mDevices.notifyDataSetChanged();
                unlock_list();
              } else if (menuItemId == R.id.action_settings) {

              } else if (menuItemId == R.id.action_about) {

              } else if (menuItemId == R.id.action_sort_by_majorminor) {
                lock_list();
                mDevices.sortDevices(
                    BeaconDeviceListAdapter.SortType.BEACON_DEVICE_SORT_BY_MAJOR_MINOR);
                mDevices.notifyDataSetChanged();
                unlock_list();
              }
              return false;
            }
          });

      toolbar.setTitle(R.string.app_name);
    }

    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
      android.util.Log.i("xgx", "current device does not support ble.");
      Toast.makeText(this, "Current phone does not support BLE.", Toast.LENGTH_SHORT).show();
      finish();
    }
    final BluetoothManager bluetoothManager =
        (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = bluetoothManager.getAdapter();

    if (mBluetoothAdapter == null) {
      Toast.makeText(this, "Current phone does not support BLE.", Toast.LENGTH_SHORT).show();
      Log.i(TAG, "get adapter failed!");
      finish();
    }

    mBluetoothAdapter.enable();

    ListView listView = (ListView) findViewById(R.id.listView);
    mDevices = new BeaconDeviceListAdapter(this);
    if (listView != null) {
      listView.setAdapter(mDevices);
      listView.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              Log.i(TAG, "onItemClick! position = " + position + " id = " + id);
              BeaconDevice device = mDevices.getDevice(position);
              Intent intent = new Intent(activity, DeviceConfigActivity.class);
              Bundle bundle = new Bundle();
              // bundle.putString("mac", device.mac);
              bundle.putParcelable("BeaconDevice", device);
              intent.putExtra("bundle", bundle);
              Log.i(TAG, "put BeaconDevice: " + device.toString());
              startActivityForResult(intent, DeviceConfigActivity.ResultReqestCode);
            }
          });
    }
  }
Ejemplo n.º 30
0
  private void setupAppBar() {
    mAppBar = (Toolbar) findViewById(R.id.app_bar);
    mAppBar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            onNavigateUp();
          }
        });

    final LayoutInflater inflater = LayoutInflater.from(this);
    Spinner sectionSpinner = (Spinner) findViewById(R.id.section_spinner);
    sectionSpinner.setAdapter(
        new BaseAdapter() {
          @Override
          public int getCount() {
            return SECTION_LABELS.length;
          }

          @Override
          public Object getItem(int position) {
            return SECTION_LABELS[position];
          }

          @Override
          public long getItemId(int position) {
            return position + 1;
          }

          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
              convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item, parent, false);
            }
            ((TextView) convertView.findViewById(android.R.id.text1))
                .setText(getString(SECTION_LABELS[position]));
            return convertView;
          }

          @Override
          public View getDropDownView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
              convertView =
                  inflater.inflate(R.layout.settings_ab_spinner_list_item_dropdown, parent, false);
            }
            ((TextView) convertView.findViewById(android.R.id.text1))
                .setText(getString(SECTION_LABELS[position]));
            return convertView;
          }
        });

    sectionSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> spinner, View view, int position, long id) {
            Class<? extends Fragment> fragmentClass = SECTION_FRAGMENTS[position];
            Fragment currentFragment =
                getSupportFragmentManager().findFragmentById(R.id.content_container);
            if (currentFragment != null && fragmentClass.equals(currentFragment.getClass())) {
              return;
            }

            inflateMenuFromFragment(0);

            try {
              Fragment newFragment = fragmentClass.newInstance();
              getSupportFragmentManager()
                  .beginTransaction()
                  .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                  .setTransitionStyle(R.style.Muzei_SimpleFadeFragmentAnimation)
                  .replace(R.id.content_container, newFragment)
                  .commitAllowingStateLoss();
            } catch (Exception e) {
              throw new RuntimeException(e);
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> spinner) {}
        });

    sectionSpinner.setSelection(mStartSection);

    inflateMenuFromFragment(0);
    mAppBar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.action_get_more_sources:
                FirebaseAnalytics.getInstance(SettingsActivity.this)
                    .logEvent("more_sources_open", null);
                try {
                  Intent playStoreIntent =
                      new Intent(
                              Intent.ACTION_VIEW,
                              Uri.parse("http://play.google.com/store/search?q=Muzei&c=apps"))
                          .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
                  preferPackageForIntent(
                      SettingsActivity.this, playStoreIntent, PLAY_STORE_PACKAGE_NAME);
                  startActivity(playStoreIntent);
                } catch (ActivityNotFoundException activityNotFoundException1) {
                  Toast.makeText(
                          SettingsActivity.this, R.string.play_store_not_found, Toast.LENGTH_LONG)
                      .show();
                }
                return true;

              case R.id.action_about:
                FirebaseAnalytics.getInstance(SettingsActivity.this).logEvent("about_open", null);
                startActivity(new Intent(SettingsActivity.this, AboutActivity.class));
                return true;
            }

            Fragment currentFragment =
                getSupportFragmentManager().findFragmentById(R.id.content_container);
            if (currentFragment != null
                && currentFragment instanceof SettingsActivityMenuListener) {
              ((SettingsActivityMenuListener) currentFragment)
                  .onSettingsActivityMenuItemClick(item);
            }

            return false;
          }
        });
  }