Skip to content

Instantly share code, notes, and snippets.

@Kozlov-V
Kozlov-V / andrlayout
Created April 21, 2013 16:15
Android layout, так, например, можно получить размеры
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Log.v("Log", "" + findViewById(R.id.qqq).getWidth());
}
}, 100);
@Kozlov-V
Kozlov-V / andrlayoutxml
Created April 21, 2013 16:38
To provide a special layout for landscape, including while on large screens, then you need to use both the large and land qualifier:
MyProject/
res/
layout/ # default (portrait)
main.xml
layout-land/ # landscape
main.xml
layout-large/ # large (portrait)
main.xml
layout-large-land/ # large landscape
main.xml
@Kozlov-V
Kozlov-V / andrcam
Last active December 16, 2015 11:58
Пример кода для работы с камерой. Задача этого кода, подогнать соотношение сторон окна (экрана телефона) и соотношения сторон кадра с камеры и повернуть изображение соответственно ориентации телефона.
Size previewSize = camera.getParameters().getPreviewSize();
float aspect = (float) previewSize.width / previewSize.height;
int previewSurfaceWidth = preview.getWidth();
int previewSurfaceHeight = preview.getHeight();
LayoutParams lp = preview.getLayoutParams();
if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)
{
// портретный вид
#!/bin/sh
mkdir ~/down/
cd ~/down/
sudo apt-get install build-essential
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xzf Python-2.7.2.tgz
cd Python-2.7.2
sudo apt-get install libsqlite3-dev zlib1g-dev libncurses5-dev
sudo apt-get install libgdbm-dev libbz2-dev libreadline5-dev
sudo apt-get install libssl-dev libdb-dev
%%%-------------------------------------------------------------------
%%% @author egobrain <egobrain@linux-ympb>
%%% @copyright (C) 2012, egobrain
%%% @doc
%%% Function for uploading files and properties,which were sent as a
%%% multipart. Files are stored in tmp_folder with random name,
%%% generated by tmp_filename function.
%%% @end
%%% Created : 25 Mar 2012 by egobrain <egobrain@linux-ympb>
%%%-------------------------------------------------------------------
@Kozlov-V
Kozlov-V / gist:6129942
Last active September 13, 2016 02:56
Android Button
public class Demo extends Activity {
private View.OnClickListener curlPostListener;
private Button curlPost;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InitializeApp();
}
@Kozlov-V
Kozlov-V / file_to_ins.java
Last active December 20, 2015 13:19
file to inputstream
File file = ...
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
@Kozlov-V
Kozlov-V / file_list.java
Created August 2, 2013 13:33
FIle dir to list
void ================================================
File dir = new File ("data/user/VRP");
List<File> files = null;
try {
files = getFileListing(dir);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
======================================================
static public List<File> getFileListing(
@Kozlov-V
Kozlov-V / actionModule
Last active December 22, 2015 00:19
ActionProcessing
P = spawn(actionModule,doAction1, [Params]),
P ! {self(), "Hello"}.
receive
{StartDoAction2} ->
doAction2(Params),
P2 =spawn(actionModule,doAction3, [Params]),
end.
doAction2(Params) -> doAnyAction. %% Выполнение POST запроса, ожидаем ответ 200
<resources>
<!-- Style you can use with a container (typically a horizontal
LinearLayout) to get the standard "button bar" background and
spacing. @hide -->
<style name="ButtonBar">
<item name="android:paddingTop">5dip</item>
<item name="android:paddingStart">4dip</item>
<item name="android:paddingEnd">4dip</item>
<item name="android:paddingBottom">1dip</item>
<item name="android:background">@android:drawable/bottom_bar</item>