Example usage for android.os Bundle getParcelableArrayList

List of usage examples for android.os Bundle getParcelableArrayList

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@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:com.facebook.samples.booleanog.LogicActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.main);//from   ww  w.  j av  a2 s .c  o  m

    // Views
    logicButton = (Button) findViewById(R.id.logic_button);
    friendsButton = (Button) findViewById(R.id.friends_button);
    settingsButton = (Button) findViewById(R.id.settings_button);
    contentButton = (Button) findViewById(R.id.content_button);

    logicGroup = (ViewGroup) findViewById(R.id.logic_group);
    leftSpinner = (Spinner) findViewById(R.id.left_spinner);
    rightSpinner = (Spinner) findViewById(R.id.right_spinner);
    andButton = (Button) findViewById(R.id.and_button);
    orButton = (Button) findViewById(R.id.or_button);
    resultText = (TextView) findViewById(R.id.result_text);
    postResultText = (TextView) findViewById(R.id.post_result_text);

    friendsGroup = (ViewGroup) findViewById(R.id.friends_group);
    ListView friendActivityList = (ListView) findViewById(R.id.friend_activity_list);
    String[] mapColumnNames = { "date", "action" };
    int[] mapViewIds = { R.id.friend_action_date, R.id.friend_action_data };
    friendActivityAdapter = new SimpleCursorAdapter(this, R.layout.friend_activity_row, createEmptyCursor(),
            mapColumnNames, mapViewIds);
    friendActivityList.setAdapter(friendActivityAdapter);
    friendActivityProgressBar = (ProgressBar) findViewById(R.id.friend_activity_progress_bar);

    settingsGroup = (ViewGroup) findViewById(R.id.settings_group);

    contentGroup = (ViewGroup) findViewById(R.id.content_group);
    contentImage = (ImageView) findViewById(R.id.content_image);
    contentSpinner = (Spinner) findViewById(R.id.content_spinner);

    // Fragments
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();

    friendPickerFragment = (FriendPickerFragment) fragmentManager.findFragmentById(R.id.friend_picker_fragment);
    if (friendPickerFragment == null) {
        Bundle args = new Bundle();
        args.putBoolean(FriendPickerFragment.SHOW_TITLE_BAR_BUNDLE_KEY, false);
        friendPickerFragment = new FriendPickerFragment(args);
        transaction.add(R.id.friend_picker_fragment, friendPickerFragment);
    }

    userSettingsFragment = (UserSettingsFragment) fragmentManager.findFragmentById(R.id.login_fragment);
    if (userSettingsFragment == null) {
        userSettingsFragment = new UserSettingsFragment();
        transaction.add(R.id.login_fragment, userSettingsFragment);
    }

    transaction.commit();

    // Spinners
    ArrayAdapter<CharSequence> truthAdapter = ArrayAdapter.createFromResource(this, R.array.truth_values,
            android.R.layout.simple_spinner_item);
    truthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    leftSpinner.setAdapter(truthAdapter);
    rightSpinner.setAdapter(truthAdapter);
    contentSpinner.setAdapter(truthAdapter);
    leftSpinner.setSelection(0);
    rightSpinner.setSelection(0);

    // Navigation
    for (Button button : Arrays.asList(logicButton, friendsButton, settingsButton, contentButton)) {
        initializeNavigationButton(button);
    }

    // Logic
    initializeCalculationButton(andButton);
    initializeCalculationButton(orButton);

    // Friends
    friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
        @Override
        public void onError(PickerFragment<?> fragment, FacebookException error) {
            LogicActivity.this.onError(error);
        }
    });
    friendPickerFragment.setUserId("me");
    friendPickerFragment.setMultiSelect(false);
    friendPickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() {
        @Override
        public void onSelectionChanged(PickerFragment<?> fragment) {
            LogicActivity.this.onFriendSelectionChanged();
        }
    });
    friendPickerFragment.setExtraFields(Arrays.asList(INSTALLED));
    friendPickerFragment.setFilter(new PickerFragment.GraphObjectFilter<GraphUser>() {
        @Override
        public boolean includeItem(GraphUser graphObject) {
            Boolean installed = graphObject.cast(GraphUserWithInstalled.class).getInstalled();
            return (installed != null) && installed.booleanValue();
        }
    });

    // Content
    contentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            LogicActivity.this.onContentSelectionChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            LogicActivity.this.onContentSelectionChanged();
        }
    });

    // Restore saved state
    Button startButton = logicButton;

    if (savedInstanceState != null) {
        leftSpinner.setSelection(savedInstanceState.getInt(SAVE_LEFT_OPERAND_SELECTION));
        rightSpinner.setSelection(savedInstanceState.getInt(SAVE_RIGHT_OPERAND_SELECTION));
        contentSpinner.setSelection(savedInstanceState.getInt(SAVE_CONTENT_SELECTION));
        resultText.setText(savedInstanceState.getString(SAVE_RESULT_TEXT));
        postResultText.setText(savedInstanceState.getString(SAVE_POST_RESULT_TEXT));
        activeTab = savedInstanceState.getString(SAVE_ACTIVE_TAB);
        pendingPost = savedInstanceState.getBundle(SAVE_PENDING);

        friendActionList = savedInstanceState.getParcelableArrayList(SAVE_FRIEND_ACTIONS);
        if ((friendActionList != null) && (friendActionList.size() > 0)) {
            updateCursor(friendActionList);
        }

        if (getString(R.string.navigate_friends).equals(activeTab)) {
            startButton = friendsButton;
        } else if (getString(R.string.navigate_content).equals(activeTab)) {
            startButton = contentButton;
        } else if (getString(R.string.navigate_settings).equals(activeTab)) {
            startButton = settingsButton;
        }
    }

    if (!handleNativeLink()) {
        onNavigateButtonClick(startButton);
    }
}

From source file:com.stockita.stockitapointofsales.activities.MainActivity.java

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

    // ButterKnife
    ButterKnife.bind(this);

    // Set the Toolbar
    setSupportActionBar(mCoordinator.getmToolbar());

    // Set the Navigation draw layout
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, mCoordinator.getmToolbar(),
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);/*from   w w w . jav a 2 s .c  o m*/
    toggle.syncState();

    // Navigation draw view
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    /**
     * The code below is about the nav_header
     */
    View headerLayout = navigationView.getHeaderView(0);
    final ImageView imageView = (ImageView) headerLayout.findViewById(R.id.imageView);
    TextView name = (TextView) headerLayout.findViewById(R.id.textView1);
    TextView email = (TextView) headerLayout.findViewById(R.id.textView2);

    // Display user image in circular frame, in the navigation header
    if (mPhotoUrl != null) {
        Glide.with(this).load("https://lh3.googleusercontent.com" + mPhotoUrl).asBitmap()
                .into(new BitmapImageViewTarget(imageView) {

                    @Override
                    protected void setResource(@NonNull Bitmap resource) {
                        super.setResource(resource);

                        RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory
                                .create(getResources(), resource);
                        circularBitmapDrawable.setCircular(true);
                        imageView.setImageDrawable(circularBitmapDrawable);

                    }
                });
    }

    // Display the user name and email on the nav_header
    name.setText(mUserName);
    email.setText(Utility.decodeEmail(mUserEncodedEmail));

    /**
     * Create the adapter that will return a fragment for each of the
     * primary sections of the activity.
     */
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    /* Set up the ViewPager with the sections adapter. */
    if (mCoordinator.getmViewPagerContainer() != null) {
        mCoordinator.getmViewPagerContainer().setAdapter(mSectionsPagerAdapter);
    }

    /* Tab layout */
    if (mCoordinator.getmTabs() != null) {
        mCoordinator.getmTabs().setupWithViewPager(mCoordinator.getmViewPagerContainer());
    }

    /**
     * This listener is to get the tab position, however it does an other think
     * but we are only interested for the current tab position
     */
    if (mCoordinator.getmTabs() != null) {
        mCoordinator.getmTabs().addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {

                /* First we invoke this method for mViewPager */
                mCoordinator.getmViewPagerContainer().setCurrentItem(tab.getPosition());

                /**
                 *  Then we can assign the value of the current position to
                 *  a static field, there are some other way to do this.
                 */
                sSelection = tab.getPosition();

                /**
                 * Make the FAB invisible in some selection
                 */
                if (tab.getPosition() == 2) {
                    mCoordinator.getmFab().setVisibility(View.INVISIBLE);
                } else {
                    mCoordinator.getmFab().setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

                // If sliding then finish the action mode
                if (mActionMode != null) {
                    mActionMode.finish();
                }
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    /**
     * Restore saved instance state on configuration changes
     */
    if (savedInstanceState != null) {

        // Restore the fragment instance state
        mItemMasterListFragmentUI = (ItemMasterListFragmentUI) getFragmentManager()
                .getFragment(savedInstanceState, KEY_ONE);
        mSalesListFragmentUI = (SalesPendingListFragmentUI) getFragmentManager().getFragment(savedInstanceState,
                KEY_TWO);
        mOpenSalesHeaderListFragmentUI = (OpenSalesHeaderListFragmentUI) getFragmentManager()
                .getFragment(savedInstanceState, KEY_THREE);

        aaItemMasterUserUid = savedInstanceState.getString(KEY_AA_ONE);
        aaItemMasterPushKey = savedInstanceState.getString(KEY_AA_TWO);
        qqUserUid = savedInstanceState.getString(KEY_MM_ONE);
        qqSalesHeaderModel = savedInstanceState.getParcelable(KEY_MM_TWO);
        qqSalesDetailModelList = savedInstanceState.getParcelableArrayList(KEY_MM_THREE);
        qqCashPaid = savedInstanceState.getString(KEY_MM_FOUR);
        qqChangeCash = savedInstanceState.getString(KEY_MM_FIVE);

    }

}

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

private void finishCreate() {
    final Bundle savedState = mInnerSavedState;
    findViews();/*w w  w  .j  av  a  2 s  .  c om*/
    // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_S
    updateFromRowByAccounts();
    // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_E
    final Intent intent = getIntent();
    final Message message;
    final ArrayList<AttachmentPreview> previews;
    mShowQuotedText = false;
    final CharSequence quotedText;
    int action;
    // Check for any of the possibly supplied accounts.;
    final Account account;
    if (hadSavedInstanceStateMessage(savedState)) {
        action = savedState.getInt(EXTRA_ACTION, COMPOSE);
        account = savedState.getParcelable(Utils.EXTRA_ACCOUNT);
        message = savedState.getParcelable(EXTRA_MESSAGE);

        previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS);
        mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE);
        quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT);

        mExtraValues = savedState.getParcelable(EXTRA_VALUES);
    } else {
        account = obtainAccount(intent);
        action = intent.getIntExtra(EXTRA_ACTION, COMPOSE);
        // Initialize the message from the message in the intent
        message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE);
        previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS);
        mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE);
        //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S
        if (mRefMessage != null && "".equals(mRefMessage.bodyHtml)) {
            String htmlbody = Body.restoreBodyHtmlWithMessageId(this, mRefMessage.getId());
            mRefMessage.bodyHtml = htmlbody;
            //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S
        } else if (message != null) {
            if ("".equals(message.bodyHtml)) {
                String htmlbody = Body.restoreBodyHtmlWithMessageId(this, message.getId());
                message.bodyHtml = htmlbody;
            }
            if ("".equals(message.bodyText)) {
                String body = Body.restoreBodyTextWithMessageId(this, message.getId());
                message.bodyText = body;
            }
            //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S
        }
        //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E
        mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI);
        quotedText = null;

        if (Analytics.isLoggable()) {
            if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) {
                Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0);
            }
        }
    }
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_S
    //        mAttachmentsView.setAttachmentPreviews(previews);
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_E
    // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_S
    if (action == EDIT_DRAFT) {
        //mIsClickIcon = true;//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535
        mEditDraft = true;
    }
    // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_E

    setAccount(account);
    if (mAccount == null) {
        return;
    }
    // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S
    //        initRecipients();
    // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S
    // Clear the notification and mark the conversation as seen, if necessary
    final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER);

    if (notificationFolder != null) {
        final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION);
        Intent actionIntent;
        if (conversationUri != null) {
            actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR);
            actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri);
        } else {
            actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS);
            actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri));
        }
        actionIntent.setPackage(getPackageName());
        actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account);
        actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder);

        startService(actionIntent);
    }

    if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) {
        mLaunchedFromEmail = true;
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        final Uri dataUri = intent.getData();
        if (dataUri != null) {
            final String dataScheme = intent.getData().getScheme();
            final String accountScheme = mAccount.composeIntentUri.getScheme();
            mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme);
        }
    }

    if (mRefMessageUri != null) {
        mShowQuotedText = true;
        mComposeMode = action;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
            String wearReply = null;
            if (remoteInput != null) {
                LogUtils.d(LOG_TAG, "Got remote input from new api");
                CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT);
                if (input != null) {
                    wearReply = input.toString();
                }
            } else {
                // TODO: remove after legacy code has been removed.
                LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode");
                ClipData clipData = intent.getClipData();
                if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) {
                    Bundle extras = clipData.getItemAt(0).getIntent().getExtras();
                    if (extras != null) {
                        wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT);
                    }
                }
            }

            if (!TextUtils.isEmpty(wearReply)) {
                createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode,
                        wearReply).execute();
                finish();
                return;
            } else {
                LogUtils.w(LOG_TAG, "remote input string is null");
            }
        }

        getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this);
        return;
    } else if (message != null && action != EDIT_DRAFT) {
        initFromDraftMessage(message);
        initQuotedTextFromRefMessage(mRefMessage, action);
        mShowQuotedText = message.appendRefMessageContent;
        // if we should be showing quoted text but mRefMessage is null
        // and we have some quotedText, display that
        if (mShowQuotedText && mRefMessage == null) {
            if (quotedText != null) {
                initQuotedText(quotedText, false /* shouldQuoteText */);
            } else if (mExtraValues != null) {
                initExtraValues(mExtraValues);
                return;
            }
        }
    } else if (action == EDIT_DRAFT) {
        if (message == null) {
            throw new IllegalStateException("Message must not be null to edit draft");
        }
        initFromDraftMessage(message);
        // Update the action to the draft type of the previous draft
        switch (message.draftType) {
        case UIProvider.DraftType.REPLY:
            action = REPLY;
            break;
        case UIProvider.DraftType.REPLY_ALL:
            action = REPLY_ALL;
            break;
        case UIProvider.DraftType.FORWARD:
            action = FORWARD;
            break;
        case UIProvider.DraftType.COMPOSE:
        default:
            action = COMPOSE;
            break;
        }
        LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action);

        mShowQuotedText = message.appendRefMessageContent;
        //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_S
        //Terrible original design,refMessageUri did not save to db,the value is always 0 here.
        //but the body's sourceKey is saved ,it points to the refMessage's id,so we can get
        //the refMessage from the body's sourceKey.
        long sourceKey = Body.restoreBodySourceKey(this, message.id);
        if (sourceKey != 0) {
            // If we're editing an existing draft that was in reference to an existing message,
            // still need to load that original message since we might need to refer to the
            // original sender and recipients if user switches "reply <-> reply-all".
            mRefMessageUri = Uri.parse("content://" + EmailContent.AUTHORITY + "/uimessage/" + sourceKey);
            //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_E
            mComposeMode = action;
            getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this);
            return;
        }
    } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) {
        if (mRefMessage != null) {
            initFromRefMessage(action);
            mShowQuotedText = true;
        }
    } else {
        if (initFromExtras(intent)) {
            return;
        }
    }

    mComposeMode = action;
    finishSetup(action, intent, savedState);
}

From source file:com.filemanager.free.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *//*  ww w.ja v a2  s  . c o m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    context = this;
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();

    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    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() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    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 ignored) {

    }
    updateDrawer();
    if (savedInstanceState == null) {

        if (openprocesses) {
            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);
    }
    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open,
                R.string.drawer_close) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.addDrawerListener(mDrawerToggle);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
        }
        mDrawerToggle.syncState();
    }

    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("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(con, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }

    //search
    searchView();
    //admob
    mInterstitialAd = new InterstitialAd(this);
    // set the ad unit ID
    mInterstitialAd.setAdUnitId("ca-app-pub-2257698129050878/4313141545");
    requestNewInterstitial();
}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

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

    // android.os.Debug.waitForDebugger();

    mPropertyManager = new PropertyManager(this);

    // must be at the beginning of any activity that can be called from an
    // external intent
    setAppName("survey");
    Uri uri = getIntent().getData();// w w  w .j a va 2 s. c  om
    Uri formUri = null;

    if (uri != null) {
        // initialize to the URI, then we will customize further based upon the
        // savedInstanceState...
        final Uri uriFormsProvider = FormsProviderAPI.CONTENT_URI;
        final Uri uriWebView = UrlUtils.getWebViewContentUri(this);
        if (uri.getScheme().equalsIgnoreCase(uriFormsProvider.getScheme())
                && uri.getAuthority().equalsIgnoreCase(uriFormsProvider.getAuthority())) {
            List<String> segments = uri.getPathSegments();
            if (segments != null && segments.size() == 1) {
                String appName = segments.get(0);
                setAppName(appName);
            } else if (segments != null && segments.size() >= 2) {
                String appName = segments.get(0);
                setAppName(appName);
                formUri = Uri.withAppendedPath(Uri.withAppendedPath(uriFormsProvider, appName),
                        segments.get(1));
            } else {
                assignContentView();
                createErrorDialog(getString(R.string.invalid_uri_expecting_n_segments, uri.toString(), 2),
                        EXIT);
                return;
            }
        } else if (uri.getScheme().equals(uriWebView.getScheme())
                && uri.getAuthority().equals(uriWebView.getAuthority())
                && uri.getPort() == uriWebView.getPort()) {
            List<String> segments = uri.getPathSegments();
            if (segments != null && segments.size() == 1) {
                String appName = segments.get(0);
                setAppName(appName);
            } else {
                assignContentView();
                createErrorDialog(getString(R.string.invalid_uri_expecting_one_segment, uri.toString()), EXIT);
                return;
            }

        } else {
            assignContentView();
            createErrorDialog(getString(R.string.unrecognized_uri, uri.toString(), uriWebView.toString(),
                    uriFormsProvider.toString()), EXIT);
            return;
        }
    }

    if (savedInstanceState != null) {
        // if appName is explicitly set, use it...
        setAppName(savedInstanceState.containsKey(APP_NAME) ? savedInstanceState.getString(APP_NAME)
                : getAppName());

        if (savedInstanceState.containsKey(CONFLICT_TABLES)) {
            mConflictTables = savedInstanceState.getBundle(CONFLICT_TABLES);
        }
    }

    WebLogger.getLogger(getAppName()).i(t, "Starting up, creating directories");
    try {
        String appName = getAppName();
        if (appName != null && appName.length() != 0) {
            ODKFileUtils.verifyExternalStorageAvailability();
            ODKFileUtils.assertDirectoryStructure(appName);
        }
    } catch (RuntimeException e) {
        assignContentView();
        createErrorDialog(e.getMessage(), EXIT);
        return;
    }

    if (savedInstanceState != null) {
        // if we are restoring, assume that initialization has already occurred.

        pageWaitingForData = savedInstanceState.containsKey(PAGE_WAITING_FOR_DATA)
                ? savedInstanceState.getString(PAGE_WAITING_FOR_DATA)
                : null;
        pathWaitingForData = savedInstanceState.containsKey(PATH_WAITING_FOR_DATA)
                ? savedInstanceState.getString(PATH_WAITING_FOR_DATA)
                : null;
        actionWaitingForData = savedInstanceState.containsKey(ACTION_WAITING_FOR_DATA)
                ? savedInstanceState.getString(ACTION_WAITING_FOR_DATA)
                : null;

        currentFragment = ScreenList.valueOf(savedInstanceState.containsKey(CURRENT_FRAGMENT)
                ? savedInstanceState.getString(CURRENT_FRAGMENT)
                : currentFragment.name());

        if (savedInstanceState.containsKey(FORM_URI)) {
            FormIdStruct newForm = FormIdStruct.retrieveFormIdStruct(getContentResolver(),
                    Uri.parse(savedInstanceState.getString(FORM_URI)));
            if (newForm != null) {
                setAppName(newForm.appName);
                setCurrentForm(newForm);
            }
        }
        setInstanceId(savedInstanceState.containsKey(INSTANCE_ID) ? savedInstanceState.getString(INSTANCE_ID)
                : getInstanceId());
        setUploadTableId(
                savedInstanceState.containsKey(UPLOAD_TABLE_ID) ? savedInstanceState.getString(UPLOAD_TABLE_ID)
                        : getUploadTableId());

        String tmpScreenPath = savedInstanceState.containsKey(SCREEN_PATH)
                ? savedInstanceState.getString(SCREEN_PATH)
                : getScreenPath();
        String tmpControllerState = savedInstanceState.containsKey(CONTROLLER_STATE)
                ? savedInstanceState.getString(CONTROLLER_STATE)
                : getControllerState();
        setSectionScreenState(tmpScreenPath, tmpControllerState);

        setAuxillaryHash(
                savedInstanceState.containsKey(AUXILLARY_HASH) ? savedInstanceState.getString(AUXILLARY_HASH)
                        : getAuxillaryHash());

        if (savedInstanceState.containsKey(SESSION_VARIABLES)) {
            sessionVariables = savedInstanceState.getBundle(SESSION_VARIABLES);
        }

        if (savedInstanceState.containsKey(SECTION_STATE_SCREEN_HISTORY)) {
            sectionStateScreenHistory = savedInstanceState.getParcelableArrayList(SECTION_STATE_SCREEN_HISTORY);
        }
    } else if (formUri != null) {
        // request specifies a specific formUri -- try to open that
        FormIdStruct newForm = FormIdStruct.retrieveFormIdStruct(getContentResolver(), formUri);
        if (newForm == null) {
            // can't find it -- launch the initialization dialog to hopefully
            // discover it.
            WebLogger.getLogger(getAppName()).i(t, "onCreate -- calling setRunInitializationTask");
            Survey.getInstance().setRunInitializationTask(getAppName());
            currentFragment = ScreenList.WEBKIT;
        } else {
            transitionToFormHelper(uri, newForm);
        }
    }

    assignContentView();
}

From source file:com.amaze.filemanager.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *//*  w ww. ja  v  a2s. c o 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:de.sourcestream.movieDB.MainActivity.java

/**
 * First configure the Universal Image Downloader,
 * then we set the main layout to be activity_main.xml
 * and we add the slide menu items./*w ww. j  a  v  a  2 s  .  c  o  m*/
 *
 * @param savedInstanceState If non-null, this activity is being re-constructed from a previous saved state as given here.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    mTitle = mDrawerTitle = getTitle();

    // load slide menu items
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
    ViewGroup header = (ViewGroup) getLayoutInflater().inflate(R.layout.drawer_header, null, false);
    ImageView drawerBackButton = (ImageView) header.findViewById(R.id.drawerBackButton);
    drawerBackButton.setOnClickListener(onDrawerBackButton);
    mDrawerList.addHeaderView(header);
    mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
    // setting the nav drawer list adapter
    mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, R.id.title, navMenuTitles));

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        toolbar.bringToFront();
    }

    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            toolbar, R.string.app_name, // nav drawer open - description for accessibility
            R.string.app_name // nav drawer close - description for accessibility
    ) {
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            // calling onPrepareOptionsMenu() to show search view
            invalidateOptionsMenu();
            syncState();
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // calling onPrepareOptionsMenu() to hide search view
            invalidateOptionsMenu();
            syncState();
        }

        // updates the title, toolbar transparency and search view
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            if (slideOffset > .55 && !isDrawerOpen) {
                // opening drawer
                // mDrawerTitle is app title
                getSupportActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu();
                isDrawerOpen = true;
            } else if (slideOffset < .45 && isDrawerOpen) {
                // closing drawer
                // mTitle is title of the current view, can be movies, tv shows or movie title
                getSupportActionBar().setTitle(mTitle);
                invalidateOptionsMenu();
                isDrawerOpen = false;
            }
        }

    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    // Get the action bar title to set padding
    TextView titleTextView = null;

    try {
        Field f = toolbar.getClass().getDeclaredField("mTitleTextView");
        f.setAccessible(true);
        titleTextView = (TextView) f.get(toolbar);
    } catch (NoSuchFieldException e) {

    } catch (IllegalAccessException e) {

    }
    if (titleTextView != null) {
        float scale = getResources().getDisplayMetrics().density;
        titleTextView.setPadding((int) scale * 15, 0, 0, 0);
    }

    phone = getResources().getBoolean(R.bool.portrait_only);

    searchDB = new SearchDB(getApplicationContext());

    if (savedInstanceState == null) {
        // Check orientation and lock to portrait if we are on phone
        if (phone) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }

        // on first time display view for first nav item
        displayView(1);

        // Use hockey module to check for updates
        checkForUpdates();

        // Universal Loader options and configuration.
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
                .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false)
                .showImageOnLoading(R.drawable.placeholder_default)
                .showImageForEmptyUri(R.drawable.placeholder_default)
                .showImageOnFail(R.drawable.placeholder_default).cacheOnDisk(true).build();
        Context context = this;
        File cacheDir = StorageUtils.getCacheDirectory(context);
        // Create global configuration and initialize ImageLoader with this config
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
                .diskCache(new UnlimitedDiscCache(cacheDir)) // default
                .defaultDisplayImageOptions(options).build();
        ImageLoader.getInstance().init(config);

        // Check cache size
        long size = 0;
        File[] filesCache = cacheDir.listFiles();
        for (File file : filesCache) {
            size += file.length();
        }
        if (cacheDir.getUsableSpace() < MinFreeSpace || size > CacheSize) {
            ImageLoader.getInstance().getDiskCache().clear();
            searchDB.cleanSuggestionRecords();
        }

    } else {
        oldPos = savedInstanceState.getInt("oldPos");
        currentMovViewPagerPos = savedInstanceState.getInt("currentMovViewPagerPos");
        currentTVViewPagerPos = savedInstanceState.getInt("currentTVViewPagerPos");
        restoreMovieDetailsState = savedInstanceState.getBoolean("restoreMovieDetailsState");
        restoreMovieDetailsAdapterState = savedInstanceState.getBoolean("restoreMovieDetailsAdapterState");
        movieDetailsBundle = savedInstanceState.getParcelableArrayList("movieDetailsBundle");
        castDetailsBundle = savedInstanceState.getParcelableArrayList("castDetailsBundle");
        tvDetailsBundle = savedInstanceState.getParcelableArrayList("tvDetailsBundle");
        currOrientation = savedInstanceState.getInt("currOrientation");
        lastVisitedSimMovie = savedInstanceState.getInt("lastVisitedSimMovie");
        lastVisitedSimTV = savedInstanceState.getInt("lastVisitedSimTV");
        lastVisitedMovieInCredits = savedInstanceState.getInt("lastVisitedMovieInCredits");
        saveInMovieDetailsSimFragment = savedInstanceState.getBoolean("saveInMovieDetailsSimFragment");

        FragmentManager fm = getFragmentManager();
        // prevent the following bug: go to gallery preview -> swap orientation ->
        // go to movies list -> swap orientation -> action bar bugged
        // so if we are not on gallery preview we show toolbar
        if (fm.getBackStackEntryCount() == 0
                || !fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName().equals("galleryList")) {
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    if (getSupportActionBar() != null && !getSupportActionBar().isShowing())
                        getSupportActionBar().show();
                }
            });
        }
    }

    // Get reference for the imageLoader
    imageLoader = ImageLoader.getInstance();

    // Options used for the backdrop image in movie and tv details and gallery
    optionsWithFade = new DisplayImageOptions.Builder()
            // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
            .bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(500))
            .imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false).showImageOnLoading(R.color.black)
            .showImageForEmptyUri(R.color.black).showImageOnFail(R.color.black).cacheOnDisk(true).build();
    optionsWithoutFade = new DisplayImageOptions.Builder()
            // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
            .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false)
            .showImageOnLoading(R.color.black).showImageForEmptyUri(R.color.black)
            .showImageOnFail(R.color.black).cacheOnDisk(true).build();

    // Options used for the backdrop image in movie and tv details and gallery
    backdropOptionsWithFade = new DisplayImageOptions.Builder()
            // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
            .bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(500))
            .imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false)
            .showImageOnLoading(R.drawable.placeholder_backdrop)
            .showImageForEmptyUri(R.drawable.placeholder_backdrop)
            .showImageOnFail(R.drawable.placeholder_backdrop).cacheOnDisk(true).build();
    backdropOptionsWithoutFade = new DisplayImageOptions.Builder()
            // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
            .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory(false)
            .showImageOnLoading(R.drawable.placeholder_backdrop)
            .showImageForEmptyUri(R.drawable.placeholder_backdrop)
            .showImageOnFail(R.drawable.placeholder_backdrop).cacheOnDisk(true).build();

    trailerListView = new TrailerList();
    galleryListView = new GalleryList();

    if (currOrientation != getResources().getConfiguration().orientation)
        orientationChanged = true;

    currOrientation = getResources().getConfiguration().orientation;

    iconConstantSpecialCase = 0;
    if (phone) {
        iconMarginConstant = 0;
        iconMarginLandscape = 0;
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        int width = displayMetrics.widthPixels;
        int height = displayMetrics.heightPixels;
        if (width <= 480 && height <= 800)
            iconConstantSpecialCase = -70;

        // used in MovieDetails, CastDetails, TVDetails onMoreIconClick
        // to check whether the animation should be in up or down direction
        threeIcons = 128;
        threeIconsToolbar = 72;
        twoIcons = 183;
        twoIconsToolbar = 127;
        oneIcon = 238;
        oneIconToolbar = 182;
    } else {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            iconMarginConstant = 232;
            iconMarginLandscape = 300;

            threeIcons = 361;
            threeIconsToolbar = 295;
            twoIcons = 416;
            twoIconsToolbar = 351;
            oneIcon = 469;
            oneIconToolbar = 407;
        } else {
            iconMarginConstant = 82;
            iconMarginLandscape = 0;

            threeIcons = 209;
            threeIconsToolbar = 146;
            twoIcons = 264;
            twoIconsToolbar = 200;
            oneIcon = 319;
            oneIconToolbar = 256;
        }

    }

    dateFormat = android.text.format.DateFormat.getDateFormat(this);
}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *//*from ww w  . j a  v  a2s.c  o  m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();
    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    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() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    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();

    // setting window background color instead of each item, in order to reduce pixel overdraw
    if (theme1 == 0) {
        /*if(Main.IS_LIST) {
                
        getWindow().setBackgroundDrawableResource(android.R.color.white);
        } else {
                
        getWindow().setBackgroundDrawableResource(R.color.grid_background_light);
        }*/
        getWindow().setBackgroundDrawableResource(android.R.color.white);
    } else {
        getWindow().setBackgroundDrawableResource(R.color.holo_dark_background);
    }

    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("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor((currentTab == 1 ? skinTwo : skin)));
        ((Activity) this).setTaskDescription(taskDescription);
    }
}

From source file:org.path.episample.android.activities.MainMenuActivity.java

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

    // android.os.Debug.waitForDebugger();

    mPropertyManager = new PropertyManager(this);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    // must be at the beginning of any activity that can be called from an
    // external intent
    setAppName("survey");
    Uri uri = getIntent().getData();//from   ww w .ja  va2 s .  c  om
    Uri formUri = null;

    if (uri != null) {
        // initialize to the URI, then we will customize further based upon the
        // savedInstanceState...
        final Uri uriFormsProvider = FormsProviderAPI.CONTENT_URI;
        final Uri uriWebView = UrlUtils.getWebViewContentUri(this);
        if (uri.getScheme().equalsIgnoreCase(uriFormsProvider.getScheme())
                && uri.getAuthority().equalsIgnoreCase(uriFormsProvider.getAuthority())) {
            List<String> segments = uri.getPathSegments();
            if (segments != null && segments.size() == 1) {
                String appName = segments.get(0);
                setAppName(appName);
            } else if (segments != null && segments.size() >= 2) {
                String appName = segments.get(0);
                setAppName(appName);
                formUri = Uri.withAppendedPath(Uri.withAppendedPath(uriFormsProvider, appName),
                        segments.get(1));
            } else {
                assignContentView();
                createErrorDialog(getString(R.string.invalid_uri_expecting_n_segments, uri.toString(), 2),
                        EXIT);
                return;
            }
        } else if (uri.getScheme().equals(uriWebView.getScheme())
                && uri.getAuthority().equals(uriWebView.getAuthority())
                && uri.getPort() == uriWebView.getPort()) {
            List<String> segments = uri.getPathSegments();
            if (segments != null && segments.size() == 1) {
                String appName = segments.get(0);
                setAppName(appName);
            } else {
                assignContentView();
                createErrorDialog(getString(R.string.invalid_uri_expecting_one_segment, uri.toString()), EXIT);
                return;
            }

        } else {
            assignContentView();
            createErrorDialog(getString(R.string.unrecognized_uri, uri.toString(), uriWebView.toString(),
                    uriFormsProvider.toString()), EXIT);
            return;
        }
    }

    if (savedInstanceState != null) {
        // if appName is explicitly set, use it...
        setAppName(savedInstanceState.containsKey(APP_NAME) ? savedInstanceState.getString(APP_NAME)
                : getAppName());

        if (savedInstanceState.containsKey(CONFLICT_TABLES)) {
            mConflictTables = savedInstanceState.getBundle(CONFLICT_TABLES);
        }
    }

    WebLogger.getLogger(getAppName()).i(t, "Starting up, creating directories");
    try {
        String appName = getAppName();
        if (appName != null && appName.length() != 0) {
            ODKFileUtils.verifyExternalStorageAvailability();
            ODKFileUtils.assertDirectoryStructure(appName);
        }
    } catch (RuntimeException e) {
        assignContentView();
        createErrorDialog(e.getMessage(), EXIT);
        return;
    }

    if (savedInstanceState != null) {
        // if we are restoring, assume that initialization has already occurred.

        pageWaitingForData = savedInstanceState.containsKey(PAGE_WAITING_FOR_DATA)
                ? savedInstanceState.getString(PAGE_WAITING_FOR_DATA)
                : null;
        pathWaitingForData = savedInstanceState.containsKey(PATH_WAITING_FOR_DATA)
                ? savedInstanceState.getString(PATH_WAITING_FOR_DATA)
                : null;
        actionWaitingForData = savedInstanceState.containsKey(ACTION_WAITING_FOR_DATA)
                ? savedInstanceState.getString(ACTION_WAITING_FOR_DATA)
                : null;

        currentFragment = ScreenList.valueOf(savedInstanceState.containsKey(CURRENT_FRAGMENT)
                ? savedInstanceState.getString(CURRENT_FRAGMENT)
                : currentFragment.name());

        if (savedInstanceState.containsKey(FORM_URI)) {
            FormIdStruct newForm = FormIdStruct.retrieveFormIdStruct(getContentResolver(),
                    Uri.parse(savedInstanceState.getString(FORM_URI)));
            if (newForm != null) {
                setAppName(newForm.appName);
                setCurrentForm(newForm);
            }
        }
        setInstanceId(savedInstanceState.containsKey(INSTANCE_ID) ? savedInstanceState.getString(INSTANCE_ID)
                : getInstanceId());
        setUploadTableId(
                savedInstanceState.containsKey(UPLOAD_TABLE_ID) ? savedInstanceState.getString(UPLOAD_TABLE_ID)
                        : getUploadTableId());

        String tmpScreenPath = savedInstanceState.containsKey(SCREEN_PATH)
                ? savedInstanceState.getString(SCREEN_PATH)
                : getScreenPath();
        String tmpControllerState = savedInstanceState.containsKey(CONTROLLER_STATE)
                ? savedInstanceState.getString(CONTROLLER_STATE)
                : getControllerState();
        setSectionScreenState(tmpScreenPath, tmpControllerState);

        setAuxillaryHash(
                savedInstanceState.containsKey(AUXILLARY_HASH) ? savedInstanceState.getString(AUXILLARY_HASH)
                        : getAuxillaryHash());

        if (savedInstanceState.containsKey(SESSION_VARIABLES)) {
            sessionVariables = savedInstanceState.getBundle(SESSION_VARIABLES);
        }

        if (savedInstanceState.containsKey(SECTION_STATE_SCREEN_HISTORY)) {
            sectionStateScreenHistory = savedInstanceState.getParcelableArrayList(SECTION_STATE_SCREEN_HISTORY);
        }
    } else if (formUri != null) {
        // request specifies a specific formUri -- try to open that
        FormIdStruct newForm = FormIdStruct.retrieveFormIdStruct(getContentResolver(), formUri);
        if (newForm == null) {
            // can't find it -- launch the initialization dialog to hopefully
            // discover it.
            WebLogger.getLogger(getAppName()).i(t, "onCreate -- calling setRunInitializationTask");
            Survey.getInstance().setRunInitializationTask(getAppName());
            currentFragment = ScreenList.WEBKIT;
        } else {
            transitionToFormHelper(uri, newForm);
        }
    }

    assignContentView();
}

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

private void initAttachmentsFromIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras == null) {
        extras = Bundle.EMPTY;/*from w ww. j av  a 2s. c  o m*/
    }
    final String action = intent.getAction();
    if (!mAttachmentsChanged) {
        long totalSize = 0;
        if (extras.containsKey(EXTRA_ATTACHMENTS)) {
            String[] uris = (String[]) extras.getSerializable(EXTRA_ATTACHMENTS);
            for (String uriString : uris) {
                final Uri uri = Uri.parse(uriString);
                long size = 0;
                try {
                    if (handleSpecialAttachmentUri(uri)) {
                        continue;
                    }

                    final Attachment a = mAttachmentsView.generateLocalAttachment(uri);
                    //TS: rong-tang 2016-03-02 EMAIL BUGFIX-1712549 ADD_S
                    if (a == null) {
                        continue;
                    }
                    //TS: rong-tang 2016-03-02 EMAIL BUGFIX-1712549 ADD_E
                    size = mAttachmentsView.addAttachment(mAccount, a, true);//TS: yanhua.chen 2015-6-8 EMAIL CR_996908 MOD

                    Analytics.getInstance().sendEvent("send_intent_attachment",
                            Utils.normalizeMimeType(a.getContentType()), null, size);

                } catch (AttachmentFailureException e) {
                    LogUtils.e(LOG_TAG, e, "Error adding attachment");
                    showAttachmentTooBigToast(e.getErrorRes());
                }
                totalSize += size;
            }
        }
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            if (!PermissionUtil.checkAndRequestPermissionForResult(this,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    PermissionUtil.REQ_CODE_PERMISSION_ADD_ATTACHMENT)) {
                return;
            }
            if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
                final ArrayList<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
                ArrayList<Attachment> attachments = new ArrayList<Attachment>();
                for (Uri uri : uris) {
                    if (uri == null) {
                        continue;
                    }
                    try {
                        if (handleSpecialAttachmentUri(uri)) {
                            continue;
                        }

                        final Attachment a = mAttachmentsView.generateLocalAttachment(uri);
                        //TS: rong-tang 2016-03-02 EMAIL BUGFIX-1712549 ADD_S
                        if (a == null) {
                            continue;
                        }
                        //TS: rong-tang 2016-03-02 EMAIL BUGFIX-1712549 ADD_E
                        attachments.add(a);

                        Analytics.getInstance().sendEvent("send_intent_attachment",
                                Utils.normalizeMimeType(a.getContentType()), null, a.size);

                    } catch (AttachmentFailureException e) {
                        LogUtils.e(LOG_TAG, e, "Error adding attachment");
                        String maxSize = AttachmentUtils.convertToHumanReadableSize(getApplicationContext(),
                                mAccount.settings.getMaxAttachmentSize());
                        showErrorToast(getString(R.string.generic_attachment_problem, maxSize));
                    }
                }
                // TS: zhaotianyong 2015-05-08 EMAIL BUGFIX_988459 MOD_S
                totalSize += addAttachments(attachments, false);
                // TS: zhaotianyong 2015-05-08 EMAIL BUGFIX_988459 MOD_E
            } else {
                final Uri uri = extras.getParcelable(Intent.EXTRA_STREAM);
                if (uri != null) {
                    long size = 0;
                    //[BUGFIX]-Modified-BEGIN by TCTNJ.wenlu.wu,12/03/2014,PR-857886
                    if (!handleSpecialAttachmentUri(uri)) {

                        new AsyncTask<Void, Void, Void>() {
                            @Override
                            protected Void doInBackground(Void... params) {
                                try {
                                    Attachment mAttachment = mAttachmentsView.generateLocalAttachment(uri);
                                    android.os.Message msg = new android.os.Message();
                                    msg.what = 1001;
                                    msg.obj = mAttachment;
                                    mHandler.sendMessage(msg);
                                } catch (AttachmentFailureException e) {
                                    LogUtils.e(LOG_TAG, e, "Error adding attachment");
                                    showAttachmentTooBigToast(e.getErrorRes());
                                }
                                return null;
                            }

                            @Override
                            protected void onPostExecute(Void result) {

                            }
                        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    }
                    //[BUGFIX]-Modified-END by TCTNJ.wenlu.wu,12/03/2014,PR-857886

                    totalSize += size;
                }
            }
        }

        if (totalSize > 0) {
            mAttachmentsChanged = true;
            updateSaveUi();

            Analytics.getInstance().sendEvent("send_intent_with_attachments",
                    Integer.toString(getAttachments().size()), null, totalSize);
        }
    }
}