@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    activity = (AppCompatActivity) getActivity();
    View rootView = inflater.inflate(R.layout.fragment_cab_details, container, false);
    ButterKnife.bind(this, rootView);
    txtSpeechInput = (EditText) rootView.findViewById(R.id.txtSpeechInput);
    btnSpeak = (ImageButton) rootView.findViewById(R.id.btnSpeak);
    tapOnMic = (ShimmerTextView) rootView.findViewById(R.id.label_tap_on_mic);
    shimmer = new Shimmer();
    shimmer.start(tapOnMic);

    btnSpeak.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            btnSpeak.setEnabled(false);
            promptSpeechInput();
          }
        });

    return rootView;
  }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 设置no title, 一定要在setContentView之前设置
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    // 初始化相关view
    initView();
    shimmer = new Shimmer();
    shimmer.start(shimmerTextView);

    preferences = context.getSharedPreferences("one", MODE_PRIVATE);

    initMethod();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // NavigationDrawer
    View[] btns = {findViewById(R.id.review), findViewById(R.id.mail)};
    for (View view : btns) {
      view.setOnClickListener(this);
    }

    // ツールバーをアクションバーとしてセット
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    toolbar.setTitle("俺的フェラーリ速報");
    setSupportActionBar(toolbar);
    toolbar.setBackgroundColor(getResources().getColor(R.color.ferrari_red));

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle =
        new ActionBarDrawerToggle(this, mDrawerLayout, R.string.app_name, R.string.app_name);
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor("#ffffff"));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    // Shimmer
    ShimmerTextView shimmerLine = (ShimmerTextView) findViewById(R.id.logo_techmond);
    Shimmer shimmer = new Shimmer();
    shimmer.setDuration(2500).setStartDelay(1000);
    shimmer.start(shimmerLine);

    setScreenName(getString(R.string.activity_main));
    sendScreenAnalytics();

    // goodAD
    mAdManager = new AdManager();
    mAdManager.init(this);
    RelativeLayout rootLayout = (RelativeLayout) findViewById(R.id.icon_ad_layout);
    mAdManager.setUpIconAd(this, rootLayout);

    // 背景画像
    ImageView bg = (ImageView) findViewById(R.id.bg_main);
    AnimationUtil anim = new AnimationUtil();
    anim.animateAlpha(bg, 1500);

    // 通知
    NotificationUtil notify = new NotificationUtil(this);
    notify.setNotification(21, 30);

    // レビュー
    if (PreferenceManager.getDefaultSharedPreferences(this).getInt("launch", 0) != 0) {
      Random rnd = new Random();
      int ran = rnd.nextInt(3);
      if (ran == 1) {
        UserSupportUtil util = new UserSupportUtil(this);
        util.popReviewDialog();
      }
    }
    PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("launch", 1).apply();

    // INDICATOR_OFFSET・・・ タブのindicatorの幅
    final float density = getResources().getDisplayMetrics().density;
    mIndicatorOffset = (int) (INDICATOR_OFFSET * density);

    // Viewを取得
    mTrackScroller = (HorizontalScrollView) findViewById(R.id.track_scroller);
    mTrack = (ViewGroup) findViewById(R.id.track);
    mIndicator = findViewById(R.id.indicator);

    // ViewPagerのセットアップ
    // adapterは自由に作成
    mPagerAdapter = new ViewPagerAdapter(this, getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);

    // サイズ計測後の処理
    final RelativeLayout mainView = (RelativeLayout) findViewById(R.id.mainView);
    mainView.post(
        new Runnable() {
          @Override
          public void run() {
            // タブをコンテナに追加
            LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
            for (int i = 0; i < mPagerAdapter.getCount(); i++) {
              final int position = i;
              TextView tv = (TextView) inflater.inflate(R.layout.tab_item, mTrack, false);
              tv.setText(mPagerAdapter.getPageTitle(position));
              tv.getLayoutParams().width = mainView.getMeasuredWidth() / mPagerAdapter.getCount();

              // タブタップ時対応したviewPagerを表示
              tv.setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      mPager.setCurrentItem(position);
                    }
                  });
              mTrack.addView(tv);
            }
            mIndicator.getLayoutParams().width =
                mainView.getMeasuredWidth() / mPagerAdapter.getCount();
            mPager.setOnPageChangeListener(new PageChangeListener());

            mPager.setCurrentItem(1);
          }
        });
  }