def doInBackground(self, params): # Unpack the location from the array. location = params[0] try: forecasts = self.fetchData(location) except WeatherException, e: Toast.makeText(self.activity, e.getMessage(), Toast.LENGTH_SHORT).show() return []
def saveSprite(self, spritefileName, spriteName, bitmap): # Create a subdirectory of the SpriteViewer directory for the current # set of sprites. subDir = File(Environment.DIRECTORY_DOWNLOADS, "SpriteViewer") outputFile = Files.createExternalFile(subDir.getPath(), spritefileName, spriteName, "", ".png") stream = BufferedOutputStream(FileOutputStream(outputFile)) bitmap.compress(Bitmap.CompressFormat.PNG, 50, stream) stream.flush() Toast.makeText(self, "Saved " + outputFile.getPath(), Toast.LENGTH_LONG).show()
def onClick(self, v): if self.working: Toast.makeText(self, 'Plz Wait...', Toast.LENGTH_SHORT).show() return None self.working = True Toast.makeText(self, 'FftCal will save outputs in your storage', Toast.LENGTH_LONG).show() mdir = os.environ['EXTERNAL_STORAGE'] + '/FftCal/' if not os.path.exists(mdir): os.makedirs(mdir) t = np.arange(0.0, 105.0001, 0.01) Fs = 1 / (t[1] - t[0]) if os.path.isfile(mdir + 'input.csv'): S = np.loadtxt(mdir + 'input.csv') else: S = 10 * cos(2 * pi * 25 * t + pi / 6) + 5 * cos( 2 * pi * 50 * t + pi / 8 ) + 2 * cos(2 * pi * 75 * t + pi / 3) + 1 * cos( 2 * pi * 8 * t + pi / 7) + 1.5 * cos(2 * pi * 35 * t + pi / 5) print('S.shape', S.shape) [freq, xdft, psdx, phase, complexx] = Mide_FFT_PSD(S, Fs) np.savetxt(mdir + 'freq_xdft_psdx_phase.csv', np.column_stack((freq, xdft, psdx, phase)), delimiter=',') np.savetxt(mdir + 'input_fft.csv', np.column_stack((S, complexx)), delimiter=',') self.working = False
def demo_toast(self, activity): from android.widget import Toast Toast.makeText(activity, R.string.demo_toast_text, Toast.LENGTH_SHORT).show()
def showError(self): Toast.makeText(self, "Failed to read weather forecast,", Toast.LENGTH_SHORT).show()
// TODO Auto-generated method stub finish(); overridePendingTransition(R.anim.slide_in_top, R.anim.slide_out_bottom); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: Toast.makeText(this, "Can be done through Home page only.", Toast.LENGTH_SHORT).show(); return true; case R.id.outdoorvis: if (MainActivity.isBright) { lp.screenBrightness = MainActivity.initBright; getWindow().setAttributes(lp); MainActivity.isBright = false; } else { lp.screenBrightness = 1; getWindow().setAttributes(lp); MainActivity.isBright = true; } return true; } return false;