forked from Tribler/trustchain-superapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Tribler#13 from MKuijpers/bitcoin_progress_download
Bitcoin progress download
- Loading branch information
Showing
8 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
demo-android/src/main/java/nl/tudelft/ipv8/android/demo/ui/bitcoin/BlockchainDownloading.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package nl.tudelft.ipv8.android.demo.ui.bitcoin | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ProgressBar | ||
import android.widget.TextView | ||
import kotlinx.android.synthetic.main.fragment_blockchain_downloading.* | ||
import nl.tudelft.ipv8.android.demo.R | ||
import nl.tudelft.ipv8.android.demo.coin.WalletManagerAndroid | ||
import nl.tudelft.ipv8.android.demo.ui.BaseFragment | ||
import kotlin.concurrent.thread | ||
|
||
|
||
/** | ||
* A simple [Fragment] subclass. | ||
* Use the [BlockchainDownloading.newInstance] factory method to | ||
* create an instance of this fragment. | ||
*/ | ||
class BlockchainDownloading( | ||
override val controller: BitcoinViewController | ||
) : BitcoinView, BaseFragment(R.layout.fragment_blockchain_downloading) { | ||
|
||
override fun onActivityCreated(savedInstanceState: Bundle?) { | ||
super.onActivityCreated(savedInstanceState) | ||
bitcoin_progress_continue.setOnClickListener { | ||
controller.showDefaultView() | ||
} | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
val fragment = inflater.inflate(R.layout.fragment_blockchain_downloading, container, false) | ||
fragment.findViewById<TextView>(R.id.bitcoin_download_percentage).text = "${WalletManagerAndroid.getInstance().progress.toString()}%" | ||
fragment.findViewById<ProgressBar>(R.id.bitcoin_download_progress).progress = WalletManagerAndroid.getInstance().progress | ||
thread { | ||
while (WalletManagerAndroid.getInstance().progress < 100) { | ||
Thread.sleep(500) | ||
fragment.findViewById<TextView>(R.id.bitcoin_download_percentage).text = "${WalletManagerAndroid.getInstance().progress}%" | ||
fragment.findViewById<ProgressBar>(R.id.bitcoin_download_progress).progress = WalletManagerAndroid.getInstance().progress | ||
} | ||
controller.showDefaultView() | ||
} | ||
return fragment | ||
} | ||
|
||
|
||
|
||
companion object { | ||
/** | ||
* Use this factory method to create a new instance of | ||
* this fragment using the provided parameters. | ||
* | ||
* @return A new instance of fragment BlockchainDownloading. | ||
*/ | ||
@JvmStatic | ||
fun newInstance(viewController: BitcoinViewController) = BlockchainDownloading(viewController) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
demo-android/src/main/res/layout/fragment_blockchain_downloading.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".BlockchainDownloading"> | ||
|
||
<TextView | ||
android:id="@+id/textView4" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Please Wait Whilst the Ketting is Downloading" | ||
android:textAlignment="center" | ||
android:textSize="24sp" | ||
android:textStyle="bold" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="bottom" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/bitcoin_progress_continue" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Continue Regardless" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center_vertical" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/bitcoin_download_percentage" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="TextView" | ||
android:textAlignment="center" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center_vertical" | ||
android:orientation="vertical" | ||
android:padding="20px"> | ||
|
||
<ProgressBar | ||
android:id="@+id/bitcoin_download_progress" | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="500dp" | ||
android:max="100" | ||
android:minHeight="60dp" | ||
android:progress="10" /> | ||
|
||
</LinearLayout> | ||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters