private void proceedIntent(Intent intent) { if (intent != null) { String link = intent.getStringExtra("link"); if (!StringUtil.isEmpty(link)) { Intents.openBrowser(this, link); finish(); return; } Uri data = intent.getData(); if (data != null && data.getScheme().equalsIgnoreCase("tel")) { String path = data.getSchemeSpecificPart(); showPhone(path); getTracker().track("onShowPhone:intent"); } String action = intent.getAction(); String type = intent.getType(); if (action != null && "com.android.phone.action.RECENT_CALLS".equals(action)) { mViewPager.setCurrentItem(1); } else if ("android.intent.action.VIEW".equals(action) && "vnd.android.cursor.dir/calls".equals(type)) { mViewPager.setCurrentItem(1); } else if (type != null && "vnd.android.cursor.dir/calls".equals(type)) { mViewPager.setCurrentItem(1); onBackPressed(); } removeMissedCallNotifications(this); } }
@Override public void perform(UiController uiController, View view) { ViewPager pager = (ViewPager) view; int pagerLength = pager.getAdapter().getCount(); if (mNumSwipes != -1) { pagerLength = Math.min(pagerLength, mNumSwipes); } for (int x = 1; x < pagerLength; x++) { switch (mDirection) { case LEFT: pager.setCurrentItem(pagerLength - (x + 1), true); uiController.loopMainThreadUntilIdle(); // If you'd like the ViewPager to pause // on each swipe for human inspection // replace loopMainThreadUntilIdle // with: // uiController.loopMainThreadForAtLeast(200); break; case RIGHT: pager.setCurrentItem(x, true); uiController.loopMainThreadUntilIdle(); // uiController.loopMainThreadForAtLeast(200); break; } } }
// 定义一个底部导航栏图标变化的方法 public void iconChange(int num) { switch (num) { case R.id.layout_home: case 0: image_home.setImageResource(R.mipmap.ic_tabbar_home_selected); text_home.setTextColor(Blue); viewPager.setCurrentItem(0); break; case R.id.layout_folders: case 1: image_folders.setImageResource(R.mipmap.ic_tabbar_folders_selected); text_folders.setTextColor(Blue); viewPager.setCurrentItem(1); break; case R.id.layout_friends: case 2: image_friends.setImageResource(R.mipmap.ic_tabbar_friends_selected); text_friends.setTextColor(Blue); viewPager.setCurrentItem(2); break; case R.id.layout_settings: case 3: image_settings.setImageResource(R.mipmap.ic_tabbar_settings_selected); text_settings.setTextColor(Blue); viewPager.setCurrentItem(3); break; } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case 100: { if (resultCode == RESULT_OK && null != data) { atual = viewPager.getCurrentItem(); ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); stringSpeak = result.get(0); if (stringSpeak.toLowerCase().contains("next")) { if (atual == (tabs.size() - 1)) { viewPager.setCurrentItem(0); } else { viewPager.setCurrentItem(atual + 1); } } else if (stringSpeak.toLowerCase().contains("back")) { if (atual == 0) { viewPager.setCurrentItem(tabs.size() - 1); } else { viewPager.setCurrentItem(atual - 1); } } else { Toast.makeText(getApplicationContext(), "Invalid Command", Toast.LENGTH_LONG).show(); } } break; } } }
@Override public void onClick(View v) { findImage.clearColorFilter(); libImage.clearColorFilter(); contriImage.clearColorFilter(); switch (v.getId()) { case R.id.activity_main_find: findImage.setColorFilter(getResources().getColor(R.color.tab_selectecolor)); mPagers.setCurrentItem(0); break; case R.id.activity_main_contri: contriImage.setColorFilter(getResources().getColor(R.color.tab_selectecolor)); if (!(PreferenceManager.getDefaultSharedPreferences(this) .getBoolean("login_state", false))) { Intent intent = new Intent(MainActivity.this, LoginActivity.class); startActivity(intent); } else { mPagers.setCurrentItem(1); } break; case R.id.activity_main_lib: libImage.setColorFilter(getResources().getColor(R.color.tab_selectecolor)); mPagers.setCurrentItem(2); break; } }
/** * 设置标题数据 * * @param postion */ private void changeTitleState(int postion) { // 改变标题颜色状态 switch (postion) { case 0: tvTest.setSelected(true); tvGirl.setSelected(false); tvAnswer.setSelected(false); viewpaer.setCurrentItem(0); break; case 1: tvTest.setSelected(false); tvGirl.setSelected(true); tvAnswer.setSelected(false); viewpaer.setCurrentItem(1); break; case 2: tvTest.setSelected(false); tvGirl.setSelected(false); tvAnswer.setSelected(true); viewpaer.setCurrentItem(2); break; default: break; } // 缩放标题 }
@Override public void onClick(View v) { resetTabs(); switch (v.getId()) { case R.id.chat_container: mViewPager.setCurrentItem(0, false); mIconIndicator.get(0).setIconAlpha(1f); mTextIndicator.get(0).setTextViewAlpha(1f); break; case R.id.contacts_container: mViewPager.setCurrentItem(1, false); mIconIndicator.get(1).setIconAlpha(1f); mTextIndicator.get(1).setTextViewAlpha(1f); break; case R.id.discover_container: mViewPager.setCurrentItem(2, false); mIconIndicator.get(2).setIconAlpha(1f); mTextIndicator.get(2).setTextViewAlpha(1f); break; case R.id.about_container: mViewPager.setCurrentItem(3, false); mIconIndicator.get(3).setIconAlpha(1f); mTextIndicator.get(3).setTextViewAlpha(1f); break; } }
@Override public void onClick(View v) { resetImg(); switch (v.getId()) { case R.id.Weixin: mViewPager.setCurrentItem(0); mWeixinImg.setImageResource(R.drawable.tab_weixin_pressed); break; case R.id.contact: mViewPager.setCurrentItem(1); mAddressImg.setImageResource(R.drawable.tab_address_pressed); break; case R.id.find: mViewPager.setCurrentItem(2); mFrdImg.setImageResource(R.drawable.tab_find_frd_pressed); break; case R.id.setting: mViewPager.setCurrentItem(3); mSettingImg.setImageResource(R.drawable.tab_settings_pressed); break; default: break; } }
private void initAssessments() { // TODO Auto-generated method stub prefsHandler = new PrefsHandler(AssessmentType.this); vpAssessments = (ViewPager) activityContentView.findViewById(R.id.assessments_view_viewPager_assessment_types); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); getActionBar().addTab(getActionBar().newTab().setText("Assignments").setTabListener(this)); getActionBar().addTab(getActionBar().newTab().setText("C.A.T's").setTabListener(this)); getActionBar().addTab(getActionBar().newTab().setText("End of Sem").setTabListener(this)); vpAssessments.setAdapter(new AssessmentsPagerAdapter(getSupportFragmentManager())); vpAssessments.setOnPageChangeListener(this); if (prefsHandler.isSeasonEnabled()) { switch (prefsHandler.getSeason()) { case 4: vpAssessments.setCurrentItem(0); break; case 5: vpAssessments.setCurrentItem(1); break; case 6: vpAssessments.setCurrentItem(2); break; default: vpAssessments.setCurrentItem(0); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_learn); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); if (flipper1) { mViewPager.setCurrentItem(8, false); flipper1 = false; } else if (flipper2) { mViewPager.setCurrentItem(4, false); flipper2 = false; } else if (mid) { mViewPager.setCurrentItem(8, false); mid = false; } }
/** * 定义一个底部导航栏图标变化的方法 * * @param num */ public void iconChange(int num) { switch (num) { case R.id.weixin_layout: case 0: weixin_img.setImageResource(R.drawable.ahj); weixin_txt.setTextColor(Green); mPager.setCurrentItem(0); break; case R.id.tongxunlu_layout: case 1: tongxunlu_img.setImageResource(R.drawable.ahh); tongxunlu_txt.setTextColor(Green); mPager.setCurrentItem(1); break; case R.id.faxian_layout: case 2: faxian_img.setImageResource(R.drawable.ahl); faxian_txt.setTextColor(Green); mPager.setCurrentItem(2); break; case R.id.me_layout: case 3: me_img.setImageResource(R.drawable.ahn); me_txt.setTextColor(Green); mPager.setCurrentItem(3); break; } }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.activity_main_return: break; case R.id.activity_main_landing: clickOnTop_bn02(); break; case R.id.activity_main_detail: mViewPage.setCurrentItem(0); break; case R.id.activity_main_mony: mViewPage.setCurrentItem(1); break; case R.id.activity_main_circle: mViewPage.setCurrentItem(2); break; case R.id.activity_main_myself: mViewPage.setCurrentItem(3); break; case R.id.activity_main_finish: clickOnTon_bnfinsh(); break; } }
// 监听点击事件 @Override public void onClick(View v) { Intent intent; switch (v.getId()) { case R.id.tv_gzzd: viewPager3.setCurrentItem(3); break; case R.id.tv_jezg: viewPager3.setCurrentItem(2); break; case R.id.tv_zxsx: viewPager3.setCurrentItem(1); break; case R.id.tv_zhtj: viewPager3.setCurrentItem(0); break; case R.id.sy_head: // Toast.makeText(this,"此时应该出来个menu",Toast.LENGTH_LONG).show(); menu.showMenu(); break; case R.id.search_words: // Toast.makeText(this,"尼玛",Toast.LENGTH_LONG).show(); intent = new Intent(); intent.setClass(MainActivity.this, SearchActivity.class); startActivity(intent); break; } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.last_listen_layout: cleanState(); last_listen_text.setTextColor(mContext.getResources().getColor(R.color.c14acf0)); record_main_viewpager.setCurrentItem(0); rec_one_line.setVisibility(View.VISIBLE); lastListenerSubView.onViewShow(); break; case R.id.colection_layout: cleanState(); colection_text.setTextColor(mContext.getResources().getColor(R.color.c14acf0)); record_main_viewpager.setCurrentItem(1); rec_two_line.setVisibility(View.VISIBLE); collectionSubView.onViewShow(); break; case R.id.have_down_layout: cleanState(); have_down_text.setTextColor(mContext.getResources().getColor(R.color.c14acf0)); record_main_viewpager.setCurrentItem(2); rec_three_line.setVisibility(View.VISIBLE); haveDownSubView.onViewShow(); break; default: break; } }
private void getAccelerometer(SensorEvent event) { float[] values = event.values; // Movement float x = values[0]; float y = values[1]; float z = values[2]; float accelationSquareRoot = (x * x + y * y + z * z) / (SensorManager.GRAVITY_EARTH * SensorManager.GRAVITY_EARTH); long actualTime = System.currentTimeMillis(); if (accelationSquareRoot >= 2) // { if (actualTime - lastUpdate < 200) { return; } lastUpdate = actualTime; // Toast.makeText(this, "Device was shuffed", Toast.LENGTH_SHORT) // .show(); if (checkImage) { position = viewpager.getCurrentItem(); viewpager.setCurrentItem(position); } else { position = viewpager.getCurrentItem(); position++; if (position == TOTAL_IMAGE) { position = TOTAL_IMAGE; } viewpager.setCurrentItem(position); } checkImage = !checkImage; } }
@Override public void onClick(View v) { if (v == buttonFuture) { pager.setCurrentItem(pager.getCurrentItem() + 1, true); } else if (v == buttonPast) { pager.setCurrentItem(pager.getCurrentItem() - 1, true); } }
/** 处理NewsDetailsTitleBar点击事件 */ @Override public void onClick(View v) { InputMethodManager m = (InputMethodManager) mNewsReplyContent.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); switch (v.getId()) { // 上一条新闻 case R.id.newsdetails_titlebar_previous: if (mPosition > 0) { detailViewPager.setCurrentItem(mPosition - 1); } else { Toast.makeText(this, "没有上条新闻", Toast.LENGTH_SHORT).show(); } break; // 下一条新闻 case R.id.newsdetails_titlebar_next: if (mPosition < mNewsData.size() - 1) { detailViewPager.setCurrentItem(mPosition + 1); } else { Toast.makeText(this, "没有下条新闻", Toast.LENGTH_SHORT).show(); } break; // 显示评论 case R.id.newsdetails_titlebar_comments: Intent intent = new Intent(NewsDetailsActivity.this, CommentsActivity.class); // 传递新闻ID intent.putExtra("nid", mNid); startActivity(intent); break; // 新闻回复图片 case R.id.news_reply_img_btn: mNewsReplyImgLayout.setVisibility(View.GONE); mNewsReplyEditLayout.setVisibility(View.VISIBLE); mNewsReplyContent.requestFocus(); // 使输入框聚焦 m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT); break; // 发表新闻回复 case R.id.news_reply_post: new PostCommentThread().start(); mNewsReplyImgLayout.setVisibility(View.VISIBLE); mNewsReplyEditLayout.setVisibility(View.GONE); m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); break; case R.id.news_share_btn: // 设置分享新闻 Intent intent2 = new Intent(Intent.ACTION_SEND); intent2.setType("image/*"); intent2.putExtra(Intent.EXTRA_TEXT, "来自展鸿新闻客户端:" + newslist_item_title); intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent2, getTitle())); break; case R.id.tap_back: mNewsReplyImgLayout.setVisibility(View.VISIBLE); mNewsReplyEditLayout.setVisibility(View.GONE); break; } }
/** * This method is used to change pager page. * * @param int position */ public void changePagerPage(int flag) { try { int position = flag; if (position == CATEGORY) viewpager.setCurrentItem(DATAPAGE); if (position == DATAPAGE) { viewpager.setCurrentItem(CATEGORY); } } catch (Exception e) { e.printStackTrace(); } }
@Override public void onClick(View v) { // TODO Auto-generated method stub int id = v.getId(); if (id == R.id.button_camera) { String sdStatus = Environment.getExternalStorageState(); if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // Log.d("MainActivity", "SD card is not avaiable/writeable right now."); return; } try { File dir = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera"); if (!dir.exists()) dir.mkdirs(); String name = DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg"; File f = new File(dir, name); Intent intent0 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent0.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intent0.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); Intent intent = Intent.createChooser(intent0, null); mCameraPicPath = f.getAbsolutePath(); startActivityForResult(intent, req_capture); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } else if (id == R.id.button_op) { if (mIndex == view_all) { if (mViewAll.haveData()) mViewAll.setEditMode(true); } else if (mIndex == view_like) { if (mViewLike.haveData()) mViewLike.setEditMode(true); } } else if (id == R.id.button_menu) { { showSettingMenu(); } } else if (id == R.id.button_all) { mViewPager.setCurrentItem(view_all); } else if (id == R.id.button_dir) { mViewPager.setCurrentItem(view_dir); } else if (id == R.id.button_like) { mViewPager.setCurrentItem(view_like); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.dateText: mViewPager.setCurrentItem(0); break; case R.id.timeText: mViewPager.setCurrentItem(1); break; default: break; } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_next: mPager.setCurrentItem(mPager.getCurrentItem() + 1); break; case R.id.action_previous: mPager.setCurrentItem(mPager.getCurrentItem() - 1); break; } return super.onOptionsItemSelected(item); }
private void setupDrawerContent(final NavigationView navigationView) { navigationView .getHeaderView(0) .findViewById(R.id.nav_weibo) .setOnClickListener( v -> { ClipboardHelper.copy(MainActivity.this, getResources().getString(R.string.weibo)); ToastUtil.showShortToast("微博地址[http://weibo.com/123466678]已经复制到剪贴板╮(╯_╰)╭"); }); navigationView.setNavigationItemSelectedListener( menuItem -> { switch (menuItem.getItemId()) { case R.id.nav_avatar: case R.id.nav_weibo: break; case R.id.nav_all: viewPager.setCurrentItem(0); drawerLayout.closeDrawers(); break; case R.id.nav_mm: viewPager.setCurrentItem(1); drawerLayout.closeDrawers(); break; case R.id.nav_android: viewPager.setCurrentItem(2); drawerLayout.closeDrawers(); break; case R.id.nav_ios: viewPager.setCurrentItem(3); drawerLayout.closeDrawers(); break; case R.id.nav_github: drawerLayout.closeDrawers(); jump2Url("https://github.com/login"); break; case R.id.nav_trending: drawerLayout.closeDrawers(); jump2Url("https://github.com/trending?l=java"); break; case R.id.nav_about: drawerLayout.closeDrawers(); startActivity(new Intent(this, AboutActivity.class)); break; default: return true; } return true; }); }
public void doClick(View v) { switch (v.getId()) { case R.id.zhu_bt: viewpage.setCurrentItem(2); break; case R.id.zhexian_bt: viewpage.setCurrentItem(0); break; case R.id.shanxing_bt: viewpage.setCurrentItem(1); default: break; } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.tv_test: viewpaer.setCurrentItem(0); changeTitleState(0); case R.id.tv_girl: viewpaer.setCurrentItem(1); changeTitleState(1); case R.id.tv_answer: viewpaer.setCurrentItem(2); changeTitleState(2); } }
@Override public void onClick(View v) { if (mViewPager.getCurrentItem() == 0) { ObjectAnimator anim = ObjectAnimator.ofFloat(v, "rotation", 360.0f, 315.0f); anim.setDuration(200); anim.start(); mViewPager.setCurrentItem(1); } else { ObjectAnimator anim = ObjectAnimator.ofFloat(v, "rotation", 315.0f, 360.0f); anim.setDuration(200); anim.start(); mViewPager.setCurrentItem(0); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_friends); This = this; Log.d(TAG, "Info oncreate"); ButterKnife.bind(this); parseUser = ParseUser.getCurrentUser(); alertD = new Alert(this); isLoadData = false; final ViewPager vpPager = (ViewPager) findViewById(R.id.vpPager); adapterViewPager = new MyPagerAdapter(getSupportFragmentManager()); vpPager.setAdapter(adapterViewPager); // Check data extra Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { String jsonData = extras.getString("com.parse.Data"); JSONObject json = null; try { json = new JSONObject(jsonData); String action = json.getString("action"); switch (action) { case "friends_invite": vpPager.setCurrentItem(2); break; case "friends_search": vpPager.setCurrentItem(1); break; default: vpPager.setCurrentItem(0); } } catch (JSONException e) { e.printStackTrace(); } } PagerSlidingTabStrip tabsStrip = (PagerSlidingTabStrip) findViewById(R.id.tabs); LinearLayout view = (LinearLayout) tabsStrip.getChildAt(0); tabsStrip.setViewPager(vpPager); loadData(); }
private void initView() { mCurrentTabIndex = 0; mTabTitles = new String[] { mActivity.getResources().getString(R.string.ml_chat), mActivity.getResources().getString(R.string.ml_contacts), mActivity.getResources().getString(R.string.ml_test) }; mContactsFragment = MLContactsFragment.newInstance(); mConversationFragment = MLConversationsFragment.newInstance(); mTestFragment = MLTestFragment.newInstance(); mFragments = new Fragment[] {mConversationFragment, mContactsFragment, mTestFragment}; MLViewPagerAdapter adapter = new MLViewPagerAdapter(getSupportFragmentManager(), mFragments, mTabTitles); mViewPager.setAdapter(adapter); mViewPager.setCurrentItem(mCurrentTabIndex); mViewPager.addOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels) {} @Override public void onPageSelected(int position) { getToolbar().setTitle(mTabTitles[position]); } @Override public void onPageScrollStateChanged(int state) {} }); mTabLayout.setupWithViewPager(mViewPager); }
@Override public void onClick(View v) { int firstPageCount = ((GiftKeyBoardAdapter) mAdapter).getFirstPageCount(); switch (v.getId()) { case 0: mRadioGroup.check(0); initUserPageSendGift(0); mViewPager.setCurrentItem(0); break; case 1: mRadioGroup.check(1); initUserPageSendGift(1); mViewPager.setCurrentItem(firstPageCount); break; } }
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. Log.d(Constants.TAG, "MainActivity.onTabSelected"); mViewPager.setCurrentItem(tab.getPosition()); }
@Override public void onRouteComplete() { pager.setCurrentItem(instructions.size() - 1); voiceNavigationController.playInstruction(instructions.get(instructions.size() - 1)); distanceToDestination.setDistance(0); footerWrapper.setVisibility(View.GONE); }