// Setup @Override protected void onCreate(Bundle savedInstanceState) { // Log.v("SDL", "onCreate()"); super.onCreate(savedInstanceState); // So we can call stuff from static callbacks mSingleton = this; // Set up the surface mSurface = new SDLSurface(getApplication()); // Make sure this variable is initialized here! mExitCalledFromJava = false; if (Build.VERSION.SDK_INT >= 12) { mJoystickHandler = new SDLJoystickHandler_API12(); } else { mJoystickHandler = new SDLJoystickHandler(); } mLayout = new AbsoluteLayout(this); mLayout.addView(mSurface); setContentView(mLayout); }
@Test(expected = RuntimeException.class) public void checkedClick_shouldThrowIfViewIsNotVisible() throws Exception { ViewGroup grandParent = new LinearLayout(null); ViewGroup parent = new LinearLayout(null); grandParent.addView(parent); parent.addView(view); grandParent.setVisibility(View.GONE); shadowOf(view).checkedPerformClick(); }
@Test public void shouldKnowIfThisOrAncestorsAreVisible() throws Exception { assertTrue(shadowOf(view).derivedIsVisible()); ViewGroup grandParent = new LinearLayout(null); ViewGroup parent = new LinearLayout(null); grandParent.addView(parent); parent.addView(view); grandParent.setVisibility(View.GONE); assertFalse(shadowOf(view).derivedIsVisible()); }
private void flipPage(final boolean forward) { if (!current.isFirstPage()) flipStarted = true; this.previousDirection = this.forward; this.forward = forward; if (!forward) decreasePageNo(); int nextPageIndex = forward ? currentPageIndex + 1 : currentPageIndex; System.out.println("debug flip"); if (currentPageIndex == -1 && forward) { // we are first timer currentPageIndex++; container.addView(current, pageViewLayoutParamsFront); slideToNextPageAsynchronized(); } else if (nextPageIndex > 0) { if (current.isLastPage() && forward) { finishActivity(); } slideToNextPageAsynchronized(); } else { if (pageIndexView.isHasUpdate()) { this.reload(); return; } else { finishActivity(); } } System.out.println("debug flip done"); }
@Override public Object instantiateItem(ViewGroup container, int position) { BasePager pager = mPagerList.get(position); container.addView(pager.mRootView); // pager.initData();// 初始化数据.... 不要放在此处初始化数据, 否则会预加载下一个页面 return pager.mRootView; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.estadistica_view, container, false); int idEstadistica = this.mPageNumber; // Titulo y descripcion de estadistica TextView tituloEstadistica = (TextView) rootView.findViewById(R.id.TxtTituloEstadistica); TextView descEstadistica = (TextView) rootView.findViewById(R.id.TxtDescEstadistica); tituloEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getTitulo()); descEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getDescripcion()); rootView.addView( new EstadisticaViewLayout(Utilidades.getAppContext()) .getView(RelacionEstadisticas.getRelacion().get(idEstadistica))); // } // catch (Exception e) // { // Toast.makeText(Utilidades.getAppContext(), "error: " + e.getLocalizedMessage(), // Toast.LENGTH_LONG).show(); // Log.e("ERROR", e.getLocalizedMessage()); // } // Set the title view to show the page number. /*((TextView) rootView.findViewById(android.R.id.text1)).setText( getString(R.string.title_template_step, mPageNumber + 1));*/ return rootView; }
/** package* */ void toggleWordWrap() { ViewGroup vSrc = this.mWordWrap ? this.mWordWrapView : this.mNoWordWrapView; ViewGroup vDst = this.mWordWrap ? this.mNoWordWrapView : this.mWordWrapView; ViewGroup vSrcParent = this.mWordWrap ? this.mWordWrapView : (ViewGroup) this.mNoWordWrapView.getChildAt(0); ViewGroup vDstParent = this.mWordWrap ? (ViewGroup) this.mNoWordWrapView.getChildAt(0) : this.mWordWrapView; vSrc.setVisibility(View.GONE); vSrcParent.removeView(this.mEditor); vDstParent.addView(this.mEditor); vDst.setVisibility(View.VISIBLE); vDst.scrollTo(0, 0); this.mWordWrap = !this.mWordWrap; }
// Setup @Override protected void onCreate(Bundle savedInstanceState) { // Log.v("SDL", "onCreate()"); super.onCreate(savedInstanceState); // So we can call stuff from static callbacks mSingleton = this; // Set up the surface mSurface = new SDLSurface(getApplication()); mLayout = new AbsoluteLayout(this); mLayout.addView(mSurface); setContentView(mLayout); }
/** Shows the SuperCardToast. */ public void show() { ManagerSuperCardToast.getInstance().add(this); if (!isIndeterminate) { mHandler = new Handler(); mHandler.postDelayed(mHideRunnable, mDuration); } mViewGroup.addView(mToastView); if (!showImmediate) { final Animation animation = this.getShowAnimation(); /** Invalidate the ViewGroup after the show animation completes * */ animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { /** Must use Handler to modify ViewGroup in onAnimationEnd() * */ Handler mHandler = new Handler(); mHandler.post(mInvalidateRunnable); } @Override public void onAnimationRepeat(Animation arg0) { // Do nothing } @Override public void onAnimationStart(Animation arg0) { // Do nothing } }); mToastView.startAnimation(animation); } }
@Override public void run() { AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(w, h + HEIGHT_PADDING, x, y); if (mTextEdit == null) { mTextEdit = new DummyEdit(getContext()); mLayout.addView(mTextEdit, params); } else { mTextEdit.setLayoutParams(params); } mTextEdit.setVisibility(View.VISIBLE); mTextEdit.requestFocus(); InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mTextEdit, 0); }
private void SetBackGroundforList() { // TODO Auto-generated method stub mDownView_parent_txt1 = new TextView(activity.getApplicationContext()); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); mDownView_parent_txt1.setId(Integer.parseInt("111111")); mDownView_parent_txt1.setLayoutParams(lp1); mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL); mDownView_parent_txt1.setText(HalfText); mDownView_parent_txt1.setWidth(textwidth2); mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0); mDownView_parent_txt1.setHeight(textheight); mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor)); mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor)); mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); mDownView_parent.addView(mDownView_parent_txt1, 0); // if(SwipeType==Double){ // mDownView_parent_txt2 = new TextView(activity.getApplicationContext()); // mDownView_parent_txt2.setId(222222); // RelativeLayout.LayoutParams lp2 =new // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); // lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId()); // mDownView_parent_txt2.setLayoutParams(lp2); // mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL); // mDownView_parent_txt2.setText(FullText); // mDownView_parent_txt2.setWidth(textwidth); // mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0); // mDownView_parent_txt2.setHeight(textheight); // mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor)); // mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor)); // mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null , // FullDrawable, null, null ); // mDownView_parent.addView(mDownView_parent_txt2, 1); // } }
private void showAnimation() { enlargedMode = false; renderNextPageIfNotRendered(); // Log.d("ANI", "start animation"); container.removeAllViews(); if (current.isFirstPage()) { next.setVisibility(View.VISIBLE); currentPageIndex++; container.addView(current, pageViewLayoutParamsBack); container.addView(next, pageViewLayoutParamsFront); current.startAnimation(fadeInPageView); } else if (isWeiboMode() || next.isLastPage() || next.getWrapperViews().size() < 2 || lastFlipDirection == ACTION_HORIZONTAL) { Animation rotation = buildFlipHorizonalAnimation(forward); if (forward) next.setVisibility(View.VISIBLE); else previous.setVisibility(View.VISIBLE); if (forward) { currentPageIndex++; container.addView(current, pageViewLayoutParamsBack); container.addView(next, pageViewLayoutParamsFront); current.startAnimation(rotation); } else { container.addView(current, pageViewLayoutParamsFront); container.addView(previous, pageViewLayoutParamsBack); previous.startAnimation(rotation); } } else { if (forward) { currentPageIndex++; container.addView(next, pageViewLayoutParamsFront); } else { container.addView(previous, pageViewLayoutParamsFront); } container.addView(current, pageViewLayoutParamsBack); if (forward) { currentUpper = current.getWrapperViews().get(0); currentBottom = current.getWrapperViews().get(1); nextUpper = next.getWrapperViews().get(0); nextBottom = next.getWrapperViews().get(1); final Animation flipToNext = buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, true); currentBottom.startAnimation(flipToNext); } else { currentUpper = current.getWrapperViews().get(0); currentBottom = current.getWrapperViews().get(1); nextUpper = previous.getWrapperViews().get(0); nextBottom = previous.getWrapperViews().get(1); final Animation flipToPrevious = buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, false); currentUpper.startAnimation(flipToPrevious); } } }
/** * Set up the activity; * * @param activity */ public void attachToActivity(Activity activity) { initValue(activity); setShadowAdjustScaleXByOrientation(); viewDecor.addView(this, 0); }
// Setup @Override protected void onCreate(Bundle savedInstanceState) { Log.v("SDL", "Device: " + android.os.Build.DEVICE); Log.v("SDL", "Model: " + android.os.Build.MODEL); Log.v("SDL", "onCreate():" + mSingleton); super.onCreate(savedInstanceState); SDLActivity.initialize(); // So we can call stuff from static callbacks mSingleton = this; // Load shared libraries String errorMsgBrokenLib = ""; try { loadLibraries(); } catch (UnsatisfiedLinkError e) { System.err.println(e.getMessage()); mBrokenLibraries = true; errorMsgBrokenLib = e.getMessage(); } catch (Exception e) { System.err.println(e.getMessage()); mBrokenLibraries = true; errorMsgBrokenLib = e.getMessage(); } if (mBrokenLibraries) { AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); dlgAlert.setMessage( "An error occurred while trying to start the application. Please try again and/or reinstall." + System.getProperty("line.separator") + System.getProperty("line.separator") + "Error: " + errorMsgBrokenLib); dlgAlert.setTitle("SDL Error"); dlgAlert.setPositiveButton( "Exit", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close current activity SDLActivity.mSingleton.finish(); } }); dlgAlert.setCancelable(false); dlgAlert.create().show(); return; } // Set up the surface mSurface = new SDLSurface(getApplication()); if (Build.VERSION.SDK_INT >= 12) { mJoystickHandler = new SDLJoystickHandler_API12(); } else { mJoystickHandler = new SDLJoystickHandler(); } mLayout = new AbsoluteLayout(this); mLayout.addView(mSurface); setContentView(mLayout); }