Example usage for android.os Bundle getCharSequence

List of usage examples for android.os Bundle getCharSequence

Introduction

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

Prototype

@Override
@Nullable
public CharSequence getCharSequence(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:de.mrapp.android.preference.activity.PreferenceActivity.java

@CallSuper
@Override/*w  w  w .  ja  v  a 2  s.c  o m*/
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
    Bundle bundle = savedInstanceState.getBundle(CURRENT_BUNDLE_EXTRA);
    CharSequence title = savedInstanceState.getCharSequence(CURRENT_TITLE_EXTRA);
    CharSequence shortTitle = savedInstanceState.getCharSequence(CURRENT_SHORT_TITLE_EXTRA);
    PreferenceHeader currentPreferenceHeader = savedInstanceState
            .getParcelable(CURRENT_PREFERENCE_HEADER_EXTRA);

    if (currentPreferenceHeader != null) {
        preferenceScreenFragment = restoredPreferenceScreenFragment;
        showPreferenceScreen(currentPreferenceHeader, bundle, false);
        showBreadCrumb(title, shortTitle);

        if (isSplitScreen()) {
            int selectedIndex = getListAdapter().indexOf(currentPreferenceHeader);

            if (selectedIndex != -1) {
                getListView().setItemChecked(selectedIndex, true);
            }
        }
    } else {
        showPreferenceHeaders();
    }
}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

/**
 * ???/*from   w ww  .ja v a  2s .c o m*/
 *
 * @param savedInstanceState Bundle
 */
private void loadActivitySavedData(Bundle savedInstanceState) {
    Field[] fields = this.getClass().getDeclaredFields();
    Field.setAccessible(fields, true);
    Annotation[] ans;
    for (Field f : fields) {
        ans = f.getDeclaredAnnotations();
        for (Annotation an : ans) {
            if (an instanceof SaveWithActivity) {
                try {
                    String fieldName = f.getName();
                    @SuppressWarnings("rawtypes")
                    Class cls = f.getType();
                    if (cls == int.class || cls == Integer.class) {
                        f.setInt(this, savedInstanceState.getInt(fieldName));
                    } else if (String.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getString(fieldName));
                    } else if (Serializable.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getSerializable(fieldName));
                    } else if (cls == long.class || cls == Long.class) {
                        f.setLong(this, savedInstanceState.getLong(fieldName));
                    } else if (cls == short.class || cls == Short.class) {
                        f.setShort(this, savedInstanceState.getShort(fieldName));
                    } else if (cls == boolean.class || cls == Boolean.class) {
                        f.setBoolean(this, savedInstanceState.getBoolean(fieldName));
                    } else if (cls == byte.class || cls == Byte.class) {
                        f.setByte(this, savedInstanceState.getByte(fieldName));
                    } else if (cls == char.class || cls == Character.class) {
                        f.setChar(this, savedInstanceState.getChar(fieldName));
                    } else if (CharSequence.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getCharSequence(fieldName));
                    } else if (cls == float.class || cls == Float.class) {
                        f.setFloat(this, savedInstanceState.getFloat(fieldName));
                    } else if (cls == double.class || cls == Double.class) {
                        f.setDouble(this, savedInstanceState.getDouble(fieldName));
                    } else if (String[].class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getStringArray(fieldName));
                    } else if (Parcelable.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getParcelable(fieldName));
                    } else if (Bundle.class.isAssignableFrom(cls)) {
                        f.set(this, savedInstanceState.getBundle(fieldName));
                    }
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.android.calculator2.Calculator.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calculator);
    setActionBar((Toolbar) findViewById(R.id.toolbar));

    // Hide all default options in the ActionBar.
    getActionBar().setDisplayOptions(0);

    mDisplayView = findViewById(R.id.display);
    mModeView = (TextView) findViewById(R.id.mode);
    mFormulaText = (CalculatorText) findViewById(R.id.formula);
    mResultText = (CalculatorResult) findViewById(R.id.result);

    mPadViewPager = (ViewPager) findViewById(R.id.pad_pager);
    mDeleteButton = findViewById(R.id.del);
    mClearButton = findViewById(R.id.clr);
    mEqualButton = findViewById(R.id.pad_numeric).findViewById(R.id.eq);
    if (mEqualButton == null || mEqualButton.getVisibility() != View.VISIBLE) {
        mEqualButton = findViewById(R.id.pad_operator).findViewById(R.id.eq);
    }// w  ww  .j  a va2s  .c o m

    mInverseToggle = (TextView) findViewById(R.id.toggle_inv);
    mModeToggle = (TextView) findViewById(R.id.toggle_mode);

    mInvertibleButtons = new View[] { findViewById(R.id.fun_sin), findViewById(R.id.fun_cos),
            findViewById(R.id.fun_tan), findViewById(R.id.fun_ln), findViewById(R.id.fun_log),
            findViewById(R.id.op_sqrt) };
    mInverseButtons = new View[] { findViewById(R.id.fun_arcsin), findViewById(R.id.fun_arccos),
            findViewById(R.id.fun_arctan), findViewById(R.id.fun_exp), findViewById(R.id.fun_10pow),
            findViewById(R.id.op_sqr) };

    mEvaluator = new Evaluator(this, mResultText);
    mResultText.setEvaluator(mEvaluator);
    KeyMaps.setActivity(this);

    if (savedInstanceState != null) {
        setState(CalculatorState.values()[savedInstanceState.getInt(KEY_DISPLAY_STATE,
                CalculatorState.INPUT.ordinal())]);
        CharSequence unprocessed = savedInstanceState.getCharSequence(KEY_UNPROCESSED_CHARS);
        if (unprocessed != null) {
            mUnprocessedChars = unprocessed.toString();
        }
        byte[] state = savedInstanceState.getByteArray(KEY_EVAL_STATE);
        if (state != null) {
            try (ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(state))) {
                mEvaluator.restoreInstanceState(in);
            } catch (Throwable ignored) {
                // When in doubt, revert to clean state
                mCurrentState = CalculatorState.INPUT;
                mEvaluator.clear();
            }
        }
    } else {
        mCurrentState = CalculatorState.INPUT;
        mEvaluator.clear();
    }

    mFormulaText.setOnKeyListener(mFormulaOnKeyListener);
    mFormulaText.setOnTextSizeChangeListener(this);
    mFormulaText.setOnPasteListener(this);
    mDeleteButton.setOnLongClickListener(this);

    onInverseToggled(mInverseToggle.isSelected());
    onModeChanged(mEvaluator.getDegreeMode());

    if (mCurrentState != CalculatorState.INPUT) {
        // Just reevaluate.
        redisplayFormula();
        setState(CalculatorState.INIT);
        mEvaluator.requireResult();
    } else {
        redisplayAfterFormulaChange();
    }
    // TODO: We're currently not saving and restoring scroll position.
    //       We probably should.  Details may require care to deal with:
    //         - new display size
    //         - slow recomputation if we've scrolled far.
}

From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRetainInstance(true);// w  w  w.j  a v  a2  s . c o m
    setHasOptionsMenu(true);
    View layout = inflater.inflate(R.layout.lyrics_view, container, false);
    if (savedInstanceState != null)
        try {
            Lyrics l = Lyrics.fromBytes(savedInstanceState.getByteArray("lyrics"));
            if (l != null)
                this.mLyrics = l;
            mSearchQuery = savedInstanceState.getString("searchQuery");
            mSearchFocused = savedInstanceState.getBoolean("searchFocused");
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    else {
        Bundle args = getArguments();
        if (args != null)
            try {
                Lyrics lyrics = Lyrics.fromBytes(args.getByteArray("lyrics"));
                this.mLyrics = lyrics;
                if (lyrics != null && lyrics.getText() == null && lyrics.getArtist() != null) {
                    String artist = lyrics.getArtist();
                    String track = lyrics.getTitle();
                    String url = lyrics.getURL();
                    fetchLyrics(artist, track, url);
                    mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout);
                    startRefreshAnimation();
                }
            } catch (IOException | ClassNotFoundException e) {
                e.printStackTrace();
            }
    }
    if (layout != null) {
        Bundle args = savedInstanceState != null ? savedInstanceState : getArguments();

        boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity())
                .getBoolean("pref_force_screen_on", false);

        TextSwitcher textSwitcher = (TextSwitcher) layout.findViewById(R.id.switcher);
        textSwitcher.setFactory(new LyricsTextFactory(layout.getContext()));
        ActionMode.Callback callback = new CustomSelectionCallback(getActivity());
        ((TextView) textSwitcher.getChildAt(0)).setCustomSelectionActionModeCallback(callback);
        ((TextView) textSwitcher.getChildAt(1)).setCustomSelectionActionModeCallback(callback);
        textSwitcher.setKeepScreenOn(screenOn);
        layout.findViewById(R.id.lrc_view).setKeepScreenOn(screenOn);

        EditText artistTV = (EditText) getActivity().findViewById(R.id.artist);
        EditText songTV = (EditText) getActivity().findViewById(R.id.song);

        if (args != null && args.containsKey("editedLyrics")) {
            EditText editedLyrics = (EditText) layout.findViewById(R.id.edit_lyrics);
            textSwitcher.setVisibility(View.GONE);
            editedLyrics.setVisibility(View.VISIBLE);
            songTV.setInputType(InputType.TYPE_CLASS_TEXT);
            artistTV.setInputType(InputType.TYPE_CLASS_TEXT);
            songTV.setBackgroundResource(R.drawable.abc_textfield_search_material);
            artistTV.setBackgroundResource(R.drawable.abc_textfield_search_material);
            editedLyrics.setText(args.getCharSequence("editedLyrics"), TextView.BufferType.EDITABLE);
            songTV.setText(args.getCharSequence("editedTitle"), TextView.BufferType.EDITABLE);
            artistTV.setText(args.getCharSequence("editedArtist"), TextView.BufferType.EDITABLE);
        }

        artistTV.setTypeface(LyricsTextFactory.FontCache.get("regular", getActivity()));
        songTV.setTypeface(LyricsTextFactory.FontCache.get("medium", getActivity()));

        final RefreshIcon refreshFab = (RefreshIcon) getActivity().findViewById(R.id.refresh_fab);
        refreshFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!mRefreshLayout.isRefreshing())
                    fetchCurrentLyrics(true);
            }
        });
        if (args != null)
            refreshFab.setEnabled(args.getBoolean("refreshFabEnabled", true));

        mScrollView = (NestedScrollView) layout.findViewById(R.id.scrollview);
        mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout);
        TypedValue primaryColor = new TypedValue();
        TypedValue accentColor = new TypedValue();
        getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, primaryColor, true);
        getActivity().getTheme().resolveAttribute(R.attr.colorAccent, accentColor, true);
        mRefreshLayout.setColorSchemeResources(primaryColor.resourceId, accentColor.resourceId);
        float offset = getResources().getDisplayMetrics().density * 64;
        mRefreshLayout.setProgressViewEndTarget(true, (int) offset);
        mRefreshLayout.setOnRefreshListener(this);

        final ImageButton editTagsButton = (ImageButton) getActivity().findViewById(R.id.edit_tags_btn);

        View.OnClickListener startEditClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startEditTagsMode();
                final View.OnClickListener startEditClickListener = this;
                editTagsButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        exitEditTagsMode();
                        editTagsButton.setOnClickListener(startEditClickListener);
                    }
                });
            }
        };
        editTagsButton.setOnClickListener(startEditClickListener);

        if (mLyrics == null) {
            if (!startEmpty)
                fetchCurrentLyrics(false);
        } else if (mLyrics.getFlag() == Lyrics.SEARCH_ITEM) {
            mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout);
            startRefreshAnimation();
            if (mLyrics.getArtist() != null)
                fetchLyrics(mLyrics.getArtist(), mLyrics.getTitle());
            ((TextView) (getActivity().findViewById(R.id.artist))).setText(mLyrics.getArtist());
            ((TextView) (getActivity().findViewById(R.id.song))).setText(mLyrics.getTitle());
        } else //Rotation, resume
            update(mLyrics, layout, false);
    }
    if (broadcastReceiver == null)
        broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                searchResultLock = false;
                String artist = intent.getStringExtra("artist");
                String track = intent.getStringExtra("track");
                if (artist != null && track != null && mRefreshLayout.isEnabled()) {
                    startRefreshAnimation();
                    new ParseTask(LyricsViewFragment.this, false, true).execute(mLyrics);
                }
            }
        };
    return layout;
}

From source file:com.he5ed.lib.cloudprovider.picker.CloudPickerActivity.java

/**
 * @hide//  ww w.ja v  a 2 s. c o  m
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cp_activity_picker);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    // lock right drawer from been swiped open
    drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null); // remove the auto grey tint to keep icon color
    Menu menu = navigationView.getMenu();
    CloudProvider cloudProvider = CloudProvider.getInstance(this);
    // check whether individual account is assigned
    String accountId = getIntent().getStringExtra(EXTRA_PICK_ACCOUNT_ID);
    if (!TextUtils.isEmpty(accountId)) {
        mAccounts = new CloudAccount[1];
        mAccounts[0] = cloudProvider.getAccountById(accountId);
    } else {
        mAccounts = cloudProvider.getCloudAccounts();
    }
    // populate navigation menu
    for (int i = 0; i < mAccounts.length; i++) {
        CloudAccount account = mAccounts[i];
        MenuItem item = menu.add(0, i, 0, account.getUser().email);
        // use cloud API class reflection
        try {
            Class clazz = Class.forName(account.api);
            Field iconResource = clazz.getField("ICON_RESOURCE");
            item.setIcon(iconResource.getInt(null));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
            item.setIcon(R.drawable.ic_cloud_black_24dp);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        item.setCheckable(true);
    }

    mFragmentManager = getSupportFragmentManager();
    mItemFragment = (ItemFragment) mFragmentManager.findFragmentById(R.id.right_drawer_view);
    if (mItemFragment == null) {
        mItemFragment = new ItemFragment();
        mFragmentManager.beginTransaction().add(R.id.right_drawer_view, mItemFragment).commit();
    }

    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mErrorView = (LinearLayout) findViewById(R.id.error_view);
    if (savedInstanceState != null) {
        switch (savedInstanceState.getInt("empty_view_visibility")) {
        case View.VISIBLE:
            mErrorView.setVisibility(View.VISIBLE);
            ImageView icon = (ImageView) mErrorView.findViewById(R.id.empty_icon_image_view);
            TextView title = (TextView) mErrorView.findViewById(R.id.empty_title_text_view);
            TextView detail = (TextView) mErrorView.findViewById(R.id.empty_detail_text_view);
            Bitmap bitmap = savedInstanceState.getParcelable("icon_drawable");
            icon.setImageBitmap(bitmap);
            title.setText(savedInstanceState.getCharSequence("title_text"));
            detail.setText(savedInstanceState.getCharSequence("detail_text"));
            break;
        case View.INVISIBLE:
            mErrorView.setVisibility(View.INVISIBLE);
            break;
        case View.GONE:
            mErrorView.setVisibility(View.GONE);
            break;
        }
    } else {
        // open drawer on first load
        drawer.openDrawer(GravityCompat.START);
    }
}

From source file:com.android.mail.compose.ComposeActivity.java

/**
 * Fill all the widgets with the content found in the Intent Extra, if any.
 * Also apply the same style to all widgets. Note: if initFromExtras is
 * called as a result of switching between reply, reply all, and forward per
 * the latest revision of Gmail, and the user has already made changes to
 * attachments on a previous incarnation of the message (as a reply, reply
 * all, or forward), the original attachments from the message will not be
 * re-instantiated. The user's changes will be respected. This follows the
 * web gmail interaction.//from   w  ww.  j  a  va  2  s.  co  m
 * @return {@code true} if the activity should not call {@link #finishSetup}.
 */
public boolean initFromExtras(Intent intent) {
    // If we were invoked with a SENDTO intent, the value
    // should take precedence
    final Uri dataUri = intent.getData();
    if (dataUri != null) {
        if (MAIL_TO.equals(dataUri.getScheme())) {
            initFromMailTo(dataUri.toString());
        } else {
            if (!mAccount.composeIntentUri.equals(dataUri)) {
                String toText = dataUri.getSchemeSpecificPart();
                if (toText != null) {
                    mTo.setText("");
                    addToAddresses(Arrays.asList(TextUtils.split(toText, ",")));
                }
            }
        }
    }

    String[] extraStrings = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
    if (extraStrings != null) {
        addToAddresses(Arrays.asList(extraStrings));
    }
    extraStrings = intent.getStringArrayExtra(Intent.EXTRA_CC);
    if (extraStrings != null) {
        addCcAddresses(Arrays.asList(extraStrings), null);
    }
    extraStrings = intent.getStringArrayExtra(Intent.EXTRA_BCC);
    if (extraStrings != null) {
        addBccAddresses(Arrays.asList(extraStrings));
    }

    String extraString = intent.getStringExtra(Intent.EXTRA_SUBJECT);
    if (extraString != null) {
        mSubject.setText(extraString);
    }

    for (String extra : ALL_EXTRAS) {
        if (intent.hasExtra(extra)) {
            String value = intent.getStringExtra(extra);
            if (EXTRA_TO.equals(extra)) {
                addToAddresses(Arrays.asList(TextUtils.split(value, ",")));
            } else if (EXTRA_CC.equals(extra)) {
                addCcAddresses(Arrays.asList(TextUtils.split(value, ",")), null);
            } else if (EXTRA_BCC.equals(extra)) {
                addBccAddresses(Arrays.asList(TextUtils.split(value, ",")));
            } else if (EXTRA_SUBJECT.equals(extra)) {
                mSubject.setText(value);
            } else if (EXTRA_BODY.equals(extra)) {
                setBody(value, true /* with signature */);
            } else if (EXTRA_QUOTED_TEXT.equals(extra)) {
                initQuotedText(value, true /* shouldQuoteText */);
            }
        }
    }

    Bundle extras = intent.getExtras();
    if (extras != null) {
        CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT);
        setBody((text != null) ? text : "", true /* with signature */);

        // TODO - support EXTRA_HTML_TEXT
    }

    mExtraValues = intent.getParcelableExtra(EXTRA_VALUES);
    if (mExtraValues != null) {
        LogUtils.d(LOG_TAG, "Launched with extra values: %s", mExtraValues.toString());
        initExtraValues(mExtraValues);
        return true;
    }

    return false;
}

From source file:com.free.searcher.MainFragment.java

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

    if (savedInstanceState == null) {
        return;/*  www. j  av  a 2  s.  c o m*/
    }

    Log.i("SearcheFragment.onViewStateRestored();", savedInstanceState + "uuu");
    selectedFiles = savedInstanceState.getStringArray("selectedFiles");
    if (savedInstanceState.getSerializable("files") instanceof File[]) {
        files = (File[]) savedInstanceState.getSerializable("files");
    }

    if (savedInstanceState.getString("currentSearching") instanceof String) {
        currentSearching = savedInstanceState.getString("currentSearching");
    }

    if (savedInstanceState.getString("currentZipFileName") instanceof String) {
        currentZipFileName = savedInstanceState.getString("currentZipFileName");
        if (currentZipFileName.length() > 0) {
            try {
                extractFile = new ExtractFile(currentZipFileName,
                        MainFragment.PRIVATE_PATH + currentZipFileName);
            } catch (RarException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    if (savedInstanceState.getString("load") instanceof String) {
        load = savedInstanceState.getString("load");
    }

    if (savedInstanceState.getString("currentUrl") instanceof String) {
        currentUrl = savedInstanceState.getString("currentUrl");
    }
    //      HtmlSourceViewJavaScriptInterface.source = savedInstanceState.getString("source");

    if (currentUrl != null && currentUrl.length() > 0) {
        (webTask = new WebTask(MainFragment.this, webView, currentUrl)).execute();
    }

    if (mSearchView != null && savedInstanceState.getCharSequence("query") != null) {
        mSearchView.setQuery(savedInstanceState.getCharSequence("query"), false);
    }

    if (savedInstanceState.getString("status") instanceof String) {
        status = savedInstanceState.getCharSequence("status");
    }
    locX = savedInstanceState.getInt("locX");
    locY = savedInstanceState.getInt("locY");

    webViewBundle = savedInstanceState.getBundle("webViewBundle");
    if (savedInstanceState.getString("home") instanceof String) {
        home = savedInstanceState.getString("home");
    }

    //      webView.setOnTouchListener(new View.OnTouchListener() {
    //            @Override
    //            public boolean onTouch(View p1, MotionEvent event) {
    //               //Log.d("onClick", p1 + "");
    //               Log.d("MotionEvent", event + "");
    //               if ((event.getAction() ==  MotionEvent.ACTION_DOWN || event.getAction() ==  MotionEvent.ACTION_POINTER_UP) && statusView != null) {
    //                  int curVis = statusView.getSystemUiVisibility();
    //                  Log.d("curVis", curVis + ", " + ((curVis&View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0));
    //                  SHOW = !SHOW;
    //                  Log.d("SHOW", SHOW + "");
    //                  setNavVisibility(SHOW); //((curVis&View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0);
    //               }
    //               return false;
    //            }
    //         });

    /**
     if (savedInstanceState.getString("readTextFiles") != null) {
     String[] readTextFilesStr = savedInstanceState.getString("readTextFiles").split(";;;"); // ,
     // Util.listToString(readTextFiles,false, ";;;"));
     for (String textFile : readTextFilesStr) {
     readTextFiles.add(new File(textFile));
     }
     }
            
     if (savedInstanceState.getString("initFolderFiles") != null) {
     String[] initFolderFilesStr = savedInstanceState.getString("initFolderFiles").split(";;;"); // ,
     // Util.listToString(initFolderFiles,false, ";;;"));
     for (String folderFile : initFolderFilesStr) {
     initFolderFiles.add(new File(folderFile));
     }
     }
     **/
}

From source file:com.jefftharris.passwdsafe.PasswdSafe.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    PasswdSafeApp.setupTheme(this);
    super.onCreate(savedInstanceState);
    ApiCompat.setRecentAppsVisible(getWindow(), false);
    setContentView(R.layout.activity_passwdsafe);
    itsIsTwoPane = (findViewById(R.id.two_pane) != null);

    itsNavDrawerFrag = (PasswdSafeNavDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_drawer);
    itsNavDrawerFrag.setUp((DrawerLayout) findViewById(R.id.drawer_layout));

    itsQueryPanel = findViewById(R.id.query_panel);
    View queryClearBtn = findViewById(R.id.query_clear_btn);
    assert queryClearBtn != null;
    queryClearBtn.setOnClickListener(this);
    itsQuery = (TextView) findViewById(R.id.query);

    itsExpiryPanel = findViewById(R.id.expiry_panel);
    assert itsExpiryPanel != null;
    itsExpiryPanel.setOnClickListener(this);
    GuiUtils.setVisible(itsExpiryPanel, false);
    View expiryClearBtn = findViewById(R.id.expiry_clear_btn);
    assert expiryClearBtn != null;
    expiryClearBtn.setOnClickListener(this);
    itsExpiry = (TextView) findViewById(R.id.expiry);

    FragmentManager fragMgr = getSupportFragmentManager();
    itsFileDataFrag = (PasswdSafeFileDataFragment) fragMgr.findFragmentByTag(FRAG_DATA);
    if (itsFileDataFrag == null) {
        itsFileDataFrag = new PasswdSafeFileDataFragment();
        fragMgr.beginTransaction().add(itsFileDataFrag, FRAG_DATA).commit();
    }//  w ww  .j av a2s .co  m
    boolean newFileDataFrag = itsFileDataFrag.checkNew();

    itsTimeoutReceiver = new FileTimeoutReceiver(this);

    if (newFileDataFrag || (savedInstanceState == null)) {
        itsTitle = getTitle();
        doUpdateView(ViewMode.INIT, new PasswdLocation());
        changeInitialView();

        Intent intent = getIntent();
        PasswdSafeUtil.dbginfo(TAG, "onCreate: %s", intent);
        switch (intent.getAction()) {
        case PasswdSafeUtil.VIEW_INTENT:
        case Intent.ACTION_VIEW: {
            changeFileOpenView(intent);
            break;
        }
        case PasswdSafeUtil.NEW_INTENT: {
            changeFileNewView(intent);
            break;
        }
        default: {
            Log.e(TAG, "Unknown action for intent: " + intent);
            finish();
            break;
        }
        }
    } else {
        itsTitle = savedInstanceState.getCharSequence(STATE_TITLE);
        itsQuery.setText(savedInstanceState.getCharSequence(STATE_QUERY));
        if (savedInstanceState.getBoolean(STATE_EXPIRY_VISIBLE, false)) {
            itsFileDataFrag.getFileDataView().resetExpiryChanged();
        }
    }
}

From source file:net.tjado.passwdsafe.PasswdSafe.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    PasswdSafeApp.setupTheme(this);
    super.onCreate(savedInstanceState);

    itsIsDisplayListTreeView = PasswdSafeApp.getDisplayTreeView(this);

    ApiCompat.setRecentAppsVisible(getWindow(), false);
    setContentView(R.layout.activity_passwdsafe);
    itsIsTwoPane = (findViewById(R.id.two_pane) != null);

    itsNavDrawerFrag = (PasswdSafeNavDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_drawer);
    itsNavDrawerFrag.setUp((DrawerLayout) findViewById(R.id.drawer_layout));

    itsQueryPanel = findViewById(R.id.query_panel);
    View queryClearBtn = findViewById(R.id.query_clear_btn);
    assert queryClearBtn != null;
    queryClearBtn.setOnClickListener(this);
    itsQuery = (TextView) findViewById(R.id.query);

    itsExpiryPanel = findViewById(R.id.expiry_panel);
    assert itsExpiryPanel != null;
    itsExpiryPanel.setOnClickListener(this);
    GuiUtils.setVisible(itsExpiryPanel, false);
    View expiryClearBtn = findViewById(R.id.expiry_clear_btn);
    assert expiryClearBtn != null;
    expiryClearBtn.setOnClickListener(this);
    itsExpiry = (TextView) findViewById(R.id.expiry);

    FragmentManager fragMgr = getSupportFragmentManager();
    itsFileDataFrag = (PasswdSafeFileDataFragment) fragMgr.findFragmentByTag(FRAG_DATA);
    if (itsFileDataFrag == null) {
        itsFileDataFrag = new PasswdSafeFileDataFragment();
        fragMgr.beginTransaction().add(itsFileDataFrag, FRAG_DATA).commit();
    }//from   w  w  w .j av a  2 s.c  o  m
    boolean newFileDataFrag = itsFileDataFrag.checkNew();

    itsTimeoutReceiver = new FileTimeoutReceiver(this);

    if (newFileDataFrag || (savedInstanceState == null)) {
        itsTitle = getTitle();
        doUpdateView(ViewMode.INIT, new PasswdLocation());
        changeInitialView();

        Intent intent = getIntent();
        PasswdSafeUtil.dbginfo(TAG, "onCreate: %s", intent);
        switch (intent.getAction()) {
        case PasswdSafeUtil.VIEW_INTENT:
        case Intent.ACTION_VIEW: {
            changeFileOpenView(intent);
            break;
        }
        case PasswdSafeUtil.NEW_INTENT: {
            changeFileNewView(intent);
            break;
        }
        default: {
            Log.e(TAG, "Unknown action for intent: " + intent);
            finish();
            break;
        }
        }
    } else {
        itsTitle = savedInstanceState.getCharSequence(STATE_TITLE);
        itsQuery.setText(savedInstanceState.getCharSequence(STATE_QUERY));
        if (savedInstanceState.getBoolean(STATE_EXPIRY_VISIBLE, false)) {
            itsFileDataFrag.getFileDataView().resetExpiryChanged();
        }
    }
}

From source file:info.staticfree.android.units.Units.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from  w w  w.ja v  a  2  s  .c om

    wantEditText = ((MultiAutoCompleteTextView) findViewById(R.id.want));
    haveEditText = ((MultiAutoCompleteTextView) findViewById(R.id.have));
    defaultInputType = wantEditText.getInputType();
    wantEditText.setOnFocusChangeListener(inputBoxOnFocusChange);
    haveEditText.setOnFocusChangeListener(inputBoxOnFocusChange);

    resultView = ((TextView) findViewById(R.id.result));
    history = ((ListView) findViewById(R.id.history_list));
    historyDrawer = ((LinearLayout) findViewById(R.id.history_drawer));
    historyClose = ((Button) findViewById(R.id.history_close));
    workspace = (WorkspaceView) findViewById(R.id.numpad_switcher);
    //workspace.setTouchSlop(); // XXX scale
    //workspace.setShowTabIndicator(false);

    mHistoryAdapter = new HistoryAdapter(this, null);
    history.setAdapter(mHistoryAdapter);
    // TODO consolidate listeners
    history.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            setCurrentEntry(
                    ContentUris.withAppendedId(HistoryEntry.CONTENT_URI, mHistoryAdapter.getItemId(position)));

            setHistoryVisible(false);
        }
    });
    history.setOnCreateContextMenuListener(this);

    resultView.setOnClickListener(this);
    resultView.setOnCreateContextMenuListener(this);
    historyClose.setOnClickListener(this);

    // Go through the numberpad and add all the onClick listeners.
    // Make sure to update if the layout changes.
    setGridChildrenListener(((LinearLayout) findViewById(R.id.numberpad)), buttonListener, buttonListener);
    setGridChildrenListener((ViewGroup) findViewById(R.id.numberpad2), buttonListener, buttonListener);

    final View backspace = findViewById(R.id.backspace);
    backspace.setOnClickListener(buttonListener);
    backspace.setOnLongClickListener(buttonListener);

    unitUsageDBHelper = new UnitUsageDBHelper(this);

    final Object instance = getLastNonConfigurationInstance();
    if (instance instanceof LoadInitialUnitUsageTask) {
        mLoadInitialUnitUsageTask = (LoadInitialUnitUsageTask) instance;
        mLoadInitialUnitUsageTask.setActivity(this);
    } else {
        if (unitUsageDBHelper.getUnitUsageDbCount() == 0) {
            mLoadInitialUnitUsageTask = new LoadInitialUnitUsageTask();
            mLoadInitialUnitUsageTask.setActivity(this);
            mLoadInitialUnitUsageTask.execute();
        }
    }

    wantEditText.setOnEditorActionListener(this);

    final UnitsMultiAutoCompleteTokenizer tokenizer = new UnitsMultiAutoCompleteTokenizer();
    haveEditText.setTokenizer(tokenizer);
    wantEditText.setTokenizer(tokenizer);
    haveEditText.setOnTouchListener(this);
    wantEditText.setOnTouchListener(this);

    if (savedInstanceState != null) {
        resultView.setText(savedInstanceState.getCharSequence(STATE_RESULT_TEXT));
        setHistoryVisible(savedInstanceState.getBoolean(STATE_DRAWER_OPENED, false), false);
        mDialogUnitCategoryUnit = savedInstanceState.getString(STATE_DIALOG_UNIT_CATEGORY);
    }

    final Intent intent = getIntent();
    handleIntent(intent);

    getSupportLoaderManager().initLoader(LOADER_HISTORY, null, this);
    getSupportLoaderManager().initLoader(LOADER_USAGE, null, this);

}