List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
private void initLayout() { /* get size of screen */ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from ww w . j a v a 2s . c om*/ //size of screen screenWidth = size.x; screenHeight = size.y; FrameLayout.LayoutParams layoutParam = null; LayoutInflater myInflate = null; myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); topLayout = new FrameLayout(this); setContentView(topLayout); mGLView = overlay.getGLView(); // OpenGLview int display_width_d = (int) (1.0 * screenWidth); int display_height_d = (int) (1.0 * screenHeight); int button_width = 0; int button_height = 0; int prev_rw, prev_rh; if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) { prev_rh = display_height_d; button_height = display_height_d; prev_rw = (int) (1.0 * display_height_d * live_width / live_height); button_width = display_width_d - prev_rw; } else { prev_rw = display_width_d; prev_rh = (int) (1.0 * display_width_d * live_height / live_width); } layoutParam = new FrameLayout.LayoutParams(1, 1, Gravity.BOTTOM); Log.d("LAYOUT", "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:" + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:" + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height); Log.d("CameraDebug", "InitLayout acquired camera"); if (CAMERA_PREVIEW) { cameraDevice = openCamera(); cameraView = new CameraView(this, cameraDevice); topLayout.addView(cameraView, layoutParam); } layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER); topLayout.addView(mGLView, layoutParam); FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null); layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight); topLayout.addView(preViewLayout, layoutParam); Log.i(LOG_TAG, "cameara preview start: OK"); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
public void onCreate(Bundle savedInstanceState) { ctx = this.getApplicationContext(); super.onCreate(savedInstanceState); //restore saved instances if necessary if (savedInstanceState != null) { Toast.makeText(HomeScreen.this, savedInstanceState.getString("message"), Toast.LENGTH_LONG).show(); GTConstants.darfileName = savedInstanceState.getString("darfileName"); GTConstants.tarfileName = savedInstanceState.getString("tarfileName"); GTConstants.trpfilename = savedInstanceState.getString("trpfilename"); GTConstants.srpfileName = savedInstanceState.getString("srpfileName"); Utility.setcurrentState(savedInstanceState.getString("currentState")); Utility.setsessionStart(savedInstanceState.getString("getsessionStart")); selectedCode = savedInstanceState.getString("selectedCode"); lunchTime = savedInstanceState.getString("lunchTime"); breakTime = savedInstanceState.getString("breakTime"); signaturefileName = savedInstanceState.getString("signaturefileName"); GTConstants.tourName = savedInstanceState.getString("tourName"); tourTime = savedInstanceState.getString("tourTime"); tourEnd = savedInstanceState.getLong("tourEnd"); lunchoutLocation = savedInstanceState.getInt("lunchoutLocation"); breakoutLocation = savedInstanceState.getInt("breakoutLocation"); touritemNumber = savedInstanceState.getInt("touritemNumber"); chekUpdate = savedInstanceState.getBoolean("chekUpdate"); GTConstants.sendData = savedInstanceState.getBoolean("send_data"); GTConstants.isTour = savedInstanceState.getBoolean("isTour"); GTConstants.isGeoFence = savedInstanceState.getBoolean("isGeoFence"); } else {//from w ww . ja v a2 s .c om //set the current state Utility.setcurrentState(GTConstants.offShift); //set the default startup code to start shift selectedCode = "start_shift"; } /* //Determine screen size if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { Toast.makeText(this, "Large screen",Toast.LENGTH_LONG).show(); } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { Toast.makeText(this, "Normal sized screen" , Toast.LENGTH_LONG).show(); } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { Toast.makeText(this, "Small sized screen" , Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Screen size is neither large, normal or small" , Toast.LENGTH_LONG).show(); } //initialize receiver to monitor for screen on / off /* IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); BroadcastReceiver mReceiver = new ScreenReceiver(); registerReceiver(mReceiver, filter); */ setContentView(R.layout.homescreen); //Create object to call the Database class myDatabase = new GuardTraxDB(this); preferenceDB = new PreferenceDB(this); ftpdatabase = new ftpDataBase(this); gtDB = new GTParams(this); aDB = new accountsDB(this); trafficDB = new trafficDataBase(this); tourDB = new tourDataBase(this); //check for updates if (chekUpdate) { //reset the preference value chekUpdate = false; //check for application updates checkUpdate(); } //initialize the message timer //initializeOnModeTimerEvent(); //get the version number and set it in constants String version_num = ""; PackageManager manager = this.getPackageManager(); try { PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0); version_num = info.versionName.toString(); } catch (NameNotFoundException e) { version_num = "0.00.00"; } GTConstants.version = version_num; //final TextView version = (TextView) findViewById(R.id.textVersion); //version.setText(version_num); //set up the animation animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in buttonClick.setDuration(50); // duration - half a second buttonClick.setInterpolator(new LinearInterpolator()); // do not alter animation rate buttonClick.setRepeatCount(1); // Repeat animation once buttonClick.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in textWarning = (TextView) findViewById(R.id.txtWarning); textWarning.setWidth(500); textWarning.setGravity(Gravity.CENTER); //allow the text to be clicked if necessary textWarning.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (GTConstants.isTour && GTConstants.tourName.length() > 1) displaytourInfo(); } }); //goto scan page button btn_scan_screen = (Button) findViewById(R.id.btn_goto_scan); btn_scan_screen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btn_scan_screen.startAnimation(buttonClick); //Utility.showScan(HomeScreen.this); scan_click(false); } }); //goto report page button btn_report_screen = (Button) findViewById(R.id.btn_goto_report); btn_report_screen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btn_report_screen.startAnimation(buttonClick); report_click(); } }); //goto dial page button btn_dial_screen = (Button) findViewById(R.id.btn_goto_dial); btn_dial_screen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btn_dial_screen.startAnimation(buttonClick); dial_click(); } }); //microphone button btn_mic = (Button) findViewById(R.id.btn_mic); btn_mic.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btn_mic.startAnimation(buttonClick); voice_click(); } }); //camera button btn_camera = (Button) findViewById(R.id.btn_camera); btn_camera.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btn_camera.startAnimation(buttonClick); camera_click(); } }); //video button btn_video = (Button) findViewById(R.id.btn_video); btn_video.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btn_video.startAnimation(buttonClick); video_click(); } }); // Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable. btn_send = (Button) findViewById(R.id.btn_Send); btn_send.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //prevent multiple fast clicking if (SystemClock.elapsedRealtime() - mLastClickTime < 2000) return; mLastClickTime = SystemClock.elapsedRealtime(); incidentcodeSent = true; btn_send.startAnimation(buttonClick); //if start shift has not been sent then the device is in do not send data mode. Warn the user if (Utility.getcurrentState().equals(GTConstants.offShift) && !selectedCode.equals("start_shift")) { show_alert_title = "Error"; show_alert_message = "You must start your shift!"; showAlert(show_alert_title, show_alert_message, true); //set spinner back to start shift spinner.setSelection(0); } else { if (Utility.deviceRegistered()) { show_alert_title = "Success"; show_alert_message = "Action success"; } else { show_alert_title = "Warning"; show_alert_message = "You are NOT registered!"; showAlert(show_alert_title, show_alert_message, true); } if (selectedCode.equals("start_shift")) { //if shift already started if (Utility.getcurrentState().equals(GTConstants.onShift)) { show_alert_title = "Warning"; show_alert_message = "You must end shift!"; showAlert(show_alert_title, show_alert_message, true); //set spinner back to all clear spinner.setSelection(2); } else { ToastMessage.displayToastFromResource(HomeScreen.this, 5, Gravity.CENTER, (ViewGroup) findViewById(R.id.toast_layout_root)); pdialog = ProgressDialog.show(HomeScreen.this, "Please wait", "Starting shift ...", true); //set the current state Utility.setcurrentState(GTConstants.onShift); setuserBanner(); //wait for start shift actions to complete (or timeout occurs) before dismissing wait dialog new CountDownTimer(5000, 1000) { @Override public void onTick(long millisUntilFinished) { if (start_shift_wait) pdialog.dismiss(); } @Override public void onFinish() { if (!(pdialog == null)) pdialog.dismiss(); } }.start(); //create dar file try { //create the dar file name GTConstants.darfileName = GTConstants.LICENSE_ID.substring(7) + "_" + Utility.getUTCDate() + "_" + Utility.getUTCTime() + ".dar"; //write the version to the dar file Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.darfileName, "Version;" + GTConstants.version + "\r\n", false); //write the start shift event to the dar file Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.darfileName, "Start shift;" + GTConstants.currentBatteryPercent + ";" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true); //create the tar file name if module installed if (GTConstants.isTimeandAttendance) { GTConstants.tarfileName = GTConstants.LICENSE_ID.substring(7) + "_" + Utility.getUTCDate() + "_" + Utility.getUTCTime() + ".tar"; //write the start shift event to the tar file Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.tarfileName, "Name;" + GTConstants.report_name + "\r\n" + "Start shift;" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", false); } } catch (Exception e) { Toast.makeText(HomeScreen.this, "error = " + e, Toast.LENGTH_LONG).show(); } GTConstants.sendData = true; //if not time and attendance then send start shift event now, otherwise wait till after location scan send_event("11"); //set the session start time SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yy HH:mm:ss"); Utility.setsessionStart(sdf.format(new Date())); //reset the server connection flag Utility.resetisConnecting(); //start the GPS location service MainService.openLocationListener(); //set spinner back to all clear spinner.setSelection(2); setwarningText(""); if (GTConstants.isTimeandAttendance) { show_taa_scan(true, false); } } } else if (selectedCode.equals("end_shift")) { if (!Utility.getcurrentState().equals(GTConstants.onShift) && GTConstants.isTimeandAttendance) { show_alert_title = "Error"; show_alert_message = "You must end your Lunch / Break!"; showAlert(show_alert_title, show_alert_message, true); //set spinner back to start shift spinner.setSelection(2); } else { btn_send.setEnabled(false); if (GTConstants.isTimeandAttendance) { show_taa_scan(false, true); } else endshiftCode(); } } else { if (Utility.isselectionValid(HomeScreen.this, selectedCode)) { //if time and attendance then write to file if (selectedCode.equalsIgnoreCase(GTConstants.lunchin) || selectedCode.equalsIgnoreCase(GTConstants.lunchout) || selectedCode.equalsIgnoreCase(GTConstants.startbreak) || selectedCode.equalsIgnoreCase(GTConstants.endbreak)) { if (GTConstants.isTimeandAttendance) Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.tarfileName, spinner.getSelectedItem().toString() + ";" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true); if (selectedCode.equalsIgnoreCase(GTConstants.lunchin)) { Utility.setcurrentState(GTConstants.onLunch); Utility.setlunchStart(true); setuserBanner(); } if (selectedCode.equalsIgnoreCase(GTConstants.startbreak)) { Utility.setcurrentState(GTConstants.onBreak); Utility.setbreakStart(true); setuserBanner(); } if (selectedCode.equalsIgnoreCase(GTConstants.lunchout)) { Utility.setcurrentState(GTConstants.onShift); lunchTime = Utility.gettimeDiff(Utility.getlunchStart(), Utility.getLocalDateTime()); setuserBanner(); } if (selectedCode.equalsIgnoreCase(GTConstants.endbreak)) { Utility.setcurrentState(GTConstants.onShift); breakTime = Utility.gettimeDiff(Utility.getbreakStart(), Utility.getLocalDateTime()); setuserBanner(); } } ToastMessage.displayToastFromResource(HomeScreen.this, 5, Gravity.CENTER, (ViewGroup) findViewById(R.id.toast_layout_root)); //save the event description as may be needed for incident report incidentDescription = spinner.getSelectedItem().toString(); //write to dar Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.darfileName, "Event; " + incidentDescription + ";" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true); //write to srp if (GTConstants.srpfileName.length() > 1) Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.srpfileName, "Event; " + incidentDescription + ";" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true); //send the data send_event(selectedCode); //ask if user wants to create an incident report. If the last character is a space, that indicates not to ask for report if (!(incidentDescription.charAt(incidentDescription.length() - 1) == ' ') && !trafficIncident) showYesNoAlert("Report", "Create an Incident Report?", incidentreportScreen); if (!(incidentDescription.charAt(incidentDescription.length() - 1) == ' ') && trafficIncident) showYesNoAlert("Report", "Create a Traffic Violation?", incidentreportScreen); //if last two characters are spaces then ask to write a note if (incidentDescription.charAt(incidentDescription.length() - 1) == ' ' && incidentDescription.charAt(incidentDescription.length() - 2) == ' ') showYesNoAlert("Report", "Create a Note?", createNote); } //set spinner back to required state if (selectedCode.equalsIgnoreCase(GTConstants.lunchin)) spinner.setSelection(lunchoutLocation); else if (selectedCode.equalsIgnoreCase(GTConstants.startbreak)) spinner.setSelection(breakoutLocation); else spinner.setSelection(2); } } } }); //Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle). spinner = (Spinner) findViewById(R.id.spinner_list); //method initialize the spinner action initializeSpinnerControl(); if (GTConstants.service_intent == null) { //Condition to check whether the Database exist and if so load data into constants try { if (preferenceDB.checkDataBase()) { preferenceDB.open(); Cursor cursor = preferenceDB.getRecordByRowID("1"); preferenceDB.close(); if (cursor == null) loadPreferenceDataBase(); else { saveInConstants(cursor); cursor.close(); } syncDB(); syncFTP(); syncftpUpload(); } else { preferenceDB.open(); preferenceDB.close(); //Toast.makeText(HomeScreen.this, "Path = " + preferenceDB.get_path(), Toast.LENGTH_LONG).show(); //Toast.makeText(HomeScreen.this, "No database found", Toast.LENGTH_LONG).show(); loadPreferenceDataBase(); syncDB(); syncFTP(); syncftpUpload(); } } catch (Exception e) { preferenceDB.createDataBase(); loadPreferenceDataBase(); Toast.makeText(HomeScreen.this, "Creating database", Toast.LENGTH_LONG).show(); } //setup the auxiliary databases if (!aDB.checkDataBase()) { aDB.open(); aDB.close(); } if (!ftpdatabase.checkDataBase()) { ftpdatabase.open(); ftpdatabase.close(); } if (!gtDB.checkDataBase()) { gtDB.open(); gtDB.close(); } if (!trafficDB.checkDataBase()) { trafficDB.open(); trafficDB.close(); } if (!tourDB.checkDataBase()) { tourDB.open(); tourDB.close(); } //get the parameters from the parameter database loadGTParams(); //this code starts the main service running which contains all the event timers if (Utility.deviceRegistered()) { //this is the application started event - sent once when application starts up if (savedInstanceState == null) send_event("PU"); initService(); } } //if device not registered than go straight to scan screen if (!Utility.deviceRegistered()) { newRegistration = true; //send_data = true; scan_click(false); } //setup the user banner setuserBanner(); //set the warning text setwarningText(""); }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
private void showPopup() { if (mScrollState != AbsListView.OnScrollListener.SCROLL_STATE_FLING) { return;/*from www.j a v a 2 s. c o m*/ } if (mPopup == null) { PopupWindow p = new PopupWindow(this); p.setFocusable(false); p.setContentView(mPopupPosition); p.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); p.setBackgroundDrawable(null); p.setAnimationStyle(android.R.style.Animation_Dialog); mPopup = p; } if (mNarratives.getWindowVisibility() == View.VISIBLE) { mPopup.showAtLocation(mNarratives, Gravity.CENTER, 0, 0); } }
From source file:com.cubic9.android.droidglove.Main.java
/** * show short message by Toast/*from ww w. j a v a 2s . co m*/ * @param code message code */ private void showToast(int code) { Toast toast = Toast.makeText(Main.this, getString(code), Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:com.sssemil.sonyirremote.ir.ir.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { setContentView(R.layout.settings_ir); main = false;//from www . java2 s . c o m final GetAwItems getAwItems1 = new GetAwItems(ir.this); String ret = getAwItems1.execute().get(); spinner6 = ((Spinner) findViewById(R.id.spinner6)); spinner6.setSelection(0); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ar); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner6.setAdapter(dataAdapter); prepItemBrandArray(); return true; } else if (id == R.id.action_about) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.about)); PackageInfo pInfo = null; String version = "?"; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } version = pInfo.versionName; builder.setMessage(getResources().getString(R.string.license1) + " v" + version + "\n" + getResources().getString(R.string.license2) + "\n" + getResources().getString(R.string.license3) + "\n" + getResources().getString(R.string.license4)); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); return true; } else if (id == R.id.action_exit) { stopIR(); System.exit(0); return true; } else if (id == R.id.action_update) { update(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.photon.phresco.nativeapp.eshop.activity.ProductDetailActivity.java
/** * Create the details sections at the bottom of the screen dynamically * * @param details/*w w w. ja v a2s . c o m*/ * @throws NumberFormatException */ private void renderProdcutDetails(Map<String, String> details) { try { LinearLayout tl = (LinearLayout) findViewById(R.id.product_details_layout); int totalDetails = details.size(); int cnt = 1; PhrescoLogger.info(TAG + "renderProdcutDetails() - totalDetails : " + totalDetails); TextView lblDetailLabel = null; for (Entry<String, String> entry : details.entrySet()) { // Create a TextView to hold the label for product detail lblDetailLabel = new TextView(this); if (cnt == 1) { lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_top); } else if (cnt == totalDetails) { lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_bottom); } else { lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_middle); } lblDetailLabel.setText(entry.getKey() + ": " + entry.getValue()); lblDetailLabel.setGravity(Gravity.CENTER); lblDetailLabel.setTypeface(Typeface.DEFAULT, style.TextViewStyle); lblDetailLabel.setTextColor(Color.WHITE); lblDetailLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f)); tl.addView(lblDetailLabel); cnt++; } } catch (Exception ex) { PhrescoLogger.info(TAG + "renderProdcutDetails - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); ActionBar actionbar = getSupportActionBar(); if (actionbar != null) { actionbar.show();//from ww w .j a va 2 s.co m } // ????APK???????BG???onCreate??Activity?? // Intent?????????????? if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { finish(); return; } if (!isRunningJunit) { setContentView(R.layout.activity_main); FirebaseRemoteConfigUtil.initialize(); LikeView likeView = (LikeView) findViewById(R.id.like_view); likeView.setObjectIdAndType(String.format(getString(R.string.app_googlePlay_url), getPackageName()), LikeView.ObjectType.PAGE); // Create the interstitial. mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_id)); // Create ad request. final AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators .addTestDevice("1BEC3806A9717F2A87F4D1FC2039D5F2") // An device ID ASUS .addTestDevice("64D37FCE47B679A7F4639D180EC4C547").build(); // Begin loading your interstitial. mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdLeftApplication() { super.onAdLeftApplication(); enableNewFunction = true; supportInvalidateOptionsMenu(); } @Override public void onAdClosed() { super.onAdClosed(); // ????????????? if (!enableNewFunction) { // Begin loading your interstitial. mInterstitialAd.loadAd(adRequest); } else { LayoutInflater inflater = LayoutInflater.from(MainActivity.this); final View layout = inflater.inflate(R.layout.new_function_dialog, (ViewGroup) findViewById(R.id.layout_root_new)); new MaterialStyledDialog(MainActivity.this).setTitle("?").setDescription( "????????\n???????????") .setCustomView(layout).setIcon(R.drawable.ic_fiber_new_white_48dp) .setHeaderDrawable(R.drawable.pattern_bg_blue) .setPositive(getString(R.string.ok), null).show(); RealmUtil.insertHistoryItemAsync(realm, createHistoryItemData(), new RealmUtil.realmTransactionCallbackListener() { @Override public void OnSuccess() { } @Override public void OnError() { } }); } } }); // FIXME : ?????? AdView mAdView = (AdView) findViewById(R.id.adView); // mAdView.loadAd(adRequest); DefaultLayoutPromptView promptView = (DefaultLayoutPromptView) findViewById(R.id.prompt_view); final BasePromptViewConfig basePromptViewConfig = new BasePromptViewConfig.Builder() .setUserOpinionQuestionTitle(getString(R.string.prompt_title)) .setUserOpinionQuestionPositiveButtonLabel(getString(R.string.prompt_btn_yes)) .setUserOpinionQuestionNegativeButtonLabel(getString(R.string.prompt_btn_no)) .setPositiveFeedbackQuestionTitle(getString(R.string.prompt_title_feedback)) .setPositiveFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure)) .setPositiveFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow)) .setCriticalFeedbackQuestionTitle(getString(R.string.prompt_title_feedback_2)) .setCriticalFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow)) .setCriticalFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure)) .setThanksTitle(getString(R.string.prompt_thanks)).build(); promptView.applyBaseConfig(basePromptViewConfig); Amplify.getSharedInstance().promptIfReady(promptView); mAnimationBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); int buttonColor = ContextCompat.getColor(this, R.color.colorPrimary); int buttonPressedColor = ContextCompat.getColor(this, R.color.colorPrimaryDark); mbtnStart = (ActionButton) findViewById(R.id.fabStart); mbtnStart.setButtonColor(buttonColor); mbtnStart.setButtonColorPressed(buttonPressedColor); // ? new MaterialIntroView.Builder(this).enableDotAnimation(false).enableIcon(true) .setFocusGravity(FocusGravity.CENTER).setFocusType(Focus.MINIMUM).setDelayMillis(500) .enableFadeAnimation(true).performClick(true).setInfoText(getString(R.string.intro_description)) .setTarget(mbtnStart).setUsageId(TUTORIAL_ID) //THIS SHOULD BE UNIQUE ID .dismissOnTouch(true).show(); mbtnStart.setOnClickListener(this); Intent mAlertServiceIntent = new Intent(MainActivity.this, AlertService.class); // ?????????????(???????) // ???????? if (!Utility.isTabletNotPhone(this)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } mTwitter = TwitterUtility.getTwitterInstance(this); mCallbackURL = getString(R.string.twitter_callback_url); mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button); // Refresh the state of the +1 button each time the activity receives focus. mPlusOneButton.initialize( String.format(getString(R.string.app_googlePlay_url_plusOne), getPackageName()), PLUS_ONE_REQUEST_CODE); RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rtlMain); relativeLayout.setOnClickListener(this); findViewById(R.id.llStepCount).setVisibility(mShouldShowPedometer ? View.VISIBLE : View.INVISIBLE); // // Service?????Activity?Destroy????Activity?????? // // UI?Service????????Service??????????Bind???????? // // Application???? // if (((AlertApplication) getApplication()).IsRunningService()) { // btnIsStarted = false; // setStartButtonFunction(findViewById(R.id.fabStart)); // } // // startService(mAlertServiceIntent); bindService(mAlertServiceIntent, mConnection, Context.BIND_AUTO_CREATE); } mIsToastOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "message", true); mIsVibrationOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "vibrate", true); mToastPosition = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "toastPosition", Gravity.CENTER); mAlertStartAngle = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "progress", ALERT_ANGLE_INITIAL_VALUE) + ALERT_ANGLE_INITIAL_OFFSET; mShouldShowPedometer = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "pedometer", true); // ?????(update??) or ??? enableNewFunction = RealmUtil.hasHistoryItem(realm) || SharedPreferencesUtil.getBoolean(this, AD_STATUS_SHAREDPREF_NAME, "AD_STATUS_SHAREDPREF_NAME", false); }
From source file:com.andfchat.frontend.activities.ChatScreen.java
public void showDescription() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_description, null); int height = (int) (this.height * 0.8f); int width = (int) (this.width * 0.8f); final PopupWindow descriptionPopup = new FListPopupWindow(layout, width, height); descriptionPopup.showAtLocation(chatFragment.getView(), Gravity.CENTER, 0, 0); final TextView descriptionText = (TextView) layout.findViewById(R.id.descriptionText); descriptionText.setText(SmileyReader.addSmileys(this, chatroomManager.getActiveChat().getDescription())); // Enable touching/clicking links in text descriptionText.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.ibm.hellotodoadvanced.MainActivity.java
/** * Launches a dialog for adding a new TodoItem. Called when plus button is tapped. * * @param view The plus button that is tapped. */// www .ja v a 2 s .co m public void addTodo(View view) { final Dialog addDialog = new Dialog(this); // UI settings for dialog pop-up addDialog.setContentView(R.layout.add_edit_dialog); addDialog.setTitle("Add Todo"); TextView textView = (TextView) addDialog.findViewById(android.R.id.title); if (textView != null) { textView.setGravity(Gravity.CENTER); } addDialog.setCancelable(true); Button add = (Button) addDialog.findViewById(R.id.Add); addDialog.show(); // When done is pressed, send POST request to create TodoItem on Bluemix add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText itemToAdd = (EditText) addDialog.findViewById(R.id.todo); final String name = itemToAdd.getText().toString(); // If text was added, continue with normal operations if (!name.isEmpty()) { // Create JSON for new TodoItem, id should be 0 for new items String json = "{\"text\":\"" + name + "\",\"isDone\":false,\"id\":0}"; // Create POST request with the Bluemix Mobile Services SDK and set HTTP headers so Bluemix knows what to expect in the request Request request = new Request(bmsClient.getBluemixAppRoute() + "/api/Items", Request.POST); HashMap headers = new HashMap(); List<String> contentType = new ArrayList<>(); contentType.add("application/json"); List<String> accept = new ArrayList<>(); accept.add("Application/json"); headers.put("Content-Type", contentType); headers.put("Accept", accept); request.setHeaders(headers); request.send(getApplicationContext(), json, new ResponseListener() { // On success, update local list with new TodoItem @Override public void onSuccess(Response response) { Log.i(TAG, "Item " + name + " created successfully"); loadList(); } // On failure, log errors @Override public void onFailure(Response response, Throwable throwable, JSONObject extendedInfo) { String errorMessage = ""; if (response != null) { errorMessage += response.toString() + "\n"; } if (throwable != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); throwable.printStackTrace(pw); errorMessage += "THROWN" + sw.toString() + "\n"; } if (extendedInfo != null) { errorMessage += "EXTENDED_INFO" + extendedInfo.toString() + "\n"; } if (errorMessage.isEmpty()) errorMessage = "Request Failed With Unknown Error."; Log.e(TAG, "addTodo failed with error: " + errorMessage); } }); } // Close dialog when finished, or if no text was added addDialog.dismiss(); } }); }
From source file:com.grass.caishi.cc.activity.AdAddActivity.java
/** * ?uri??/*from www. j a v a2 s. co m*/ * * @param selectedImage */ private String getPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } return picturePath; } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } return file.getAbsolutePath(); } }