Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
meiron03 committed Aug 31, 2024
1 parent 31eb7e3 commit 1ca079a
Show file tree
Hide file tree
Showing 97 changed files with 1,410 additions and 1,256 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:

- name: Install ktlint
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.2.1/ktlint
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.1/ktlint
chmod a+x ktlint
sudo mv ktlint /usr/local/bin/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,31 @@ class AboutFragment : Fragment() {
if (gif is AnimatedVectorDrawable) {
gif.start()
} else {
Glide.with(this).asGif().load(R.drawable.logo_gif_transparent).listener(
object : RequestListener<GifDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
isFirstResource: Boolean,
): Boolean {
return false
}
Glide
.with(this)
.asGif()
.load(R.drawable.logo_gif_transparent)
.listener(
object : RequestListener<GifDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
isFirstResource: Boolean,
): Boolean = false

override fun onResourceReady(
resource: GifDrawable,
model: Any,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
dataSource: DataSource,
isFirstResource: Boolean,
): Boolean {
resource.setLoopCount(1)
return false
}
},
).into(binding.logoGifIv)
override fun onResourceReady(
resource: GifDrawable,
model: Any,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
dataSource: DataSource,
isFirstResource: Boolean,
): Boolean {
resource.setLoopCount(1)
return false
}
},
).into(binding.logoGifIv)
}

binding.ourTeamRv.layoutManager = GridLayoutManager(context, 3)
Expand Down Expand Up @@ -103,7 +105,8 @@ class AboutFragment : Fragment() {
binding.licensesBtn.setOnClickListener {
val webView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_licenses, null) as WebView
webView.loadUrl("file:///android_asset/open_source_licenses.html")
AlertDialog.Builder(mActivity, R.style.AppTheme_AppBarOverlay_Light)
AlertDialog
.Builder(mActivity, R.style.AppTheme_AppBarOverlay_Light)
.setTitle(getString(R.string.action_licenses))
.setView(webView)
.setPositiveButton(android.R.string.ok, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ class BookGsrFragment : Fragment() {
emailEt.setText(email)

submit.setOnClickListener {
if (firstNameEt.text.toString().matches("".toRegex()) || lastNameEt.text.toString().matches("".toRegex()) ||
if (firstNameEt.text.toString().matches("".toRegex()) ||
lastNameEt.text.toString().matches("".toRegex()) ||
emailEt.text.toString().matches("".toRegex())
) {
Toast.makeText(
activity,
"Please fill in all fields before booking",
Toast.LENGTH_LONG,
).show()
Toast
.makeText(
activity,
"Please fill in all fields before booking",
Toast.LENGTH_LONG,
).show()
} else if (!emailEt.text.toString().matches("""\w+@(seas\.|sas\.|wharton\.|nursing\.)?upenn\.edu""".toRegex())) {
Toast.makeText(activity, "Please enter a valid Penn email", Toast.LENGTH_LONG).show()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class CampusExpressLoginFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
return inflater.inflate(R.layout.fragment_campus_express_login, container, false)
}
): View? = inflater.inflate(R.layout.fragment_campus_express_login, container, false)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -86,7 +84,8 @@ class CampusExpressLoginFragment : Fragment() {
headerLayout = view.findViewById(R.id.linear_layout)
cancelButton = view.findViewById(R.id.cancel_button)
val uri =
Uri.parse(campusExpressAuthUrl)
Uri
.parse(campusExpressAuthUrl)
.buildUpon()
.appendQueryParameter("response_type", "code")
.appendQueryParameter("client_id", clientID)
Expand Down Expand Up @@ -135,7 +134,8 @@ class CampusExpressLoginFragment : Fragment() {
private fun goToDiningInsights(refresh: Boolean) {
if (refresh) {
val fragment = DiningInsightsFragment()
parentFragmentManager.beginTransaction()
parentFragmentManager
.beginTransaction()
.replace(R.id.campus_express_page, fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ class DiningFragment : Fragment() {

// Map each item in the list of venues to a Venue Observable, then map each Venue to a DiningHall Observable
try {
mStudentLife.venues()
mStudentLife
.venues()
.flatMap { venues -> Observable.from(venues) }
.flatMap { venue ->
val hall = createHall(venue)
Observable.just(hall)
}
.toList()
}.toList()
.subscribe({ diningHalls ->
mActivity.runOnUiThread {
getMenus(diningHalls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class DiningHallWidget : AppWidgetProvider() {
okHttpClient.setWriteTimeout(35, TimeUnit.SECONDS) // Write timeout

val restAdapter =
RestAdapter.Builder()
RestAdapter
.Builder()
.setConverter(GsonConverter(gson))
.setClient(OkClient(okHttpClient))
.setEndpoint("https://pennmobile.org/api")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ class DiningInfoFragment : Fragment() {
}
}

private fun hasMeals(day: VenueInterval): Boolean {
return day.meals.isNotEmpty()
}
private fun hasMeals(day: VenueInterval): Boolean = day.meals.isNotEmpty()

private fun addDiningHour(
day: VenueInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class DiningInsightsFragment : Fragment() {
val accessToken = networkManager.getAccessToken()
if (accessToken == "") {
val fragment = CampusExpressLoginFragment()
parentFragmentManager.beginTransaction()
parentFragmentManager
.beginTransaction()
.replace(R.id.dining_insights_page, fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack("DiningInsightsFragment")
Expand Down Expand Up @@ -112,7 +113,8 @@ class DiningInsightsFragment : Fragment() {
if (accessToken == "") {
binding.diningInsightsRefresh.isRefreshing = false
val fragment = CampusExpressLoginFragment()
parentFragmentManager.beginTransaction()
parentFragmentManager
.beginTransaction()
.replace(R.id.dining_insights_page, fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack("DiningInsightsFragment")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import retrofit.RetrofitError
import retrofit.client.Response
import rx.Observable

class DiningSettingsFragment(dataModel: HomepageDataModel) : Fragment() {
class DiningSettingsFragment(
dataModel: HomepageDataModel,
) : Fragment() {
private lateinit var mActivity: MainActivity
private lateinit var mStudentLife: StudentLife
private lateinit var halls: List<DiningHall>
Expand Down Expand Up @@ -93,13 +95,13 @@ class DiningSettingsFragment(dataModel: HomepageDataModel) : Fragment() {
// Map each item in the list of venues to a Venue Observable, then map each Venue to a DiningHall Observable
originalPreferences = dataModel.getDiningHallPrefs()
try {
mStudentLife.venues()
mStudentLife
.venues()
.flatMap { venues -> Observable.from(venues) }
.flatMap { venue ->
val hall = DiningFragment.createHall(venue)
Observable.just(hall)
}
.toList()
}.toList()
.subscribe({ diningHalls ->
mActivity.runOnUiThread {
halls = diningHalls
Expand Down Expand Up @@ -162,11 +164,12 @@ class DiningSettingsFragment(dataModel: HomepageDataModel) : Fragment() {

override fun failure(error: RetrofitError) {
Log.e("Dining", "Error saving dining preferences: $error")
Toast.makeText(
mActivity,
"Error saving dining preferences",
Toast.LENGTH_SHORT,
).show()
Toast
.makeText(
mActivity,
"Error saving dining preferences",
Toast.LENGTH_SHORT,
).show()
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FlingFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
): View {
// Inflate the layout for this fragment
_binding = FragmentFlingBinding.inflate(inflater, container, false)
val view = binding.root
Expand All @@ -75,13 +75,15 @@ class FlingFragment : Fragment() {
},
{
activity?.runOnUiThread {
Toast.makeText(
activity,
"Could not retrieve Spring Fling schedule",
Toast.LENGTH_LONG
).show()
Toast
.makeText(
activity,
"Could not retrieve Spring Fling schedule",
Toast.LENGTH_LONG,
).show()
}
})
},
)
} catch (e: Exception) {
e.printStackTrace()
}
Expand All @@ -96,8 +98,8 @@ class FlingFragment : Fragment() {

override fun onResume() {
super.onResume()
val mActivity: MainActivity? = activity as MainActivity
mActivity?.removeTabs()
mActivity?.setTitle(R.string.spring_fling)
val mActivity: MainActivity = activity as MainActivity
mActivity.removeTabs()
mActivity.setTitle(R.string.spring_fling)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.gsr_building.view.gsr_availability_in_building
import kotlinx.android.synthetic.main.gsr_building.view.gsr_building_name

class GsrBuildingHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class GsrBuildingHolder(
itemView: View,
) : RecyclerView.ViewHolder(itemView) {
internal var gsrBuildingName: TextView? = null
internal var recyclerView: RecyclerView? = null

Expand Down
Loading

0 comments on commit 1ca079a

Please sign in to comment.