This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…loses #1158)
- Loading branch information
Showing
18 changed files
with
398 additions
and
268 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
95 changes: 0 additions & 95 deletions
95
app/src/main/java/com/itsaky/androidide/fragments/DiagnosticsListFragment.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/itsaky/androidide/fragments/DiagnosticsListFragment.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,35 @@ | ||
/* | ||
* This file is part of AndroidIDE. | ||
* | ||
* AndroidIDE is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* AndroidIDE is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.itsaky.androidide.fragments | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.itsaky.androidide.R | ||
import com.itsaky.androidide.adapters.DiagnosticsAdapter | ||
|
||
class DiagnosticsListFragment : RecyclerViewFragment<DiagnosticsAdapter>() { | ||
|
||
override fun onCreateAdapter(): RecyclerView.Adapter<*> { | ||
return DiagnosticsAdapter(ArrayList(), null) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
emptyStateViewModel.emptyMessage.value = getString(R.string.msg_emptyview_diagnostics) | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/itsaky/androidide/fragments/EmptyStateFragment.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,79 @@ | ||
/* | ||
* This file is part of AndroidIDE. | ||
* | ||
* AndroidIDE is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* AndroidIDE is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.itsaky.androidide.fragments | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.viewModels | ||
import androidx.viewbinding.ViewBinding | ||
import com.itsaky.androidide.databinding.FragmentEmptyStateBinding | ||
import com.itsaky.androidide.viewmodel.EmptyStateFragmentViewModel | ||
|
||
/** | ||
* A fragment that shows a message when there is no data to show in the subclass fragment. | ||
* | ||
* @author Akash Yadav | ||
*/ | ||
abstract class EmptyStateFragment<T : ViewBinding>(layout: Int, | ||
bind: (View) -> T) : FragmentWithBinding<T>(layout, bind) { | ||
|
||
protected var emptyStateBinding: FragmentEmptyStateBinding? = null | ||
private set | ||
|
||
protected val emptyStateViewModel by viewModels<EmptyStateFragmentViewModel>() | ||
|
||
internal var isEmpty: Boolean | ||
get() = emptyStateViewModel.isEmpty.value ?: false | ||
set(value) { | ||
emptyStateViewModel.isEmpty.value = value | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View { | ||
|
||
return FragmentEmptyStateBinding.inflate(inflater, container, false).also { emptyStateBinding -> | ||
this.emptyStateBinding = emptyStateBinding | ||
|
||
// add the main fragment view | ||
emptyStateBinding.root.addView( | ||
super.onCreateView(inflater, emptyStateBinding.root, savedInstanceState) | ||
) | ||
}.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
emptyStateViewModel.isEmpty.observe(viewLifecycleOwner) { isEmpty -> | ||
emptyStateBinding?.apply { | ||
root.displayedChild = if (isEmpty) 0 else 1 | ||
} | ||
} | ||
|
||
emptyStateViewModel.emptyMessage.observe(viewLifecycleOwner) { message -> | ||
emptyStateBinding?.emptyView?.message = message | ||
} | ||
} | ||
|
||
override fun onDestroyView() { | ||
this.emptyStateBinding = null | ||
super.onDestroyView() | ||
} | ||
} |
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.