List of usage examples for android.support.v4.app FragmentTransaction replace
public abstract FragmentTransaction replace(int containerViewId, Fragment fragment);
From source file:android.support.v17.leanback.app.BrowseSupportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getChildFragmentManager().findFragmentById(R.id.scale_frame) == null) { mHeadersSupportFragment = new HeadersSupportFragment(); createMainFragment(mAdapter, mSelectedPosition); FragmentTransaction ft = getChildFragmentManager().beginTransaction().replace(R.id.browse_headers_dock, mHeadersSupportFragment); if (mMainFragment != null) { ft.replace(R.id.scale_frame, mMainFragment); } else {/*from ww w .java 2 s. com*/ // Empty adapter used to guard against lazy adapter loading. When this // fragment is instantiated, mAdapter might not have the data or might not // have been set. In either of those cases mFragmentAdapter will be null. // This way we can maintain the invariant that mMainFragmentAdapter is never // null and it avoids doing null checks all over the code. mMainFragmentAdapter = new MainFragmentAdapter(null); mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl()); } ft.commit(); } else { mHeadersSupportFragment = (HeadersSupportFragment) getChildFragmentManager() .findFragmentById(R.id.browse_headers_dock); mMainFragment = getChildFragmentManager().findFragmentById(R.id.scale_frame); mMainFragmentAdapter = ((MainFragmentAdapterProvider) mMainFragment).getMainFragmentAdapter(); mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl()); mIsPageRow = savedInstanceState != null ? savedInstanceState.getBoolean(IS_PAGE_ROW, false) : false; mSelectedPosition = savedInstanceState != null ? savedInstanceState.getInt(CURRENT_SELECTED_POSITION, 0) : 0; if (!mIsPageRow) { if (mMainFragment instanceof MainFragmentRowsAdapterProvider) { mMainFragmentRowsAdapter = ((MainFragmentRowsAdapterProvider) mMainFragment) .getMainFragmentRowsAdapter(); } else { mMainFragmentRowsAdapter = null; } } else { mMainFragmentRowsAdapter = null; } } mHeadersSupportFragment.setHeadersGone(!mCanShowHeaders); if (mHeaderPresenterSelector != null) { mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector); } mHeadersSupportFragment.setAdapter(mAdapter); mHeadersSupportFragment.setOnHeaderViewSelectedListener(mHeaderViewSelectedListener); mHeadersSupportFragment.setOnHeaderClickedListener(mHeaderClickedListener); View root = inflater.inflate(R.layout.lb_browse_fragment, container, false); getProgressBarManager().setRootView((ViewGroup) root); mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame); mBrowseFrame.setOnChildFocusListener(mOnChildFocusListener); mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener); installTitleView(inflater, mBrowseFrame, savedInstanceState); mScaleFrameLayout = (ScaleFrameLayout) root.findViewById(R.id.scale_frame); mScaleFrameLayout.setPivotX(0); mScaleFrameLayout.setPivotY(mContainerListAlignTop); setupMainFragment(); if (mBrandColorSet) { mHeadersSupportFragment.setBackgroundColor(mBrandColor); } mSceneWithHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { showHeaders(true); } }); mSceneWithoutHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { showHeaders(false); } }); mSceneAfterEntranceTransition = TransitionHelper.createScene(mBrowseFrame, new Runnable() { @Override public void run() { setEntranceTransitionEndState(); } }); return root; }
From source file:cl.ipp.katbag.fragment.Develop.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();//w w w . j a v a2 s .co m inflater.inflate(R.menu.develop, menu); menuItemEdit = menu.findItem(R.id.develop_dropdown_menu_edit); menuItemAddWorld = menu.findItem(R.id.develop_dropdown_menu_add_world); menuItemAddDrawing = menu.findItem(R.id.develop_dropdown_menu_add_drawing); menuItemAddMotion = menu.findItem(R.id.develop_dropdown_menu_add_motion); menuItemAddLook = menu.findItem(R.id.develop_dropdown_menu_add_look); menuItemAddSound = menu.findItem(R.id.develop_dropdown_menu_add_sound); menuItemAddControl = menu.findItem(R.id.develop_dropdown_menu_add_control); menuItemAddSensing = menu.findItem(R.id.develop_dropdown_menu_add_sensing); menuItemPlayer = menu.findItem(R.id.develop_dropdown_menu_player); menuItemEdit.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (editMode) { editMode = false; menuItemEdit.setIcon(R.drawable.ic_action_edit); } else { editMode = true; menuItemEdit.setIcon(R.drawable.ic_action_accept); } loadListView(); return true; } }); menuItemAddWorld.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_WORLD, -1); return true; } }); menuItemAddDrawing.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_DRAWING, -1); return true; } }); menuItemAddMotion.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_MOTION, -1); return true; } }); menuItemAddLook.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_LOOK, -1); return true; } }); menuItemAddSound.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_SOUND, -1); return true; } }); menuItemAddControl.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_CONTROL, -1); return true; } }); menuItemAddSensing.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_SENSING, -1); return true; } }); menuItemPlayer.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mFragment = new Player(); Bundle bundle = new Bundle(); bundle.putLong("id_app", id_app); bundle.putBoolean("editMode", true); bundle.putString("name_app", Add.name_app_text); mFragment.setArguments(bundle); FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.addToBackStack(mFragment.getClass().getSimpleName()); t.commit(); return true; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.amaze.filemanager.activities.MainActivity.java
@Override public void onNewIntent(Intent i) { intent = i;/*from ww w . j a va 2 s . com*/ path = i.getStringExtra("path"); if (path != null) { if (new File(path).isDirectory()) { Fragment f = getDFragment(); if ((f.getClass().getName().contains("TabFragment"))) { Main m = ((Main) getFragment().getTab()); m.loadlist(path, false, 0); } else goToMain(path); } else utils.openFile(new File(path), mainActivity); } else if (i.getStringArrayListExtra("failedOps") != null) { ArrayList<BaseFile> failedOps = i.getParcelableArrayListExtra("failedOps"); if (failedOps != null) { mainActivityHelper.showFailedOperationDialog(failedOps, i.getBooleanExtra("move", false), this); } } else if ((openprocesses = i.getBooleanExtra("openprocesses", false))) { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame, new ProcessViewer()); // transaction.addToBackStack(null); select = 102; openprocesses = false; //title.setText(utils.getString(con, R.string.process_viewer)); //Commit the transaction transaction.commitAllowingStateLoss(); supportInvalidateOptionsMenu(); } else if (intent.getAction() != null) if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) { // file picker intent mReturnIntent = true; Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show(); } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) { // ringtone picker intent mReturnIntent = true; mRingtonePickerIntent = true; Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show(); } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { // zip viewer intent Uri uri = intent.getData(); zippath = uri.toString(); openZip(zippath); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
public void selectItem(final int i) { ArrayList<Item> list = DataUtils.getList(); if (!list.get(i).isSection()) if ((select == null || select >= list.size())) { TabFragment tabFragment = new TabFragment(); Bundle a = new Bundle(); a.putString("path", ((EntryItem) list.get(i)).getPath()); tabFragment.setArguments(a); android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction(); transaction.replace(R.id.content_frame, tabFragment); transaction.addToBackStack("tabt1" + 1); pending_fragmentTransaction = transaction; select = i;/*from www . j a v a 2 s . com*/ adapter.toggleChecked(select); if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); floatingActionButton.setVisibility(View.VISIBLE); floatingActionButton.showMenuButton(true); } else { pending_path = ((EntryItem) list.get(i)).getPath(); if (pending_path.equals("drive")) { pending_path = ((EntryItem) list.get(i)).getTitle(); } select = i; adapter.toggleChecked(select); if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from ww w.jav a 2 s . c o m displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); if (theme1 == 1) v.setBackgroundColor(Color.parseColor("#a6ffffff")); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
/** * Called when the activity is first created. *//*from w ww . j ava2 s. co m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Sp = PreferenceManager.getDefaultSharedPreferences(this); initialisePreferences(); setTheme(); setContentView(R.layout.main_toolbar); initialiseViews(); DataUtils.clear(); DataUtils.registerOnDataChangedListener(this); tabHandler = new TabHandler(this, null, null, 1); utils = new Futils(); //requesting storage permissions if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) if (!checkStoragePermission()) requestStoragePermission(); mainActivityHelper = new MainActivityHelper(this); initialiseFab(); if (mAsyncHelperFragment != null) { FragmentManager fm = getSupportFragmentManager(); mAsyncHelperFragment = (AsyncHelper) fm.findFragmentByTag(TAG_ASYNC_HELPER); } history = new HistoryManager(this, "Table2"); history.initializeTable(DataUtils.HISTORY, 0); history.initializeTable(DataUtils.HIDDEN, 0); grid = new HistoryManager(this, "listgridmodes"); grid.initializeTable(DataUtils.LIST, 0); grid.initializeTable(DataUtils.GRID, 0); grid.initializeTable(DataUtils.BOOKS, 1); grid.initializeTable(DataUtils.DRIVE, 1); grid.initializeTable(DataUtils.SMB, 1); if (!Sp.getBoolean("booksadded", false)) { grid.make(DataUtils.BOOKS); Sp.edit().putBoolean("booksadded", true).commit(); } DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN)); DataUtils.setGridfiles(grid.readTable(DataUtils.GRID)); DataUtils.setListfiles(grid.readTable(DataUtils.LIST)); // initialize g+ api client as per preferences if (Sp.getBoolean("plus_pic", false)) { mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN).build(); } util = new IconUtils(Sp, this); icons = new IconUtils(Sp, this); timer = new CountDownTimer(5000, 1000) { @Override public void onTick(long l) { } @Override public void onFinish() { crossfadeInverse(); } }; path = getIntent().getStringExtra("path"); openprocesses = getIntent().getBooleanExtra("openprocesses", false); try { intent = getIntent(); if (intent.getStringArrayListExtra("failedOps") != null) { ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps"); if (failedOps != null) { mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false), this); } } if (intent.getAction() != null) if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) { // file picker intent mReturnIntent = true; Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show(); } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) { // ringtone picker intent mReturnIntent = true; mRingtonePickerIntent = true; Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show(); } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { // zip viewer intent Uri uri = intent.getData(); openzip = true; zippath = uri.toString(); } } catch (Exception e) { } updateDrawer(); if (savedInstanceState == null) { if (openprocesses) { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction(); transaction.replace(R.id.content_frame, new ProcessViewer()); // transaction.addToBackStack(null); select = 102; openprocesses = false; //title.setText(utils.getString(con, R.string.process_viewer)); //Commit the transaction transaction.commit(); supportInvalidateOptionsMenu(); } else { if (path != null && path.length() > 0) { HFile file = new HFile(HFile.UNKNOWN, path); file.generateMode(this); if (file.isDirectory()) goToMain(path); else { goToMain(""); utils.openFile(new File(path), this); } } else { goToMain(""); } } } else { COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH"); MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH"); oppathe = savedInstanceState.getString("oppathe"); oppathe1 = savedInstanceState.getString("oppathe1"); oparrayList = savedInstanceState.getParcelableArrayList("oparrayList"); operation = savedInstanceState.getInt("operation"); select = savedInstanceState.getInt("selectitem", 0); adapter.toggleChecked(select); //mainFragment = (Main) savedInstanceState.getParcelable("main_fragment"); } if (theme1 == 1) { mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background)); } mDrawerList.setDivider(null); if (!isDrawerLocked) { mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer_l, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { mainActivity.onDrawerClosed(); } public void onDrawerOpened(View drawerView) { //title.setText("Amaze File Manager"); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerToggle.syncState(); } /*((ImageButton) findViewById(R.id.drawer_buttton)).setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View view) { if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) { mDrawerLayout.closeDrawer(mDrawerLinear); } else mDrawerLayout.openDrawer(mDrawerLinear); } });*/ if (mDrawerToggle != null) { mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l); } //recents header color implementation if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin)); ((Activity) this).setTaskDescription(taskDescription); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
public void goToMain(String path) { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); //title.setText(R.string.app_name); TabFragment tabFragment = new TabFragment(); if (path != null && path.length() > 0) { Bundle b = new Bundle(); b.putString("path", path); tabFragment.setArguments(b);//from w ww. j av a 2s. c om } transaction.replace(R.id.content_frame, tabFragment); // Commit the transaction select = 0; transaction.addToBackStack("tabt" + 1); transaction.commitAllowingStateLoss(); setActionBarTitle(null); floatingActionButton.setVisibility(View.VISIBLE); floatingActionButton.showMenuButton(true); if (openzip && zippath != null) { if (zippath.endsWith(".zip") || zippath.endsWith(".apk")) openZip(zippath); else { openRar(zippath); } zippath = null; } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void selectItem(final int i) { ArrayList<Item> directoryItems = dataUtils.getList(); if (!directoryItems.get(i).isSection()) { if ((selectedStorage == NO_VALUE || selectedStorage >= directoryItems.size())) { TabFragment tabFragment = new TabFragment(); Bundle a = new Bundle(); a.putString("path", ((EntryItem) directoryItems.get(i)).getPath()); tabFragment.setArguments(a); android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager() .beginTransaction(); transaction.replace(R.id.content_frame, tabFragment); transaction.addToBackStack("tabt1" + 1); pending_fragmentTransaction = transaction; selectedStorage = i;/*from ww w .j a va2 s. c o m*/ adapter.toggleChecked(selectedStorage); if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); floatingActionButton.setVisibility(View.VISIBLE); floatingActionButton.showMenuButton(true); } else { pendingPath = ((EntryItem) directoryItems.get(i)).getPath(); selectedStorage = i; adapter.toggleChecked(selectedStorage); if (((EntryItem) directoryItems.get(i)).getPath().contains(OTGUtil.PREFIX_OTG) && sharedPref.getString(KEY_PREF_OTG, null).equals(VALUE_PREF_OTG_NULL)) { // we've not gotten otg path yet // start system request for storage access framework Toast.makeText(getApplicationContext(), getString(R.string.otg_access), Toast.LENGTH_LONG) .show(); Intent safIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(safIntent, REQUEST_CODE_SAF); } else { if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); } } } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override//from ww w.j av a2 s . c om public boolean onLongClick(View v) { Intent intent; if (SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (getAppTheme().equals(AppTheme.DARK)) mDrawerLinear.setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background)); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); fabBgView = findViewById(R.id.fab_bg); if (getAppTheme().equals(AppTheme.DARK)) { fabBgView.setBackgroundResource(R.drawable.fab_shadow_dark); } fabBgView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (getAppTheme().equals(AppTheme.LIGHT)) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsButton = findViewById(R.id.settingsbutton); if (getAppTheme().equals(AppTheme.DARK)) { settingsButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsButton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsButton.findViewById(R.id.settingtext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, PreferencesActivity.class); startActivity(in); finish(); } }); View appButton = findViewById(R.id.appbutton); if (getAppTheme().equals(AppTheme.DARK)) { appButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appButton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appButton.findViewById(R.id.apptext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } appButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); selectedStorage = SELECT_MINUS_2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (getAppTheme().equals(AppTheme.DARK)) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); selectedStorage = SELECT_MINUS_2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 if (SDK_INT == 20 || SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(Utils.getColor(this, android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void goToMain(String path) { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); //title.setText(R.string.app_name); TabFragment tabFragment = new TabFragment(); if (path != null && path.length() > 0) { Bundle b = new Bundle(); b.putString("path", path); tabFragment.setArguments(b);/* www . j a v a 2s. c om*/ } transaction.replace(R.id.content_frame, tabFragment); // Commit the transaction selectedStorage = SELECT_0; transaction.addToBackStack("tabt" + 1); transaction.commitAllowingStateLoss(); setActionBarTitle(null); floatingActionButton.setVisibility(View.VISIBLE); floatingActionButton.showMenuButton(true); if (openzip && zippath != null) { if (zippath.endsWith(".zip") || zippath.endsWith(".apk")) openZip(zippath); else { openRar(zippath); } zippath = null; } }