Example usage for android.os CountDownTimer CountDownTimer

List of usage examples for android.os CountDownTimer CountDownTimer

Introduction

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

Prototype

public CountDownTimer(long millisInFuture, long countDownInterval) 

Source Link

Usage

From source file:produvia.com.lights.SmartLightsActivity.java

public void promptLogin(final JSONObject loginService, final JSONObject responseData) {

    runOnUiThread(new Runnable() {
        public void run() {
            try {
                String type = loginService.getString("type");
                //there was a login error. login again
                if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_NORMAL)) {
                    //prompt for username and password and retry:
                    promptUsernamePassword(loginService, responseData, false, null);

                } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_KEY)) {

                    promptUsernamePassword(loginService, responseData, true,
                            loginService.getString("description"));

                } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_PRESS2LOGIN)) {
                    //prompt for username and password and retry:
                    int countdown = loginService.has("login_timeout") ? loginService.getInt("login_timeout")
                            : 15;/*from  ww w  . ja  v a  2s. c  o  m*/
                    final AlertDialog alertDialog = new AlertDialog.Builder(SmartLightsActivity.this).create();
                    alertDialog.setTitle(loginService.getString("description"));
                    alertDialog.setCancelable(false);
                    alertDialog.setCanceledOnTouchOutside(false);
                    alertDialog.setMessage(loginService.getString("description") + "\n"
                            + "Attempting to login again in " + countdown + " seconds...");
                    alertDialog.show(); //

                    new CountDownTimer(countdown * 1000, 1000) {
                        @Override
                        public void onTick(long millisUntilFinished) {
                            try {
                                alertDialog.setMessage(loginService.getString("description") + "\n"
                                        + "Attempting to login again in " + millisUntilFinished / 1000
                                        + " seconds...");
                            } catch (JSONException e) {

                            }
                        }

                        @Override
                        public void onFinish() {
                            alertDialog.dismiss();
                            new Thread(new Runnable() {
                                public void run() {

                                    try {
                                        JSONArray services = new JSONArray();
                                        services.put(loginService);
                                        responseData.put("services", services);
                                        WeaverSdkApi.servicesSet(SmartLightsActivity.this, responseData);
                                    } catch (JSONException e) {

                                    }
                                }
                            }).start();

                        }
                    }.start();

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }

    });

}

From source file:com.pukulab.puku0x.gscalendar.CalendarActivity.java

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

    // ?//from   ww  w. j  ava2  s . c o  m
    mBackKeyTimer = new CountDownTimer(2000, 2000) {
        @Override
        public void onTick(long millisUntilFinished) {
        }

        @Override
        public void onFinish() {
            mBackKeyPressed = false;
        }
    };

    // ?
    Bundle extras = getIntent().getExtras();

    // ?
    if (mLoginUser == null) {
        mLoginUser = (UserData) extras.getSerializable(ARGS_LOGIN_USER);
    }

    // 
    if (mDisplayedUser == null) {
        mDisplayedUser = (UserData) extras.getSerializable(ARGS_DISPLAYED_USER);
    }

    // ?
    if (mDisplayedDate == null) {
        mDisplayedDate = (Date) extras.getSerializable(ARGS_DISPLAYED_DATE);
        mLastDisplayedDate = mDisplayedDate;
    }

    // 
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // ?????????
        if (mDisplayedUser.usid != null && !mDisplayedUser.usid.equals(mLoginUser.usid)) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        // 
        actionBar.setTitle(mDisplayedUser.name);
        actionBar.setSubtitle(DateFormat.format(getString(R.string.date_year_month_day), mDisplayedDate));
    }

    // Retrieve the CalendarView
    mCalendarView = (MultiCalendarView) findViewById(R.id.calendarView);
    mProgressBar = (ProgressBar) findViewById(R.id.pb_detail);
    //mScheduleLayout = (LinearLayout) findViewById(R.id.scheduleList);

    // ?
    mScheduleDataList = new ArrayList<>();
    mDailyScheduleList = new ArrayList<>();
    mDailyScheduleaListAdapter = new ScheduleDataAdapter(CalendarActivity.this, 0, mDailyScheduleList);
    mDailyScheduleListView = (ListView) findViewById(R.id.lv_schedule);
    mDailyScheduleListView.setAdapter(mDailyScheduleaListAdapter);
    mDailyScheduleListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ListView listView = (ListView) parent;
            Schedule schedule = (Schedule) listView.getItemAtPosition(position);
            // ???
            mLastSchedule = new Schedule(schedule);

            // ??
            Intent intent = DetailActivity.createIntent(CalendarActivity.this, mLoginUser, mDisplayedUser,
                    schedule);
            int requestCode = DetailActivity.REQUEST_DETAIL;
            startActivityForResult(intent, requestCode);
        }
    });

    // Set the first valid day
    final Calendar firstValidDay = Calendar.getInstance();
    firstValidDay.add(Calendar.YEAR, -1);
    firstValidDay.set(Calendar.DAY_OF_MONTH, 1);
    firstValidDay.set(Calendar.HOUR_OF_DAY, 0);
    firstValidDay.set(Calendar.MINUTE, 0);
    firstValidDay.set(Calendar.SECOND, 0);
    firstValidDay.set(Calendar.MILLISECOND, 0);
    mCalendarView.setFirstValidDay(firstValidDay);

    // Set the last valid day
    final Calendar lastValidDay = Calendar.getInstance();
    lastValidDay.add(Calendar.YEAR, 1);
    lastValidDay.set(Calendar.HOUR_OF_DAY, 0);
    lastValidDay.set(Calendar.MINUTE, 0);
    lastValidDay.set(Calendar.SECOND, 0);
    lastValidDay.set(Calendar.MILLISECOND, 0);
    mCalendarView.setLastValidDay(lastValidDay);

    // ~
    mCalendarView.setFirstDayOfWeek(Calendar.SUNDAY);
    mCalendarView.setLastDayOfWeek(Calendar.SATURDAY);

    // Create adapter
    final CustomDayAdapter adapter = new CustomDayAdapter();

    // Set listener and adapter
    mCalendarView.setOnDayClickListener(this);
    mCalendarView.getIndicator().setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            //System.out.println("position:" + position);
            final Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis((mCalendarView.getFirstValidDay().getTimeInMillis()));
            cal.add(Calendar.MONTH, position);
            mStartDate = cal.getTime();
            cal.add(Calendar.MONTH, 1);
            mEndDate = cal.getTime();
            mViewPagerPosition = position;
            new DisplaySchedulesTask(CalendarActivity.this, mDisplayedUser, mDisplayedDate).execute(mStartDate,
                    mEndDate);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    mCalendarView.setDayAdapter(adapter);

    // ????????
    mCalendarView.setViewPagerPosition(12);
}

From source file:produvia.com.scanner.DevicesActivity.java

public void promptLogin(final JSONObject loginService, final JSONObject responseData) {

    runOnUiThread(new Runnable() {
        public void run() {
            try {
                String type = loginService.getString("type");
                //there was a login error. login again
                if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_NORMAL)) {
                    //prompt for username and password and retry:
                    promptUsernamePassword(loginService, responseData, false, null);

                } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_KEY)) {

                    promptUsernamePassword(loginService, responseData, true,
                            loginService.getString("description"));

                } else if (type.equals(WeaverSdk.FIRST_LOGIN_TYPE_PRESS2LOGIN)) {
                    //prompt for username and password and retry:
                    int countdown = loginService.has("login_timeout") ? loginService.getInt("login_timeout")
                            : 15;/* w w  w.  j  a  va  2s  .c o m*/
                    final AlertDialog alertDialog = new AlertDialog.Builder(DevicesActivity.this).create();
                    alertDialog.setTitle(loginService.getString("description"));
                    alertDialog.setCancelable(false);
                    alertDialog.setCanceledOnTouchOutside(false);
                    alertDialog.setMessage(loginService.getString("description") + "\n"
                            + "Attempting to login again in " + countdown + " seconds...");
                    alertDialog.show(); //

                    new CountDownTimer(countdown * 1000, 1000) {
                        @Override
                        public void onTick(long millisUntilFinished) {
                            try {
                                alertDialog.setMessage(loginService.getString("description") + "\n"
                                        + "Attempting to login again in " + millisUntilFinished / 1000
                                        + " seconds...");
                            } catch (JSONException e) {

                            }
                        }

                        @Override
                        public void onFinish() {
                            alertDialog.dismiss();
                            new Thread(new Runnable() {
                                public void run() {

                                    try {
                                        JSONArray services = new JSONArray();
                                        services.put(loginService);
                                        responseData.put("services", services);
                                        WeaverSdkApi.servicesSet(DevicesActivity.this, responseData);
                                    } catch (JSONException e) {

                                    }
                                }
                            }).start();

                        }
                    }.start();

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }

    });

}

From source file:com.PPRZonDroid.MainActivity.java

private void setup_counter() {
    //Get timeout from appsettings
    BL_CountDownTimerDuration = Integer.parseInt(AppSettings.getString("block_change_timeout", "3")) * 1000;
    BL_CountDownTimerValue = BL_CountDownTimerDuration;
    //Setup timer for progressbar of clicked block
    BL_CountDown = new CountDownTimer(BL_CountDownTimerDuration, 100) {
        @Override//from  www.java2s  . c  om
        public void onTick(long l) {

            if (BL_CountDownTimerDuration > 0) {
                BL_CountDownTimerValue = BL_CountDownTimerValue - 100;
                mBlListAdapter.BlProgress
                        .setProgress(((BL_CountDownTimerValue * 100) / BL_CountDownTimerDuration));
                //if (DEBUG) Log.d("PPRZ_info", "Counter value: " + process_val );
            }
        }

        @Override
        public void onFinish() {
            if (BL_CountDownTimerDuration > 0) {

                BL_CountDownTimerValue = BL_CountDownTimerValue - 100;
                mBlListAdapter.BlProgress
                        .setProgress(((BL_CountDownTimerValue * 100) / BL_CountDownTimerDuration));
                BL_CountDownTimerValue = BL_CountDownTimerDuration;
                mBlListAdapter.ClickedInd = -1;
                set_selected_block(JumpToBlock, false);
                mBlListAdapter.notifyDataSetChanged();

            }
        }

    };
}

From source file:com.google.android.apps.santatracker.map.TvSantaMapActivity.java

/**
 * Call when Santa is en route to the given destination.
 *///from ww  w  .j  a  va2 s .  c o  m
private void travelToDestination(final Destination origin, final Destination nextDestination) {

    if (origin != null) {
        // add marker at origin position to map.
        mMapFragment.addLocation(origin);
    }

    // check if finished
    if (mDestinations.isFinished() || nextDestination == null) {
        // App Measurement
        MeasurementManager.recordCustomEvent(mMeasurement, getString(R.string.analytics_event_category_tracker),
                getString(R.string.analytics_tracker_action_finished),
                getString(R.string.analytics_tracker_error_nodata));

        // [ANALYTICS EVENT]: Error NoData after API error
        AnalyticsManager.sendEvent(R.string.analytics_event_category_tracker,
                R.string.analytics_tracker_action_finished, R.string.analytics_tracker_error_nodata);

        // No more destinations left, return to village
        returnToStartupActivity();
        return;
    }

    if (mHaveApiError) {
        // App Measurement
        MeasurementManager.recordCustomEvent(mMeasurement, getString(R.string.analytics_event_category_tracker),
                getString(R.string.analytics_tracker_action_error),
                getString(R.string.analytics_tracker_error_nodata));

        // [ANALYTICS EVENT]: Error NoData after API error
        AnalyticsManager.sendEvent(R.string.analytics_event_category_tracker,
                R.string.analytics_tracker_action_error, R.string.analytics_tracker_error_nodata);
        handleErrorFinish();
        return;
    }

    final String nextString = DashboardFormats.formatDestination(nextDestination);
    setNextLocation(nextString);
    setNextDestination(nextDestination);

    // get the previous position
    Destination previous = mDestinations.getPrevious();

    SantaLog.d(TAG, "Travel: " + (origin != null ? origin.identifier : "null") + " -> "
            + nextDestination.identifier + " prev=" + (previous != null ? previous.identifier : "null"));

    // if this is the very first location, move santa directly
    if (previous == null) {
        mMapFragment.setSantaVisiting(nextDestination, false);
        mPresents.init(0, nextDestination.presentsDelivered, nextDestination.arrival,
                nextDestination.departure);
    } else {
        mMapFragment.setSantaTravelling(previous, nextDestination, !mJumpingToUserDestination);
        // only hand out X% of presents during travel
        long presentsEnd = previous.presentsDelivered
                + Math.round((nextDestination.presentsDeliveredAtDestination) * FACTOR_PRESENTS_TRAVELLING);
        mPresents.init(previous.presentsDelivered, presentsEnd, previous.departure, nextDestination.arrival);
    }

    // Notify dashboard to send accessibility event
    AccessibilityUtil.announceText(String.format(ANNOUNCE_TRAVEL_TO, nextString), mVerticalGridView,
            mAccessibilityManager);

    // cancel the countdown if it is already running
    if (mTimer != null) {
        mTimer.cancel();
    }

    mTimer = new CountDownTimer(nextDestination.arrival - SantaPreferences.getCurrentTime(),
            DESTINATION_COUNTDOWN_UPDATEINTERVAL) {

        @Override
        public void onTick(long millisUntilFinished) {
            countdownTick();
        }

        @Override
        public void onFinish() {
            // reached destination - visit destination
            visitDestination(nextDestination, true);
        }
    };
    if (mResumed) {
        mTimer.start();
    }
}

From source file:com.sim2dial.dialer.StatusFragment.java

private void showZRTPDialog(final LinphoneCall call) {
    boolean authVerified = call.isAuthenticationTokenVerified();
    String format = getString(authVerified ? R.string.reset_sas_fmt : R.string.verify_sas_fmt);

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View layout = inflater.inflate(R.layout.zrtp_dialog,
            (ViewGroup) getActivity().findViewById(R.id.toastRoot));

    TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
    toastText.setText(String.format(format, call.getAuthenticationToken()));

    zrtpToast = new Toast(getActivity());
    zrtpToast.setGravity(Gravity.TOP | Gravity.RIGHT, 0, LinphoneUtils.pixelsToDpi(getResources(), 40));
    zrtpToast.setDuration(Toast.LENGTH_LONG);

    ImageView ok = (ImageView) layout.findViewById(R.id.toastOK);
    ok.setOnClickListener(new OnClickListener() {
        @Override/*  w ww  . j  a v a2 s  .c om*/
        public void onClick(View v) {
            if (call != null) {
                call.setAuthenticationTokenVerified(true);
            }
            if (encryption != null) {
                encryption.setImageResource(R.drawable.security_ok);
            }
            hideZRTPDialog();
        }
    });

    ImageView notOk = (ImageView) layout.findViewById(R.id.toastNotOK);
    notOk.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (call != null) {
                call.setAuthenticationTokenVerified(false);
            }
            if (encryption != null) {
                encryption.setImageResource(R.drawable.security_pending);
            }
            hideZRTPDialog();
        }
    });

    zrtpHack = new CountDownTimer(3000, 1000) {
        public void onTick(long millisUntilFinished) {
            if (!hideZrtpToast) {
                zrtpToast.show();
            }
        }

        public void onFinish() {
            if (!hideZrtpToast) {
                zrtpToast.show();
                zrtpHack.start();
            }
        }

    };

    zrtpToast.setView(layout);
    hideZrtpToast = false;
    zrtpToast.show();
    zrtpHack.start();
}

From source file:projekt.substratum.MainActivity.java

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

    startService(new Intent(this, ThemeService.class));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// w w  w.  ja v a2 s.com
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);

    AccountHeader header = new AccountHeaderBuilder().withActivity(this)
            .withHeaderBackground(R.drawable.material_drawer_header_background).withProfileImagesVisible(false)
            .withSelectionListEnabledForSingleProfile(false).addProfiles(new ProfileDrawerItem()
                    .withName(getString(R.string.drawer_name)).withEmail(BuildConfig.VERSION_NAME))
            .withCurrentProfileHiddenInList(true).build();

    final LibsSupportFragment fragment = new LibsBuilder().supportFragment();

    if (References.checkOMS()) {
        drawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(header)
                .withSavedInstance(savedInstanceState).withActionBarDrawerToggleAnimated(true)
                .addDrawerItems(
                        new PrimaryDrawerItem().withName(R.string.nav_home)
                                .withIcon(R.drawable.nav_theme_packs),
                        new PrimaryDrawerItem().withName(R.string.nav_overlays)
                                .withIcon(R.drawable.nav_overlays),
                        new PrimaryDrawerItem().withName(R.string.nav_bootanim)
                                .withIcon(R.drawable.nav_bootanim),
                        new PrimaryDrawerItem().withName(R.string.nav_fonts).withIcon(R.drawable.nav_fonts),
                        new PrimaryDrawerItem().withName(R.string.nav_sounds).withIcon(R.drawable.nav_sounds),
                        new SectionDrawerItem().withName(R.string.nav_section_header_utilities),
                        new PrimaryDrawerItem().withName(R.string.nav_overlay_manager)
                                .withIcon(R.drawable.nav_overlay_manager),
                        new PrimaryDrawerItem().withName(R.string.nav_manage).withIcon(R.drawable.nav_manage),
                        new PrimaryDrawerItem().withName(R.string.nav_priorities)
                                .withIcon(R.drawable.nav_drawer_priorities),
                        new PrimaryDrawerItem().withName(R.string.nav_backup_restore)
                                .withIcon(R.drawable.nav_drawer_profiles),
                        new SectionDrawerItem().withName(R.string.nav_section_header_more),
                        new SecondaryDrawerItem().withName(R.string.nav_troubleshooting)
                                .withIcon(R.drawable.nav_troubleshooting),
                        new SecondaryDrawerItem().withName(R.string.nav_team)
                                .withIcon(R.drawable.nav_drawer_team),
                        new SecondaryDrawerItem().withName(getString(R.string.nav_opensource))
                                .withIcon(R.drawable.nav_drawer_licenses),
                        new SecondaryDrawerItem().withName(R.string.nav_settings)
                                .withIcon(R.drawable.nav_drawer_settings))
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                        if (drawerItem != null) {
                            switch (position) {
                            case 1:
                                if (drawerSelected != position) {
                                    switchFragment(((References.checkOMS()) ? getString(R.string.app_name)
                                            : getString(R.string.legacy_app_name)), "HomeFragment");
                                    drawerSelected = 1;
                                }
                                break;
                            case 2:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_overlays), "OverlaysFragment");
                                    drawerSelected = 2;
                                }
                                break;
                            case 3:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_bootanim), "BootAnimationsFragment");
                                    drawerSelected = 3;
                                }
                                break;
                            case 4:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_fonts), "FontsFragment");
                                    drawerSelected = 4;
                                }
                                break;
                            case 5:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_sounds), "SoundsFragment");
                                    drawerSelected = 5;
                                }
                                break;
                            case 7:
                                switchFragment(getString(R.string.nav_overlay_manager),
                                        "AdvancedManagerFragment");
                                drawerSelected = 7;
                                break;
                            case 8:
                                switchFragment(getString(R.string.nav_manage), "ManageFragment");
                                drawerSelected = 8;
                                break;
                            case 9:
                                switchFragment(getString(R.string.nav_priorities), "PriorityLoaderFragment");
                                drawerSelected = 9;
                                break;
                            case 10:
                                switchFragment(getString(R.string.nav_backup_restore), "ProfileFragment");
                                drawerSelected = 10;
                                break;
                            case 12:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_troubleshooting),
                                            "TroubleshootingFragment");
                                    drawerSelected = 12;
                                }
                                break;
                            case 13:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_team), "TeamFragment");
                                    drawerSelected = 13;
                                }
                                break;
                            case 14:
                                switchFragmentToLicenses(getString(R.string.nav_opensource), fragment);
                                drawerSelected = 14;
                                break;
                            case 15:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_settings), "SettingsFragment");
                                    drawerSelected = 15;
                                }
                                break;
                            }
                        }
                        return false;
                    }
                }).withSelectedItem(1).withSelectedItemByPosition(1).build();
    } else {
        drawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(header)
                .withSavedInstance(savedInstanceState).withActionBarDrawerToggleAnimated(true)
                .addDrawerItems(
                        new PrimaryDrawerItem().withName(R.string.nav_home)
                                .withIcon(R.drawable.nav_theme_packs),
                        new PrimaryDrawerItem().withName(R.string.nav_overlays)
                                .withIcon(R.drawable.nav_overlays),
                        new PrimaryDrawerItem().withName(R.string.nav_sounds).withIcon(R.drawable.nav_sounds),

                        new SectionDrawerItem().withName(R.string.nav_section_header_utilities),
                        new PrimaryDrawerItem().withName(R.string.nav_overlay_manager)
                                .withIcon(R.drawable.nav_overlay_manager),
                        new PrimaryDrawerItem().withName(R.string.nav_manage).withIcon(R.drawable.nav_manage),
                        new PrimaryDrawerItem().withName(R.string.nav_backup_restore)
                                .withIcon(R.drawable.nav_drawer_profiles),

                        new SectionDrawerItem().withName(R.string.nav_section_header_more),
                        new SecondaryDrawerItem().withName(R.string.nav_troubleshooting)
                                .withIcon(R.drawable.nav_troubleshooting),
                        new SecondaryDrawerItem().withName(R.string.nav_team)
                                .withIcon(R.drawable.nav_drawer_team),
                        new SecondaryDrawerItem().withName(getString(R.string.nav_opensource))
                                .withIcon(R.drawable.nav_drawer_licenses),
                        new SecondaryDrawerItem().withName(R.string.nav_settings)
                                .withIcon(R.drawable.nav_drawer_settings))
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                        if (drawerItem != null) {
                            switch (position) {
                            case 1:
                                if (drawerSelected != position) {
                                    switchFragment(((References.checkOMS()) ? getString(R.string.app_name)
                                            : getString(R.string.legacy_app_name)), "HomeFragment");
                                    drawerSelected = 1;
                                }
                                break;
                            case 2:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_overlays), "OverlaysFragment");
                                    drawerSelected = 2;
                                }
                                break;
                            case 3:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_sounds), "SoundsFragment");
                                    drawerSelected = 3;
                                }
                                break;
                            case 5:
                                switchFragment(getString(R.string.nav_overlay_manager),
                                        "AdvancedManagerFragment");
                                drawerSelected = 5;
                                break;
                            case 6:
                                switchFragment(getString(R.string.nav_manage), "ManageFragment");
                                drawerSelected = 6;
                                break;
                            case 7:
                                switchFragment(getString(R.string.nav_backup_restore), "ProfileFragment");
                                drawerSelected = 7;
                                break;
                            case 9:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_troubleshooting),
                                            "TroubleshootingFragment");
                                    drawerSelected = 10;
                                }
                                break;
                            case 10:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_team), "TeamFragment");
                                    drawerSelected = 10;
                                }
                                break;
                            case 11:
                                switchFragmentToLicenses(getString(R.string.nav_opensource), fragment);
                                drawerSelected = 11;
                                break;
                            case 12:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_settings), "SettingsFragment");
                                    drawerSelected = 12;
                                }
                                break;
                            }
                        }
                        return false;
                    }
                }).withSelectedItem(1).withSelectedItemByPosition(1).build();
    }
    if (!Root.requestRootAccess()) {
        final ProgressDialog mProgressDialog = new ProgressDialog(this,
                R.style.SubstratumBuilder_ActivityTheme);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        mProgressDialog.setContentView(R.layout.root_rejected_loader);

        final float radius = 5;
        final View decorView = getWindow().getDecorView();
        final View rootView = decorView.findViewById(android.R.id.content);
        final Drawable windowBackground = decorView.getBackground();

        BlurView blurView = (BlurView) mProgressDialog.findViewById(R.id.blurView);

        blurView.setupWith(rootView).windowBackground(windowBackground)
                .blurAlgorithm(new RenderScriptBlur(this, true)).blurRadius(radius);

        final TextView textView = (TextView) mProgressDialog.findViewById(R.id.timer);
        CountDownTimer Count = new CountDownTimer(5000, 1000) {
            public void onTick(long millisUntilFinished) {
                if ((millisUntilFinished / 1000) > 1) {
                    textView.setText(String.format(getString(R.string.root_rejected_timer_plural),
                            (millisUntilFinished / 1000) + ""));
                } else {
                    textView.setText(String.format(getString(R.string.root_rejected_timer_singular),
                            (millisUntilFinished / 1000) + ""));
                }

            }

            public void onFinish() {
                mProgressDialog.dismiss();
                finish();
            }
        };
        Count.start();
    }

    permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.WRITE_EXTERNAL_STORAGE);
    permissionCheck2 = ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.READ_PHONE_STATE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (!Settings.System.canWrite(getApplicationContext())) {
            Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
            intent.setData(Uri.parse("package:" + MainActivity.this.getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        } else {
            Log.d("SubstratumLogger", "Substratum was granted " + "'android.permission.WRITE_SETTINGS' "
                    + "permissions for system runtime code execution.");
        }
    }

    if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
        // permission already granted, allow the program to continue running
        File directory = new File(Environment.getExternalStorageDirectory(), "/.substratum/");
        if (!directory.exists()) {
            directory.mkdirs();
        }
        File cacheDirectory = new File(getCacheDir(), "/SubstratumBuilder/");
        if (!cacheDirectory.exists()) {
            cacheDirectory.mkdirs();
        }
        if (permissionCheck2 == PackageManager.PERMISSION_GRANTED) {
            // permission already granted, allow the program to continue running
            // Set the first option to start at app boot
            drawer.setSelectionAtPosition(1);
        } else {
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_PHONE_STATE },
                    PERMISSIONS_REQUEST_READ_PHONE_STATE);
        }
    } else {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
    }

    // Now, let's grab root on the helper
    Intent rootIntent = new Intent(Intent.ACTION_MAIN);
    rootIntent.setAction("masquerade.substratum.INITIALIZE");
    try {
        startActivity(rootIntent);
    } catch (RuntimeException re) {
        // Exception: At this point, Masquerade is not installed at all.
    }

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (References.checkOMS()) {
        if (!prefs.getBoolean("substratum_oms", true)) {
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/.substratum/");
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/substratum/");
            File directory = new File(Environment.getExternalStorageDirectory(), "/.substratum/");
            if (!directory.exists()) {
                directory.mkdirs();
            }
        }
    } else {
        if (prefs.getBoolean("substratum_oms", true)) {
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/.substratum/");
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/substratum/");
            File directory = new File(Environment.getExternalStorageDirectory(), "/.substratum/");
            if (!directory.exists()) {
                directory.mkdirs();
            }
        }
    }

    printFCMtoken();
}

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

/**
 * Called when the activity is first created.
 *//*from w ww .ja  va 2 s. c  o m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    initializeInteractiveShell();

    dataUtils = new DataUtils();
    dataUtils.registerOnDataChangedListener(this);

    setContentView(R.layout.main_toolbar);
    initialiseViews();
    tabHandler = new TabHandler(this);
    mImageLoader = AppConfig.getInstance().getImageLoader();
    utils = getFutils();
    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    // TODO: Create proper SQLite database handler class with calls to database from background thread
    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.SMB, 1);

    if (!sharedPref.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        sharedPref.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 (sharedPref.getBoolean("plus_pic", false)) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    if (CloudSheetFragment.isCloudProviderAvailable(this)) {

        getSupportLoaderManager().initLoader(REQUEST_CODE_CLOUD_LIST_KEY_CLOUD, null, this);
    }

    util = new IconUtils(sharedPref, this);
    icons = new IconUtils(sharedPref, 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(KEY_INTENT_PROCESS_VIEWER, false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS);
            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, getString(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, getString(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) {

        e.printStackTrace();
    }

    if (savedInstanceState != null) {

        selectedStorage = savedInstanceState.getInt("selectitem", SELECT_0);
    }

    refreshDrawer();

    // setting window background color instead of each item, in order to reduce pixel overdraw
    if (getAppTheme().equals(AppTheme.LIGHT)) {
        /*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(), KEY_INTENT_PROCESS_VIEWER);
            //transaction.addToBackStack(null);
            selectedStorage = SELECT_102;
            openProcesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else if (intent.getAction() != null
                && intent.getAction().equals(TileService.ACTION_QS_TILE_PREFERENCES)) {
            // tile preferences, open ftp fragment

            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();

            selectedStorage = SELECT_MINUS_2;
            adapter.toggleChecked(false);
            transaction2.commit();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(OpenMode.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");
        selectedStorage = savedInstanceState.getInt("selectitem", SELECT_0);
        //mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
        adapter.toggleChecked(selectedStorage);
    }

    if (getAppTheme().equals(AppTheme.DARK)) {
        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 (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        setTaskDescription(taskDescription);
    }
}

From source file:com.almalence.opencam.ApplicationScreen.java

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

    sEvPref = getResources().getString(R.string.Preference_EvCompensationValue);
    sSceneModePref = getResources().getString(R.string.Preference_SceneModeValue);
    sWBModePref = getResources().getString(R.string.Preference_WBModeValue);
    sColorTemperaturePref = getResources().getString(R.string.Preference_ColorTemperatureValue);
    sFrontFocusModePref = getResources().getString(R.string.Preference_FrontFocusModeValue);
    sFrontFocusModeVideoPref = getResources().getString(R.string.Preference_FrontFocusModeVideoValue);
    sRearFocusModePref = getResources().getString(R.string.Preference_RearFocusModeValue);
    sRearFocusModeVideoPref = getResources().getString(R.string.Preference_RearFocusModeVideoValue);
    sFrontColorEffectPref = getResources().getString(R.string.Preference_FrontColorEffectValue);
    sRearColorEffectPref = getResources().getString(R.string.Preference_RearColorEffectValue);
    sFlashModePref = getResources().getString(R.string.Preference_FlashModeValue);
    sISOPref = getResources().getString(R.string.Preference_ISOValue);
    sMeteringModePref = getResources().getString(R.string.Preference_MeteringModeValue);
    sExposureTimePref = getResources().getString(R.string.Preference_ExposureTimeValue);
    sExposureTimeModePref = getResources().getString(R.string.Preference_ExposureTimeModeValue);
    sRealExposureTimeOnPreviewPref = getResources()
            .getString(R.string.Preference_RealExposureTimeOnPreviewValue);
    sFocusDistancePref = getResources().getString(R.string.Preference_FocusDistanceValue);
    sFocusDistanceModePref = getResources().getString(R.string.Preference_FocusDistanceModeValue);
    sCameraModePref = getResources().getString(R.string.Preference_CameraModeValue);

    sUseFrontCameraPref = getResources().getString(R.string.Preference_UseFrontCameraValue);

    sImageSizeRearPref = getResources().getString(R.string.Preference_ImageSizeRearValue);
    sImageSizeFrontPref = getResources().getString(R.string.Preference_ImageSizeFrontValue);
    sImageSizeSonyRemotePref = getResources().getString(R.string.Preference_ImageSizeSonyRemoteValue);

    sImageSizeMultishotBackPref = getResources()
            .getString(R.string.Preference_ImageSizePrefSmartMultishotBackValue);
    sImageSizeMultishotFrontPref = getResources()
            .getString(R.string.Preference_ImageSizePrefSmartMultishotFrontValue);
    sImageSizeMultishotSonyRemotePref = getResources()
            .getString(R.string.Preference_ImageSizePrefSmartMultishotSonyRemoteValue);

    sImageSizePanoramaBackPref = getResources().getString(R.string.Preference_ImageSizePrefPanoramaBackValue);
    sImageSizePanoramaFrontPref = getResources().getString(R.string.Preference_ImageSizePrefPanoramaFrontValue);

    sImageSizeVideoBackPref = getResources().getString(R.string.Preference_ImageSizePrefVideoBackValue);
    sImageSizeVideoFrontPref = getResources().getString(R.string.Preference_ImageSizePrefVideoFrontValue);

    sCaptureRAWPref = getResources().getString(R.string.Preference_CaptureRAWValue);

    sJPEGQualityPref = getResources().getString(R.string.Preference_JPEGQualityCommonValue);

    sAntibandingPref = getResources().getString(R.string.Preference_AntibandingValue);

    sExportNamePref = getResources().getString(R.string.Preference_ExportNameValue);
    sExportNameSeparatorPref = getResources().getString(R.string.Preference_ExportNameSeparatorValue);
    sExportNamePrefixPref = getResources().getString(R.string.Preference_SavePathPrefixValue);
    sExportNamePostfixPref = getResources().getString(R.string.Preference_SavePathPostfixValue);
    sSavePathPref = getResources().getString(R.string.Preference_SavePathValue);
    sSaveToPref = getResources().getString(R.string.Preference_SaveToValue);
    sSortByDataPref = getResources().getString(R.string.Preference_SortByDataValue);
    sEnableExifOrientationTagPref = getResources().getString(R.string.Preference_EnableExifTagOrientationValue);
    sAdditionalRotationPref = getResources().getString(R.string.Preference_AdditionalRotationValue);
    sUseGeotaggingPref = getResources().getString(R.string.Preference_UseGeotaggingValue);

    sTimestampDate = getResources().getString(R.string.Preference_TimestampDateValue);
    sTimestampAbbreviation = getResources().getString(R.string.Preference_TimestampAbbreviationValue);
    sTimestampTime = getResources().getString(R.string.Preference_TimestampTimeValue);
    sTimestampGeo = getResources().getString(R.string.Preference_TimestampGeoValue);
    sTimestampSeparator = getResources().getString(R.string.Preference_TimestampSeparatorValue);
    sTimestampCustomText = getResources().getString(R.string.Preference_TimestampCustomTextValue);
    sTimestampColor = getResources().getString(R.string.Preference_TimestampColorValue);
    sTimestampFontSize = getResources().getString(R.string.Preference_TimestampFontSizeValue);

    sAELockPref = getResources().getString(R.string.Preference_AELockValue);
    sAWBLockPref = getResources().getString(R.string.Preference_AWBLockValue);

    sExpoPreviewModePref = getResources().getString(R.string.Preference_ExpoBracketingPreviewModePref);

    sDefaultModeName = getResources().getString(R.string.Preference_DefaultModeName);

    mainContext = this.getBaseContext();
    messageHandler = new Handler(this);
    instance = this;

    surfaceCreated = false;/*w ww.j a v a 2 s.c o  m*/

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ensure landscape orientation
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // set to fullscreen
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

    // set some common view here
    //      setContentView(R.layout.opencamera_main_layout);

    createPluginManager();
    duringOnCreate();

    try {
        cameraController = CameraController.getInstance();
    } catch (VerifyError exp) {
        Log.e("ApplicationScreen", exp.getMessage());
    }
    CameraController.onCreate(ApplicationScreen.instance, ApplicationScreen.instance, pluginManager,
            ApplicationScreen.instance.messageHandler);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    keepScreenOn = prefs.getBoolean("keepScreenOn", false);

    // set preview, on click listener and surface buffers
    //      findViewById(R.id.SurfaceView02).setVisibility(View.GONE);
    //      preview = (SurfaceView) this.findViewById(R.id.SurfaceView01);
    //      preview.setOnClickListener(this);
    //      preview.setOnTouchListener(this);
    //      preview.setKeepScreenOn(true);
    //
    //      surfaceHolder = preview.getHolder();
    //      surfaceHolder.addCallback(this);

    orientListener = new OrientationEventListener(this) {
        @Override
        public void onOrientationChanged(int orientation) {
            // figure landscape or portrait
            if (ApplicationScreen.instance.landscapeIsNormal) {
                orientation += 90;
            }

            if ((orientation < 45) || (orientation > 315 && orientation < 405)
                    || ((orientation > 135) && (orientation < 225))) {
                if (ApplicationScreen.wantLandscapePhoto) {
                    ApplicationScreen.wantLandscapePhoto = false;
                }
            } else {
                if (!ApplicationScreen.wantLandscapePhoto) {
                    ApplicationScreen.wantLandscapePhoto = true;
                }
            }

            // orient properly for video
            if ((orientation > 135) && (orientation < 225))
                orientationMain = 270;
            else if ((orientation < 45) || (orientation > 315))
                orientationMain = 90;
            else if ((orientation < 325) && (orientation > 225))
                orientationMain = 0;
            else if ((orientation < 135) && (orientation > 45))
                orientationMain = 180;

            if (orientationMain != orientationMainPrevious) {
                orientationMainPrevious = orientationMain;
            }
        }
    };

    // prevent power drain
    screenTimer = new CountDownTimer(180000, 180000) {
        public void onTick(long millisUntilFinished) {
            // Not used
        }

        public void onFinish() {
            boolean isVideoRecording = PreferenceManager
                    .getDefaultSharedPreferences(ApplicationScreen.getMainContext())
                    .getBoolean("videorecording", false);
            if (isVideoRecording || keepScreenOn) {
                // restart timer
                screenTimer.start();
                isScreenTimerRunning = true;
                if (preview != null) {
                    preview.setKeepScreenOn(true);
                }
                return;
            }
            if (preview != null) {
                preview.setKeepScreenOn(keepScreenOn);
            }
            isScreenTimerRunning = false;
        }
    };
    screenTimer.start();
    isScreenTimerRunning = true;

    if (this.getIntent().getAction() != null) {
        if (this.getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) {
            try {
                forceFilenameUri = this.getIntent().getExtras().getParcelable(MediaStore.EXTRA_OUTPUT);
                ApplicationScreen.setForceFilename(new File(((Uri) forceFilenameUri).getPath()));
                if (ApplicationScreen.getForceFilename().getAbsolutePath().equals("/scrapSpace")) {
                    ApplicationScreen.setForceFilename(
                            new File(Environment.getExternalStorageDirectory().getAbsolutePath()
                                    + "/mms/scrapSpace/.temp.jpg"));
                    new File(ApplicationScreen.getForceFilename().getParent()).mkdirs();
                }
            } catch (Exception e) {
                ApplicationScreen.setForceFilename(null);
            }
        } else {
            ApplicationScreen.setForceFilename(null);
        }
    } else {
        ApplicationScreen.setForceFilename(null);
    }

    afterOnCreate();
}

From source file:com.quwu.xinwo.release.Release_Activity.java

public void onClick(View v) {
    if (Tool.isFastDoubleClick()) {
        return;/*from   ww  w  . ja v a2 s.  c  o  m*/
    } else {
        switch (v.getId()) {
        case R.id.release_pleyerBtn:// 
            isPlayRecording();
            new CountDownTimer(isRecordingTime(), 1000) {
                public void onTick(long millisUntilFinished) {
                    playerBtn.setText((millisUntilFinished / 1000) + "s");
                    playerBtn.setEnabled(false);
                }

                public void onFinish() {
                    playerBtn.setText((isRecordingTime() / 1000) + "s");
                    playerBtn.setEnabled(true);
                }
            }.start();
            break;
        case R.id.release_saveBtn:// ???

            break;
        case R.id.release_cordeles_questionIamge:// ?
            isQuestionImage("", "??", "", Release_Activity.this);
            break;
        case R.id.release_auction_questionImage:// ??
            isQuestionImage("", "??", "", Release_Activity.this);
            break;
        case R.id.release_rent_out_rentImage:// 
            isQuestionImage("", "??", "", Release_Activity.this);
            break;
        case R.id.release_classifyLin:// 
            // Goods_Category_Pop pop=new
            // Goods_Category_Pop(Release_Activity.this);
            // pop.showPopupWindow(classifyLin);
            Intent intent = new Intent(Release_Activity.this, Area_selection1Activity.class);
            startActivityForResult(intent, 20);
            break;
        case R.id.release_rent_out_rent_yearText:// POP
            showPopupWindow(release_rent_out_rent_yearText, 1);
            releaseLin.setAlpha(0.5f);
            break;
        case R.id.release_rent_out_tenancy_term_yearText:// POP
            showPopupWindow(release_rent_out_tenancy_term_yearText, 2);
            releaseLin.setAlpha(0.5f);
            break;
        case R.id.release_confirmBtn:// ?
            pd.show();
            layout.setAlpha(0.5f);
            if (cordelesBox.isChecked()) {
                new ConfirmTask().executeOnExecutor(Executors.newCachedThreadPool());
            } else if (auctionBox.isChecked()) {
                new ConfirmTask1().executeOnExecutor(Executors.newCachedThreadPool());
            } else if (rent_outBox.isChecked()) {
                new ConfirmTask2().executeOnExecutor(Executors.newCachedThreadPool());
            } else if (freeBox.isChecked()) {
                new ConfirmTask3().executeOnExecutor(Executors.newCachedThreadPool());
            }
            break;
        case R.id.release_cordelesBoxLin:// ?
            cordelesBox.setChecked(true);
            auctionBox.setChecked(false);
            rent_outBox.setChecked(false);
            freeBox.setChecked(false);
            isCheckCordeles();
            break;
        case R.id.release_auctionBoxLin:// ??
            cordelesBox.setChecked(false);
            auctionBox.setChecked(true);
            rent_outBox.setChecked(false);
            freeBox.setChecked(false);
            isCheckAuction();
            break;
        case R.id.release_rent_outBoxLin:// 
            cordelesBox.setChecked(false);
            auctionBox.setChecked(false);
            rent_outBox.setChecked(true);
            freeBox.setChecked(false);
            isCheckRentOut();
            break;
        case R.id.release_freeBoxLin:// ??
            cordelesBox.setChecked(false);
            auctionBox.setChecked(false);
            rent_outBox.setChecked(false);
            freeBox.setChecked(true);
            isCheckFree();
            break;
        case R.id.release_cordeles_Box1Lin:// 
            cordelesBox1.setChecked(true);
            cordelesBox2.setChecked(false);
            break;
        case R.id.release_cordeles_Box2Lin:// 
            cordelesBox2.setChecked(true);
            cordelesBox1.setChecked(false);
            break;
        default:
            break;
        }
    }
}