トリック
アプリ
■特徴
・このアプリを使って6秒動画を撮影できる
・撮影画面をタップしている間だけ撮影可能
・6秒以内なら何度も撮影可能
・前回タップして撮影下部分がうっすら見えた状態で次のシーンを撮影できる
・保存してある動画を組み込み可能
・撮影した部分をカット可能
・撮影した動画はVineに投稿可能
サイト
■Vine
興味があればこちらもご利用ください。
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"></uses-permission>
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == REQUEST_GALLERY && resultCode == RESULT_OK)
{
try {
InputStream in = getContentResolver().openInputStream(data.getData());
Bitmap img = BitmapFactory.decodeStream(in);
in.close();
// 選択した画像をアイコン(ショートカット)として追加
shortcutAdd(getString(R.string.app_name), img);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/*********************************************************************
* アイコン(ショートカット)の作成
*********************************************************************/
private void shortcutAdd(String name, Bitmap bmp)
{
// Delete Shortcut
shortcutDel(name);
// Intent to be send, when shortcut is pressed by user ("launched")
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName(this, MainActivity.class.getName());
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bmp, 128, 128, true);
// Decorate the shortcut
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, scaledBitmap);
//addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
// Inform launcher to create shortcut
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(addIntent);
}
/*********************************************************************
* アイコン(ショートカット)の削除
*********************************************************************/
private void shortcutDel(String name)
{
// Intent to be send, when shortcut is pressed by user ("launched")
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName(this, MainActivity.class.getName());
// Decorate the shortcut
Intent delIntent = new Intent();
delIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
delIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
// Inform launcher to remove shortcut
delIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
sendBroadcast(delIntent);
}
//////////////////////////////////
@Override
public void onSaveInstanceState(final Bundle outState)
{
super.onSaveInstanceState(outState);
outState.putInt("KEY_FRAGMENT_ID", mListID);
outState.putString("KEY_FRAGMENT_SITENAMES", mSiteNameS);
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null)
{
mListID = savedInstanceState.getInt("KEY_FRAGMENT_ID");
mSiteNameS = savedInstanceState.getString("KEY_FRAGMENT_SITENAMES");
}
}
//////////////////////////////////
//////////////////////////////////
final ActionBar actionBar = getActionBar();
// タイトルバーを消去
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
//////////////////////////////////
import android.os.Parcel;
import android.os.Parcelable;
/***********************************************************************
* RSS情報アイテムクラス
***********************************************************************/
public class RssItem implements Parcelable
{
// 記事のサイト名
private CharSequence mSiteName;
// 記事のタイトル
private CharSequence mTitle;
// 記事の日付
private CharSequence mDate;
// 記事のリンク
private CharSequence mLink;
// 記事のカテゴリ
private CharSequence mCategory;
// コンストラクタ
public RssItem()
{
mSiteName = "";
mTitle = "";
mDate = "";
mLink = "";
mCategory = "";
}
private RssItem(Parcel in)
{
mSiteName = in.readString();
mTitle = in.readString();
mDate = in.readString();
mLink = in.readString();
mCategory = in.readString();
}
/***********************************************************************
* 日付の取得・セット
***********************************************************************/
public CharSequence getDate() {
return mDate;
}
public void setDate(CharSequence date) {
mDate = date;
}
/***********************************************************************
* タイトルの取得・セット
***********************************************************************/
public CharSequence getTitle() {
return mTitle;
}
public void setTitle(CharSequence title) {
mTitle = title;
}
/***********************************************************************
* サイト名の取得・セット
***********************************************************************/
public CharSequence getSiteName() {
return mSiteName;
}
public void setSiteName(CharSequence name) {
mSiteName = name;
}
/***********************************************************************
* リンクの取得・セット
***********************************************************************/
public CharSequence getLink() {
return mLink;
}
public void setLink(CharSequence link) {
mLink = link;
}
/***********************************************************************
* カテゴリの取得・セット
***********************************************************************/
public CharSequence getCategory() {
return mCategory;
}
public void setCategory(CharSequence category) {
mCategory = category;
}
@Override
public int describeContents()
{
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags)
{
out.writeString(mSiteName.toString());
out.writeString(mTitle.toString());
out.writeString(mDate.toString());
out.writeString(mLink.toString());
out.writeString(mCategory.toString());
}
public static final Parcelable.Creator CREATOR
= new Parcelable.Creator()
{
public RssItem createFromParcel(Parcel in)
{
return new RssItem(in);
}
public RssItem[] newArray(int size)
{
return new RssItem[size];
}
};
}
// 判定用
boolean IsItemTag(String tag){ return (tag.equals("entry") || tag.equals("item")); }
boolean IsTitleTag(String tag){ return tag.equals("title"); }
boolean IsDateTag(String tag){ return (tag.equals("issued") || tag.equals("date")); }
boolean IsLinkTag(String tag){ return tag.equals("link"); }
boolean IsSubjectTag(String tag){ return tag.equals("subject"); }
/*******************************************************************************
* XMLをパースする
*
* @param InputStream is : XMLテキスト
*******************************************************************************/
public void parseXml(InputStream is) throws IOException, XmlPullParserException
{
// パーサー準備
XmlPullParser parser = Xml.newPullParser();
try
{
parser.setInput(is, null);
int eventType = parser.getEventType();
RssItem currentItem = null;
while (eventType != XmlPullParser.END_DOCUMENT)
{
String tag = null;
switch (eventType)
{
// 開始タグの判定
case XmlPullParser.START_TAG:
tag = parser.getName();
if (IsItemTag(tag))
{
// <item><entry>の場合、RssItemクラス生成
currentItem = new RssItem();
}
else if (currentItem != null)
{
if (IsTitleTag(tag))
{
// <title>の場合、タイトルセット
currentItem.setTitle(parser.nextText());
}
else if (IsDateTag(tag))
{
// <issued><date>の場合、日付セット
currentItem.setDate(parser.nextText());
}
else if(IsLinkTag(tag))
{
// <link>の場合、リンク先のURLをセット
String strLink = "";
for(int i=0; i<parser.getAttributeCount(); i++)
{
if(parser.getAttributeName(i).equals("href"))
{
strLink = parser.getAttributeValue(i);
}
}
if(strLink.equals(""))
{
strLink = parser.nextText();
}
currentItem.setLink(strLink);
}
else if(IsSubjectTag(tag))
{
// <subject>の場合、題名セット
currentItem.setCategory(parser.nextText());
}
}
break;
// 終了タグの判定
case XmlPullParser.END_TAG:
tag = parser.getName();
if (IsItemTag(tag))
{
:
}
break;
}
// 次のタグを取得
eventType = parser.next();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
// 線と円の描画
public void DrawBackground011(Canvas csCanvas)
{
Random rand = new Random();
Paint csPaint = new Paint();
csPaint.setAntiAlias(true);
csPaint.setColor(Color.argb(128+rand.nextInt(80),rand.nextInt(256),rand.nextInt(256),rand.nextInt(256)));
RectF sOval = new RectF();
for(int x=0; x<=320; x+=20)
{
if(x==160) csPaint.setColor(Color.argb(128+rand.nextInt(80),rand.nextInt(256),rand.nextInt(256),rand.nextInt(256)));
for(int y=0; y<=320; y+=80)
{
int nX = 0, nY = 0;
boolean bLoop=true;
while(bLoop)
{
nX = rand.nextInt(320);
nY = rand.nextInt(320);
if(240 < Math.sqrt(nX*nX+nY*nY)) bLoop = false;
}
int nSize = rand.nextInt(30)+10;
sOval.set(nX, nY, nX+nSize, nY+nSize);
csCanvas.drawOval(sOval, csPaint);
}
int nX = rand.nextInt(320);
int nY = rand.nextInt(320);
int nSize = rand.nextInt(40);
csCanvas.drawLine(nX, nY, nX+nSize, nY+nSize, csPaint);
}
}
// 四角形の幾何学模様
public void DrawBackground008(Canvas csCanvas)
{
Paint csPaint = new Paint();
csPaint.setAntiAlias(true);
RectF sRect = new RectF();
for(int xy=320; xy>0; )
{
csPaint.setColor(Color.BLACK);
sRect.set(160-xy/2, 160-xy/2, 160+xy/2, 160+xy/2);
csCanvas.drawRect(sRect, csPaint);
xy/=Math.sqrt(2);
csCanvas.rotate(45, 160, 160);
csPaint.setColor(Color.WHITE);
sRect.set(160-xy/2, 160-xy/2, 160+xy/2, 160+xy/2);
csCanvas.drawRect(sRect, csPaint);
xy/=Math.sqrt(2);
csCanvas.rotate(45, 160, 160);
}
}
<!-- 読込中表示プログレスバー -->
<ProgressBar
android:id="@+id/loadingProgress"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/ic_progress_green"
android:layout_width="match_parent"
android:layout_height="3dp"/>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#000000"
android:centerColor="#000000"
android:centerY="0.5"
android:endColor="#000000"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_light"
android:centerY="0.5"
android:endColor="@color/holo_green_dark"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
<!-- 読込中表示プログレスバー -->
<ProgressBar
android:id="@+id/loadingProgress"
android:layout_width="match_parent"
android:layout_height="3dp"
android:indeterminateDrawable="@drawable/ic_progress_indeterminate_green" />
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item android:duration="200">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="1.0"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_light"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="50">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.8"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_light"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="50">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.6"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_light"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="50">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.4"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_light"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="50">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.2"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_light"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="70">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.0"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_normal"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="100">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.2"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_normal"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="100">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.4"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_normal"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="100">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.6"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_normal"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="100">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="0.8"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_normal"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
<item android:duration="100">
<shape android:shape="rectangle" >
<gradient
android:angle="180"
android:centerY="1.0"
android:endColor="@color/holo_green_dark"
android:centerColor="@color/holo_green_normal"
android:startColor="@color/holo_green_dark"
android:type="linear" />
</shape>
</item>
</animation-list>
// 自動的にリンクを生成するように設定
TextView csLinkedTextView = new TextView(this);
csLinkedTextView.setText("URL:http://www.takahara-books.com/Android/");
csLinkedTextView.setAutoLinkMask(Linkify.ALL);
// ビューに表示するフォントを指定
TextView csFontTextView = new TextView(this);
csFontTextView.setText("サンプル");
csFontTextView.setTypeface(Typeface.SERIF, Typeface.BOLD_ITALIC);
// 候補に表示される文字列
String[] strAutoWordlist = new String[]{
"Cupcake",
"Cute",
"Donut",
"Eclair",
"Froyo",
"Gingerbread",
"Honeycomb",
"IceCreamSandwich",
"Kitkat"
}
// アダプタを作成
ArrayAdapter adapterAuto = new ArrayAdapter(
this,
android.R.layout.simple_dropdown_item_1line,
strAutoWordlist
);
// AutoCompleteTextViewインスタンスを作成
AutoCompleteTextView csAutoCompTextView = new AutoCompleteTextView(this);
// アダプタをセット
csAutoCompTextView.setAdapter(adapterAuto);
/***************************************************************************
* CSVコントロールクラス
***************************************************************************/
public class CSVCtrl
{
/***************************************************************************
* CSVファイルから読み込んだデータリストを取得
*
* @param csContext コンテキスト
* @param strCsvFileName CSVファイル名
* @return 読み込んだCSVデータリスト
*
* @author k0j1
***************************************************************************/
static public List ReadCSV(Context csContext, String strCsvFileName)
{
InputStream csInputStream = null;
BufferedReader csBufReader = null;
List sCsvList = new ArrayList();
try
{
AssetManager csAsset = csContext.getResources().getAssets();
csInputStream = csAsset.open(strCsvFileName);
csBufReader = new BufferedReader(new InputStreamReader(csInputStream));
// タイトル処理
// タイトルは読み捨てる
csBufReader.readLine();
// データ処理
{
// 最終行まで読み込む
for( String line = ""; (line = csBufReader.readLine()) != null; )
{
// 1行をデータの要素に分割
StringTokenizer csStringToken = new StringTokenizer(line, ",");
// リストに保持
sCsvList.add(csStringToken);
}
csBufReader.close();
}
} catch (FileNotFoundException e) {
// Fileオブジェクト生成時の例外捕捉
e.printStackTrace();
} catch (IOException e) {
// BufferedReaderオブジェクトのクローズ時の例外捕捉
e.printStackTrace();
}
return sCsvList;
}
}
番号,50音順(1:あ行、2:か行、…),地域区分,区,愛称,経路区分,経路・時刻表名,URL 1,1,1,荒川区,さくら・汐入さくら,1,運行ルート,http://yamatocreation.cocotte.jp/bus/arakawa/keiro 2,1,1,荒川区,さくら・汐入さくら,2,さくら時刻表,http://yamatocreation.cocotte.jp/bus/arakawa/sakura 3,1,1,荒川区,さくら・汐入さくら,3,汐入さくら時刻表,http://yamatocreation.cocotte.jp/bus/arakawa/sioiri 4,1,1,荒川区,さくら・汐入さくら,4,町屋さくら時刻表,http://yamatocreation.cocotte.jp/bus/arakawa/matiya :