Java Code Examples for android.os.Bundle#getFloat()

The following examples show how to use android.os.Bundle#getFloat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TouchImageView.java    From GankMeizhi with Apache License 2.0 6 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        normalizedScale = bundle.getFloat("saveScale");
        m = bundle.getFloatArray("matrix");
        prevMatrix.setValues(m);
        prevMatchViewHeight = bundle.getFloat("matchViewHeight");
        prevMatchViewWidth = bundle.getFloat("matchViewWidth");
        prevViewHeight = bundle.getInt("viewHeight");
        prevViewWidth = bundle.getInt("viewWidth");
        imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
        return;
    }

    super.onRestoreInstanceState(state);
}
 
Example 2
Source File: CircleProgress.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    if(state instanceof Bundle) {
        final Bundle bundle = (Bundle) state;
        textColor = bundle.getInt(INSTANCE_TEXT_COLOR);
        textSize = bundle.getFloat(INSTANCE_TEXT_SIZE);
        finishedColor = bundle.getInt(INSTANCE_FINISHED_STROKE_COLOR);
        unfinishedColor = bundle.getInt(INSTANCE_UNFINISHED_STROKE_COLOR);
        initPainters();
        setMax(bundle.getInt(INSTANCE_MAX));
        setProgress(bundle.getInt(INSTANCE_PROGRESS));
        prefixText = bundle.getString(INSTANCE_PREFIX);
        suffixText = bundle.getString(INSTANCE_SUFFIX);
        super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
        return;
    }
    super.onRestoreInstanceState(state);
}
 
Example 3
Source File: BootstrapBaseThumbnail.java    From Android-Bootstrap with MIT License 6 votes vote down vote up
@Override public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;

        this.hasBorder = bundle.getBoolean(BorderView.KEY_DISPLAYED);
        this.bootstrapSize = bundle.getFloat(BootstrapSizeView.KEY);

        Serializable brand = bundle.getSerializable(BootstrapBrandView.KEY);

        if (brand instanceof BootstrapBrand) {
            this.bootstrapBrand = (BootstrapBrand) brand;
        }
        state = bundle.getParcelable(TAG);
    }
    super.onRestoreInstanceState(state);
    updateImageState();
}
 
Example 4
Source File: MainActivity.java    From XYStudy with MIT License 6 votes vote down vote up
@Override
public void run() {
    Looper.prepare();
    tHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_MOTIONEVENT:
                    Bundle bundle = msg.getData();
                    float rx = bundle.getFloat("x");
                    float ry = bundle.getFloat("y");

                    mInst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),
                            SystemClock.uptimeMillis(), msg.arg1,
                            rx, ry, 0));
                    break;
            }
        }
    };
    Looper.loop();
}
 
Example 5
Source File: TouchImageView.java    From SwipableLayout with Apache License 2.0 6 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        normalizedScale = bundle.getFloat("saveScale");
        m = bundle.getFloatArray("matrix");
        prevMatrix.setValues(m);
        prevMatchViewHeight = bundle.getFloat("matchViewHeight");
        prevMatchViewWidth = bundle.getFloat("matchViewWidth");
        prevViewHeight = bundle.getInt("viewHeight");
        prevViewWidth = bundle.getInt("viewWidth");
        imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
        return;
    }

    super.onRestoreInstanceState(state);
}
 
Example 6
Source File: TouchImageView.java    From Ecommerce-Retronight-Android with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
  	if (state instanceof Bundle) {
     Bundle bundle = (Bundle) state;
     normalizedScale = bundle.getFloat("saveScale");
     m = bundle.getFloatArray("matrix");
     prevMatrix.setValues(m);
     prevMatchViewHeight = bundle.getFloat("matchViewHeight");
     prevMatchViewWidth = bundle.getFloat("matchViewWidth");
     prevViewHeight = bundle.getInt("viewHeight");
     prevViewWidth = bundle.getInt("viewWidth");
     imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
     super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
     return;
  	}

  	super.onRestoreInstanceState(state);
}
 
Example 7
Source File: NumberProgressBar.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    if(state instanceof Bundle){
        final Bundle bundle = (Bundle)state;
        mTextColor = bundle.getInt(INSTANCE_TEXT_COLOR);
        mTextSize = bundle.getFloat(INSTANCE_TEXT_SIZE);
        mReachedBarHeight = bundle.getFloat(INSTANCE_REACHED_BAR_HEIGHT);
        mUnreachedBarHeight = bundle.getFloat(INSTANCE_UNREACHED_BAR_HEIGHT);
        mReachedBarColor = bundle.getInt(INSTANCE_REACHED_BAR_COLOR);
        mUnreachedBarColor = bundle.getInt(INSTANCE_UNREACHED_BAR_COLOR);
        initializePainters();
        setMax(bundle.getInt(INSTANCE_MAX));
        setProgress(bundle.getInt(INSTANCE_PROGRESS));
        setPrefix(bundle.getString(INSTANCE_PREFIX));
        setSuffix(bundle.getString(INSTANCE_SUFFIX));
        setProgressTextVisibility(bundle.getBoolean(INSTANCE_TEXT_VISBILITY) ? ProgressTextVisibility.Visible : ProgressTextVisibility.Invisible);
        super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
        return;
    }
    super.onRestoreInstanceState(state);
}
 
Example 8
Source File: TouchImageView.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        normalizedScale = bundle.getFloat("saveScale");
        m = bundle.getFloatArray("matrix");
        prevMatrix.setValues(m);
        prevMatchViewHeight = bundle.getFloat("matchViewHeight");
        prevMatchViewWidth = bundle.getFloat("matchViewWidth");
        prevViewHeight = bundle.getInt("viewHeight");
        prevViewWidth = bundle.getInt("viewWidth");
        imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
        return;
    }

    super.onRestoreInstanceState(state);
}
 
Example 9
Source File: TouchImageView.java    From Document-Scanner with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        normalizedScale = bundle.getFloat("saveScale");
        m = bundle.getFloatArray("matrix");
        prevMatrix.setValues(m);
        prevMatchViewHeight = bundle.getFloat("matchViewHeight");
        prevMatchViewWidth = bundle.getFloat("matchViewWidth");
        prevViewHeight = bundle.getInt("viewHeight");
        prevViewWidth = bundle.getInt("viewWidth");
        imageRenderedAtLeastOnce = bundle.getBoolean("imageRendered");
        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
        return;
    }

    super.onRestoreInstanceState(state);
}
 
Example 10
Source File: ColorPicker.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
	Bundle savedState = (Bundle) state;

	Parcelable superState = savedState.getParcelable(STATE_PARENT);
	super.onRestoreInstanceState(superState);

	mAngle = savedState.getFloat(STATE_ANGLE);
	setOldCenterColor(savedState.getInt(STATE_OLD_COLOR));
	mShowCenterOldColor = savedState.getBoolean(STATE_SHOW_OLD_COLOR);
	int currentColor = calculateColor(mAngle);
	mPointerColor.setColor(currentColor);
	setNewCenterColor(currentColor);
}
 
Example 11
Source File: BottomItemView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        mAlpha = bundle.getFloat(STATUS_ALPHA);
        super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATUS));
        return;
    }
    super.onRestoreInstanceState(state);
}
 
Example 12
Source File: CameraService.java    From glass_snippets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	if (intent.getExtras() != null) {
		Bundle e = intent.getExtras();

		Log.d(TAG, e.keySet().toString());

		mWidth = e.getInt(Parameters.WIDTH, mWidth);
		Log.e(TAG, String.format("mWidth is %d", mWidth));
		mHeight = e.getInt(Parameters.HEIGHT, mHeight);
		mX = e.getInt(Parameters.X, mX);
		mY = e.getInt(Parameters.Y, mY);
		mOutFile = e.getString(Parameters.OUTFILE, mOutFile);
		mCaptureRate = e.getFloat(Parameters.RATE, mCaptureRate);
	}

	// Create new SurfaceView, and put on top of all other windows
	windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
	surfaceView = new SurfaceView(this);
	LayoutParams layoutParams = new WindowManager.LayoutParams(
			mWidth, mHeight, mX, mY,
			WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
			WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
			PixelFormat.TRANSLUCENT
	);
	layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
	windowManager.addView(surfaceView, layoutParams);
	surfaceView.getHolder().addCallback(this);

	super.onStartCommand(intent, flags, startId);
	return START_NOT_STICKY;
}
 
Example 13
Source File: SpinnerLoader.java    From SpinnerLoader with MIT License 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    if(state instanceof Bundle){
        final Bundle bundle = (Bundle)state;
        angle = bundle.getInt(ANGLE);
        bigCircleCenterX = bundle.getFloat(BIGCIRCLECENTERX);
        bigCircleCenterY = bundle.getFloat(BIGCIRCLECENTERY);
        raduis = bundle.getFloat(RADUIS);
        circleRaduis = bundle.getFloat(CIRCLERADUIS);
        moveRaduis = bundle.getFloat(MOVERADUIS);
        startX1 = bundle.getFloat(STARTX1);
        startY1 = bundle.getFloat(STARTY1);
        endX1 = bundle.getFloat(ENDX1);
        endY1 = bundle.getFloat(ENDY1);
        startX2 = bundle.getFloat(STARTX2);
        startY2 = bundle.getFloat(STARTY2);
        endX2 = bundle.getFloat(ENDX2);
        endY2 = bundle.getFloat(ENDY2);
        controlX1 = bundle.getFloat(CONTROLX1);
        controlY1 = bundle.getFloat(CONTROLY1);
        pointColor = bundle.getInt(POINTCOLOR);
        bigStep = bundle.getInt(BIGSTEP);
        init();
        super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
        return;
    }
    super.onRestoreInstanceState(state);
}
 
Example 14
Source File: SlideUpBuilder.java    From SlideUp-Android with MIT License 5 votes vote down vote up
/**
 * <p>Trying restore saved state</p>
 */
private void restoreParams(@Nullable Bundle savedState) {
    if (savedState == null) return;
    mStateRestored = savedState.getBoolean(SlideUp.KEY_STATE_SAVED, false);
    if (savedState.getSerializable(SlideUp.KEY_STATE) != null) {
        mStartState = (SlideUp.State) savedState.getSerializable(SlideUp.KEY_STATE);
    }
    mStartGravity = savedState.getInt(SlideUp.KEY_START_GRAVITY, mStartGravity);
    mDebug = savedState.getBoolean(SlideUp.KEY_DEBUG, mDebug);
    mTouchableArea = savedState.getFloat(SlideUp.KEY_TOUCHABLE_AREA, mTouchableArea) * mDensity;
    mAutoSlideDuration = savedState.getInt(SlideUp.KEY_AUTO_SLIDE_DURATION, mAutoSlideDuration);
    mHideKeyboard = savedState.getBoolean(SlideUp.KEY_HIDE_SOFT_INPUT, mHideKeyboard);
}
 
Example 15
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
if( savedInstanceState != null ) {
	if( savedInstanceState.containsKey( EXTRA_LAT ) && savedInstanceState.containsKey( EXTRA_LONG ) ) {
		mCurrentLocation = new LatLng( savedInstanceState.getDouble( EXTRA_LAT ), savedInstanceState.getDouble( EXTRA_LONG ) );
		if( savedInstanceState.containsKey( EXTRA_TILT ) && savedInstanceState.containsKey( EXTRA_BEARING ) ) {
			mTilt = savedInstanceState.getFloat( EXTRA_TILT );
			mBearing = savedInstanceState.getFloat( EXTRA_BEARING );
			mZoom = savedInstanceState.getFloat( EXTRA_ZOOM );
		}
	}
}
  }
 
Example 16
Source File: ColorWheelView.java    From memoir with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    Bundle savedState = (Bundle) state;

    Parcelable superState = savedState.getParcelable(STATE_PARENT);
    super.onRestoreInstanceState(superState);

    mAngle = savedState.getFloat(STATE_ANGLE);
    setOldCenterColor(savedState.getInt(STATE_OLD_COLOR));
    mShowCenterOldColor = savedState.getBoolean(STATE_SHOW_OLD_COLOR);
    int currentColor = calculateColor(mAngle);
    mPointerColor.setColor(currentColor);
    setNewCenterColor(currentColor);
}
 
Example 17
Source File: QRCodeEncoder.java    From weex with Apache License 2.0 4 votes vote down vote up
private void encodeQRCodeContents(Intent intent, String type) {
  switch (type) {
    case Contents.Type.TEXT:
      String textData = intent.getStringExtra(Intents.Encode.DATA);
      if (textData != null && !textData.isEmpty()) {
        contents = textData;
        displayContents = textData;
        title = activity.getString(R.string.contents_text);
      }
      break;

    case Contents.Type.EMAIL:
      String emailData = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
      if (emailData != null) {
        contents = "mailto:" + emailData;
        displayContents = emailData;
        title = activity.getString(R.string.contents_email);
      }
      break;

    case Contents.Type.PHONE:
      String phoneData = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
      if (phoneData != null) {
        contents = "tel:" + phoneData;
        displayContents = PhoneNumberUtils.formatNumber(phoneData);
        title = activity.getString(R.string.contents_phone);
      }
      break;

    case Contents.Type.SMS:
      String smsData = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
      if (smsData != null) {
        contents = "sms:" + smsData;
        displayContents = PhoneNumberUtils.formatNumber(smsData);
        title = activity.getString(R.string.contents_sms);
      }
      break;

    case Contents.Type.CONTACT:
      Bundle contactBundle = intent.getBundleExtra(Intents.Encode.DATA);
      if (contactBundle != null) {

        String name = contactBundle.getString(ContactsContract.Intents.Insert.NAME);
        String organization = contactBundle.getString(ContactsContract.Intents.Insert.COMPANY);
        String address = contactBundle.getString(ContactsContract.Intents.Insert.POSTAL);
        List<String> phones = getAllBundleValues(contactBundle, Contents.PHONE_KEYS);
        List<String> phoneTypes = getAllBundleValues(contactBundle, Contents.PHONE_TYPE_KEYS);
        List<String> emails = getAllBundleValues(contactBundle, Contents.EMAIL_KEYS);
        String url = contactBundle.getString(Contents.URL_KEY);
        List<String> urls = url == null ? null : Collections.singletonList(url);
        String note = contactBundle.getString(Contents.NOTE_KEY);

        ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
        String[] encoded = encoder.encode(Collections.singletonList(name),
                                          organization,
                                          Collections.singletonList(address),
                                          phones,
                                          phoneTypes,
                                          emails,
                                          urls,
                                          note);
        // Make sure we've encoded at least one field.
        if (!encoded[1].isEmpty()) {
          contents = encoded[0];
          displayContents = encoded[1];
          title = activity.getString(R.string.contents_contact);
        }

      }
      break;

    case Contents.Type.LOCATION:
      Bundle locationBundle = intent.getBundleExtra(Intents.Encode.DATA);
      if (locationBundle != null) {
        // These must use Bundle.getFloat(), not getDouble(), it's part of the API.
        float latitude = locationBundle.getFloat("LAT", Float.MAX_VALUE);
        float longitude = locationBundle.getFloat("LONG", Float.MAX_VALUE);
        if (latitude != Float.MAX_VALUE && longitude != Float.MAX_VALUE) {
          contents = "geo:" + latitude + ',' + longitude;
          displayContents = latitude + "," + longitude;
          title = activity.getString(R.string.contents_location);
        }
      }
      break;
  }
}
 
Example 18
Source File: CaptureActivityHandler.java    From BarcodeScanner with Apache License 2.0 4 votes vote down vote up
@Override
public void handleMessage(Message message) {
	switch (message.what) {
		case R.id.restart_preview: // 准备进行下一次扫描
			Log.d(TAG, "Got restart preview message");
			restartPreviewAndDecode();
			break;
		case R.id.decode_succeeded:
			Log.d(TAG, "Got decode succeeded message");
			state = State.SUCCESS;
			Bundle bundle = message.getData();
			Bitmap barcode = null;
			float scaleFactor = 1.0f;
			if (bundle != null) {
				byte[] compressedBitmap = bundle
						.getByteArray(DecodeThread.BARCODE_BITMAP);
				if (compressedBitmap != null) {
					barcode = BitmapFactory.decodeByteArray(
							compressedBitmap, 0, compressedBitmap.length,
							null);
					// Mutable copy:
					barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
				}
				scaleFactor = bundle
						.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
			}
			activity.handleDecode((Result) message.obj, barcode,
					scaleFactor);
			break;
		case R.id.decode_failed:
			// We're decoding as fast as possible, so when one decode fails,
			// start another.
			state = State.PREVIEW;
			cameraManager.requestPreviewFrame(decodeThread.getHandler(),
					R.id.decode);
			break;
		case R.id.return_scan_result:
			Log.d(TAG, "Got return scan result message");
			activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
			activity.finish();
			break;
		case R.id.launch_product_query:
			Log.d(TAG, "Got product query message");
			String url = (String) message.obj;

			Intent intent = new Intent(Intent.ACTION_VIEW);
			intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
			intent.setData(Uri.parse(url));

			/**
			 * 这段代码是zxing项目组想要用chrome打开浏览器浏览url
			 */
			ResolveInfo resolveInfo = activity.getPackageManager()
					.resolveActivity(intent,
							PackageManager.MATCH_DEFAULT_ONLY);
			String browserPackageName = null;
			if (resolveInfo != null && resolveInfo.activityInfo != null) {
				browserPackageName = resolveInfo.activityInfo.packageName;
				Log.d(TAG, "Using browser in package " + browserPackageName);
			}

			// Needed for default Android browser / Chrome only apparently
			if ("com.android.browser".equals(browserPackageName)
					|| "com.android.chrome".equals(browserPackageName)) {
				intent.setPackage(browserPackageName);
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra(Browser.EXTRA_APPLICATION_ID,
						browserPackageName);
			}

			try {
				activity.startActivity(intent);
			}
			catch (ActivityNotFoundException ignored) {
				Log.w(TAG, "Can't find anything to handle VIEW of URI "
						+ url);
			}
			break;
	}
}
 
Example 19
Source File: TextToSpeechService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
float getFloatParam(Bundle params, String key, float defaultValue) {
    return params == null ? defaultValue : params.getFloat(key, defaultValue);
}
 
Example 20
Source File: TextViewStateSaver.java    From YcShareElement with Apache License 2.0 4 votes vote down vote up
public float getTextSize(Bundle bundle){
    return bundle.getFloat("textSize");
}