void inflateMenuFromFragment(int menuResId) {
    if (mAppBar == null) {
      return;
    }

    mAppBar.getMenu().clear();
    if (menuResId != 0) {
      mAppBar.inflateMenu(menuResId);
    }
    mAppBar.inflateMenu(R.menu.settings);
  }
  /** {@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;
  }
Exemple #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*getSupportActionBar().setTitle("Event Details");
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);*/
    setContentView(R.layout.event_detail_view);

    ButterKnife.bind(this);

    Bundle b = this.getIntent().getExtras();
    Event event = (Event) b.getSerializable("curItem");

    lblTitle.setText(event.getTitle());
    lblEventDetail.setText(
        "From " + event.getStartdate() + " till " + event.getEnddate() + " at " + event.getCity());
    U.LoadImage(this, iv, event.getImgName());

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setAdapter(new SampleFragmentPagerAdapter(getSupportFragmentManager(), event));

    PagerSlidingTabStrip tabsStrip = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    tabsStrip.setShouldExpand(true);
    tabsStrip.setViewPager(viewPager);
    tabsStrip.setShouldExpand(false);

    final Toolbar advToolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
    advToolbar.setTitle("Event Detail");
    advToolbar.setTitleTextColor(R.color.colorPrimaryDark);
    advToolbar.inflateMenu(R.menu.advance_search);
  }
  protected void initializeToolbar() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mToolbar == null) {
      throw new IllegalStateException(
          "Layout is required to include a Toolbar with id " + "'toolbar'");
    }
    mToolbar.inflateMenu(R.menu.main);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout != null) {
      NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
      if (navigationView == null) {
        throw new IllegalStateException("Layout requires a NavigationView " + "with id 'nav_view'");
      }

      // Create an ActionBarDrawerToggle that will handle opening/closing of the drawer:
      mDrawerToggle =
          new ActionBarDrawerToggle(
              this,
              mDrawerLayout,
              mToolbar,
              R.string.open_content_drawer,
              R.string.close_content_drawer);
      mDrawerLayout.setDrawerListener(mDrawerListener);
      populateDrawerItems(navigationView);
      setSupportActionBar(mToolbar);
      updateDrawerToggle();
    } else {
      setSupportActionBar(mToolbar);
    }

    mToolbarInitialized = true;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_mealplan, container, false);
    loadingProgress = (ProgressBar) view.findViewById(R.id.loading_mealplan);
    backButton = (ImageButton) view.findViewById(R.id.toolbarButton);
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.meal_plan_toolbar);
    toolbar.setTitle("");
    toolbar.inflateMenu(R.menu.drawer_view);
    toolbar.showOverflowMenu();

    TextView toolbarName = (TextView) view.findViewById(R.id.toolbarName);
    toolbarName.setText("Awesome Mealplan");

    mainActivity = (MainActivity) getActivity();
    mainActivity.setSupportActionBar(toolbar);
    viewPager = (ViewPager) view.findViewById(R.id.meal_plan_viewpager);
    tabLayout = (TabLayout) view.findViewById(R.id.meal_plan_tablayout);

    hideToolbar();
    sendJSONRequest();

    backButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            getActivity().onBackPressed();
          }
        });

    return view;
  }
  private void createSaveButton() {
    mToolbar = ((MainActivity) getActivity()).getToolbar();
    mToolbar.inflateMenu(R.menu.menu_save);

    ImageButton saveButton =
        (ImageButton) mToolbar.getMenu().findItem(R.id.save_view).getActionView();
    saveButton.setImageDrawable(
        ContextCompat.getDrawable(getActivity(), R.drawable.ic_action_save));
    saveButton.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.ColorPrimaryDark));
    saveButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (isReadyToSave()) {
              saveUpdatedProfile();
              Toast.makeText(getActivity(), "Successfully saved", Toast.LENGTH_SHORT).show();
              InputMethodManager imm =
                  (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(
                  view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
              ((MainActivity) getActivity()).setupProfileOnDrawer();
              ((MainActivity) getActivity()).openDrawer();
            }
          }
        });
  }
  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;
          }
        });
  }
 @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();
 }
 @Override
 public void onCreateToolbar(Toolbar toolbar) {
   super.onCreateToolbar(toolbar);
   if (shouldAddActionItems()) {
     toolbar.inflateMenu(R.menu.feeditem_overflow);
     mMenu = toolbar.getMenu();
     configureOverflow(mFavorited);
   }
 }
  @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 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
  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);
  }
 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);
 }
  @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();
  }
Exemple #15
0
 private void initToolBar() {
   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   setSupportActionBar(toolbar);
   setTitle(R.string.book_detail);
   toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
   toolbar.setNavigationOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           onBackPressed();
         }
       });
   toolbar.inflateMenu(R.menu.book_detail);
 }
  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);
  }
  @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);
  }
  private void setUpToolBar() {

    ((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar);
    mToolbar.inflateMenu(R.menu.menu_movie_details);

    if (!Utils.isTablet(mContext)) {
      ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeButtonEnabled(true);
      ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    collapsingToolbarLayout.setTitle(mMovie.getTitle());
    collapsingToolbarLayout.setExpandedTitleColor(
        getResources().getColor(android.R.color.transparent));
    Glide.with(mContext)
        .load(mMovie.getBackdrop_url())
        .asBitmap()
        .error(R.drawable.not_available)
        .placeholder(R.drawable.placeholder)
        .into(
            new BitmapImageViewTarget(backdrop) {
              @Override
              public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                super.onResourceReady(bitmap, anim);
                Palette.from(bitmap)
                    .generate(
                        new Palette.PaletteAsyncListener() {
                          @SuppressWarnings("ResourceType")
                          @Override
                          public void onGenerated(Palette palette) {
                            mutedColor = palette.getMutedColor(R.color.colorPrimary);
                            if (getLuminance(mutedColor) < 240) {
                              collapsingToolbarLayout.setContentScrimColor(mutedColor);
                              collapsingToolbarLayout.setStatusBarScrimColor(
                                  getDarkerColor(mutedColor));
                              return;
                            }
                          }
                        });
              }
            });

    collapsingToolbarLayout.setContentScrimColor(getResources().getColor(R.color.colorPrimary));
    collapsingToolbarLayout.setStatusBarScrimColor(
        getResources().getColor(R.color.colorPrimaryDark));
  }
Exemple #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);
 }
  @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;
          }
        });
  }
  @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));
  }
  private void setToolbar(View view) {
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.menu_main);
    toolbar.setNavigationIcon(R.drawable.back);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            backToCatalogueFragment();
          }

          private void backToCatalogueFragment() {
            CatalogueFragment catalogueFragment =
                (CatalogueFragment)
                    getActivity()
                        .getSupportFragmentManager()
                        .findFragmentByTag(CatalogueFragment.TAG);
            FragmentManager fm = getActivity().getSupportFragmentManager();
            fm.beginTransaction()
                .replace(R.id.container, catalogueFragment, CatalogueFragment.TAG)
                .commit();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (BuildConfig.DEBUG) {
      // デバッグ時にステータスバー消去
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    setContentView(getLayoutId());
    prepareCreate();

    // ToolBar
    mToolBar = (Toolbar) findViewById(R.id.toolbar);
    mToolBar.setTitle(R.string.app_name);
    mToolBar.inflateMenu(getToolBarId());
    if (!mToolBarEnabled) {
      mToolBar.setVisibility(View.GONE);
    }

    // FloatingActionButton
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            // TODO:クリック時の動作を指定できる仕組みを作る
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
    if (!mFabEnabled) {
      fab.setVisibility(View.GONE);
    }

    // NavigationView
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            mToolBar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    toggle.setDrawerIndicatorEnabled(true);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(getNavViewId());
    navigationView.setNavigationItemSelectedListener(this);

    mToolBar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (drawer.isDrawerOpen(Gravity.LEFT)) {
              drawer.closeDrawer(Gravity.LEFT);
            } else {
              drawer.openDrawer(Gravity.LEFT);
            }
          }
        });

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
  }
Exemple #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lex);

    // checkTTS();
    speaker = new Speaker(this);

    lexTitle = (TextView) findViewById(R.id.lexTitle);
    Typeface frutiger = Typeface.createFromAsset(getAssets(), "fonts/Frutiger-Bold.ttf");
    lexTitle.setTypeface(frutiger);

    speechDisplay = (TextView) findViewById(R.id.speech_display);
    speechDisplay2 = (TextView) findViewById(R.id.speech_display2);

    homeButton = (ImageButton) findViewById(R.id.homeButton);
    homeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(LexActivity.this, MainActivity.class));
          }
        });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.lex_menu);

    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem menuItem) {

            switch (menuItem.getItemId()) {
              case R.id.lighting_menu:
                startActivity(new Intent(LexActivity.this, LightingActivity.class));
                return true;
              case R.id.heating_menu:
                startActivity(new Intent(LexActivity.this, HeatingActivity.class));
                return true;
              case R.id.appliances_menu:
                startActivity(new Intent(LexActivity.this, AppliancesActivity.class));
                return true;
              case R.id.usage_menu:
                startActivity(new Intent(LexActivity.this, UsageActivity.class));
                return true;
            }

            return false;
          }
        });

    lexSpeech = (ImageButton) findViewById(R.id.lex_speech);
    lexSpeech.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            speechDisplay.setText("");
            speechDisplay2.setText("");
            Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en_gb");
            startActivityForResult(intent, REQUEST_SPEECH);
          }
        });

    // checkTTS();
  }
Exemple #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);

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

    if (getResources().getBoolean(R.bool.is_wide)) {
      toolbar.setOnMenuItemClickListener(
          new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
              int id = item.getItemId();

              //noinspection SimplifiableIfStatement
              if (id == R.id.action_settings) {
                return true;
              }
              return true;
            }
          });

      // Inflate a menu to be displayed in the toolbar
      toolbar.inflateMenu(R.menu.menu_main);
    } else {
      setSupportActionBar(toolbar);
    }

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    fab = (FloatingActionButton) findViewById(R.id.fab);

    tabLayout = (TabLayout) findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);

    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());

            if (!getResources().getBoolean(R.bool.is_wide)) {
              switch (tab.getPosition()) {
                case 0:
                  fab.show();
                  getIntent()
                      .putExtra(
                          FloatingActionButtonBehavior.FAB_ENABLED_PARAM,
                          FloatingActionButtonBehavior.FAB_ENABLED_TRUE);
                  break;
                case 1:
                  fab.hide();
                  getIntent()
                      .putExtra(
                          FloatingActionButtonBehavior.FAB_ENABLED_PARAM,
                          FloatingActionButtonBehavior.FAB_ENABLED_FALSE);
                  break;
              }
            }
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Exemple #26
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);
            }
          });
    }
  }
  @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();
    }
  }
  @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) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_contact_view, container, false);

    // Use this to indicate the ratio
    /*Display display = getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    int width = point.x;
    int height = point.y;

    // This indicate ratio based on Material design
    RelativeLayout headerSection = (RelativeLayout) v.findViewById(R.id.contact_view_header);

    // We are using LinearLayout is because in activity_contact_view the root layout is LinearLayout
    // and this layout contains contact_view_header
    headerSection.setLayoutParams(new LinearLayout.LayoutParams(width, (int) (width * (9.0 / 16.0))));*/

    mContact = ContactList.getInstance().get(mPosition);

    mContactName = (TextView) v.findViewById(R.id.contact_name);

    Toolbar toolbar = (Toolbar) v.findViewById(R.id.contact_view_toolbar);
    //  setSupportActionBar(toolbar);

    // To catch the click on the menu item edit (icon)
    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.contact_view_edit) {
              getContrat().selectedEditPosition(mPosition);
              // Before we use Intent here so fragment was couple with activity
              /* Intent intent = new Intent(getActivity(), ContactEditActivity.class);
              intent.putExtra(ContactEditActivity.EXTRA, mPosition);
              startActivity(intent);*/
              Log.d(TAG, "Edit is clicked");
            }

            return false;
          }
        });

    toolbar.inflateMenu(R.menu.menu_contact_view);

    ListView listView = (ListView) v.findViewById(R.id.contact_view_fields);
    mAdapter = new FieldsAdapter(mContact);
    listView.setAdapter(mAdapter);

    // To use this palette we have to add an external library
    // compile "com.android.support:palette-v7:21.0.+"  in build.gradle (Module:app)

    // Palette takes an image, analyzes it and finds the prominent colors.
    // To do this we need a bitmap which is an object that holds image data.
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.parrots);
    Palette palette = Palette.generate(bitmap);

    // With our Palette now created, we can get a color from it and use that to change the color of
    // our icons.
    mColor = palette.getDarkVibrantSwatch().getRgb();

    updateUI();
    return v;
  }
  @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;
  }