Java Code Examples for android.os.Bundle.getParcelable()

The following are Jave code examples for showing how to use getParcelable() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Sega   File: TouchImageView.java   View Source Code Vote up 7 votes
@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
Project: EsperantoRadio   File: SetAlarm_akt.java   View Source Code Vote up 6 votes
@Override
protected void onRestoreInstanceState(Bundle state) {
  super.onRestoreInstanceState(state);

  Alarm alarmFromBundle = new Alarm(state.getString(KEY_ORIGINAL_ALARM));
  if (alarmFromBundle != null) {
    mOriginalAlarm = alarmFromBundle;
  }

  alarmFromBundle = new Alarm(state.getString(KEY_CURRENT_ALARM));
  if (alarmFromBundle != null) {
    updatePrefs(alarmFromBundle);
  }

  Bundle b = state.getParcelable(KEY_TIME_PICKER_BUNDLE);
  if (b != null) {
    showTimePicker();
    mTimePickerDialog.onRestoreInstanceState(b);
  }
}
 
Example 3
Project: MDWechat   File: ColorPickerView.java   View Source Code Vote up 6 votes
@Override public void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;

      alpha = bundle.getInt("alpha");
      hue = bundle.getFloat("hue");
      sat = bundle.getFloat("sat");
      val = bundle.getFloat("val");
      showAlphaPanel = bundle.getBoolean("show_alpha");
      alphaSliderText = bundle.getString("alpha_text");

      state = bundle.getParcelable("instanceState");
    }
    super.onRestoreInstanceState(state);
  }
 
Example 4
Project: Farmacias   File: ListTabFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_tab_list, container, false);
    Utils.logD(LOG_TAG, "onCreateView:" + this);
    unbinder = ButterKnife.bind(this, view);
    setUpRecyclerView();
    setUpSwipeRefreshLayout();
    if (savedInstanceState == null) {
        mPresenter.onGetAddressFromLocation(mLocation);
    } else {
        mRotation = true;
        if (savedInstanceState.containsKey(RECYCLER_STATE_KEY)) {
            mLayoutManagerState = savedInstanceState.getParcelable(RECYCLER_STATE_KEY);
        }
        if (savedInstanceState.containsKey(ADDRESS_KEY)) {
            mAddress = savedInstanceState.getString(ADDRESS_KEY);
        }

    }


    return view;
}
 
Example 5
Project: Asteroid   File: GameHelper.java   View Source Code Vote up 5 votes
/**
 * Called when we successfully obtain a connection to a client.
 */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example 6
Project: PickColorFromImageAndroid   File: PickColorFromImage.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.setpickedimage);
    context = this;
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        if (intent == null) {
            uri = null;
        } else {
            uri = intent.getParcelableExtra("imageUri");
        }
    } else {
        uri = savedInstanceState.getParcelable("imageUri");
    }

    setRGBColorButton=(Button) findViewById(R.id.button);
    setHEXColorButton=(Button) findViewById(R.id.button2);

    setRGBColorTextView=(TextView) findViewById(R.id.textView2);
    setHEXColorTextView=(TextView) findViewById(R.id.textView3);
    picked_imageView = (ImageView) findViewById(R.id.imageView2);
    picked_imageView.setOnTouchListener(this);

    String uriString = getRealPathFromURI(uri);

    picked_imageView.setImageBitmap(decodeSampledBitmapFromResource(uriString, 100, 100));

}
 
Example 7
Project: xlight_android_native   File: Parcelables.java   View Source Code Vote up 5 votes
public static <T extends Parcelable> Map<String, T> readParcelableMap(Parcel parcel) {
    Map<String, T> map = new ArrayMap<>();
    Bundle bundle = parcel.readBundle(Parcelables.class.getClassLoader());
    for (String key : bundle.keySet()) {
        T parcelable = bundle.getParcelable(key);
        map.put(key, parcelable);
    }
    return map;
}
 
Example 8
Project: AndroidUiKit   File: SlidingTabLayout.java   View Source Code Vote up 5 votes
@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        mCurrentTab = bundle.getInt("mCurrentTab");
        state = bundle.getParcelable("instanceState");
        if (mCurrentTab != 0 && mTabsContainer.getChildCount() > 0) {
            updateTabSelection(mCurrentTab);
            scrollToCurrentTab();
        }
    }
    super.onRestoreInstanceState(state);
}
 
Example 9
Project: AndroidToolbox   File: BaseActivityWithViewModelSupport.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if (savedInstanceState != null)
        data = savedInstanceState.getParcelable(DATA); //Restore data if they exist
    else
        connectData(); //Connect new data if non exist


    setActivity(); //link activity
    super.onCreate(savedInstanceState);
}
 
Example 10
Project: TrainPonctuality   File: InputArrivalActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_input_arrival);
    setTitle(R.string.titleArrival);

    txtArrivalDate = (TextView) findViewById(R.id.txtArrivalDate);
    txtArrivalTime = (TextView) findViewById(R.id.txtArrivalTime);
    txtArrivalStation = (TextView) findViewById(R.id.txtLocation);

    Bundle data = getIntent().getExtras();
    currentTravel = data.getParcelable("travel");

    setArrivalDateTime(GregorianCalendar.getInstance());

    locationObserver = new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            Log.i(TAG, "update: Stopping Location");
            LocationProxy.getInstance().stopRequest(getApplicationContext());
            autoSelectStation();
        }
    };
    Log.i(TAG, "onCreate: AddObserver");
    LocationProxy.getInstance().addObserver(locationObserver);
    autoSelectStation();
}
 
Example 11
Project: fancyDialog   File: FancyAlertDialog.java   View Source Code Vote up 5 votes
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    this.setCancelable(true);

    if (savedInstanceState != null) {
        if (builder != null) {
            builder = (Builder) savedInstanceState.getParcelable(Builder.class.getSimpleName());
        }
    }
    setRetainInstance(true);
    super.onCreate(savedInstanceState);
}
 
Example 12
Project: GitHub   File: CutPictureActivity.java   View Source Code Vote up 5 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	if (resultCode == RESULT_OK) {
		switch (requestCode) {
		case REQUEST_CUT_PHOTO: //发送本地图片
			if (data != null) {
				if (Build.VERSION.SDK_INT < 23 || new File(cuttedPicturePath).exists() == false) {
					Bundle bundle = data.getExtras();
					if (bundle != null) {
						Bitmap photo = bundle.getParcelable("data");
						//photo.
						if (photo != null) {
							//照片的路径
							setCuttedPicturePath();
							cuttedPicturePath = CommonUtil.savePhotoToSDCard(cuttedPicturePath, cuttedPictureName, "jpg", photo);
						}
					} 
				}
				setResult(RESULT_OK, new Intent().putExtra(RESULT_PICTURE_PATH, cuttedPicturePath));
			} 
			break;
		default:
			break;
		}
	}

	finish();
}
 
Example 13
Project: Allshare   File: WXEntryActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    wxapi = WXAPIFactory.createWXAPI(this, AllShare.getWxId(), true);
    boolean registered = wxapi.registerApp(AllShare.getWxId());
    // 若是接收结果,处理完直接finish
    if (wxapi.handleIntent(intent, this)) {
        finish();
        return;
    }

    Bundle bundle;
    boolean paramError = false;
    if (!registered) {
        LogUtils.e("%s: api is null, finish.", TAG);
        paramError = true;
    } else if (null == intent || null == (bundle = intent.getExtras())) {
        LogUtils.e("%s: params is null, finish.", TAG);
        paramError = true;
    } else {
        bundle.setClassLoader(WXContent.class.getClassLoader());
        if (null == (shareContent = bundle.getParcelable(KEY_SHARE_CONTENT))) {
            LogUtils.e("%s: share content is null, finish.", TAG);
            paramError = true;
        } else if (null == (listener = bundle.getParcelable(KEY_SHARE_LISTENER))) {
            LogUtils.e("%s: result receiver is null.", TAG);
        }
    }
    if (paramError) {
        Toast.makeText(this, R.string.share_failed, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    share();
}
 
Example 14
Project: Ae4Team   File: UserProfileActivity.java   View Source Code Vote up 4 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.i(TAG, String.valueOf(requestCode));
    Log.i(TAG, String.valueOf(resultCode));

    if (resultCode != RESULT_OK) {
        return;
    }

    switch (requestCode) {
        case PICK_FROM_ALBUM: {
            mlmageCaptureUri = data.getData();
            Log.i(TAG, "test2");
        }

        case PICK_FROM_CAMERA: {
            Log.i(TAG, "test3");

            Intent intent = new Intent("com.android.camera.action.CROP");
            intent.setDataAndType(mlmageCaptureUri, "image/*");

            intent.putExtra("outputX", 100);
            intent.putExtra("outputY", 100);
            intent.putExtra("aspectX", 1);
            intent.putExtra("aspectY", 1);
            intent.putExtra("scale", true);
            intent.putExtra("return-data", true);
            startActivityForResult(intent, CROP_FROM_IMAGE);
            break;
        }

        case CROP_FROM_IMAGE: {
            if (resultCode != RESULT_OK) {
                return;
            }
            Log.i(TAG, "test4");
            final Bundle extras = data.getExtras();
            String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/temp/" + System.currentTimeMillis() + ".jpg";

            if (extras != null) {
                bitmap = extras.getParcelable("data");
                iv_UserPhoto.setImageBitmap(bitmap);
                imageUpload();
                storeCropImage(bitmap, filePath);
                break;
            }

            //임시파일 삭제
            File f = new File(mlmageCaptureUri.getPath());
            if (f.exists()) {
                f.delete();
            }
            break;
        }
    }
}
 
Example 15
Project: Android-Demo_ImageCroper   File: CropImageView.java   View Source Code Vote up 4 votes
@Override
public void onRestoreInstanceState(Parcelable state) {

    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;

        // prevent restoring state if already set by outside code
        if (mBitmapLoadingWorkerTask == null && mLoadedImageUri == null && mBitmap == null && mImageResource == 0) {

            Uri uri = bundle.getParcelable("LOADED_IMAGE_URI");
            if (uri != null) {
                String key = bundle.getString("LOADED_IMAGE_STATE_BITMAP_KEY");
                if (key != null) {
                    Bitmap stateBitmap = BitmapUtils.mStateBitmap != null && BitmapUtils.mStateBitmap.first.equals(key)
                            ? BitmapUtils.mStateBitmap.second.get() : null;
                    if (stateBitmap != null && !stateBitmap.isRecycled()) {
                        BitmapUtils.mStateBitmap = null;
                        setBitmap(stateBitmap, uri, bundle.getInt("LOADED_SAMPLE_SIZE"), 0);
                    }
                }
                if (mLoadedImageUri == null) {
                    setImageUriAsync(uri);
                }
            } else {
                int resId = bundle.getInt("LOADED_IMAGE_RESOURCE");
                if (resId > 0) {
                    setImageResource(resId);
                } else {
                    Bitmap bitmap = bundle.getParcelable("SET_BITMAP");
                    if (bitmap != null) {
                        setBitmap(bitmap);
                    } else {
                        uri = bundle.getParcelable("LOADING_IMAGE_URI");
                        if (uri != null) {
                            setImageUriAsync(uri);
                        }
                    }
                }
            }

            mDegreesRotated = bundle.getInt("DEGREES_ROTATED");

            mCropOverlayView.setInitialCropWindowRect((Rect) bundle.getParcelable("INITIAL_CROP_RECT"));

            mRestoreCropWindowRect = bundle.getParcelable("CROP_WINDOW_RECT");

            mCropOverlayView.setCropShape(CropShape.valueOf(bundle.getString("CROP_SHAPE")));

            mAutoZoomEnabled = bundle.getBoolean("CROP_AUTO_ZOOM_ENABLED");
            mMaxZoom = bundle.getInt("CROP_MAX_ZOOM");
        }

        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
    } else {
        super.onRestoreInstanceState(state);
    }
}
 
Example 16
Project: FragmentRigger   File: _FragmentRigger.java   View Source Code Vote up 4 votes
/**
 * Init the params of {@link #startFragmentForResult(Fragment, int)}
 */
private void initResultParams(Bundle savedInstanceState) {
  Bundle bundle = savedInstanceState == null ? mFragment.getArguments() : savedInstanceState;
  mForResultTarget = bundle.getParcelable(BUNDLE_KEY_FOR_RESULT);
}
 
Example 17
Project: Inflix   File: MovieDetailsFragment.java   View Source Code Vote up 4 votes
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState == null) {
        //noinspection ConstantConditions
        mResourceId = getArguments().getLong(RESOURCE_ID, 0);
        mResourceTitle = getArguments().getString(RESOURCE_TITLE, "");

        if (mResourceId != 0) {
            final URL similarURL = URIBuilderUtils.buildSimilarMoviesURL(String.valueOf(mResourceId));
            final URL castsURL = URIBuilderUtils.buildMovieCastURL(String.valueOf(mResourceId));
            Uri uri = DataContract.MEDIA_CONTENT_URI
                    .buildUpon()
                    .appendPath(String.valueOf(mResourceId))
                    .build();
            loadFromDatabase(uri, LOCAL_MOVIE_DETAILS_LOADER_ID);
            lazyLoadAdditionalInfoFromNetwork(new Runnable() {
                @Override
                public void run() {
                    if (similarURL != null) {
                        loadFromNetwork(similarURL, MOVIE_SIMILAR_LOADER_ID);
                    }

                    if (castsURL != null) {
                        loadFromNetwork(castsURL, MOVIE_CAST_LOADER_ID);
                    }
                }
            });
        } else {
            mContentLoadingUtil.error();
            mCastLoadingUtil.error();
            mSimilarLoadingUtil.error();
        }
    } else {
        mResourceId = savedInstanceState.getLong(RESOURCE_ID);
        mResourceTitle = savedInstanceState.getString(RESOURCE_TITLE);
        mMovieDetail = savedInstanceState.getParcelable(DETAILS);
        mSimilarList = savedInstanceState.getParcelableArrayList(SIMILAR);
        mCastList = savedInstanceState.getParcelableArrayList(CAST);

        updateContent();
        updateCasts();
        updateSimilar();
    }
}
 
Example 18
Project: TFG-SmartU-La-red-social   File: VideoActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    Bundle bundle = getIntent().getExtras();
    if(bundle!=null && bundle.containsKey("multimedia")) {

        Multimedia multimedia = bundle.getParcelable("multimedia");
        SimpleExoPlayerView videoView = (SimpleExoPlayerView) findViewById(R.id.video);

        // 1. Crea un slector de pista por defecto
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        // 2. Creo un control para el player
        LoadControl loadControl = new DefaultLoadControl();

        // 3. Creo el player con los componentes anteriores
        player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector, loadControl);

        //Obtengo la URL completa del archivo de video
        Uri uri = Uri.parse(ConsultasBBDD.server + ConsultasBBDD.imagenes +  multimedia.getUrl());

        //A la vista le establezco el reproductor que va a usar
        videoView.setPlayer(player);

        // Procuce que se instancie el DataSource a través de los datos del video que ha sido cargado.
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), Util.getUserAgent(getApplicationContext(), "SmartU"));
        // Produce un extractor que parsea el video.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // Construyo un MediaSource con el formato y los datos del video para asignarselo al reproductor.
        MediaSource videoSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
        // If has subtitles load video with subtitles
        if (multimedia.getUrlSubtitulos() != null && multimedia.getUrlSubtitulos().compareTo("") != 0) {
            //Obtengo la URL completa para los subtitulos del video
            Uri subtitulosUri = Uri.parse(ConsultasBBDD.server + ConsultasBBDD.imagenes +  multimedia.getUrlSubtitulos());
            //Asigno el formato de los subtitulos
            Format textFormat = Format.createTextSampleFormat(null, MimeTypes.TEXT_VTT,
                    null, Format.NO_VALUE, Format.NO_VALUE, Locale.getDefault().getLanguage(), null);
            //Creo un MediaSource para los subtitulos para añadirselos al video
            MediaSource subtitleSource = new SingleSampleMediaSource(subtitulosUri, dataSourceFactory, textFormat, C.TIME_UNSET);
            // Mezcla el video con los subtitulos
            MergingMediaSource mergedSource = new MergingMediaSource(videoSource, subtitleSource);
            // Preparo el reproductor con los subtitulos y el video
            player.prepare(mergedSource);
        } else // Si no tiene subtitulos preparo solo el video
            player.prepare(videoSource);
    }
}
 
Example 19
Project: GitHub   File: NucleusLayout.java   View Source Code Vote up 4 votes
@Override
protected void onRestoreInstanceState(Parcelable state) {
    Bundle bundle = (Bundle) state;
    super.onRestoreInstanceState(bundle.getParcelable(PARENT_STATE_KEY));
    presenterDelegate.onRestoreInstanceState(bundle.getBundle(PRESENTER_STATE_KEY));
}
 
Example 20
Project: buildAPKsSamples   File: GameView.java   View Source Code Vote up 4 votes
@Override
protected void onRestoreInstanceState(Parcelable state) {

    if (!(state instanceof Bundle)) {
        // Not supposed to happen.
        super.onRestoreInstanceState(state);
        return;
    }

    Bundle b = (Bundle) state;
    Parcelable superState = b.getParcelable("gv_super_state");

    setEnabled(b.getBoolean("gv_en", true));

    int[] data = b.getIntArray("gv_data");
    if (data != null && data.length == mData.length) {
        for (int i = 0; i < data.length; i++) {
            mData[i] = State.fromInt(data[i]);
        }
    }

    mSelectedCell = b.getInt("gv_sel_cell", -1);
    mSelectedValue = State.fromInt(b.getInt("gv_sel_val", State.EMPTY.getValue()));
    mCurrentPlayer = State.fromInt(b.getInt("gv_curr_play", State.EMPTY.getValue()));
    mWinner = State.fromInt(b.getInt("gv_winner", State.EMPTY.getValue()));

    mWinCol = b.getInt("gv_win_col", -1);
    mWinRow = b.getInt("gv_win_row", -1);
    mWinDiag = b.getInt("gv_win_diag", -1);

    mBlinkDisplayOff = b.getBoolean("gv_blink_off", false);
    Rect r = b.getParcelable("gv_blink_rect");
    if (r != null) {
        mBlinkRect.set(r);
    }

    // let the blink handler decide if it should blink or not
    mHandler.sendEmptyMessage(MSG_BLINK);

    super.onRestoreInstanceState(superState);
}