List of usage examples for android.app Dialog setContentView
public void setContentView(@NonNull View view)
From source file:ua.mkh.settings.full.MainActivity.java
private void zimowets() { try {/*from w w w.j a va2s . c o m*/ //possibleEmail += "************* Get Registered Yandex Account *************nn"; Account[] accounts = AccountManager.get(this).getAccountsByType("com.yandex.passport"); for (Account account : accounts) { YA = account.name; if (account.name.contains("zimowets.leha") || account.name.contains("elmin0101")) { //do somethin final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_inform); // set the custom dialog components - text, image and button Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); TextView text = (TextView) dialog.findViewById(R.id.text); TextView textB = (TextView) dialog.findViewById(R.id.textBold); text.setText(R.string.zimowets_block); textB.setText(R.string.attention); dialogButton.setTypeface(typefaceRoman); text.setTypeface(typefaceRoman); textB.setTypeface(typefaceBold); // if button is clicked, close the custom dialog dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); dialog.show(); } } Account[] accounts2 = AccountManager.get(this).getAccountsByType("com.google"); for (Account account : accounts2) { G = account.name; //textView2.setText(account.name); account_name = account.name; } } catch (Exception e) { } }
From source file:androidVNC.VncCanvasActivity.java
private void selectColorModel() { // Stop repainting the desktop // because the display is composited! vncCanvas.disableRepaints();//from w w w . ja v a 2 s. com String[] choices = new String[COLORMODEL.values().length]; int currentSelection = -1; for (int i = 0; i < choices.length; i++) { COLORMODEL cm = COLORMODEL.values()[i]; choices[i] = cm.toString(); if (vncCanvas.isColorModel(cm)) currentSelection = i; } final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); ListView list = new ListView(this); list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, choices)); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemChecked(currentSelection, true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { dialog.dismiss(); COLORMODEL cm = COLORMODEL.values()[arg2]; vncCanvas.setColorModel(cm); connection.setColorModel(cm.nameString()); connection.save(database.getWritableDatabase()); //Toast.makeText(VncCanvasActivity.this,"Updating Color Model to " + cm.toString(), Toast.LENGTH_SHORT).show(); } }); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { Log.i(TAG, "Color Model Selector dismissed"); // Restore desktop repaints vncCanvas.enableRepaints(); } }); dialog.setContentView(list); dialog.show(); }
From source file:com.zen.androidhtmleditor.AHEActivity.java
@SuppressLint("NewApi") @Override/* ww w .j av a 2 s.com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setContentView(R.layout.main); SystemBarTintManager tintManager = new SystemBarTintManager(this); // enable status bar tint tintManager.setStatusBarTintEnabled(true); tintManager.setTintColor(Color.parseColor("#4acab4")); SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); Settings.init(settings); //Uncomment this for non Market installs. This will allow version checking. //new Version(this,getVersionName(this,DeveloperToolsActivity.class),"http://androidhtmleditor.com/version.php").execute(); deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID); getOverflowMenu(); getActionBar().setIcon(R.drawable.icon_white); tabactivity = (TabActivity) this; tabHost = tabactivity.getTabHost(); hsv = (HorizontalScrollView) tabactivity.findViewById(R.id.topmenu); mLicenseCheckerCallback = new MyLicenseCheckerCallback(); mChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)), BASE64_PUBLIC_KEY // Your public licensing key. ); mHandler = new Handler(); // doCheck(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (LinearLayout) findViewById(R.id.l1); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* 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) { getActionBar().setTitle("File(s)"); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle("Server"); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { onButtonClickEvent(v); } }); Button disconnect_button = (Button) findViewById(R.id.disconnect_button); disconnect_button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { disconnect(); } }); /* Button button2 = (Button)findViewById(R.id.button2); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { hsv.setVisibility(View.GONE); v.setVisibility(View.GONE); RelativeLayout rl = (RelativeLayout)v.getParent(); Button button1 = (Button)findViewById(R.id.button1); button1.setVisibility(View.VISIBLE); Button button3 = (Button)findViewById(R.id.button3); button3.setVisibility(View.VISIBLE); ImageView logo = (ImageView)findViewById(R.id.logo); logo.setVisibility(View.VISIBLE); TextView slogan = (TextView)findViewById(R.id.appSlogan); slogan.setVisibility(View.VISIBLE); ScrollView frontLayout = (ScrollView)findViewById(R.id.front); frontLayout.setVisibility(View.VISIBLE); TextView appTitle = (TextView)findViewById(R.id.appTitle); appTitle.setVisibility(View.VISIBLE); Button backButton = (Button)rl.findViewById(R.id.backButton); backButton.setVisibility(View.GONE); arrayAdapter.clear(); arrayAdapter.notifyDataSetChanged(); TextView pathInfo = (TextView)rl.findViewById(R.id.path); pathInfo.setText(""); folderPath = ""; //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute(); connectedTo = -1; Toast.makeText(AHEActivity.this, "Disconnected", Toast.LENGTH_SHORT).show(); } });*/ Button button3 = (Button) findViewById(R.id.button3); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent SettingsIntent = new Intent(AHEActivity.this, Settings.class); startActivity(SettingsIntent); } }); /*Button backButton = (Button)findViewById(R.id.backButton); backButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String[] pathBits = folderPath.split("/"); folderPath = ""; for(int i=0;i<pathBits.length-1;i++){ folderPath += pathBits[i]+"/"; } arrayAdapter.clear(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if(currentServers.equals("")){}else{ Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if(l.serverName!="" && l.userName!="" && l.port.trim()!=""){ if(l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")){ new MyFetchTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute(); }else if(l.sftp.equals("3")){ new FetchSSLTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute(); } } } } });*/ TextView pathInfo = (TextView) findViewById(R.id.path); pathInfo.setText(folderPath); lstTest = (ListView) findViewById(R.id.list); // lstTest.setDividerHeight(10); lstTest.setPadding(0, 5, 0, 5); alrts = new ArrayList<String[]>(); arrayAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, alrts); lstTest.setAdapter(arrayAdapter); lstTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) { final View d = v; final CharSequence[] items = { "Delete", "Rename", "Chmod", "Download" }; TextView t = (TextView) v.findViewById(R.id.fileFolderName); final String oldName = t.getText().toString(); final int position = pos; AlertDialog.Builder builder = new AlertDialog.Builder(AHEActivity.this); builder.setTitle("Choose Action"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { AlertDialog.Builder dbuilder = new AlertDialog.Builder(AHEActivity.this); dbuilder.setMessage("Delete this file?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { deleteFile(d); dialog.cancel(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog dalert = dbuilder.create(); dalert.show(); } else if (item == 1) { final Dialog renameDialog = new Dialog(AHEActivity.this); renameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); renameDialog.setContentView(R.layout.renamediag); renameDialog.setCancelable(true); Button closeServer = (Button) renameDialog.findViewById(R.id.closeServer); closeServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { renameDialog.cancel(); } }); Button saveServer = (Button) renameDialog.findViewById(R.id.saveServer); saveServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText themeUrl = (EditText) renameDialog.findViewById(R.id.themeLink); String newName = themeUrl.getText().toString(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { new RenameTask(l.serverName, l.userName, l.passWord, oldName, newName, folderPath, l.sftp, l.port, position).execute(); renameDialog.cancel(); } } } }); renameDialog.show(); } else if (item == 2) { final Dialog chmodDialog = new Dialog(AHEActivity.this); chmodDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); chmodDialog.setContentView(R.layout.chmoddiag); chmodDialog.setCancelable(true); Button closeServer = (Button) chmodDialog.findViewById(R.id.closeServer); closeServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { chmodDialog.cancel(); } }); Button saveServer = (Button) chmodDialog.findViewById(R.id.saveServer); saveServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText themeUrl = (EditText) chmodDialog.findViewById(R.id.themeLink); String perms = themeUrl.getText().toString(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) { new ChmodTask(l.serverName, l.userName, l.passWord, oldName, perms, folderPath, l.sftp, l.port, position).execute(); } else { Toast.makeText(AHEActivity.this, "CHMOD could not be performed on your server via sftp", Toast.LENGTH_SHORT).show(); } chmodDialog.cancel(); } } } }); chmodDialog.show(); } else if (item == 3) { //Make new class to download a file SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) { new DlTask(l.serverName, l.userName, l.passWord, oldName, l.sftp, l.port) .execute(); } } } } //Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> av, View v, int pos, long id) { loadFileFolder(v); } }); }
From source file:ua.mkh.settings.full.MainActivity.java
public void update() { final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); dialog.setContentView(R.layout.activity_update); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; Button ButtonInfo = (Button) dialog.getWindow().findViewById(R.id.button1); TextView time = (TextView) dialog.getWindow().findViewById(R.id.textView1); TextView data = (TextView) dialog.getWindow().findViewById(R.id.textView2); TextView textView3 = (TextView) dialog.getWindow().findViewById(R.id.textView3); TextView textView4 = (TextView) dialog.getWindow().findViewById(R.id.textView4); time.setTypeface(typefaceThin);/*ww w.j a v a2 s . c o m*/ data.setTypeface(typefaceRoman); textView3.setTypeface(typefaceRoman); textView4.setTypeface(typefaceRoman); ButtonInfo.setTypeface(typefaceRoman); ButtonInfo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:foam.starwisp.StarwispBuilder.java
public void Update(final StarwispActivity ctx, final String ctxname, JSONArray arr) { String type = ""; Integer tid = 0;// w w w . j a va 2 s.com String token = ""; try { type = arr.getString(0); tid = arr.getInt(1); token = arr.getString(2); } catch (JSONException e) { Log.e("starwisp", "Error parsing update arguments for " + ctxname + " " + arr.toString() + e.toString()); } final Integer id = tid; //Log.i("starwisp", "Update: "+type+" "+id+" "+token); try { // non widget commands if (token.equals("toast")) { Toast msg = Toast.makeText(ctx.getBaseContext(), arr.getString(3), Toast.LENGTH_SHORT); LinearLayout linearLayout = (LinearLayout) msg.getView(); View child = linearLayout.getChildAt(0); TextView messageTextView = (TextView) child; messageTextView.setTextSize(arr.getInt(4)); msg.show(); return; } if (token.equals("play-sound")) { String name = arr.getString(3); if (name.equals("ping")) { MediaPlayer mp = MediaPlayer.create(ctx, R.raw.ping); mp.start(); } if (name.equals("active")) { MediaPlayer mp = MediaPlayer.create(ctx, R.raw.active); mp.start(); } } if (token.equals("soundfile-start-recording")) { String filename = arr.getString(3); m_SoundManager.StartRecording(filename); } if (token.equals("soundfile-stop-recording")) { m_SoundManager.StopRecording(); } if (token.equals("soundfile-start-playback")) { String filename = arr.getString(3); m_SoundManager.StartPlaying(filename); } if (token.equals("soundfile-stop-playback")) { m_SoundManager.StopPlaying(); } if (token.equals("vibrate")) { Vibrator v = (Vibrator) ctx.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(arr.getInt(3)); } if (type.equals("replace-fragment")) { int ID = arr.getInt(1); String name = arr.getString(2); Fragment fragment = ActivityManager.GetFragment(name); FragmentTransaction ft = ctx.getSupportFragmentManager().beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); //ft.setCustomAnimations( R.animator.fragment_slide_left_enter, // R.animator.fragment_slide_right_exit); //ft.setCustomAnimations( // R.animator.card_flip_right_in, R.animator.card_flip_right_out, // R.animator.card_flip_left_in, R.animator.card_flip_left_out); ft.replace(ID, fragment); ft.addToBackStack(null); ft.commit(); return; } if (token.equals("dialog-fragment")) { FragmentManager fm = ctx.getSupportFragmentManager(); final int ID = arr.getInt(3); final JSONArray lp = arr.getJSONArray(4); final String name = arr.getString(5); final Dialog dialog = new Dialog(ctx); dialog.setTitle("Title..."); LinearLayout inner = new LinearLayout(ctx); inner.setId(ID); inner.setLayoutParams(BuildLayoutParams(lp)); dialog.setContentView(inner); // Fragment fragment = ActivityManager.GetFragment(name); // FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); // fragmentTransaction.add(ID,fragment); // fragmentTransaction.commit(); dialog.show(); /* DialogFragment df = new DialogFragment() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout inner = new LinearLayout(ctx); inner.setId(ID); inner.setLayoutParams(BuildLayoutParams(lp)); return inner; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog ret = super.onCreateDialog(savedInstanceState); Log.i("starwisp","MAKINGDAMNFRAGMENT"); Fragment fragment = ActivityManager.GetFragment(name); FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(1,fragment); fragmentTransaction.commit(); return ret; } }; df.show(ctx.getFragmentManager(), "foo"); */ } if (token.equals("time-picker-dialog")) { final Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); // Create a new instance of TimePickerDialog and return it TimePickerDialog d = new TimePickerDialog(ctx, null, hour, minute, true); d.show(); return; } ; if (token.equals("view")) { //ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse())); File f = new File(arr.getString(3)); Uri fileUri = Uri.fromFile(f); Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(arr.getString(3)); String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); myIntent.setDataAndType(fileUri, mimetype); ctx.startActivity(myIntent); return; } if (token.equals("make-directory")) { File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(3)); file.mkdirs(); return; } if (token.equals("list-files")) { final String name = arr.getString(3); File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(5)); // todo, should probably call callback with empty list if (file != null) { File list[] = file.listFiles(); if (list != null) { String code = "("; for (int i = 0; i < list.length; i++) { code += " \"" + list[i].getName() + "\""; } code += ")"; DialogCallback(ctx, ctxname, name, code); } } return; } if (token.equals("gps-start")) { final String name = arr.getString(3); if (m_LocationManager == null) { m_LocationManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); m_GPS = new DorisLocationListener(m_LocationManager); } m_GPS.Start((StarwispActivity) ctx, name, this, arr.getInt(5), arr.getInt(6)); return; } if (token.equals("sensors-get")) { final String name = arr.getString(3); if (m_SensorHandler == null) { m_SensorHandler = new SensorHandler((StarwispActivity) ctx, this); } m_SensorHandler.GetSensors((StarwispActivity) ctx, name, this); return; } if (token.equals("sensors-start")) { final String name = arr.getString(3); final JSONArray requested_json = arr.getJSONArray(5); ArrayList<Integer> requested = new ArrayList<Integer>(); try { for (int i = 0; i < requested_json.length(); i++) { requested.add(requested_json.getInt(i)); } } catch (JSONException e) { Log.e("starwisp", "Error parsing data in sensors start " + e.toString()); } // start it up... if (m_SensorHandler == null) { m_SensorHandler = new SensorHandler((StarwispActivity) ctx, this); } m_SensorHandler.StartSensors((StarwispActivity) ctx, name, this, requested); return; } if (token.equals("sensors-stop")) { if (m_SensorHandler != null) { m_SensorHandler.StopSensors(); } return; } if (token.equals("walk-draggable")) { final String name = arr.getString(3); int iid = arr.getInt(5); DialogCallback(ctx, ctxname, name, WalkDraggable(ctx, name, ctxname, iid).replace("\\", "")); return; } if (token.equals("delayed")) { final String name = arr.getString(3); final int d = arr.getInt(5); Runnable timerThread = new Runnable() { public void run() { DialogCallback(ctx, ctxname, name, ""); } }; m_Handler.removeCallbacksAndMessages(null); m_Handler.postDelayed(timerThread, d); return; } if (token.equals("network-connect")) { final String name = arr.getString(3); final String ssid = arr.getString(5); m_NetworkManager.Start(ssid, (StarwispActivity) ctx, name, this); return; } if (token.equals("http-request")) { Log.i("starwisp", "http-request called"); if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http request"); final String name = arr.getString(3); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "normal", "", name); } return; } if (token.equals("http-post")) { Log.i("starwisp", "http-post called"); if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http request"); final String name = arr.getString(3); final String url = arr.getString(5); final String data = arr.getString(6); m_NetworkManager.StartRequestThread(url, "post", data, name); } return; } if (token.equals("http-upload")) { if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http ul request"); final String filename = arr.getString(4); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "upload", "", filename); } return; } if (token.equals("http-download")) { if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http dl request"); final String filename = arr.getString(4); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "download", "", filename); } return; } if (token.equals("take-photo")) { photo(ctx, arr.getString(3), arr.getInt(4)); } if (token.equals("bluetooth")) { final String name = arr.getString(3); m_Bluetooth.Start((StarwispActivity) ctx, name, this); return; } if (token.equals("bluetooth-send")) { m_Bluetooth.Write(arr.getString(3)); } if (token.equals("process-image-in-place")) { BitmapCache.ProcessInPlace(arr.getString(3)); } if (token.equals("send-mail")) { final String to[] = new String[1]; to[0] = arr.getString(3); final String subject = arr.getString(4); final String body = arr.getString(5); JSONArray attach = arr.getJSONArray(6); ArrayList<String> paths = new ArrayList<String>(); for (int a = 0; a < attach.length(); a++) { Log.i("starwisp", attach.getString(a)); paths.add(attach.getString(a)); } email(ctx, to[0], "", subject, body, paths); } if (token.equals("date-picker-dialog")) { final Calendar c = Calendar.getInstance(); int day = c.get(Calendar.DAY_OF_MONTH); int month = c.get(Calendar.MONTH); int year = c.get(Calendar.YEAR); final String name = arr.getString(3); // Create a new instance of TimePickerDialog and return it DatePickerDialog d = new DatePickerDialog(ctx, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int month, int day) { DialogCallback(ctx, ctxname, name, day + " " + month + " " + year); } }, year, month, day); d.show(); return; } ; if (token.equals("alert-dialog")) { final String name = arr.getString(3); final String msg = arr.getString(5); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int result = 0; if (which == DialogInterface.BUTTON_POSITIVE) result = 1; DialogCallback(ctx, ctxname, name, "" + result); } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(msg).setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); return; } if (token.equals("ok-dialog")) { final String name = arr.getString(3); final String msg = arr.getString(5); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int result = 0; if (which == DialogInterface.BUTTON_POSITIVE) result = 1; DialogCallback(ctx, ctxname, name, "" + result); } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(msg).setPositiveButton("Ok", dialogClickListener).show(); return; } if (token.equals("start-activity")) { ActivityManager.StartActivity(ctx, arr.getString(3), arr.getInt(4), arr.getString(5)); return; } if (token.equals("start-activity-goto")) { ActivityManager.StartActivityGoto(ctx, arr.getString(3), arr.getString(4)); return; } if (token.equals("finish-activity")) { ctx.setResult(arr.getInt(3)); ctx.finish(); return; } /////////////////////////////////////////////////////////// if (id == 0) { Log.i("starwisp", "Zero ID, aborting..."); return; } // now try and find the widget final View vv = ctx.findViewById(id); if (vv == null) { Log.i("starwisp", "Can't find widget : " + id); return; } // tokens that work on everything if (token.equals("hide")) { vv.setVisibility(View.GONE); return; } if (token.equals("show")) { vv.setVisibility(View.VISIBLE); return; } // only tested on spinners if (token.equals("disabled")) { vv.setAlpha(0.3f); //vv.getSelectedView().setEnabled(false); vv.setEnabled(false); return; } if (token.equals("enabled")) { vv.setAlpha(1.0f); //vv.getSelectedView().setEnabled(true); vv.setEnabled(true); return; } if (token.equals("animate")) { JSONArray trans = arr.getJSONArray(3); final TranslateAnimation animation = new TranslateAnimation(getPixelsFromDp(ctx, trans.getInt(0)), getPixelsFromDp(ctx, trans.getInt(1)), getPixelsFromDp(ctx, trans.getInt(2)), getPixelsFromDp(ctx, trans.getInt(3))); animation.setDuration(1000); animation.setFillAfter(false); animation.setInterpolator(new AnticipateOvershootInterpolator(1.0f)); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { vv.clearAnimation(); Log.i("starwisp", "animation end"); ((ViewManager) vv.getParent()).removeView(vv); //LayoutParams lp = new LayoutParams(imageView.getWidth(), imageView.getHeight()); //lp.setMargins(50, 100, 0, 0); //imageView.setLayoutParams(lp); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { Log.i("starwisp", "animation start"); } }); vv.startAnimation(animation); return; } // tokens that work on everything if (token.equals("set-enabled")) { Log.i("starwisp", "set-enabled called..."); vv.setEnabled(arr.getInt(3) == 1); vv.setClickable(arr.getInt(3) == 1); if (vv.getBackground() != null) { if (arr.getInt(3) == 0) { //vv.setBackgroundColor(0x00000000); vv.getBackground().setColorFilter(0x20000000, PorterDuff.Mode.MULTIPLY); } else { vv.getBackground().setColorFilter(null); } } return; } if (token.equals("background-colour")) { JSONArray col = arr.getJSONArray(3); if (type.equals("linear-layout")) { vv.setBackgroundColor(Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2))); } else { //vv.setBackgroundColor(); vv.getBackground().setColorFilter( Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2)), PorterDuff.Mode.MULTIPLY); } vv.invalidate(); return; } // special cases if (type.equals("linear-layout")) { //Log.i("starwisp","linear-layout update id: "+id); StarwispLinearLayout.Update(this, (LinearLayout) vv, token, ctx, ctxname, arr); return; } if (type.equals("relative-layout")) { StarwispRelativeLayout.Update(this, (RelativeLayout) vv, token, ctx, ctxname, arr); return; } if (type.equals("draggable")) { LinearLayout v = (LinearLayout) vv; if (token.equals("contents")) { v.removeAllViews(); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } } if (token.equals("contents-add")) { JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } } } if (type.equals("button-grid")) { LinearLayout horiz = (LinearLayout) vv; if (token.equals("grid-buttons")) { horiz.removeAllViews(); JSONArray params = arr.getJSONArray(3); String buttontype = params.getString(0); int height = params.getInt(1); int textsize = params.getInt(2); LayoutParams lp = BuildLayoutParams(params.getJSONArray(3)); final JSONArray buttons = params.getJSONArray(4); final int count = buttons.length(); int vertcount = 0; LinearLayout vert = null; for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); if (vertcount == 0) { vert = new LinearLayout(ctx); vert.setId(0); vert.setOrientation(LinearLayout.VERTICAL); horiz.addView(vert); } vertcount = (vertcount + 1) % height; if (buttontype.equals("button")) { Button b = new Button(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } else if (buttontype.equals("toggle")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg); } }); vert.addView(b); } else if (buttontype.equals("single")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); int bid = button.getInt(0); if (bid != v.getId()) { ToggleButton tb = (ToggleButton) ctx.findViewById(bid); tb.setChecked(false); } } } catch (JSONException e) { Log.e("starwisp", "Error parsing on click data " + e.toString()); } CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } } } } /* if (type.equals("grid-layout")) { GridLayout v = (GridLayout)vv; if (token.equals("contents")) { v.removeAllViews(); JSONArray children = arr.getJSONArray(3); for (int i=0; i<children.length(); i++) { Build(ctx,ctxname,new JSONArray(children.getString(i)), v); } } } */ if (type.equals("view-pager")) { ViewPager v = (ViewPager) vv; if (token.equals("switch")) { v.setCurrentItem(arr.getInt(3)); } if (token.equals("pages")) { final JSONArray items = arr.getJSONArray(3); v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) { @Override public int getCount() { return items.length(); } @Override public Fragment getItem(int position) { try { String fragname = items.getString(position); return ActivityManager.GetFragment(fragname); } catch (JSONException e) { Log.e("starwisp", "Error parsing pages data " + e.toString()); } return null; } }); } } if (type.equals("image-view")) { ImageView v = (ImageView) vv; if (token.equals("image")) { int iid = ctx.getResources().getIdentifier(arr.getString(3), "drawable", ctx.getPackageName()); v.setImageResource(iid); } if (token.equals("external-image")) { v.setImageBitmap(BitmapCache.Load(arr.getString(3))); } return; } if (type.equals("text-view") || type.equals("debug-text-view")) { TextView v = (TextView) vv; if (token.equals("text")) { if (type.equals("debug-text-view")) { //v.setMovementMethod(new ScrollingMovementMethod()); } v.setText(Html.fromHtml(arr.getString(3)), BufferType.SPANNABLE); // v.invalidate(); } if (token.equals("file")) { v.setText(LoadData(arr.getString(3))); } return; } if (type.equals("edit-text")) { EditText v = (EditText) vv; if (token.equals("text")) { v.setText(arr.getString(3)); } if (token.equals("request-focus")) { v.requestFocus(); InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); } return; } if (type.equals("button")) { Button v = (Button) vv; if (token.equals("text")) { v.setText(arr.getString(3)); } if (token.equals("listener")) { final String fn = arr.getString(3); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { m_Scheme.eval("(" + fn + ")"); } }); } return; } if (type.equals("toggle-button")) { ToggleButton v = (ToggleButton) vv; if (token.equals("text")) { v.setText(arr.getString(3)); return; } if (token.equals("checked")) { if (arr.getInt(3) == 0) v.setChecked(false); else v.setChecked(true); return; } if (token.equals("listener")) { final String fn = arr.getString(3); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { m_Scheme.eval("(" + fn + ")"); } }); } return; } if (type.equals("canvas")) { StarwispCanvas v = (StarwispCanvas) vv; if (token.equals("drawlist")) { v.SetDrawList(arr.getJSONArray(3)); } return; } if (type.equals("camera-preview")) { final CameraPreview v = (CameraPreview) vv; if (token.equals("take-picture")) { final String path = ((StarwispActivity) ctx).m_AppDir + arr.getString(3); v.TakePicture(new PictureCallback() { public void onPictureTaken(byte[] input, Camera camera) { Bitmap original = BitmapFactory.decodeByteArray(input, 0, input.length); Bitmap resized = Bitmap.createScaledBitmap(original, PHOTO_WIDTH, PHOTO_HEIGHT, true); ByteArrayOutputStream blob = new ByteArrayOutputStream(); resized.compress(Bitmap.CompressFormat.JPEG, 100, blob); String datetime = getDateTime(); String filename = path + datetime + ".jpg"; SaveData(filename, blob.toByteArray()); v.Shutdown(); ctx.finish(); } }); } // don't shut the activity down and use provided path if (token.equals("take-picture-cont")) { final String path = ((StarwispActivity) ctx).m_AppDir + arr.getString(3); Log.i("starwisp", "take-picture-cont fired"); v.TakePicture(new PictureCallback() { public void onPictureTaken(byte[] input, Camera camera) { Log.i("starwisp", "on picture taken..."); // the version used by the uav app Bitmap original = BitmapFactory.decodeByteArray(input, 0, input.length); //Bitmap resized = Bitmap.createScaledBitmap(original, PHOTO_WIDTH, PHOTO_HEIGHT, true); ByteArrayOutputStream blob = new ByteArrayOutputStream(); original.compress(Bitmap.CompressFormat.JPEG, 95, blob); original.recycle(); String filename = path; Log.i("starwisp", path); SaveData(filename, blob.toByteArray()); // burn gps into exif data if (m_GPS.currentLocation != null) { double latitude = m_GPS.currentLocation.getLatitude(); double longitude = m_GPS.currentLocation.getLongitude(); try { ExifInterface exif = new ExifInterface(filename); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, GPS.convert(latitude)); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, GPS.latitudeRef(latitude)); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, GPS.convert(longitude)); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, GPS.longitudeRef(longitude)); exif.saveAttributes(); } catch (IOException e) { Log.i("starwisp", "Couldn't open " + filename + " to add exif data: ioexception caught."); } } v.TakenPicture(); } }); } if (token.equals("shutdown")) { v.Shutdown(); } return; } if (type.equals("seek-bar")) { SeekBar v = new SeekBar(ctx); if (token.equals("max")) { // android seekbar bug workaround int p = v.getProgress(); v.setMax(0); v.setProgress(0); v.setMax(arr.getInt(3)); v.setProgress(1000); // not working.... :( } } if (type.equals("spinner")) { Spinner v = (Spinner) vv; if (token.equals("selection")) { v.setSelection(arr.getInt(3)); } if (token.equals("array")) { final JSONArray items = arr.getJSONArray(3); ArrayList<String> spinnerArray = new ArrayList<String>(); for (int i = 0; i < items.length(); i++) { spinnerArray.add(items.getString(i)); } ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, R.layout.spinner_item, spinnerArray) { public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface); return v; } }; spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout); v.setAdapter(spinnerArrayAdapter); final int wid = id; // need to update for new values v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> a, View v, int pos, long id) { CallbackArgs(ctx, ctxname, wid, "" + pos); } public void onNothingSelected(AdapterView<?> v) { } }); } return; } if (type.equals("draw-map")) { DrawableMap v = m_DMaps.get(id); if (v != null) { if (token.equals("polygons")) { v.UpdateFromJSON(arr.getJSONArray(3)); } if (token.equals("centre")) { JSONArray tokens = arr.getJSONArray(3); v.Centre(tokens.getDouble(0), tokens.getDouble(1), tokens.getInt(2)); } if (token.equals("layout")) { v.m_parent.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); } } else { Log.e("starwisp", "Asked to update a drawmap which doesn't exist"); } } } catch (JSONException e) { Log.e("starwisp", "Error parsing builder data " + e.toString()); Log.e("starwisp", "type:" + type + " id:" + id + " token:" + token); } }
From source file:com.mitre.holdshort.MainActivity.java
private void showNotSupportedDialog(String airport) { final Dialog dialog = new Dialog(MainActivity.this); OnCancelListener notSupportedCancelListener = null; notSupportedCancelListener = new OnCancelListener() { @Override/*from w w w. ja v a 2 s . c o m*/ public void onCancel(DialogInterface dialog) { dialog.dismiss(); finish(); } }; OnClickListener noAirportClickListener = new OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.exit: dialog.dismiss(); finish(); break; case R.id.contactMitre: Log.d(LOG_TAG, "TEST"); contactMITRE("RIPPLE App Support"); case R.id.uploadData: AlertLogger al = new AlertLogger("999", MainActivity.this); default: return; } } }; if (airport == null) { dialog.setOnCancelListener(notSupportedCancelListener); dialog.setContentView(R.layout.no_airport_found_dialog); dialog.setTitle("No Airport Found!"); dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); Button exit = (Button) dialog.findViewById(R.id.exit); Button contact = (Button) dialog.findViewById(R.id.contactMitre); Button uploadData = (Button) dialog.findViewById(R.id.uploadData); contact.setOnClickListener(noAirportClickListener); exit.setOnClickListener(noAirportClickListener); uploadData.setOnClickListener(noAirportClickListener); dialog.show(); } else { dialog.setOnCancelListener(notSupportedCancelListener); dialog.setContentView(R.layout.airport_not_supported_dialog); dialog.setTitle("Airport " + (airport.split("_"))[0] + " Not Supported"); dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); Button exit = (Button) dialog.findViewById(R.id.exit); Button contact = (Button) dialog.findViewById(R.id.contactMitre); contact.setOnClickListener(noAirportClickListener); exit.setOnClickListener(noAirportClickListener); dialog.show(); } }
From source file:net.kjmaster.cookiemom.booth.add.AddBoothDialogFragment.java
private void showDateTimeDialog() { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) getActivity().getLayoutInflater() .inflate(R.layout.ui_date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); // Check is system is set to use 24h time (this doesn't seem to work as expected though) final String timeS = android.provider.Settings.System.getString(getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); // Update demo TextViews when the "OK" button is clicked mDateTimeDialogView.findViewById(R.id.SetDateTime).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); // TODO Auto-generated method stub String eventDate = SimpleDateFormat.getDateInstance(DateFormat.LONG) .format(new Date(mDateTimePicker.getDateTimeMillis())); ((TextView) getActivity().findViewById(R.id.Date)).setText(eventDate); if (mDateTimePicker.is24HourView()) { ((TextView) getActivity().findViewById(R.id.Time)).setText( mDateTimePicker.get(Calendar.HOUR_OF_DAY) + ":" + mDateTimePicker.get(Calendar.MINUTE)); } else { NumberFormat fmt = NumberFormat.getNumberInstance(); fmt.setMinimumIntegerDigits(2); ((TextView) getActivity().findViewById(R.id.Time)) .setText(fmt.format(mDateTimePicker.get(Calendar.HOUR)) + ":" + fmt.format(mDateTimePicker.get(Calendar.MINUTE)) + " " + (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM")); }// w ww . j av a2s . c o m hiddenDateTime.setText(String.valueOf(mDateTimePicker.getDateTimeMillis())); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked mDateTimeDialogView.findViewById(R.id.CancelDialog).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is clicked mDateTimeDialogView.findViewById(R.id.ResetDateTime).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); }
From source file:org.anurag.file.quest.TaskerActivity.java
/** * FUNCTION MAKE 3d LIST VIEW VISIBLE OR GONE AS PER REQUIREMENT * @param mode/*from ww w. jav a 2 s .c o m*/ * @param con */ public static void load_FIle_Gallery(final int mode) { final Dialog pDialog = new Dialog(mContext, R.style.custom_dialog_theme); final Handler handle = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case 0: try { pDialog.setContentView(R.layout.p_dialog); pDialog.setCancelable(false); pDialog.getWindow().getAttributes().width = size.x * 4 / 5; WebView web = (WebView) pDialog.findViewById(R.id.p_Web_View); web.loadUrl("file:///android_asset/Progress_Bar_HTML/index.html"); web.setEnabled(false); pDialog.show(); } catch (InflateException e) { error = true; Toast.makeText(mContext, "An exception encountered please wait while loading" + " file list", Toast.LENGTH_SHORT).show(); } break; case 1: if (pDialog != null) if (pDialog.isShowing()) pDialog.dismiss(); if (mediaFileList.size() > 0) { FILE_GALLEY.setVisibility(View.GONE); LIST_VIEW_3D.setVisibility(View.VISIBLE); element = new MediaElementAdapter(mContext, R.layout.row_list_1, mediaFileList); //AT THE PLACE OF ELEMENT YOU CAN USE MUSIC ADAPTER.... // AND SEE WHAT HAPPENS if (mediaFileList.size() > 0) { LIST_VIEW_3D.setAdapter(element); LIST_VIEW_3D.setEnabled(true); } else if (mediaFileList.size() == 0) { LIST_VIEW_3D.setAdapter(new EmptyAdapter(mContext, R.layout.row_list_3, EMPTY)); LIST_VIEW_3D.setEnabled(false); } LIST_VIEW_3D.setDynamics(new SimpleDynamics(0.7f, 0.6f)); if (!elementInFocus) { mFlipperBottom.showPrevious(); mFlipperBottom.setAnimation(prevAnim()); elementInFocus = true; } if (SEARCH_FLAG) { mVFlipper.showPrevious(); mVFlipper.setAnimation(nextAnim()); } } else { LIST_VIEW_3D.setVisibility(View.GONE); FILE_GALLEY.setVisibility(View.VISIBLE); Toast.makeText(mContext, R.string.empty, Toast.LENGTH_SHORT).show(); if (elementInFocus) { mFlipperBottom.showNext(); mFlipperBottom.setAnimation(nextAnim()); } elementInFocus = false; } break; } } }; Thread thread = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub handle.sendEmptyMessage(0); while (!Utils.loaded) { //STOPPING HERE WHILE FILES ARE BEING LOADED IN BACKGROUND.... } if (mode == 0) mediaFileList = Utils.music; else if (mode == 1) mediaFileList = Utils.apps; else if (mode == 2) mediaFileList = Utils.doc; else if (mode == 3) mediaFileList = Utils.img; else if (mode == 4) mediaFileList = Utils.vids; else if (mode == 5) mediaFileList = Utils.zip; else if (mode == 6) mediaFileList = Utils.mis; handle.sendEmptyMessage(1); } }); thread.start(); }
From source file:com.citrus.sample.WalletPaymentFragment.java
private void showSavedAccountsDialog() { final Dialog dialog = new Dialog(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_saved_cards, null); RecyclerView recyclerViewSavedAcc = (RecyclerView) view.findViewById(R.id.recycler_view_saved_options); if (walletList != null && walletList.size() > 0) { recyclerViewSavedAcc.setAdapter(savedOptionsAdapter); } else {//from www. j a va 2 s.c o m // In case there are no saved accounts. recyclerViewSavedAcc.setVisibility(View.GONE); view.findViewById(R.id.noSavedAccTextViewId).setVisibility(View.VISIBLE); } // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView recyclerViewSavedAcc.setHasFixedSize(true); // use a linear layout manager RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); recyclerViewSavedAcc.setLayoutManager(mLayoutManager); recyclerViewSavedAcc.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View childView, int position) { PaymentOption paymentOption = getItem(position); dialog.dismiss(); if (paymentOption instanceof CardOption) { if (mCitrusClient.isOneTapPaymentEnabledForCard((CardOption) paymentOption)) { otherPaymentOption = paymentOption; //otherPaymentOption.setTransactionAmount(new Amount(amount)); } else { showCvvPrompt(paymentOption); } } else { otherPaymentOption = paymentOption; //otherPaymentOption.setTransactionAmount(new Amount(amount)); } } @Override public void onItemLongPress(View childView, int position) { } })); dialog.setContentView(view); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
@SuppressLint("InflateParams") private void aboutSMBSync() { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.about_dialog_title_view); final TextView title = (TextView) dialog.findViewById(R.id.about_dialog_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(getString(R.string.msgs_dlg_title_about) + "(Ver " + packageVersionName + ")"); // get our tabHost from the xml final TabHost tab_host = (TabHost) dialog.findViewById(R.id.about_tab_host); tab_host.setup();/*from ww w . j a va 2 s . c om*/ final TabWidget tab_widget = (TabWidget) dialog.findViewById(android.R.id.tabs); if (Build.VERSION.SDK_INT >= 11) { tab_widget.setStripEnabled(false); tab_widget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); } CustomTabContentView tabViewProf = new CustomTabContentView(this, getString(R.string.msgs_about_dlg_func_btn)); tab_host.addTab(tab_host.newTabSpec("func").setIndicator(tabViewProf).setContent(android.R.id.tabcontent)); CustomTabContentView tabViewHist = new CustomTabContentView(this, getString(R.string.msgs_about_dlg_change_btn)); tab_host.addTab( tab_host.newTabSpec("change").setIndicator(tabViewHist).setContent(android.R.id.tabcontent)); LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout ll_func = (LinearLayout) vi.inflate(R.layout.about_dialog_func, null); LinearLayout ll_change = (LinearLayout) vi.inflate(R.layout.about_dialog_change, null); final WebView func_view = (WebView) ll_func.findViewById(R.id.about_dialog_function); func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_func_desc)); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); func_view.getSettings().setBuiltInZoomControls(true); final WebView change_view = (WebView) ll_change.findViewById(R.id.about_dialog_change_history); change_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_change_desc)); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setBuiltInZoomControls(true); final CustomViewPagerAdapter mAboutViewPagerAdapter = new CustomViewPagerAdapter(this, new WebView[] { func_view, change_view }); final CustomViewPager mAboutViewPager = (CustomViewPager) dialog.findViewById(R.id.about_view_pager); // mMainViewPager.setBackgroundColor(mThemeColorList.window_color_background); mAboutViewPager.setAdapter(mAboutViewPagerAdapter); mAboutViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // util.addDebugMsg(2,"I","onPageSelected entered, pos="+position); tab_widget.setCurrentTab(position); tab_host.setCurrentTab(position); } @Override public void onPageScrollStateChanged(int state) { // util.addDebugMsg(2,"I","onPageScrollStateChanged entered, state="+state); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // util.addDebugMsg(2,"I","onPageScrolled entered, pos="+position); } }); tab_host.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { util.addDebugMsg(2, "I", "onTabchanged entered. tab=" + tabId); mAboutViewPager.setCurrentItem(tab_host.getCurrentTab()); } }); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); CommonDialog.setDlgBoxSizeLimit(dialog, true); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); dialog.show(); }