Skip to content

Commit

Permalink
Use material card view
Browse files Browse the repository at this point in the history
  • Loading branch information
premnirmal committed Jul 24, 2022
1 parent 1008b62 commit 154f9f6
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import com.github.premnirmal.tickerwidget.R.dimen
import com.github.premnirmal.tickerwidget.databinding.FragmentNewsFeedBinding

class NewsFeedFragment : BaseFragment<FragmentNewsFeedBinding>(), ChildFragment, NewsFeedAdapter.NewsClickListener {
override val binding: (FragmentNewsFeedBinding) by viewBinding(FragmentNewsFeedBinding::inflate)

companion object {
private const val INDEX_PROGRESS = 0
private const val INDEX_ERROR = 1
private const val INDEX_EMPTY = 2
private const val INDEX_DATA = 3
}

override val binding: (FragmentNewsFeedBinding) by viewBinding(FragmentNewsFeedBinding::inflate)
private lateinit var adapter: NewsFeedAdapter
private val viewModel: NewsFeedViewModel by viewModels()
override val simpleName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import com.github.premnirmal.ticker.ui.SpacingDecoration
import com.github.premnirmal.ticker.viewBinding
import com.github.premnirmal.ticker.widget.WidgetDataProvider
import com.github.premnirmal.tickerwidget.R
import com.github.premnirmal.tickerwidget.R.dimen
import com.github.premnirmal.tickerwidget.databinding.ActivityQuoteDetailBinding
import com.google.android.material.appbar.AppBarLayout
import com.robinhood.ticker.TickerUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PortfolioFragment : BaseFragment<FragmentPortfolioBinding>(), ChildFragmen
) {
super.onViewCreated(view, savedInstanceState)
binding.stockList.addItemDecoration(
SpacingDecoration(requireContext().resources.getDimensionPixelSize(R.dimen.list_spacing))
SpacingDecoration(requireContext().resources.getDimensionPixelSize(R.dimen.list_spacing_double))
)
val gridLayoutManager = androidx.recyclerview.widget.GridLayoutManager(context, 2)
binding.stockList.layoutManager = gridLayoutManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(), ChildFragment, Sug
})
}

override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden)
if (hidden) dismissKeyboard() else {
binding.searchView.showKeyboard()
}
override fun onResume() {
super.onResume()
binding.searchView.showKeyboard()
}

override fun onPause() {
super.onPause()
dismissKeyboard()
}

override fun onSaveInstanceState(outState: Bundle) {
Expand Down
21 changes: 13 additions & 8 deletions app/src/main/res/layout-land/activity_quote_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,16 @@
/>

</LinearLayout>
<LinearLayout
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/positions_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

Expand Down Expand Up @@ -375,7 +377,7 @@
/>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -406,13 +408,16 @@
/>
</LinearLayout>

<LinearLayout
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/alerts_container"
android:visibility="gone"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
tools:visibility="visible"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

Expand Down Expand Up @@ -441,7 +446,7 @@
/>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
27 changes: 17 additions & 10 deletions app/src/main/res/layout-sw600dp-land/activity_quote_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,17 @@
/>

</LinearLayout>
<LinearLayout
<com.google.android.material.card.MaterialCardView
app:layout_constraintTop_toBottomOf="@id/positions_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/positions_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
android:orientation="vertical"
>

Expand Down Expand Up @@ -378,7 +382,7 @@
/>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -410,15 +414,18 @@
/>
</LinearLayout>

<LinearLayout
android:id="@+id/alerts_container"
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
android:orientation="vertical"
android:id="@+id/alerts_container"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintTop_toBottomOf="@id/alert_header"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

<com.github.premnirmal.ticker.ui.StockFieldView
Expand Down Expand Up @@ -446,7 +453,7 @@
/>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/activity_positions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@
android:textSize="@dimen/thin_title_text"
/>


<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
android:orientation="vertical"
android:padding="16dp"
>
Expand Down Expand Up @@ -271,7 +274,7 @@
</LinearLayout>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
21 changes: 15 additions & 6 deletions app/src/main/res/layout/activity_quote_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,17 @@
/>

</LinearLayout>
<LinearLayout

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/positions_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

Expand Down Expand Up @@ -382,7 +385,7 @@
/>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -414,13 +417,18 @@
/>
</LinearLayout>

<LinearLayout

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/alerts_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/card_bg"
android:orientation="vertical"
>

Expand Down Expand Up @@ -449,6 +457,7 @@
/>

</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<LinearLayout
android:layout_width="match_parent"
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/fragment_news_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"

>

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

android:elevation="0dp"
app:elevation="0dp"
>
Expand Down Expand Up @@ -44,6 +42,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view_flipper"
android:background="?attr/colorSurface"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>

Expand All @@ -60,7 +59,7 @@
android:gravity="center"
android:text="@string/error_fetching_news"
style="@style/Widget.StocksWidget.TextView.FetchError"
android:textAppearance="@style/TextAppearance.StocksWidget.FetchError"
android:textAppearance="@style/TextAppearance.StocksWidget.FetchError"
/>

<TextView
Expand All @@ -70,7 +69,7 @@
android:gravity="center"
android:text="@string/no_data"
style="@style/Widget.StocksWidget.TextView.FetchError"
android:textAppearance="@style/TextAppearance.StocksWidget.FetchError"
android:textAppearance="@style/TextAppearance.StocksWidget.FetchError"
/>

<androidx.recyclerview.widget.RecyclerView
Expand Down
Loading

0 comments on commit 154f9f6

Please sign in to comment.