-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e659113
commit f49bb69
Showing
19 changed files
with
345 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
54 changes: 52 additions & 2 deletions
54
app/src/main/java/dev/jahidhasanco/bmicalculator/MainActivity.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 |
---|---|---|
@@ -1,11 +1,61 @@ | ||
package dev.jahidhasanco.bmicalculator | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.recyclerview.widget.LinearSnapHelper | ||
import androidx.recyclerview.widget.SnapHelper | ||
import com.sccomponents.gauges.library.ScArcGauge | ||
import dev.jahidhasanco.bmicalculator.databinding.ActivityMainBinding | ||
import dev.jahidhasanco.bmicalculator.presentation.adapter.WeightPickerAdapter | ||
import travel.ithaka.android.horizontalpickerlib.PickerLayoutManager | ||
|
||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
private lateinit var binding: ActivityMainBinding | ||
val _binding get() = binding | ||
|
||
lateinit var weightAdapter:WeightPickerAdapter | ||
|
||
private val mAngle = 1f | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
binding = DataBindingUtil.setContentView(this,R.layout.activity_main) | ||
|
||
_binding.genderMeter.angleStart = mAngle | ||
|
||
val pickerLayoutManager = PickerLayoutManager(this, PickerLayoutManager.HORIZONTAL, false) | ||
pickerLayoutManager.apply { | ||
isChangeAlpha = true | ||
scaleDownBy = 0.99f | ||
scaleDownDistance = 0.8f | ||
} | ||
|
||
|
||
val snapHelper: SnapHelper = LinearSnapHelper() | ||
snapHelper.attachToRecyclerView(_binding.weightRecyclerBtn) | ||
|
||
weightAdapter = WeightPickerAdapter(this, getData(100), _binding.weightRecyclerBtn) | ||
|
||
_binding.weightRecyclerBtn.apply { | ||
layoutManager = pickerLayoutManager | ||
adapter = weightAdapter | ||
} | ||
|
||
|
||
pickerLayoutManager.setOnScrollStopListener { | ||
|
||
} | ||
|
||
} | ||
|
||
fun getData(count: Int): List<String> { | ||
val data: MutableList<String> = ArrayList() | ||
for (i in 0 until count) { | ||
data.add(i.toString()) | ||
} | ||
return data | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
app/src/main/java/dev/jahidhasanco/bmicalculator/presentation/adapter/WeightPickerAdapter.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,50 @@ | ||
package dev.jahidhasanco.bmicalculator.presentation.adapter | ||
|
||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import dev.jahidhasanco.bmicalculator.R | ||
|
||
|
||
class WeightPickerAdapter(private val context: Context, private var dataList: List<String>, private val recyclerView: RecyclerView) : | ||
RecyclerView.Adapter<WeightPickerAdapter.TextVH>() { | ||
|
||
|
||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TextVH { | ||
val view: View | ||
val inflater = LayoutInflater.from(context) | ||
view = inflater.inflate(R.layout.weight_picker_item_layout, parent, false) | ||
return TextVH(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: TextVH, position: Int) { | ||
|
||
holder.pickerTxt.text = dataList[position] | ||
holder.pickerTxt.setOnClickListener { | ||
recyclerView.smoothScrollToPosition(position) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return dataList.size | ||
} | ||
|
||
fun swapData(newData: List<String>) { | ||
dataList = newData | ||
notifyDataSetChanged() | ||
} | ||
|
||
class TextVH(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
var pickerTxt: TextView | ||
|
||
init { | ||
pickerTxt = itemView.findViewById(R.id.weight_picker_item) | ||
} | ||
} | ||
|
||
} |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#4D7CF2" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/> | ||
</vector> |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<solid android:color="@color/backgroundColorAdditional2"/> | ||
<corners android:radius="40dp"/> | ||
|
||
</shape> |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<solid android:color="@color/backgroundColor"/> | ||
<corners android:radius="10dp"/> | ||
|
||
</shape> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.