見出し画像

パチスロデータ収集アプリの作成

過去にpythonで作った日付指定型のパチスロ全台データ取得のプログラムですが、今回は、Android StudioでJavaを使って、アプリにしてみました。

pythonのほうは、最終的にCSVに出力するので、深く、分析・統計がとれるのですが、パソコンがないと使用できないというデメリットがありました。

今回は、アプリにすることによって、スマホで使用できるので、パソコンよりは深く分析することはできないのですが、どこでも、データを出力して、確認できるというメリットがあります。

過去の記事はこちら

実際のアプリの画面

ダウンロード (13)

ダウンロード (14)

ダウンロード (15)

店舗番号と日付を入力し、データ取得ボタンを押すことによって、指定した日付の指定店舗の全台データを取得することができます。店舗番号がわからなければ、店舗番号を調査するために台データオンラインのサイトへ飛ぶようなリンクも設定。

データの取得中は、データの総件数をMAXと置いて、それまでの進捗率をプログレスバーにて表示させます。私の2,3世代前の携帯だと1件あたり、2秒ほどの処理時間でした。上記だと79台データ取得するので大体、160秒ほどで完了。

データ読み込みを押すことで別画面にうつり、先ほど取得したデータを表示させます。一度、取得したデータはデータベースに保持させてるのでアプリを閉じても、また起動して、読み込むことができます。

データクリアを押すことによって、データを全部消します。

Google Play Storeへの公開

手直しして、今週中に公開予定です。少々お待ちください。

全体的なアプリの処理フローについて

全体的なアプリの処理フローは簡単に以下の4つのフローとなります。

1.台データオンラインにアクセス

2.台データオンラインでデータ取得

3.データをDBへ書き込み

4.データを出力

※台データオンライン様のサイトはこちら

アプリ作成のために必要な環境

Android Studioのインストール(環境構築)が必要です。下記の記事を参考に環境構築してからご参照ください。

また、ある程度のJavaの知識が必要です。progateで学習しながら進めていただくのがお勧めです。


①各種設定

jsoup導入設定(build.gradle(app))

キャプチャ

build.gradle(app)に以下のコードを追記

 implementation 'org.jsoup:jsoup:1.12.1' 

※2020-02時点 ver

ネットアクセス設定(AndroidManifest.xml)

キャプチャ

AndroidManifest.xmlに 以下のコードを追記


<uses-permission android:name="android.permission.INTERNET" /> 

②レイアウト関連

上部のバーを削除(AndroidManifest.xml)

キャプチャ

AndroidManifest.xmlへ以下のコードを追記

android:theme="@style/Theme.AppCompat.Light.NoActionBar" >

Topデザイン(activity_main.xml)

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="#4169e1"
   tools:context=".MainActivity">

   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:fontFamily="sans-serif-black"
       android:text="@string/title"
       android:textColor="@android:color/white"
       android:textColorHighlight="@color/colorPrimary"
       android:textSize="25sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.122"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.022" />

   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/dis"
       android:textColor="?attr/colorButtonNormal"
       android:textSize="15sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.296" />

   <EditText
       android:id="@+id/edit_text_key"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_margin="50dp"
       android:autofillHints="@string/store_no"
       android:background="#f5f5f5"
       android:hint="@string/store_no"
       android:inputType="number"
       android:maxLength="6"
       android:textSize="20sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintHorizontal_bias="0.211"
       app:layout_constraintLeft_toLeftOf="parent"
       app:layout_constraintRight_toLeftOf="@+id/edit_text_value"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.096" />

   <EditText
       android:id="@+id/edit_text_value"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_margin="50dp"
       android:autofillHints="@string/date"
       android:background="#f5f5f5"
       android:hint="@string/date"
       android:inputType="text"
       android:textSize="20sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.988"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.100" />

   <Button
       android:id="@+id/button_test"
       android:layout_width="150dp"
       android:layout_height="50dp"
       android:background="@drawable/button_background"
       android:fontFamily="sans-serif-black"
       android:onClick="data_Get"
       android:text="@string/insert"
       android:textSize="18sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.494"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.386" />

   <Button
       android:id="@+id/button_read"
       android:layout_width="150dp"
       android:layout_height="50dp"
       android:background="@drawable/button_background"
       android:fontFamily="sans-serif-black"
       android:onClick="data_Read"
       android:text="@string/read"
       android:textSize="18sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.494"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.499" />

   <Button
       android:id="@+id/button_clear"
       android:layout_width="150dp"
       android:layout_height="50dp"
       android:onClick="data_Clear"
       android:text="@string/clear"
       android:fontFamily="sans-serif-black"
       android:background="@drawable/button_background"
       android:textSize="18sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.494"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.612" />

   <Button
       android:id="@+id/button_store_s"
       android:layout_width="130dp"
       android:layout_height="40dp"
       android:onClick="data_Store_s"
       android:text="@string/store_s"
       android:textSize="13sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.128"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.224" />

   <Button
       android:id="@+id/button_url"
       android:layout_width="200dp"
       android:layout_height="40dp"
       android:onClick="data_Url"
       android:text="@string/url"
       android:textSize="13sp"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintHorizontal_bias="0.498"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintVertical_bias="0.955" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView>2つ➡タイトルと店舗番号の注記

<EditText>2つ➡店舗番号、日付入力用

<Button>5つ➡店舗を探す、データ取得、データ読み込み、データクリア、台データオンラインへのアクセス

テキスト関連変数(string.xml)

キャプチャ

<resources>
   <string name="app_name">PachiPachi</string>
   <string name="title">データ収集アプリ</string>
   <string name="title2">データ一覧</string>
   <string name="store_s">店舗番号をさがす</string>
   <string name="dis">店舗名のURLの下6桁の数字が店舗番号となります</string>
   <string name="store_no">店舗番号</string>
   <string name="date">yyyy-mm-dd</string>
   <string name="insert">データ取得</string>
   <string name="read">データ読み込み</string>
   <string name="clear">データクリア</string>
   <string name="url">台データオンライン様サイト</string>
</resources>

ボタンデザイン(button_background.xml)

キャプチャ

drawableの上で右クリックでファイルを新規作成してください。名前は『button_background.xml』

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval">
   <solid android:color="#7fffd4"/>
   <corners android:radius="8dp"/>
   <stroke
       android:color="#7fffd4"
       android:width="2dp"/>
</shape>


③DB用クラスの作成

ここから先は

13,881字 / 1画像

¥ 980

この記事が気に入ったらサポートをしてみませんか?