-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update track/myshipment page and change nearby page to settings page
- Loading branch information
1 parent
92c28d2
commit ea16fe6
Showing
40 changed files
with
1,611 additions
and
190 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
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/anugrahdev/app/ikurir/adapter/MyPagerAdapter.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,25 @@ | ||
package com.anugrahdev.app.ikurir.adapter | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.fragment.app.FragmentPagerAdapter | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
import com.anugrahdev.app.ikurir.ui.myshipment.DeliveredFragment | ||
import com.anugrahdev.app.ikurir.ui.myshipment.OnProcessFragment | ||
|
||
class MyPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) { | ||
override fun getItemCount(): Int { | ||
return 2 | ||
} | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
when(position){ | ||
0 -> return OnProcessFragment() | ||
1 -> return DeliveredFragment() | ||
} | ||
return OnProcessFragment() | ||
} | ||
|
||
|
||
} |
84 changes: 84 additions & 0 deletions
84
app/src/main/java/com/anugrahdev/app/ikurir/adapter/MyShipmentAdapter.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,84 @@ | ||
package com.anugrahdev.app.ikurir.adapter | ||
|
||
import android.os.Handler | ||
import android.transition.AutoTransition | ||
import android.transition.TransitionManager | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.content.ContextCompat | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.recyclerview.widget.AsyncListDiffer | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.anugrahdev.app.ikurir.R | ||
import com.anugrahdev.app.ikurir.data.models.waybill.WaybillData | ||
import com.anugrahdev.app.ikurir.databinding.ItemSavedawbBinding | ||
import kotlinx.android.synthetic.main.item_savedawb.view.* | ||
|
||
class MyShipmentAdapter(): RecyclerView.Adapter<MyShipmentAdapter.WaybillListViewHolder>() { | ||
|
||
inner class WaybillListViewHolder(val item: ItemSavedawbBinding, viewType: Int): | ||
RecyclerView.ViewHolder(item.root) | ||
|
||
private val differCallback = object : DiffUtil.ItemCallback<WaybillData>(){ | ||
override fun areItemsTheSame(oldItem: WaybillData, newItem: WaybillData): Boolean { | ||
return oldItem.waybillNumber == newItem.waybillNumber | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: WaybillData, newItem: WaybillData): Boolean { | ||
return oldItem == newItem | ||
} | ||
} | ||
|
||
val differ = AsyncListDiffer(this, differCallback) | ||
|
||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WaybillListViewHolder { | ||
return WaybillListViewHolder( | ||
DataBindingUtil.inflate<ItemSavedawbBinding>( | ||
LayoutInflater.from(parent.context), | ||
R.layout.item_savedawb, | ||
parent, | ||
false), viewType) | ||
} | ||
|
||
override fun getItemCount(): Int = differ.currentList.size | ||
|
||
override fun onBindViewHolder(holder: WaybillListViewHolder, position: Int) { | ||
val waybill = differ.currentList[position] | ||
holder.itemView.expand.setOnClickListener { | ||
if (holder.itemView.expandableLayout.visibility == View.GONE) { | ||
TransitionManager.beginDelayedTransition(holder.itemView.cv_savedawb, AutoTransition()) | ||
holder.itemView.expandableLayout.visibility = View.VISIBLE | ||
holder.itemView.ic_expand.setImageResource(R.drawable.ic_arrow_drop_up) | ||
} else { | ||
Handler().postDelayed({ | ||
// TransitionManager.beginDelayedTransition(holder.itemView.cv_savedawb, AutoTransition()) | ||
holder.itemView.expandableLayout.visibility = View.GONE | ||
holder.itemView.ic_expand.setImageResource(R.drawable.ic_arrow_drop_down) | ||
},200) | ||
|
||
} | ||
} | ||
holder.itemView.apply { | ||
holder.item.waybill = waybill | ||
when(waybill.courier.code){ | ||
"sicepat" -> ic_courier.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.ic_sicepat)) | ||
"lion" -> ic_courier.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.ic_lion)) | ||
"jnt" -> ic_courier.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.ic_jnt)) | ||
"tiki" -> ic_courier.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.ic_tiki)) | ||
} | ||
setOnClickListener { | ||
onItemClickListener?.let{ it(waybill) } | ||
} | ||
} | ||
} | ||
|
||
private var onItemClickListener: ((WaybillData)->Unit)? = null | ||
|
||
fun setOnItemClickListener(listener : (WaybillData)->Unit){ | ||
onItemClickListener = listener | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.