List of usage examples for android.os Bundle getStringArrayList
@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key)
From source file:com.filemanager.free.activities.MainActivity.java
public void bbar(final Main main) { final String text = main.CURRENT_PATH; try {/*from w w w . ja v a2 s . c o m*/ buttons.removeAllViews(); buttons.setMinimumHeight(pathbar.getHeight()); Drawable arrow = ContextCompat.getDrawable(con, R.drawable.abc_ic_ab_back_holo_dark); Bundle b = utils.getPaths(text, this); ArrayList<String> names = b.getStringArrayList("names"); ArrayList<String> rnames = new ArrayList<String>(); assert names != null; for (int i = names.size() - 1; i >= 0; i--) { rnames.add(names.get(i)); } ArrayList<String> paths = b.getStringArrayList("paths"); final ArrayList<String> rpaths = new ArrayList<String>(); assert paths != null; for (int i = paths.size() - 1; i >= 0; i--) { rpaths.add(paths.get(i)); } View view = new View(this); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(toolbar.getContentInsetLeft(), LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(params1); buttons.addView(view); for (int i = 0; i < names.size(); i++) { final int k = i; ImageView v = new ImageView(this); v.setImageDrawable(arrow); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; v.setLayoutParams(params); final int index = i; if (rpaths.get(i).equals("/")) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getRootDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist(("/"), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else if (isStorage(rpaths.get(i))) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getSdDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else { Button button = new Button(this); button.setText(rnames.get(index)); button.setTextColor(ContextCompat.getColor(con, android.R.color.white)); button.setTextSize(13); button.setLayoutParams(params); button.setBackgroundResource(0); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); button.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { File file1 = new File(rpaths.get(index)); copyToClipboard(MainActivity.this, file1.getPath()); Toast.makeText(MainActivity.this, getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT).show(); return false; } }); buttons.addView(button); if (names.size() - i != 1) buttons.addView(v); } } scroll.post(new Runnable() { @Override public void run() { sendScroll(scroll); sendScroll(scroll1); } }); if (buttons.getVisibility() == View.VISIBLE) { timer.cancel(); timer.start(); } } catch (Exception e) { e.printStackTrace(); System.out.println("button view not available"); } }
From source file:com.ruesga.rview.fragments.EditorFragment.java
private void startLoadersWithValidContext(@Nullable Bundle savedInstanceState) { // Configure the diff_options menu BaseActivity activity = ((BaseActivity) getActivity()); activity.configureOptionsTitle(/*from www .j a v a 2s . c om*/ getString(!mReadOnly ? R.string.menu_edit_options : R.string.menu_view_options)); activity.configureOptionsMenu(R.menu.edit_options_menu, mOptionsItemListener); mAccount = Preferences.getAccount(getContext()); mWrap = Preferences.getAccountWrapMode(getContext(), mAccount); mTextSizeFactor = Preferences.getAccountTextSizeFactor(getContext(), mAccount); if (!mReadOnly) { // Edit mode mFileChooserBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.edit_file_chooser_header, activity.getOptionsMenu(), false); mFileChooserBinding.setHandlers(mEventHandlers); activity.getOptionsMenu().addHeaderView(mFileChooserBinding.getRoot()); mEditActionsBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.edit_actions_header, activity.getOptionsMenu(), false); mEditActionsBinding.setHandlers(mEventHandlers); activity.getOptionsMenu().addHeaderView(mEditActionsBinding.getRoot()); // Load the files RxLoaderManager loaderManager = RxLoaderManagerCompat.get(this); mContentLoader = loaderManager.create("content", fetchContent(), mContentObserver); mPublishLoader = loaderManager.create("publish", publishEdit(), mPublishObserver); if (!mReadOnly) { // Load current edit operations readFileOps(); } if (savedInstanceState != null) { mFile = savedInstanceState.getString(Constants.EXTRA_FILE); mFiles = savedInstanceState.getStringArrayList("files"); final String json = savedInstanceState.getString("file_infos"); if (TextUtils.isEmpty(json)) { Type type = new TypeToken<Map<String, FileInfo>>() { }.getType(); mFileInfo = SerializationManager.getInstance().fromJson(json, type); } mCurrentFile = savedInstanceState.getInt("current_file"); mIsDirty = savedInstanceState.getBoolean("is_dirty"); createFileHashes(); updateModel(); requestFileContent(); } else { // Cancel any previous edit and request files mCancelLoader = loaderManager.create("cancel", cancelEdit(), mCancelObserver).start(); loaderManager.create("files", fetchFiles(), mFilesObserver).start(); } } else { // Viewer mode RxLoaderManager loaderManager = RxLoaderManagerCompat.get(this); mContentLoader = loaderManager.create("local_content", fetchLocalContent(), mLocalContentObserver); updateModel(); requestFileContent(); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
public void bbar(final Main main) { final String text = main.CURRENT_PATH; try {/*from w w w . j a v a2 s .com*/ buttons.removeAllViews(); buttons.setMinimumHeight(pathbar.getHeight()); Drawable arrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_holo_dark); Bundle b = utils.getPaths(text, this); ArrayList<String> names = b.getStringArrayList("names"); ArrayList<String> rnames = new ArrayList<String>(); for (int i = names.size() - 1; i >= 0; i--) { rnames.add(names.get(i)); } ArrayList<String> paths = b.getStringArrayList("paths"); final ArrayList<String> rpaths = new ArrayList<String>(); for (int i = paths.size() - 1; i >= 0; i--) { rpaths.add(paths.get(i)); } View view = new View(this); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(toolbar.getContentInsetLeft(), LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(params1); buttons.addView(view); for (int i = 0; i < names.size(); i++) { final int k = i; ImageView v = new ImageView(this); v.setImageDrawable(arrow); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; v.setLayoutParams(params); final int index = i; if (rpaths.get(i).equals("/")) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getRootDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist(("/"), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else if (isStorage(rpaths.get(i))) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getSdDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else { Button button = new Button(this); button.setText(rnames.get(index)); button.setTextColor(getResources().getColor(android.R.color.white)); button.setTextSize(13); button.setLayoutParams(params); button.setBackgroundResource(0); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); button.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { File file1 = new File(rpaths.get(index)); copyToClipboard(MainActivity.this, file1.getPath()); Toast.makeText(MainActivity.this, getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT).show(); return false; } }); buttons.addView(button); if (names.size() - i != 1) buttons.addView(v); } } scroll.post(new Runnable() { @Override public void run() { sendScroll(scroll); sendScroll(scroll1); } }); if (buttons.getVisibility() == View.VISIBLE) { timer.cancel(); timer.start(); } } catch (Exception e) { e.printStackTrace(); System.out.println("button view not available"); } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void bbar(final MainFragment mainFrag) { final String path = mainFrag.CURRENT_PATH; try {//w ww .j a va2 s . c o m buttons.removeAllViews(); buttons.setMinimumHeight(pathbar.getHeight()); Drawable arrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_holo_dark); Bundle bundle = utils.getPaths(path, this); ArrayList<String> names = bundle.getStringArrayList("names"); ArrayList<String> rnames = bundle.getStringArrayList("names"); Collections.reverse(rnames); ArrayList<String> paths = bundle.getStringArrayList("paths"); final ArrayList<String> rpaths = bundle.getStringArrayList("paths"); Collections.reverse(rpaths); View view = new View(this); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(toolbar.getContentInsetLeft(), LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(params1); buttons.addView(view); for (int i = 0; i < names.size(); i++) { final int k = i; ImageView v = new ImageView(this); v.setImageDrawable(arrow); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; v.setLayoutParams(params); final int index = i; if (rpaths.get(i).equals("/")) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getRootDrawable()); ib.setBackgroundColor(Color.TRANSPARENT); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { mainFrag.loadlist(("/"), false, mainFrag.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else if (isStorage(rpaths.get(i))) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getSdDrawable()); ib.setBackgroundColor(Color.TRANSPARENT); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { mainFrag.loadlist((rpaths.get(k)), false, mainFrag.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else { Button b = new Button(this); b.setText(rnames.get(index)); b.setTextColor(Utils.getColor(this, android.R.color.white)); b.setTextSize(13); b.setLayoutParams(params); b.setBackgroundResource(0); b.setOnClickListener(new Button.OnClickListener() { public void onClick(View p1) { mainFrag.loadlist((rpaths.get(k)), false, mainFrag.openMode); mainFrag.loadlist((rpaths.get(k)), false, mainFrag.openMode); timer.cancel(); timer.start(); } }); b.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { File file1 = new File(rpaths.get(index)); copyToClipboard(MainActivity.this, file1.getPath()); Toast.makeText(MainActivity.this, getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT).show(); return false; } }); buttons.addView(b); if (names.size() - i != 1) buttons.addView(v); } } scroll.post(new Runnable() { @Override public void run() { sendScroll(scroll); sendScroll(scroll1); } }); if (buttons.getVisibility() == View.VISIBLE) { timer.cancel(); timer.start(); } } catch (Exception e) { e.printStackTrace(); Log.d("BBar", "button view not available"); } }
From source file:com.facebook.LegacyTokenCacheTest.java
@Test public void testAllTypes() { Bundle originalBundle = new Bundle(); putBoolean(BOOLEAN_KEY, originalBundle); putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle); putByte(BYTE_KEY, originalBundle);/*from w w w. ja va 2 s . com*/ 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(); LegacyTokenHelper cache = new LegacyTokenHelper(RuntimeEnvironment.application); cache.save(originalBundle); LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application); Bundle cachedBundle = cache2.load(); assertEquals(originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY)); assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY), cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY)); assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY)); assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY)); assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY)); assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY)); assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY)); assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY)); assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY)); assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY)); assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY)); assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY), cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY)); assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY)); assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY)); assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY)); assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(STRING_LIST_KEY)); assertEquals(originalBundle.getSerializable(SERIALIZABLE_KEY), cachedBundle.getSerializable(SERIALIZABLE_KEY)); }
From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFilesFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (activity == null) { activity = (AppCompatActivity) getActivity(); }/*from www. j av a 2s.co m*/ if (savedInstanceState != null) { fileTree = (TorrentContentFileTree) savedInstanceState.getSerializable(TAG_FILE_TREE); curDir = (TorrentContentFileTree) savedInstanceState.getSerializable(TAG_CUR_DIR); } else { ArrayList<BencodeFileItem> files = getArguments().getParcelableArrayList(TAG_FILES); ArrayList<Priority> priorities = (ArrayList<Priority>) getArguments().getSerializable(TAG_PRIORITIES); if ((files == null || priorities == null) || files.size() != priorities.size()) { return; } fileTree = TorrentContentFileTreeUtils.buildFileTree(files); FileTreeDepthFirstSearch<TorrentContentFileTree> search = new FileTreeDepthFirstSearch<TorrentContentFileTree>(); /* Set priority for selected files */ for (int i = 0; i < files.size(); i++) { if (priorities.get(i) != Priority.IGNORE) { BencodeFileItem f = files.get(i); TorrentContentFileTree file = search.find(fileTree, f.getIndex()); if (file != null) { file.setPriority(priorities.get(i)); /* * Disable the ability to select the file * because it's being downloaded/download */ file.select(TorrentContentFileTree.SelectState.DISABLED); } } } /* Is assigned the root dir of the file tree */ curDir = fileTree; } filesSize = (TextView) activity.findViewById(R.id.files_size); if (filesSize != null) { filesSize.setText(String.format(getString(R.string.files_size), Formatter.formatFileSize(activity.getApplicationContext(), fileTree.selectedFileSize()), Formatter.formatFileSize(activity.getApplicationContext(), fileTree.size()))); } fileList = (RecyclerView) activity.findViewById(R.id.file_list); if (fileList != null) { layoutManager = new LinearLayoutManager(activity); fileList.setLayoutManager(layoutManager); /* * A RecyclerView by default creates another copy of the ViewHolder in order to * fade the views into each other. This causes the problem because the old ViewHolder gets * the payload but then the new one doesn't. So needs to explicitly tell it to reuse the old one. */ DefaultItemAnimator animator = new DefaultItemAnimator() { @Override public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) { return true; } }; fileList.setItemAnimator(animator); adapter = new TorrentContentFilesAdapter(getChildren(curDir), activity, R.layout.item_torrent_content_file, this); fileList.setAdapter(adapter); } if (savedInstanceState != null) { selectedFiles = savedInstanceState.getStringArrayList(TAG_SELECTED_FILES); if (savedInstanceState.getBoolean(TAG_IN_ACTION_MODE, false)) { actionMode = activity.startActionMode(actionModeCallback); adapter.setSelectedItems(savedInstanceState.getIntegerArrayList(TAG_SELECTABLE_ADAPTER)); actionMode.setTitle(String.valueOf(adapter.getSelectedItemCount())); } } }
From source file:com.google.samples.drive.trash.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mFileFolderListView = (ListView) findViewById(R.id.fileListView); mFileFolderAdapter = new FileFolderAdapter(this, R.layout.resource_item, new ArrayList<Metadata>()); mFileFolderListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override//w ww. j a v a 2 s .co m public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // Metadata provides access to a DriveFile or DriveFolder's trash state. Metadata metadata = mFileFolderAdapter.getItem(position); DriveResource driveResource = metadata.getDriveId().asDriveResource(); // If a DriveResource is a folder it will only be trashed if all of its children // are also accessible to this app. if (metadata.isTrashable()) { if (metadata.isTrashed()) { driveResource.untrash(mGoogleApiClient).setResultCallback(trashStatusCallback); } else { driveResource.trash(mGoogleApiClient).setResultCallback(trashStatusCallback); } } else { Log.d(TAG, getResources().getString(R.string.trashable_error)); Toast.makeText(view.getContext(), getResources().getString(R.string.trashable_error), Toast.LENGTH_LONG).show(); } return true; } }); mFileFolderListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Metadata metadata = mFileFolderAdapter.getItem(position); if (metadata.isFolder()) { // Push current folder onto stack so the user can return to it later. mPreviousFolders.push(mCurrentFolder); mPreviousFolderButton.setEnabled(true); mCurrentFolder = metadata.getDriveId(); mFileFolderAdapter.setEnabled(false); queryFolders(); } } }); mFileFolderListView.setAdapter(mFileFolderAdapter); mFileFolderListView.setEmptyView(findViewById(R.id.emptyMessageView)); mAddFileButton = (Button) findViewById(R.id.addFileButton); mAddFileButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { addFile(); } }); mAddFolderButton = (Button) findViewById(R.id.addFolderButton); mAddFolderButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { addFolder(); } }); mPreviousFolderButton = (Button) findViewById(R.id.previousButton); mPreviousFolderButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!mPreviousFolders.isEmpty()) { // Pop folder stack to query children of previous folder. mCurrentFolder = mPreviousFolders.pop(); if (mPreviousFolders.isEmpty()) { mPreviousFolderButton.setEnabled(false); } queryFolders(); } } }); mPreviousFolders = new Stack<>(); if (savedInstanceState != null) { ArrayList<String> driveIds = savedInstanceState.getStringArrayList("previousFolders"); if (driveIds.size() > 0) { mPreviousFolderButton.setEnabled(true); } while (driveIds != null && driveIds.size() > 0) { mPreviousFolders.push(DriveId.decodeFromString(driveIds.remove(driveIds.size() - 1))); } String currentFolder = savedInstanceState.getString("currentFolder"); if (currentFolder != null) { mCurrentFolder = DriveId.decodeFromString(currentFolder); } } mChildren = new ArrayList<>(); mCurrentFolderNameTextView = (TextView) findViewById(R.id.folderNameTextView); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Drive.API).addScope(Drive.SCOPE_FILE) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); }
From source file:com.amaze.filemanager.fragments.BookmarksManager.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(false);//from w w w .j a va 2s. c o m setRetainInstance(false); s = new Shortcuts(getActivity()); Calendar calendar = Calendar.getInstance(); Sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); int hour = calendar.get(Calendar.HOUR_OF_DAY); theme = Integer.parseInt(Sp.getString("theme", "0")); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.activity_main_swipe_refresh_layout); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refresh(); } }); theme1 = theme; if (theme == 2) { if (hour <= 6 || hour >= 18) { theme1 = 1; } else theme1 = 0; } if (theme1 == 1) { getActivity().getWindow().getDecorView().setBackgroundColor(Color.BLACK); listview.setBackgroundColor(Color.BLACK); } m = (MainActivity) getActivity(); m.supportInvalidateOptionsMenu(); Animation animation1 = AnimationUtils.loadAnimation(getActivity(), R.anim.fab_newtab); FloatingActionButton floatingActionButton = (FloatingActionButton) rootView.findViewById(R.id.fab); floatingActionButton.show(true); floatingActionButton.setColorNormal(Color.parseColor(((MainActivity) getActivity()).skin)); floatingActionButton.setColorPressed(Color.parseColor(((MainActivity) getActivity()).skin)); floatingActionButton.setAnimation(animation1); //getActivity().findViewById(R.id.fab).setVisibility(View.VISIBLE); listview.setHasFixedSize(true); getActivity().findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final MaterialDialog.Builder ba1 = new MaterialDialog.Builder(getActivity()); ba1.title(utils.getString(getActivity(), R.string.addbook)); View v = getActivity().getLayoutInflater().inflate(R.layout.dialog, null); final EditText edir = (EditText) v.findViewById(R.id.newname); edir.setHint(utils.getString(getActivity(), R.string.enterpath)); ba1.customView(v, true); if (theme1 == 1) ba1.theme(Theme.DARK); ba1.negativeText(R.string.cancel); ba1.positiveText(R.string.create); String skin = Sp.getString("skin_color", "#03A9F4"); ba1.positiveColor(Color.parseColor(skin)); ba1.negativeColor(Color.parseColor(skin)); ba1.callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog materialDialog) { try { File a = new File(edir.getText().toString()); if (a.isDirectory()) { s.addS(a); b.items.add(a); b.notifyDataSetChanged(); Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.success), Toast.LENGTH_LONG).show(); } else { Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.invalid_dir), Toast.LENGTH_LONG).show(); } } catch (Exception e) { // TODO Auto-generated catch block Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.error), Toast.LENGTH_LONG).show(); } m.updateDrawer(); } @Override public void onNegative(MaterialDialog materialDialog) { } }); ba1.build().show(); } }); icons = new IconUtils(Sp, getActivity()); if (savedInstanceState == null) refresh(); else { bx = utils.toFileArray(savedInstanceState.getStringArrayList("bx")); refresh(bx); linearLayoutManager.scrollToPositionWithOffset(savedInstanceState.getInt("index"), savedInstanceState.getInt("top")); } }
From source file:org.strongswan.android.ui.VpnProfileDetailActivity.java
/** * Load an existing profile if we got an ID * * @param savedInstanceState previously saved state *///from ww w. ja v a 2 s.c o m private void loadProfileData(Bundle savedInstanceState) { String useralias = null, local_id = null, alias = null; Integer flags = null; getSupportActionBar().setTitle(R.string.add_profile); if (mId != null && mId != 0) { mProfile = mDataSource.getVpnProfile(mId); if (mProfile != null) { mName.setText(mProfile.getName()); mGateway.setText(mProfile.getGateway()); mVpnType = mProfile.getVpnType(); mUsername.setText(mProfile.getUsername()); mPassword.setText(mProfile.getPassword()); mRemoteId.setText(mProfile.getRemoteId()); mMTU.setText(mProfile.getMTU() != null ? mProfile.getMTU().toString() : null); mPort.setText(mProfile.getPort() != null ? mProfile.getPort().toString() : null); mNATKeepalive .setText(mProfile.getNATKeepAlive() != null ? mProfile.getNATKeepAlive().toString() : null); mIncludedSubnets.setText(mProfile.getIncludedSubnets()); mExcludedSubnets.setText(mProfile.getExcludedSubnets()); mBlockIPv4.setChecked(mProfile.getSplitTunneling() != null && (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4) != 0); mBlockIPv6.setChecked(mProfile.getSplitTunneling() != null && (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6) != 0); mSelectedAppsHandling = mProfile.getSelectedAppsHandling(); mSelectedApps = mProfile.getSelectedAppsSet(); mIkeProposal.setText(mProfile.getIkeProposal()); mEspProposal.setText(mProfile.getEspProposal()); flags = mProfile.getFlags(); useralias = mProfile.getUserCertificateAlias(); local_id = mProfile.getLocalId(); alias = mProfile.getCertificateAlias(); getSupportActionBar().setTitle(mProfile.getName()); } else { Log.e(VpnProfileDetailActivity.class.getSimpleName(), "VPN profile with id " + mId + " not found"); finish(); } } mSelectVpnType.setSelection(mVpnType.ordinal()); mCertReq.setChecked(flags == null || (flags & VpnProfile.FLAGS_SUPPRESS_CERT_REQS) == 0); /* check if the user selected a user certificate previously */ useralias = savedInstanceState == null ? useralias : savedInstanceState.getString(VpnProfileDataSource.KEY_USER_CERTIFICATE); local_id = savedInstanceState == null ? local_id : savedInstanceState.getString(VpnProfileDataSource.KEY_LOCAL_ID); if (useralias != null) { UserCertificateLoader loader = new UserCertificateLoader(this, useralias); mUserCertLoading = useralias; mSelectedUserId = local_id; loader.execute(); } /* check if the user selected a CA certificate previously */ alias = savedInstanceState == null ? alias : savedInstanceState.getString(VpnProfileDataSource.KEY_CERTIFICATE); mCheckAuto.setChecked(alias == null); if (alias != null) { X509Certificate certificate = TrustedCertificateManager.getInstance().getCACertificateFromAlias(alias); if (certificate != null) { mCertEntry = new TrustedCertificateEntry(alias, certificate); } else { /* previously selected certificate is not here anymore */ showCertificateAlert(); mCertEntry = null; } } mSelectSelectedAppsHandling.setSelection(mSelectedAppsHandling.ordinal()); if (savedInstanceState != null) { ArrayList<String> selectedApps = savedInstanceState .getStringArrayList(VpnProfileDataSource.KEY_SELECTED_APPS_LIST); mSelectedApps = new TreeSet<>(selectedApps); } }