forked from hush/SilentDragonAndroid-old
adityapk00
6 years ago
7 changed files with 221 additions and 32 deletions
@ -0,0 +1,120 @@ |
|||
package com.adityapk.zcash.zqwandroid |
|||
|
|||
import android.content.Context |
|||
import android.content.Intent |
|||
import android.net.Uri |
|||
import android.os.Bundle |
|||
import android.support.constraint.ConstraintLayout |
|||
import android.support.v4.app.Fragment |
|||
import android.support.v4.content.ContextCompat |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
import android.widget.ImageView |
|||
import android.widget.TextView |
|||
import com.beust.klaxon.Klaxon |
|||
import java.text.DateFormat |
|||
import java.text.DecimalFormat |
|||
import java.util.* |
|||
|
|||
|
|||
// TODO: Rename parameter arguments, choose names that match |
|||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER |
|||
private const val ARG_PARAM1 = "param1" |
|||
private const val ARG_PARAM2 = "param2" |
|||
|
|||
/** |
|||
* A simple [Fragment] subclass. |
|||
* Activities that contain this fragment must implement the |
|||
* [UnconfirmedTxItemFragment.OnFragmentInteractionListener] interface |
|||
* to handle interaction events. |
|||
* Use the [UnconfirmedTxItemFragment.newInstance] factory method to |
|||
* create an instance of this fragment. |
|||
* |
|||
*/ |
|||
class UnconfirmedTxItemFragment : Fragment() { |
|||
// TODO: Rename and change types of parameters |
|||
private var tx: DataModel.TransactionItem? = null |
|||
private var param2: String? = null |
|||
private var listener: OnFragmentInteractionListener? = null |
|||
|
|||
override fun onCreate(savedInstanceState: Bundle?) { |
|||
super.onCreate(savedInstanceState) |
|||
arguments?.let { |
|||
tx = Klaxon().parse(it.getString(ARG_PARAM1)) |
|||
param2 = it.getString(ARG_PARAM2) |
|||
} |
|||
} |
|||
|
|||
override fun onCreateView( |
|||
inflater: LayoutInflater, container: ViewGroup?, |
|||
savedInstanceState: Bundle? |
|||
): View? { |
|||
// Inflate the layout for this fragment |
|||
val view = inflater.inflate(R.layout.fragment_unconfirmed_tx_item, container, false) |
|||
|
|||
view.findViewById<ConstraintLayout>(R.id.layoutUnconfirmedItem).setOnClickListener { v -> |
|||
val intent = Intent(activity, TxDetailsActivity::class.java) |
|||
intent.putExtra("EXTRA_TXDETAILS", Klaxon().toJsonString(tx)) |
|||
startActivity(intent) |
|||
} |
|||
|
|||
val txt = view.findViewById<TextView>(R.id.txtUnconfirmedTx) |
|||
txt.text = (if (tx?.type == "send") "Sending" else "Receiving") + |
|||
" ZEC " + (if (tx?.type == "send") "" else "+") + |
|||
DecimalFormat("#0.00########").format(tx?.amount?.toDoubleOrNull() ?: 0.0) |
|||
|
|||
return view |
|||
} |
|||
|
|||
|
|||
override fun onAttach(context: Context) { |
|||
super.onAttach(context) |
|||
if (context is OnFragmentInteractionListener) { |
|||
listener = context |
|||
} else { |
|||
throw RuntimeException(context.toString() + " must implement OnFragmentInteractionListener") |
|||
} |
|||
} |
|||
|
|||
override fun onDetach() { |
|||
super.onDetach() |
|||
listener = null |
|||
} |
|||
|
|||
/** |
|||
* This interface must be implemented by activities that contain this |
|||
* fragment to allow an interaction in this fragment to be communicated |
|||
* to the activity and potentially other fragments contained in that |
|||
* activity. |
|||
* |
|||
* |
|||
* See the Android Training lesson [Communicating with Other Fragments] |
|||
* (http://developer.android.com/training/basics/fragments/communicating.html) |
|||
* for more information. |
|||
*/ |
|||
interface OnFragmentInteractionListener { |
|||
// TODO: Update argument type and name |
|||
fun onFragmentInteraction(uri: Uri) |
|||
} |
|||
|
|||
companion object { |
|||
/** |
|||
* Use this factory method to create a new instance of |
|||
* this fragment using the provided parameters. |
|||
* |
|||
* @param param1 Parameter 1. |
|||
* @param param2 Parameter 2. |
|||
* @return A new instance of fragment UnconfirmedTxItemFragment. |
|||
*/ |
|||
// TODO: Rename and change types and number of parameters |
|||
@JvmStatic |
|||
fun newInstance(param1: String, param2: String) = |
|||
UnconfirmedTxItemFragment().apply { |
|||
arguments = Bundle().apply { |
|||
putString(ARG_PARAM1, param1) |
|||
putString(ARG_PARAM2, param2) |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<android.support.constraint.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" |
|||
tools:context=".UnconfirmedTxItemFragment" android:id="@+id/frameLayout"> |
|||
<android.support.constraint.ConstraintLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" |
|||
app:layout_constraintTop_toTopOf="parent" |
|||
android:layout_marginTop="8dp" android:background="@color/light_grey" |
|||
android:id="@+id/layoutUnconfirmedItem" android:layout_marginBottom="8dp" |
|||
app:layout_constraintBottom_toBottomOf="parent"> |
|||
|
|||
<ProgressBar |
|||
style="?android:attr/progressBarStyle" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:id="@+id/prgUnconfirmed" app:layout_constraintTop_toTopOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="8dp" |
|||
android:layout_marginStart="32dp" app:layout_constraintBottom_toBottomOf="parent" |
|||
android:layout_marginBottom="8dp" android:progress="23"/> |
|||
<TextView |
|||
android:text="Recieving ZEC 0.12345678" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" android:id="@+id/txtUnconfirmedTx" |
|||
app:layout_constraintTop_toTopOf="parent" |
|||
android:layout_marginTop="8dp" android:layout_marginStart="24dp" |
|||
app:layout_constraintStart_toEndOf="@+id/prgUnconfirmed" android:textSize="18sp"/> |
|||
<TextView |
|||
android:text="Unconfirmed Transaction" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:id="@+id/textView9" |
|||
app:layout_constraintTop_toBottomOf="@+id/txtUnconfirmedTx" android:layout_marginTop="8dp" |
|||
app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="8dp" |
|||
app:layout_constraintLeft_toLeftOf="@+id/txtUnconfirmedTx" android:textColor="@color/colorAccent"/> |
|||
</android.support.constraint.ConstraintLayout> |
|||
</android.support.constraint.ConstraintLayout> |
Loading…
Reference in new issue