//@Override ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); SetContentView(R::layout::main); AutoPtr<IView> view; FindViewById(R::id::myWv, (IView**)&view); mWebView = IWebView::Probe(view); AutoPtr<IWebSettingsClassic> settings; mWebView->GetSettings((IWebSettings**)&settings); settings->SetJavaScriptEnabled(TRUE); settings->SetPluginsEnabled(TRUE); mClickListener = new ButtonOnClickListener(this); AutoPtr<IView> gotoButton; gotoButton = NULL; FindViewById(R::id::goto_button1, (IView**)&gotoButton); gotoButton->SetOnClickListener(mClickListener); AutoPtr<IView> exitButton; FindViewById(R::id::exit_button, (IView**)&exitButton); exitButton->SetOnClickListener(mClickListener); AutoPtr<IView> testButton; FindViewById(R::id::test_button, (IView**)&testButton); testButton->SetOnClickListener(mClickListener); mWebView->AddJavascriptInterface(THIS_PROBE(IObjectFactory), String("CarObjectFactory")); mWebView->AddJavascriptInterface(THIS_PROBE(ILogger), String("CarLogger")); return NOERROR; }
ECode CAboutActivity::OnCreate( /* [in] */ IBundle* savedInstanceState) { Logger::D(TAG, "OnCreate()---"); Activity::OnCreate(savedInstanceState); SetContentView(R::layout::activity_about); AutoPtr<MyListener> l = new MyListener(this); AutoPtr<IView> view = FindViewById(R::id::about_back); mBackButton = IImageView::Probe(view); assert(mBackButton != NULL); mBackButton->SetOnClickListener(l.Get()); view = FindViewById(R::id::about_version); AutoPtr<ITextView> versionView = ITextView::Probe(view); assert(versionView != NULL); String pkgName, pkgVersion; AutoPtr<IPackageManager> pkgMgr; AutoPtr<IPackageInfo> pkgInfo; GetPackageName(&pkgName); GetPackageManager((IPackageManager**)&pkgMgr); pkgMgr->GetPackageInfo(pkgName, 0, (IPackageInfo**)&pkgInfo); pkgInfo->GetVersionName(&pkgVersion); Logger::D(TAG, "OnCreate()---pkgVersion:%s", pkgVersion.string()); AutoPtr<ICharSequence> cs; CStringWrapper::New(pkgVersion, (ICharSequence**)&cs); versionView->SetText(cs); return NOERROR; }
ECode CSplitClockView::OnFinishInflate() { LinearLayout::OnFinishInflate(); AutoPtr<IView> view; FindViewById(R::id::time_view, (IView**)&view); mTimeView = ITextClock::Probe(view); FindViewById(R::id::am_pm_view, (IView**)&view); mAmPmView = ITextClock::Probe(view); return NOERROR; }
ECode CompatModePanel::OnFinishInflate() { AutoPtr<IView> tmpView = FindViewById(SystemUIR::id::compat_mode_on_radio); mOnButton = IRadioButton::Probe(tmpView.Get()); tmpView = FindViewById(SystemUIR::id::compat_mode_off_radio); mOffButton = IRadioButton::Probe(tmpView.Get()); mOnButton->SetOnClickListener(THIS_PROBE(IViewOnClickListener)); mOffButton->SetOnClickListener(THIS_PROBE(IViewOnClickListener)); Refresh(); return NOERROR; }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); PRINT_ENTER_LEAVE("CActivityOne::OnCreate"); SetContentView(R::layout::main); AutoPtr<IObjectContainer> dataList; CParcelableObjectContainer::New((IObjectContainer**)&dataList); for (Int32 i = 0; i < 2; ++i) { StringBuilder sb("测试 "); sb += i; AutoPtr<ICharSequence> seq = sb.ToCharSequence(); dataList->Add(seq.Get()); } AutoPtr<IArrayAdapter> adapter; CArrayAdapter::New(this, R::layout::list_item, dataList, (IArrayAdapter**)&adapter); assert(adapter != NULL); AutoPtr<IView> temp = FindViewById(R::id::autoCompleteTextView1); mView = IAutoCompleteTextView::Probe(temp); AutoPtr<IListAdapter> tempAdapter = IListAdapter::Probe(adapter.Get()); mView->SetAdapter(tempAdapter); AutoPtr<IViewOnFocusChangeListener> li = new FocusChange(this); //mView->SetOnFocusChangeListener(li); return NOERROR; }
ECode CVideoPlayer::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); SetContentView(2130903046);//R.layout.videoplayer mVideoView = IVideoView::Probe(FindViewById(0x7f07000a));//R::Id::VideoView AutoPtr<IMediaController> mediaController; // FAIL_RETURN(CMediaController::New(this, (IMediaController**)&mediaController)); mediaController->SetAnchorView(mVideoView); AutoPtr<IIntent> intent; FAIL_RETURN(GetIntent((IIntent**)&intent)); AutoPtr<IUri> data; intent->GetData((IUri**)&data); if (data == NULL) return NOERROR; String spec; String scheme; data->GetScheme(&scheme) ; if (String("vnd.youtube").Equals(scheme)) { String ssp; data->GetSchemeSpecificPart(&ssp); String id = ssp.Substring(0, ssp.IndexOf('?')); FAIL_RETURN(GetSpecFromYouTubeVideoID(id, &spec)); } if (spec == NULL) return NOERROR; AutoPtr<IUri> video; // FAIL_RETURN(Uri::Parse(spec, (IUri**)&video)); FAIL_RETURN(mVideoView->SetMediaController(mediaController)); FAIL_RETURN(mVideoView->SetVideoURI(video)); FAIL_RETURN(IMediaPlayerControl::Probe(mVideoView)->Start()); return NOERROR; }
ECode ActionBarContainer::OnFinishInflate() { FrameLayout::OnFinishInflate(); mActionBarView = IActionBarView::Probe(FindViewById(R::id::action_bar)); return NOERROR; }
ZoomControlExternal::ExtendedZoomControls::ExtendedZoomControls( /* [in] */ IContext* context) : FrameLayout(context, NULL) { //because this will be transfer to other function(see below) //which will store this in a local AutoPtr variable, //without this, after the func, the memory for this object is destroyed //also remember to add the Release for this, see ZoomControlExternal::CreateZoomControls. this->AddRef(); AutoPtr<ILayoutInflater> inflater; context->GetSystemService(IContext::LAYOUT_INFLATER_SERVICE, (IInterface**)&inflater); AutoPtr<IView> view; inflater->Inflate(R::layout::zoom_magnify, this, TRUE, (IView**)&view); FindViewById(R::id::zoomControls, (IView**)&mPlusMinusZoomControls); AutoPtr<IView> v; FindViewById(R::id::zoomMagnify, (IView**)&v); v->SetVisibility(IView::GONE); }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); SetContentView(R::layout::main); AutoPtr<MyListener> l = new MyListener(this); IViewOnClickListener* clickListener = (IViewOnClickListener*)(l->Probe(EIID_IViewOnClickListener)); mSharingSimpleData = FindViewById(R::id::sharingsimpledata); assert(mSharingSimpleData != NULL); mSharingSimpleData->SetOnClickListener(clickListener); mSharingFiles = FindViewById(R::id::sharingfiles); assert(mSharingFiles != NULL); mSharingFiles->SetOnClickListener(clickListener); return NOERROR; }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); PRINT_ENTER_LEAVE("CActivityOne::OnCreate"); SetContentView(R::layout::main); AutoPtr<IView> temp = FindViewById(R::id::ratingBar); AutoPtr<IRatingBar> bar = IRatingBar::Probe(temp); AutoPtr<IOnRatingBarChangeListener> listener = new RatingBarListener(this); bar->SetOnRatingBarChangeListener(listener); return NOERROR; }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { SetContentView(0x7f030000); AutoPtr<IView> view = FindViewById(0x7f050000); assert(view != NULL); //AutoPtr<MyListener> l = new MyListener(this); //view->SetOnClickListener(l.Get()); return NOERROR; }
ECode ToggleSlider::InitImpl( /* [in] */ IContext* context, /* [in] */ IAttributeSet* attrs, /* [in] */ Int32 defStyle) { AutoPtr<IView> tmpView; View::Inflate(context, SystemUIR::layout::status_bar_toggle_slider, THIS_PROBE(IViewGroup), (IView**)&tmpView); AutoPtr<IResources> res; context->GetResources((IResources**)&res); AutoPtr<ArrayOf<Int32> > attrIds = ArrayOf<Int32>::Alloc( const_cast<Int32 *>(SystemUIR::styleable::ToggleSlider), ARRAY_SIZE(SystemUIR::styleable::ToggleSlider)); AutoPtr<ITypedArray> a; context->ObtainStyledAttributes(attrs, attrIds, defStyle, 0, (ITypedArray**)&a); tmpView = FindViewById(SystemUIR::id::toggle); mToggle = ICompoundButton::Probe(tmpView.Get()); mToggle->SetOnCheckedChangeListener(THIS_PROBE(ICompoundButtonOnCheckedChangeListener)); AutoPtr<IDrawable> drawable; res->GetDrawable(SystemUIR::drawable::status_bar_toggle_button, (IDrawable**)&drawable); mToggle->SetBackgroundDrawable(drawable); tmpView = FindViewById(SystemUIR::id::slider); mSlider = ISeekBar::Probe(tmpView.Get()); mSlider->SetOnSeekBarChangeListener(THIS_PROBE(ISeekBarOnSeekBarChangeListener)); tmpView = FindViewById(SystemUIR::id::label); mLabel = ITextView::Probe(tmpView.Get()); String text; a->GetString(SystemUIR::styleable::ToggleSlider_text, &text); AutoPtr<ICharSequence> textSeq; CString::New(text, (ICharSequence**)&textSeq); mLabel->SetText(textSeq); a->Recycle(); return NOERROR; }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { SetContentView(0x7f030000); AutoPtr<IView> view = FindViewById(0x7f050000); AutoPtr<INumberPicker> numberPicker = INumberPicker::Probe(view); assert(numberPicker != NULL); ArrayOf<String>* rangs = ArrayOf<String>::Alloc(10); (*rangs)[0] = String("0"); (*rangs)[1] = String("1"); (*rangs)[2] = String("2"); (*rangs)[3] = String("3"); (*rangs)[4] = String("4"); (*rangs)[5] = String("5"); (*rangs)[6] = String("6"); (*rangs)[7] = String("7"); (*rangs)[8] = String("8"); (*rangs)[9] = String("9"); Int32 len = rangs->GetLength(); numberPicker->SetRangeEx(0, 9, *rangs); return NOERROR; }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); PEL("CActivityOne::OnCreate"); SetContentView(R::layout::main); AutoPtr<IView> tabhost = FindViewById(R::id::tabhost); mTabHost = ITabHost::Probe(tabhost); assert(mTabHost); mTabHost->Setup(); AutoPtr<ITabSpec> specone; mTabHost->NewTabSpec(String("tab1"), (ITabSpec**)&specone); AutoPtr<ICharSequence> one; CStringWrapper::New(String("Tab One"), (ICharSequence**)&one); specone->SetIndicator(one); specone->SetContent(R::id::view1); mTabHost->AddTab(specone); AutoPtr<ITabSpec> spectwo; mTabHost->NewTabSpec(String("tab2"), (ITabSpec**)&spectwo); AutoPtr<ICharSequence> two; CStringWrapper::New(String("Tab Two"), (ICharSequence**)&two); spectwo->SetIndicator(two); spectwo->SetContent(R::id::view2); mTabHost->AddTab(spectwo); AutoPtr<ITabSpec> specthree; mTabHost->NewTabSpec(String("tab3"), (ITabSpec**)&specthree); AutoPtr<ICharSequence> three; CStringWrapper::New(String("Tab Three"), (ICharSequence**)&three); specthree->SetIndicator(three); specthree->SetContent(R::id::view3); mTabHost->AddTab(specthree); /*AutoPtr<IView> DatePicker = FindViewById(R::id::DatePicker); mDate = IDatePicker::Probe(DatePicker);*/ /*AutoPtr<IView> bar = FindViewById(R::id::SeekBar); mBar = ISeekBar::Probe(bar); AutoPtr<IView> ProgressBar = FindViewById(R::id::ProgressBar); mProgress = IProgressBar::Probe(ProgressBar); AutoPtr<IView> num = FindViewById(R::id::NumberPicker); mNumber = INumberPicker::Probe(num); AutoPtr<IView> timepicker = FindViewById(R::id::TimePicker); mTime = ITimePicker::Probe(timepicker); AutoPtr<IView> switcher = FindViewById(R::id::ViewSwitcher); mSwitcher = IViewSwitcher::Probe(switcher); AutoPtr<IView> prev = FindViewById(R::id::prev); AutoPtr<IView> next = FindViewById(R::id::next); mPrev = IImageButton::Probe(prev); mNext = IImageButton::Probe(next); AutoPtr<IView> imageswitcher = FindViewById(R::id::ImageSwitcher); mImageSwitch = IImageSwitcher::Probe(imageswitcher); AutoPtr<IView> imageprev = FindViewById(R::id::last); AutoPtr<IView> imagenext = FindViewById(R::id::next); mImagePrev = IImageButton::Probe(imageprev); mImageNext = IImageButton::Probe(imagenext);*/ /*assert(mBar); assert (mProgress); assert (mNumber); assert(mSwitcher); assert(mPrev && mNext); assert(mImageSwitch && mImagePrev && mImageNext); AutoPtr<IViewOnClickListener> vl = new ActivityListener(this); AutoPtr<IViewFactory> factory = new Switcher(this); mImageSwitch->SetFactory(factory); AutoPtr<IViewOnClickListener> il = new ImageSwitcherListener(this); mImagePrev->SetOnClickListener(il); mImageNext->SetOnClickListener(il); AutoPtr<IDrawable> d; AutoPtr<IResources> res; GetResources((IResources**)&res); res->GetDrawable(R::drawable::test0, (IDrawable**)&d); mList.PushBack(d); res->GetDrawable(R::drawable::test1, (IDrawable**)&d); mList.PushBack(d); res->GetDrawable(R::drawable::test2, (IDrawable**)&d); mList.PushBack(d); res->GetDrawable(R::drawable::test3, (IDrawable**)&d); mList.PushBack(d); res->GetDrawable(R::drawable::test4, (IDrawable**)&d); mList.PushBack(d); mPrev->SetOnClickListener(vl); mNext->SetOnClickListener(vl); mSwitcher->SetDisplayedChild(0); mNumber->SetMinValue(0); mNumber->SetMaxValue(9); AutoPtr<ActivityListener> listener = new ActivityListener(this); mBar->SetOnSeekBarChangeListener((ISeekBarOnSeekBarChangeListener*)listener->Probe(EIID_ISeekBarOnSeekBarChangeListener));*/ return NOERROR; }
ECode CActivityOne::OnCreate( /* [in] */ IBundle* savedInstanceState) { Activity::OnCreate(savedInstanceState); // gid_t groups0[2]; // groups0[0] = 1015; // groups0[1] = 3003; // setgroups(2, groups0); // int ngroups = getgroups(0, NULL); // gid_t* groups = (gid_t*)malloc(ngroups * sizeof(gid_t)); // int val = getgroups(ngroups, groups); // if (val >= 0) { // for (int i = 0; i < ngroups; ++i) { // printf("group: %d\n", groups[i]); // } // } // GetWindow()->SetFlags(IWindowManagerLayoutParams::FLAG_FULLSCREEN, // IWindowManagerLayoutParams::FLAG_FULLSCREEN); SetContentView(R::layout::main); AutoPtr<IView> view; view = FindViewById(R::id::videoView1); assert(view != NULL); mVideoView = IVideoView::Probe(view); String videoPath = String("/data/data/com.elastos.runtime/elastos/VideoViewDemo/data/Transformer3.flv"); //String videoPath = String("/sdcard/rainbow.mp4"); // AutoPtr<IIntent> startedIntent; // GetIntent((IIntent**)&startedIntent); // if (startedIntent != NULL) { // String tmpStr; // startedIntent->GetStringExtra(String(IIntent::EXTRA_STREAM), &tmpStr); // if (!tmpStr.IsNull()) { // videoPath = tmpStr; // } // } /*** * 将播放器关联上一个音频或者视频文件 * videoView.setVideoURI(Uri uri) * videoView.setVideoPath(String path) * 以上两个方法都可以。 */ mVideoView->SetVideoPath(videoPath); /** * w为其提供一个控制器,控制其暂停、播放……等功能 */ AutoPtr<IMediaController> mc; CMediaController::New((IContext*)this->Probe(EIID_IContext), (IMediaController**)&mc); mVideoView->SetMediaController(mc); mc->SetMediaPlayer(IMediaPlayerControl::Probe(mVideoView)); Boolean rst; mVideoView->RequestFocus(&rst); /** * 视频或者音频到结尾时触发的方法 */ // videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // @Override // public void onCompletion(MediaPlayer mp) { // Log.i("通知", "完成"); // } // }); // videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { // @Override // public boolean onError(MediaPlayer mp, int what, int extra) { // Log.i("通知", "播放中出现错误"); // return false; // } // }); IMediaPlayerControl::Probe(mVideoView)->Start(); return NOERROR; }