Example usage for android.os Bundle getLong

List of usage examples for android.os Bundle getLong

Introduction

In this page you can find the example usage for android.os Bundle getLong.

Prototype

public long getLong(String key, long defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Usage

From source file:com.handpoint.headstart.client.ui.MainActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    this.mPager.setCurrentItem(savedInstanceState.getInt(CURRENT_PAGE));
    long voidedId = savedInstanceState.getLong(VOIDED_ID, -1);
    if (voidedId != -1) {
        mOriginalId = Long.valueOf(voidedId);
    }//from   w ww  .  j a  v a2  s.  c  o  m
    ParcelDeferredTransaction parcel = savedInstanceState.getParcelable(DEFERRED_TRANSACTION);
    if (null != parcel) {
        mDeferredTransaction = parcel.getResult();
    }
}

From source file:com.iaraby.template.view.fragment.DetailsFrag.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);//from w  ww.  j  a va  2 s .  co  m
    View rootView = inflater.inflate(R.layout.fragment_details, container, false);

    // Initial
    this.selectedPosition = 0;
    catPosition = Constants.EMPTY_INT;
    if (getArguments() != null) {
        this.catPosition = getArguments().getInt(Constants.PARAM_CAT_POS_TAG, Constants.EMPTY_INT);
        this.catId = getArguments().getLong(Constants.PARAM_CAT_ID_TAG);
        this.isFav = getArguments().getBoolean(Constants.PARAM_IS_FAV);
        if (isFav)
            this.selectedPosition = this.catPosition;
    }

    if (savedInstanceState != null) {
        this.selectedPosition = savedInstanceState.getInt(Constants.PARAM_SEL_POS_TAG, this.selectedPosition);
        this.catPosition = savedInstanceState.getInt(Constants.PARAM_CAT_POS_TAG, catPosition);
        this.catId = savedInstanceState.getLong(Constants.PARAM_CAT_ID_TAG, catId);
        this.isFav = savedInstanceState.getBoolean(Constants.PARAM_IS_FAV, this.isFav);

    }
    // UI
    pager = (ViewPager) rootView.findViewById(R.id.content_pager);
    titleView = (TextView) rootView.findViewById(R.id.content_header);
    adView = (AdView) rootView.findViewById(R.id.ad_container);
    titleView.setText("");
    FontManager.getInstance(getActivity()).setTextFont(titleView, FontManager.CONTENT);

    // Process
    if (catPosition != Constants.EMPTY_INT) {
        DetailsTask process = new DetailsTask(getActivity(), catId, catPosition, this.isFav,
                new DetailsTask.HandleResult() {

                    @Override
                    public void setResult(String title, String desc) {
                    }

                    @Override
                    public void setResult(String title, Cursor contCur) {
                        fillData(title, contCur);
                    }

                    @Override
                    public void handleError(String error) {
                        LogManager.getIns().e(Constants.LOG_TAG, error);
                    }

                });
        process.execute();
        handleAds(adView);
    } // make sure the data is well received
    return rootView;
}

From source file:com.ultramegasoft.flavordex2.EntryListActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_entry_list);

    if (findViewById(R.id.entry_detail_container) != null) {
        mTwoPane = true;/* w w  w. jav  a 2s .c om*/
        mWelcomeFragment = new WelcomeFragment();
    }

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.entry_list, mCatListFragment).commit();
        if (mTwoPane) {
            getSupportFragmentManager().beginTransaction().add(R.id.entry_detail_container, mWelcomeFragment)
                    .commit();
        }

        loadPreferences(PreferenceManager.getDefaultSharedPreferences(this));

        PermissionUtils.checkExternalStoragePerm(this, R.string.message_request_storage);
    } else {
        mSelectedCat = savedInstanceState.getLong(STATE_SELECTED_CAT, mSelectedCat);
        mSelectedItem = savedInstanceState.getLong(STATE_SELECTED_ENTRY, mSelectedItem);
        mFilters = savedInstanceState.getParcelable(STATE_FILTERS);
    }
}

From source file:com.pseudosudostudios.jdd.activities.GameActivity.java

private boolean loadFromBundle(Bundle state) {
    if (state == null)
        return false;
    Log.d("onCreateStuff", "Using bundle");
    Log.d("Loading", "Reading from bundle");
    // Reload the game after a screen rotation
    Tile.initPaints();/*from ww w  . ja v a 2  s.c om*/
    Tile[][] loadedTiles = new Tile[3][3];
    Tile[][] loadedSol = new Tile[3][3];
    for (int r = 0; r < bg.tiles.length; r++)
        for (int c = 0; c < bg.tiles[r].length; c++) {
            loadedTiles[r][c] = new Tile(this, state.getIntArray(onSaveBaseString + r + c));
            int[] arr = state.getIntArray(onSaveSolution + r + c);
            if (arr != null)
                loadedSol[r][c] = new Tile(this, arr);
        }
    int moves = state.getInt(onSaveMoves, 0);
    long time = state.getLong(onSaveTime, 0L);
    bg.setTileArray(loadedTiles, loadedSol, moves, time, state.getInt(jsonTileSize, 0));
    bg.setDifficulty(findDifficulty(state.getString(onSaveBaseString)));
    Grid.numberOfColors = state.getInt(bundleGameColors);
    bg.setCenterTile(new Tile(this, state.getIntArray(onSaveCeterTile)));
    Tile.initPaints();
    bg.invalidate();
    return true;
}

From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java

public Loader<Response<UserList>> onCreateLoader(final int id, final Bundle args) {
    mListContainer.setVisibility(View.VISIBLE);
    mErrorMessageView.setText(null);//from   w  w w . jav a  2 s  .  c  o  m
    mErrorMessageView.setVisibility(View.GONE);
    mErrorRetryContainer.setVisibility(View.GONE);
    setListShown(false);
    setProgressBarIndeterminateVisibility(true);
    long account_id = -1, user_id = -1;
    int list_id = -1;
    String screen_name = null, list_name = null;
    if (args != null) {
        account_id = args.getLong(INTENT_KEY_ACCOUNT_ID, -1);
        user_id = args.getLong(INTENT_KEY_USER_ID, -1);
        list_id = args.getInt(INTENT_KEY_LIST_ID, -1);
        list_name = args.getString(INTENT_KEY_LIST_NAME);
        screen_name = args.getString(INTENT_KEY_SCREEN_NAME);
    }
    return new ListInfoLoader(getActivity(), account_id, list_id, list_name, user_id, screen_name);
}

From source file:com.android.mms.quickmessage.QuickMessagePopup.java

private void parseIntent(Bundle extras, boolean newMessage) {
    if (extras == null) {
        return;/*w ww .j  av  a2s.  co  m*/
    }

    // Check if we are being called to remove messages already showing
    if (extras.getBoolean(QR_REMOVE_MESSAGES_EXTRA, false)) {
        // Get the ID
        long threadId = extras.getLong(QR_THREAD_ID_EXTRA, -1);
        if (threadId != -1) {
            removeMatchingMessages(threadId);
        }
    } else {
        // Parse the intent and ensure we have a notification object to work with
        NotificationInfo nm = (NotificationInfo) extras.getParcelable(SMS_NOTIFICATION_OBJECT_EXTRA);
        if (nm != null) {
            QuickMessage qm = new QuickMessage(extras.getString(SMS_FROM_NAME_EXTRA),
                    extras.getString(SMS_FROM_NUMBER_EXTRA), nm);
            mMessageList.add(qm);
            mPagerAdapter.notifyDataSetChanged();

            // If triggered from Quick Reply the keyboard should be visible immediately
            if (extras.getBoolean(QR_SHOW_KEYBOARD_EXTRA, false)) {
                getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }

            if (newMessage && mCurrentPage != -1) {
                // There is already a message showing
                // Stay on the current message
                mMessagePager.setCurrentItem(mCurrentPage);
            } else {
                // Set the current message to the last message received
                mCurrentPage = mMessageList.size() - 1;
                mMessagePager.setCurrentItem(mCurrentPage);
            }

            if (DEBUG) {
                Log.d(LOG_TAG,
                        "parseIntent(): New message from " + qm.getThreadId() + " added. Number of messages = "
                                + mMessageList.size() + ". Displaying page #" + (mCurrentPage + 1));
            }

            // Make sure the counter is accurate
            updateMessageCounter();
        }
    }
}

From source file:de.vanita5.twittnuker.activity.support.HomeActivity.java

private int handleIntent(final Intent intent, final boolean firstCreate) {
    // use packge's class loader to prevent BadParcelException
    intent.setExtrasClassLoader(getClassLoader());
    // reset intent
    setIntent(new Intent(this, HomeActivity.class));
    final String action = intent.getAction();
    if (Intent.ACTION_SEARCH.equals(action)) {
        final String query = intent.getStringExtra(SearchManager.QUERY);
        final Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA);
        final long accountId;
        if (appSearchData != null && appSearchData.containsKey(EXTRA_ACCOUNT_ID)) {
            accountId = appSearchData.getLong(EXTRA_ACCOUNT_ID, -1);
        } else {//  w  w w. ja va2s.  c o  m
            accountId = getDefaultAccountId(this);
        }
        openSearch(this, accountId, query);
        return -1;
    }
    final boolean refreshOnStart = mPreferences.getBoolean(KEY_REFRESH_ON_START, false);
    final long[] refreshedIds = intent.getLongArrayExtra(EXTRA_IDS);
    if (refreshedIds != null) {
        mTwitterWrapper.refreshAll(refreshedIds);
    } else if (firstCreate && refreshOnStart) {
        mTwitterWrapper.refreshAll();
    }

    final int tab = intent.getIntExtra(EXTRA_INITIAL_TAB, -1);
    final int initialTab = tab != -1 ? tab : getAddedTabPosition(this, intent.getStringExtra(EXTRA_TAB_TYPE));
    if (initialTab != -1 && mViewPager != null) {
        // clearNotification(initial_tab);
    }
    final Intent extraIntent = intent.getParcelableExtra(EXTRA_EXTRA_INTENT);
    if (extraIntent != null && firstCreate) {
        extraIntent.setExtrasClassLoader(getClassLoader());
        SwipebackActivityUtils.startSwipebackActivity(this, extraIntent);
    }
    return initialTab;
}

From source file:com.owncloud.android.ui.activity.FileActivity.java

/**
 * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
 * the {@link FileActivity}.//from   w ww .  j  a  v a  2 s  .  c o  m
 *
 * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user
 * is requested to create a new one.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    mFileOperationsHelper = new FileOperationsHelper(this);
    Account account = null;
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
        mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
        mFileOperationsHelper
                .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE));
        mTryShareAgain = savedInstanceState.getBoolean(KEY_TRY_SHARE_AGAIN);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
        }
    } else {
        account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
        mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
    }

    AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager
                                             // or database

    setAccount(account, savedInstanceState != null);

    mOperationsServiceConnection = new OperationsServiceConnection();
    bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE);

    mDownloadServiceConnection = newTransferenceServiceConnection();
    if (mDownloadServiceConnection != null) {
        bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection,
                Context.BIND_AUTO_CREATE);
    }
    mUploadServiceConnection = newTransferenceServiceConnection();
    if (mUploadServiceConnection != null) {
        bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE);
    }

}

From source file:com.folkcat.run.activity.PhotoViewPagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //???/* w w w.jav a  2s . co  m*/
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //??
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    setContentView(R.layout.activity_photo_pager);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    toolbar.setNavigationIcon(getResources().getDrawable(R.mipmap.ic_close));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(false);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    if (savedInstanceState == null) {
        Intent i = getIntent();
        mPosition = i.getIntExtra("position", 0);
        mRunningId = i.getLongExtra("runningId", 0);
    } else {
        mPosition = savedInstanceState.getInt("position", 0);
        mRunningId = savedInstanceState.getLong("runningId", 0);
    }

    mPhotoList = PhotoUtil.getPthotosByRunningIdAndUpdateUi(mRunningId);
    mViewPager.setAdapter(new SamplePagerAdapter());
    if (savedInstanceState != null) {
        boolean isLocked = savedInstanceState.getBoolean(ISLOCKED_ARG, false);
        ((HackyViewPager) mViewPager).setLocked(isLocked);
    }
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            mPosition = position;

        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    mViewPager.setCurrentItem(mPosition);

}

From source file:com.cerema.cloud2.ui.activity.FileActivity.java

/**
 * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
 * the {@link FileActivity}./*from   ww w.ja v  a  2s  . co  m*/
 *
 * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user
 * is requested to create a new one.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    mFileOperationsHelper = new FileOperationsHelper(this);
    Account account = null;
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
        mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
        mFileOperationsHelper
                .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE));
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
        }
    } else {
        account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
        mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
    }

    AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager
                                             // or database

    setAccount(account, savedInstanceState != null);

    mOperationsServiceConnection = new OperationsServiceConnection();
    bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE);

    mDownloadServiceConnection = newTransferenceServiceConnection();
    if (mDownloadServiceConnection != null) {
        bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection,
                Context.BIND_AUTO_CREATE);
    }
    mUploadServiceConnection = newTransferenceServiceConnection();
    if (mUploadServiceConnection != null) {
        bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE);
    }

}