@Override
  public void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {

      final Bundle bundle = (Bundle) state;

      mTickCount = bundle.getInt("TICK_COUNT");
      mTickHeightDP = bundle.getFloat("TICK_HEIGHT_DP");
      mBarWeight = bundle.getFloat("BAR_WEIGHT");
      mBarColor = bundle.getInt("BAR_COLOR");
      mConnectingLineWeight = bundle.getFloat("CONNECTING_LINE_WEIGHT");
      mConnectingLineColor = bundle.getInt("CONNECTING_LINE_COLOR");

      mThumbImageNormal = bundle.getInt("THUMB_IMAGE_NORMAL");
      mThumbImagePressed = bundle.getInt("THUMB_IMAGE_PRESSED");

      mThumbRadiusDP = bundle.getFloat("THUMB_RADIUS_DP");
      mThumbColorNormal = bundle.getInt("THUMB_COLOR_NORMAL");
      mThumbColorPressed = bundle.getInt("THUMB_COLOR_PRESSED");

      mLeftIndex = bundle.getInt("LEFT_INDEX");
      mRightIndex = bundle.getInt("RIGHT_INDEX");
      mFirstSetTickCount = bundle.getBoolean("FIRST_SET_TICK_COUNT");

      setThumbIndices(mLeftIndex, mRightIndex);

      super.onRestoreInstanceState(bundle.getParcelable("instanceState"));

    } else {

      super.onRestoreInstanceState(state);
    }
  }
  @Override
  public void onStart() {
    super.onStart();

    Bundle args = getArguments();
    if (args != null) {
      // Set article based on argument passed in
      mPrefsIndex = args.getInt(ORDER_PREFERENCES_INDEX, mPrefsIndex);
      mHueStart = args.getFloat(ARG_HUE_START, 0);
      mHueEnd = args.getFloat(ARG_HUE_END, 360);
      mSaturation = args.getFloat(ARG_SATURATION, 1);
      mValue = args.getFloat(ARG_VALUE, 1);

      // Log.d("Args:", " HueStart: " + mHueStart + " HueEnd: " + mHueEnd + " Sat:" + mSaturation +
      // " Val: " + mValue);
    }

    ListView lv = (ListView) getActivity().findViewById(R.id.list);
    lv.setDividerHeight(2);
    fillData(lv);
    setListListener(lv);

    Button configButton = (Button) getActivity().findViewById(R.id.button);
    configButton.setText(R.string.config_sort_order);
    setButtonListener(configButton);
  }
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;
      super.onRestoreInstanceState(bundle.getParcelable(INATANCE_STATE));
      mMaxProcess = bundle.getInt(INSTANCE_MAX_PROCESS);
      mCurProcess = bundle.getInt(INSTANCE_CUR_PROCESS);
      mReachedColor = bundle.getInt(INSTANCE_REACHED_COLOR);
      mReachedWidth = bundle.getFloat(INSTANCE_REACHED_WIDTH);
      isHasReachedCornerRound = bundle.getBoolean(INSTANCE_REACHED_CORNER_ROUND);
      mUnreachedColor = bundle.getInt(INSTANCE_UNREACHED_COLOR);
      mUnreachedWidth = bundle.getFloat(INSTANCE_UNREACHED_WIDTH);
      mPointerColor = bundle.getInt(INSTANCE_POINTER_COLOR);
      mPointerRadius = bundle.getFloat(INSTANCE_POINTER_RADIUS);
      isHasPointerShadow = bundle.getBoolean(INSTANCE_POINTER_SHADOW);
      mPointerShadowRadius = bundle.getFloat(INSTANCE_POINTER_SHADOW_RADIUS);
      isHasWheelShadow = bundle.getBoolean(INSTANCE_WHEEL_SHADOW);
      mPointerShadowRadius = bundle.getFloat(INSTANCE_WHEEL_SHADOW_RADIUS);
      isHasCache = bundle.getBoolean(INSTANCE_WHEEL_HAS_CACHE);
      isCanTouch = bundle.getBoolean(INSTANCE_WHEEL_CAN_TOUCH);
      initPaints();
    } else {
      super.onRestoreInstanceState(state);
    }

    if (mChangListener != null) {
      mChangListener.onChanged(this, mMaxProcess, mCurProcess);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see android.view.View#onRestoreInstanceState(android.os.Parcelable)
   */
  @Override
  protected void onRestoreInstanceState(final Parcelable state) {
    if (state instanceof Bundle) {
      final Bundle bundle = (Bundle) state;
      setProgress(bundle.getFloat(INSTANCE_STATE_PROGRESS));
      setMarkerProgress(bundle.getFloat(INSTANCE_STATE_MARKER_PROGRESS));

      final int progressColor = bundle.getInt(INSTANCE_STATE_PROGRESS_COLOR);
      if (progressColor != mProgressColor) {
        mProgressColor = progressColor;
        updateProgressColor();
      }

      final int progressBackgroundColor = bundle.getInt(INSTANCE_STATE_PROGRESS_BACKGROUND_COLOR);
      if (progressBackgroundColor != mProgressBackgroundColor) {
        mProgressBackgroundColor = progressBackgroundColor;
        updateBackgroundColor();
      }

      super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE_SAVEDSTATE));
      return;
    }

    super.onRestoreInstanceState(state);
  }
  @Override
  protected void onRestoreInstanceState(final Parcelable state) {
    final Bundle bundle = (Bundle) state;
    final Parcelable superState = bundle.getParcelable("superState");
    super.onRestoreInstanceState(superState);

    mNeedleInitialized = bundle.getBoolean("needleInitialized");
    mNeedleVelocity = bundle.getFloat("needleVelocity");
    mNeedleAcceleration = bundle.getFloat("needleAcceleration");
    mNeedleLastMoved = bundle.getLong("needleLastMoved");
    mCurrentValue = bundle.getFloat("currentValue");
    mTargetValue = bundle.getFloat("targetValue");
  }
Example #6
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    Bundle bundle = (Bundle) state;
    Parcelable superState = bundle.getParcelable("superState");
    super.onRestoreInstanceState(superState);

    handInitialized = bundle.getBoolean("handInitialized");
    handPosition = bundle.getFloat("handPosition");
    handTarget = bundle.getFloat("handTarget");
    handVelocity = bundle.getFloat("handVelocity");
    handAcceleration = bundle.getFloat("handAcceleration");
    lastHandMoveTime = bundle.getLong("lastHandMoveTime");
  }
Example #7
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    Bundle savedState = (Bundle) state;

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

    setColor(Color.HSVToColor(savedState.getFloatArray(STATE_COLOR)));
    if (savedState.containsKey(STATE_SATURATION)) {
      setSaturation(savedState.getFloat(STATE_SATURATION));
    } else {
      setValue(savedState.getFloat(STATE_VALUE));
    }
    mOrientation = savedState.getBoolean(STATE_ORIENTATION, ORIENTATION_DEFAULT);
  }
Example #8
0
        @Override
        public void handleMessage(Message msg) {
          Bundle data = msg.getData();

          String jobIdString = data.getString(SiteController.MESSAGE_KEY_JOB_ID);
          int jobId = (jobIdString != null) ? Integer.parseInt(jobIdString) : -1;
          Job job = (Job) (new JobTable()).get(mContext, jobId);

          int messageType = data.getInt(SiteController.MESSAGE_KEY_TYPE);
          switch (messageType) {
            case SiteController.MESSAGE_TYPE_SUCCESS:
              String result = data.getString(SiteController.MESSAGE_KEY_RESULT);
              jobSucceeded(result);
              break;
            case SiteController.MESSAGE_TYPE_FAILURE:
              int errorCode = data.getInt(SiteController.MESSAGE_KEY_CODE);
              String errorMessage = data.getString(SiteController.MESSAGE_KEY_MESSAGE);
              Exception exception =
                  (Exception) data.getSerializable(SiteController.MESSAGE_KEY_EXCEPTION);
              jobFailed(exception, errorCode, errorMessage);
              break;
            case SiteController.MESSAGE_TYPE_PROGRESS:
              String message = data.getString(SiteController.MESSAGE_KEY_MESSAGE);
              float progress = data.getFloat(SiteController.MESSAGE_KEY_PROGRESS);
              jobProgress(job, progress, message);
              break;
          }
        }
  @Override
  protected void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {

      final Bundle bundle = (Bundle) state;

      progressStrokeColor = bundle.getInt(KEY_PROGRESS_STROKE_COLOR);
      backgroundStrokeColor = bundle.getInt(KEY_BACKGROUND_STROKE_COLOR);
      strokeWidth = bundle.getInt(KEY_STROKE_WIDTH);
      progress = bundle.getInt(KEY_PROGRESS);
      maxProgress = bundle.getInt(KEY_MAX_PROGRESS);
      textSize = bundle.getFloat(KEY_TEXT_SIZE);
      textColor = bundle.getInt(KEY_TEXT_COLOR);

      Parcelable parcelable = bundle.getParcelable(KEY_SUPER);

      super.onRestoreInstanceState(parcelable);

    } else {

      super.onRestoreInstanceState(state);
    }

    initializeView();
  }
  @Override
  public void handleMessage(Message message) {
    if (message.what == R.id.zxing_decode_succeeded) {
      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);

    } else if (message.what
        == R.id
            .zxing_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.zxing_decode);

    } else if (message.what == R.id.zxing_return_scan_result) {
      activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
      activity.finish();
    }
  }
Example #11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_map);
    /* ActionBar items */
    try {
      getActionBar().setHomeButtonEnabled(true);
      getActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (NullPointerException e) {
      Toast.makeText(this, "Something went wrong. Try again.", Toast.LENGTH_SHORT).show();
    }
    ICON_HEIGHT = getResources().getDimensionPixelSize(R.dimen.mapIconHeight);

    // Toast.makeText(this, "onCreate", Toast.LENGTH_SHORT).show();
    FragmentManager fm = getFragmentManager();
    /* Obtain a reference to the UI element */
    MapFragment frag = (MapFragment) fm.findFragmentById(R.id.overworld);

    /* Obtain a reference to GoogleMap object associated with the fragment */
    worldMap = frag.getMap();
    mapClient = new LocationClient(this, this, this);
    mapClient = new LocationClient(this, this, this);
    ePrefs = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean infoShown = ePrefs.getBoolean(infoDialoguePref, false);

    if (!infoShown) {
      String title = "Map Gallery";
      String text = getResources().getString(R.string.mapInfo);
      new AlertDialog.Builder(this)
          .setTitle(title)
          .setMessage(text)
          .setPositiveButton(
              android.R.string.ok,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              })
          .show();
      SharedPreferences.Editor editor = ePrefs.edit();
      editor.putBoolean(infoDialoguePref, true);
      editor.commit();
    }

    if (savedInstanceState != null) {
      zoomlevel = savedInstanceState.getFloat("zoom");
      loaded = savedInstanceState.getBoolean("loaded");
      currentLat = savedInstanceState.getDouble("lat");
      currentLng = savedInstanceState.getDouble("lng");
      fileToReload = savedInstanceState.getString("redo");

      dataRestorer =
          new DataRestorer(
              savedInstanceState.getStringArrayList("allFiles"),
              savedInstanceState.getParcelableArrayList("allBitmaps"),
              savedInstanceState.getFloatArray("allLat"),
              savedInstanceState.getFloatArray("allLng"));
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.xuetang);

    sharedPrefrences = getSharedPreferences("user", MODE_PRIVATE);
    cradnumber = sharedPrefrences.getString("cradnumber", "");

    initView();

    intent = getIntent();
    if (intent != null) {

      bundle = intent.getBundleExtra(BGActivity.BG_BUNDLE);
      bg_value = bundle.getFloat(BG, 00.0f);
      addr = bundle.getString(BT_ADDR);
      xuetang.setText("" + bg_value);
      Log.e(TAG, "===== BG_value:" + bg_value + "   BT Addr:  " + addr);
    }

    // 假设值
    xuetang.setText("11.0");

    startService(new Intent(BGActivity.this, ScreenService.class));
  }
 @Override
 public void handleMessage(Message message) {
   if (message.what == R.id.restart_preview) {
     Log.d(TAG, "Got restart preview message");
     restartPreviewAndDecode();
   } else if (message.what == 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);
   } else if (message.what == 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);
   } else if (message.what == R.id.return_scan_result) {
     Log.d(TAG, "Got return scan result message");
     activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
     activity.finish();
   } else if (message.what == 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);
     }
   }
 }
Example #14
0
  void SetProduct(Bundle bundle) {
    totalSale += bundle.getFloat("price");
    lblTotal.setText(
        getString(R.string.currency_symbol) + Functions.GetFloatValueWithTwoDecimals(totalSale));

    Product product = new Product(bundle.getInt("id"), bundle.getString("name"));
    product.setPrice(bundle.getFloat("price"));

    if (productAdapter == null) {
      ArrayList<Product> products = new ArrayList<Product>();
      productAdapter = new ProductAdapter(this, products);
      ListView lstProducts = (ListView) findViewById(R.id.lstProductList);
      lstProducts.setAdapter(productAdapter);
    }

    productAdapter.add(product);
    productAdapter.notifyDataSetChanged();
  }
Example #15
0
  @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);
  }
 public static float getSavedFloatValue(Intent intent, Bundle savedInstanceState, String id) {
   MyLog.v(TAG, "getSavedFloatValue(%s)", id);
   Float result =
       savedInstanceState != null && savedInstanceState.containsKey(id)
           ? savedInstanceState.getFloat(id)
           : null;
   // IF the activity was already launch, get the last id
   if (result == null) {
     // get the extras bundles from the intent
     Bundle extras = intent.getExtras();
     // IF there is extras, get the line id
     result = extras != null && extras.containsKey(id) ? extras.getFloat(id) : null;
   }
   if (result == null) {
     MyLog.d(TAG, "Can't find the saved float value for ID '%s' (returned null)", id);
   }
   return result;
 }
Example #17
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    Bundle savedState = (Bundle) state;

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

    setColor(Color.HSVToColor(savedState.getFloatArray(STATE_COLOR)));
    setSaturation(savedState.getFloat(STATE_SATURATION));
  }
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   if (state instanceof Bundle) {
     Bundle bundle = (Bundle) state;
     mAlpha = bundle.getFloat(STATE_ALPHA);
     super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
   } else {
     super.onRestoreInstanceState(state);
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    setHasOptionsMenu(true);
    View rootView = inflater.inflate(R.layout.fragment_temperature, container, false);

    chart = (LineChartView) rootView.findViewById(R.id.chart);
    previewChart = (PreviewLineChartView) rootView.findViewById(R.id.chart_preview);

    // Generate data for previewed chart and copy of that data for preview chart.

    if (getArguments() != null) {
      temperatureData = getArguments();
      latitude = temperatureData.getFloat("latitude");
      longitude = temperatureData.getFloat("longitude");
      temperatures = temperatureData.getDoubleArray("temperatureArr");
      times = temperatureData.getIntArray("timeArr");
      numData = temperatureData.getInt("numData");
      Log.d("ARRAY", Arrays.toString(temperatures));
      Log.d("ARRAY", Arrays.toString(times));
      getForecastData();

      Log.d("receiver", "OK");
    } else {
      generateDefaultData();
    }
    chart.setLineChartData(data);
    // Disable zoom/scroll for previewed chart, visible chart ranges depends on preview chart
    // viewport so
    // zoom/scroll is unnecessary.
    chart.setZoomEnabled(false);
    chart.setScrollEnabled(false);

    previewChart.setLineChartData(previewData);
    previewChart.setViewportChangeListener(new ViewportListener());

    previewX(false);

    return rootView;
  }
Example #20
0
  @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));
    mPointerColor.setColor(calculateColor(mAngle));
  }
Example #21
0
 @Override
 public ParcableMovie createFromParcel(Parcel source) {
   Bundle bundle = source.readBundle();
   return new ParcableMovie(
       bundle.getString(KEY_ID),
       bundle.getString(KEY_TITLE_NAME),
       bundle.getString(KEY_POSTER_IMAGE),
       bundle.getString(KEY_SYNOPSIS),
       bundle.getFloat(KEY_USER_RATING),
       bundle.getString(KEY_RELEASE_DATE));
 }
Example #22
0
  @Override
  protected boolean setVelocity(Bundle data, ICommandListener listener) {
    // Retrieve the normalized values
    float normalizedXVel = data.getFloat(ControlActions.EXTRA_VELOCITY_X);
    float normalizedYVel = data.getFloat(ControlActions.EXTRA_VELOCITY_Y);
    float normalizedZVel = data.getFloat(ControlActions.EXTRA_VELOCITY_Z);

    double attitudeInRad = Math.toRadians(attitude.getYaw());

    final double cosAttitude = Math.cos(attitudeInRad);
    final double sinAttitude = Math.sin(attitudeInRad);

    float projectedX =
        (float) (normalizedXVel * cosAttitude) - (float) (normalizedYVel * sinAttitude);
    float projectedY =
        (float) (normalizedXVel * sinAttitude) + (float) (normalizedYVel * cosAttitude);

    // Retrieve the speed parameters.
    float defaultSpeed = 5; // m/s

    ParameterManager parameterManager = getParameterManager();

    // Retrieve the horizontal speed value
    Parameter horizSpeedParam = parameterManager.getParameter("WPNAV_SPEED");
    double horizontalSpeed =
        horizSpeedParam == null ? defaultSpeed : horizSpeedParam.getValue() / 100;

    // Retrieve the vertical speed value.
    String vertSpeedParamName = normalizedZVel >= 0 ? "WPNAV_SPEED_UP" : "WPNAV_SPEED_DN";
    Parameter vertSpeedParam = parameterManager.getParameter(vertSpeedParamName);
    double verticalSpeed = vertSpeedParam == null ? defaultSpeed : vertSpeedParam.getValue() / 100;

    MavLinkCommands.setVelocityInLocalFrame(
        this,
        (float) (projectedX * horizontalSpeed),
        (float) (projectedY * horizontalSpeed),
        (float) (normalizedZVel * verticalSpeed),
        listener);
    return true;
  }
Example #23
0
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   if (state instanceof Bundle) {
     final Bundle bundle = (Bundle) state;
     strokeWidth = bundle.getFloat(INSTANCE_STROKE_WIDTH);
     suffixTextSize = bundle.getFloat(INSTANCE_SUFFIX_TEXT_SIZE);
     suffixTextPadding = bundle.getFloat(INSTANCE_SUFFIX_TEXT_PADDING);
     bottomTextSize = bundle.getFloat(INSTANCE_BOTTOM_TEXT_SIZE);
     bottomText = bundle.getString(INSTANCE_BOTTOM_TEXT);
     textSize = bundle.getFloat(INSTANCE_TEXT_SIZE);
     textColor = bundle.getInt(INSTANCE_TEXT_COLOR);
     setMax(bundle.getInt(INSTANCE_MAX));
     setProgress(bundle.getInt(INSTANCE_PROGRESS));
     finishedStrokeColor = bundle.getInt(INSTANCE_FINISHED_STROKE_COLOR);
     unfinishedStrokeColor = bundle.getInt(INSTANCE_UNFINISHED_STROKE_COLOR);
     suffixText = bundle.getString(INSTANCE_SUFFIX);
     initPainters();
     super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
     return;
   }
   super.onRestoreInstanceState(state);
 }
 private void parseInput() {
   // parse input
   Intent inputIntent = getIntent();
   if (inputIntent != null) {
     mEditMode = inputIntent.getBooleanExtra("edit-mode", false);
     if (mEditMode) mLocationAlert = inputIntent.getParcelableExtra("data");
     else {
       Bundle extras = inputIntent.getExtras();
       circleRadius = extras.getFloat("Radius");
       circleLatitude = extras.getDouble("Latitude");
       circleLongitude = extras.getDouble("Longitude");
     }
   }
 }
  private void setupRowPositionAndTextSize(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
      mRowId = savedInstanceState.getLong(KEY_SAVED_POSITION);
      mTextSize = savedInstanceState.getFloat(TEXT_SIZE, 0);
    }

    if (mTextSize == 0) {
      mTextSize = getSharedPreferences(PREFS_NAME, MODE_PRIVATE).getFloat(TEXT_SIZE, 0);
    }

    if (mTextSize != 0) {
      bodyEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
    }
  }
Example #26
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_entry, container, false);

    mCancelFullscreenBtn = rootView.findViewById(R.id.cancelFullscreenBtn);
    mCancelFullscreenBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            toggleFullScreen();
          }
        });

    mEntryPager = (ViewPager) rootView.findViewById(R.id.pager);
    // mEntryPager.setPageTransformer(true, new DepthPageTransformer());
    mEntryPager.setAdapter(mEntryPagerAdapter);

    if (savedInstanceState != null) {
      mBaseUri = savedInstanceState.getParcelable(STATE_BASE_URI);
      mEntriesIds = savedInstanceState.getLongArray(STATE_ENTRIES_IDS);
      mInitialEntryId = savedInstanceState.getLong(STATE_INITIAL_ENTRY_ID);
      mCurrentPagerPos = savedInstanceState.getInt(STATE_CURRENT_PAGER_POS);
      mEntryPager.getAdapter().notifyDataSetChanged();
      mEntryPager.setCurrentItem(mCurrentPagerPos);
      mEntryPagerAdapter.setScrollPercentage(savedInstanceState.getFloat(STATE_SCROLL_PERCENTAGE));
    }

    mEntryPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int i, float v, int i2) {}

          @Override
          public void onPageSelected(int i) {
            mCurrentPagerPos = i;
            mEntryPagerAdapter.onPause(); // pause all webviews
            mEntryPagerAdapter.onResume(); // resume the current webview

            refreshUI(mEntryPagerAdapter.getCursor(i));
          }

          @Override
          public void onPageScrollStateChanged(int i) {}
        });

    return rootView;
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle data = intent.getExtras();

    numPDUsReceived++;

    if (numPDUsReceived == 1) {
      // Add packet type + time stamp
      buffer.put((byte) 0x03); // Type
      buffer.put((byte) data.getInt("usli.smd.payload.hour")); // Hour
      buffer.put((byte) data.getInt("usli.smd.payload.minute")); // Minute
      buffer.put((byte) data.getInt("usli.smd.payload.second")); // Second
    }

    // Add data
    buffer.putDouble(data.getDouble("usli.smd.payload.latitude")); // Latitude
    buffer.putDouble(data.getDouble("usli.smd.payload.longitude")); // Longitude
    buffer.putShort(data.getShort("usli.smd.payload.pressure1")); // Pressure
    buffer.putShort(data.getShort("usli.smd.payload.temperature1")); // Temperature
    buffer.putShort(data.getShort("usli.smd.payload.humidity1")); // Humidity
    buffer.putShort(data.getShort("usli.smd.payload.solarIrradiance1")); // Solar Irradiance
    buffer.putShort(data.getShort("usli.smd.payload.uvRadiation1")); // UV Radiation

    if (numPDUsReceived == numPDUs) {
      String message = "";
      message += data.getInt("usli.smd.payload.hour");
      message += ":" + data.getInt("usli.smd.payload.minute");
      message += ":" + data.getInt("usli.smd.payload.second");
      message += ";" + data.getDouble("usli.smd.payload.latitude");
      message += "," + data.getDouble("usli.smd.payload.longitude");
      message += "," + data.getFloat("usli.smd.payload.bearing");
      message += "," + data.getInt("usli.smd.payload.signal");
      // message += "," + data.getFloat("usli.smd.payload.accelX");
      // message += "," + data.getFloat("usli.smd.payload.accelY");
      // message += "," + data.getFloat("usli.smd.payload.accelZ");
      // Send byte[] to SMSSender
      SMSDataPacket.putExtra("destination", 0);
      SMSDataPacket.putExtra("message", message);
      startService(SMSDataPacket);

      // Reset service
      numPDUsReceived = 0;
      buffer.clear();
    }

    return START_STICKY;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.friendsr_details_activity);

    ratingBar = (RatingBar) findViewById(R.id.rating_bar);
    detailedPicture = (ImageView) findViewById(R.id.picture);
    detailedInformation = (TextView) findViewById(R.id.details);

    Bundle extras = getIntent().getExtras();
    friendName = extras.getString(Friendsr_Main_Activity.nameKey);
    String friendDetails = extras.getString(Friendsr_Main_Activity.detailsKey);
    float currentFriendRating = extras.getFloat(Friendsr_Main_Activity.ratingKey);

    if (currentFriendRating != Friendsr_Main_Activity.initialRating) {
      ratingBar.setRating(currentFriendRating);
    }

    showPictureAndDetails(friendDetails);
  }
Example #29
0
  @Override
  public void handleMessage(final Message msg) {
    final BluetoothState state = BluetoothState.fromInt(msg.what);
    Bundle data = null;
    if (msg != null) {
      data = msg.getData();
    }

    What what = What.fromInt(msg.what);
    switch (what) {
      case CONNECTED_TO:
        {
          String deviceAddress = data.getString(Data.DEVICE_NAME.v());
          float connectionTime = data.getFloat(Data.EVENT_TIME.v());
          onCONNECTED_TO(state, msg, deviceAddress, connectionTime);
          break;
        }
      case ERROR:
        {
          String deviceAddress = data.getString(Data.DEVICE_NAME.v());
          float errorTime = data.getFloat(Data.EVENT_TIME.v());
          int errorMessage = data.getInt(Data.MESSAGE.v());
          onERROR(state, msg, errorMessage, deviceAddress, errorTime);
          break;
        }
      case NOTIFICATION:
        {
          float errorTime = data.getFloat(Data.EVENT_TIME.v());
          int message = data.getInt(Data.MESSAGE.v());
          onNOTIFICATION(state, msg, message, errorTime);
          break;
        }
      case READ_DATA:
        onREAD_DATA(state, msg);
        break;
      case READ_BEGIN:
        onREAD_BEGIN(state, msg);
        break;
      case READ_TURN:
        onREAD_TURN(state, msg);
        break;
      case READ_REAL_TIME:
        onREAD_REAL_TIME(state, msg);
        break;
      case READ_FINISH:
        onREAD_FINISH(state, msg);
        break;
      case WRITE_BEGIN:
        onWRITE_BEGIN(state, msg);
        break;
      case WRITE_DATA:
        onWRITE_DATA(state, msg);
        break;
      case WRITE_TURN:
        onWRITE_TURN(state, msg);
        break;
      case WRITE_REAL_TIME:
        onWRITE_REAL_TIME(state, msg);
        break;
      case WRITE_FINISH:
        onWRITE_FINISH(state, msg);
        break;
      default:
        // TODO error unexpected message arrived
        break;
    }
  }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testAllTypes() {
    Bundle originalBundle = new Bundle();

    putBoolean(BOOLEAN_KEY, originalBundle);
    putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle);
    putByte(BYTE_KEY, originalBundle);
    putByteArray(BYTE_ARRAY_KEY, originalBundle);
    putShort(SHORT_KEY, originalBundle);
    putShortArray(SHORT_ARRAY_KEY, originalBundle);
    putInt(INT_KEY, originalBundle);
    putIntArray(INT_ARRAY_KEY, originalBundle);
    putLong(LONG_KEY, originalBundle);
    putLongArray(LONG_ARRAY_KEY, originalBundle);
    putFloat(FLOAT_KEY, originalBundle);
    putFloatArray(FLOAT_ARRAY_KEY, originalBundle);
    putDouble(DOUBLE_KEY, originalBundle);
    putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle);
    putChar(CHAR_KEY, originalBundle);
    putCharArray(CHAR_ARRAY_KEY, originalBundle);
    putString(STRING_KEY, originalBundle);
    putStringList(STRING_LIST_KEY, originalBundle);
    originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB);

    ensureApplicationContext();

    SharedPreferencesTokenCachingStrategy cache =
        new SharedPreferencesTokenCachingStrategy(getContext());
    cache.save(originalBundle);

    SharedPreferencesTokenCachingStrategy cache2 =
        new SharedPreferencesTokenCachingStrategy(getContext());
    Bundle cachedBundle = cache2.load();

    Assert.assertEquals(
        originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY));
    assertArrayEquals(
        originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY),
        cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY));
    assertArrayEquals(
        originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY));
    assertArrayEquals(
        originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY));
    assertArrayEquals(
        originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY));
    assertArrayEquals(
        originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY));
    assertArrayEquals(
        originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY));
    assertArrayEquals(
        originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY),
        cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY));
    assertArrayEquals(
        originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY));
    assertListEquals(
        originalBundle.getStringArrayList(STRING_LIST_KEY),
        cachedBundle.getStringArrayList(STRING_LIST_KEY));
    Assert.assertEquals(
        originalBundle.getSerializable(SERIALIZABLE_KEY),
        cachedBundle.getSerializable(SERIALIZABLE_KEY));
  }