Skip to content

Commit

Permalink
a bit of refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ai-null committed Mar 11, 2021
1 parent 8215cca commit 9a37ab2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 47 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/com/ainul/oprek/adapter/ListItemAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class ListItemAdapter(private val clickListener: ListItemListener) :
ListAdapter<Project, ListItemAdapter.ListItemViewHolder>(ProjectDiffUtil()) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListItemViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
val holder = ListItemBinding.inflate(layoutInflater, parent, false)

return ListItemViewHolder(holder)
return ListItemViewHolder.from(parent)
}

override fun onBindViewHolder(holder: ListItemViewHolder, position: Int) {
Expand All @@ -44,5 +41,14 @@ class ListItemAdapter(private val clickListener: ListItemListener) :
binding.project = data
binding.executePendingBindings()
}

companion object {
fun from (parent: ViewGroup): ListItemViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
val holder = ListItemBinding.inflate(layoutInflater, parent, false)

return ListItemViewHolder(holder)
}
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/ainul/oprek/util/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ object Constants {
CANCEL(-1);
}

const val MASTER_KEY = "oprek-master-key"

// Screen navigation request code
const val REQUEST_CODE_UPDATE_PROJECT = 1
const val REQUEST_CODE_CHOOSE_IMAGE = 2
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ainul/oprek/util/EncryptManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.security.crypto.MasterKey
class EncryptManager(context: Context) {

// this will be our private key for the app, also with the schema to encrypt
private val masterKey = MasterKey.Builder(context, "oprek-master-key")
private val masterKey = MasterKey.Builder(context, Constants.MASTER_KEY)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()

Expand Down
16 changes: 0 additions & 16 deletions app/src/main/res/layout/activity_detail_user.xml

This file was deleted.

27 changes: 1 addition & 26 deletions app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_marginBottom="@dimen/medium_margin"
android:layout_height="wrap_content">

<LinearLayout
Expand Down Expand Up @@ -189,32 +190,6 @@
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/medium_margin"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/margin"
android:text="Statistics"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textStyle="bold" />


</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,5 @@

<string name="dialog_alert_message">%s name can\'t be empty!</string>
<string name="history">History</string>
<string name="statistics">Statistics</string>
</resources>

0 comments on commit 9a37ab2

Please sign in to comment.