瀏覽代碼

Merge pull request #12168 from nextcloud/refactor/convert-FilePickerActivity-to-kt

Convert FilePickerActivity to Kotlin
Andy Scherzinger 1 年之前
父節點
當前提交
ddad5ebf6e

+ 18 - 29
app/src/main/java/com/owncloud/android/ui/activity/FilePickerActivity.java → app/src/main/java/com/owncloud/android/ui/activity/FilePickerActivity.kt

@@ -18,40 +18,29 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
+package com.owncloud.android.ui.activity
 
-package com.owncloud.android.ui.activity;
-
-import android.os.Bundle;
-import android.view.View;
-
-import com.owncloud.android.R;
-import com.owncloud.android.ui.fragment.OCFileListFragment;
-
-import androidx.fragment.app.FragmentTransaction;
+import android.os.Bundle
+import com.owncloud.android.R
+import com.owncloud.android.ui.fragment.OCFileListFragment
 
 /**
  * File picker of remote files
  */
-public class FilePickerActivity extends FolderPickerActivity {
-
-    @Override
-    public void onClick(View v) {
-        super.onClick(v);
-    }
+class FilePickerActivity : FolderPickerActivity() {
 
-    @Override
-    protected void createFragments() {
-        OCFileListFragment listOfFiles = new OCFileListFragment();
-        Bundle args = new Bundle();
-        args.putBoolean(OCFileListFragment.ARG_ONLY_FOLDERS_CLICKABLE, true);
-        args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true);
-        args.putBoolean(OCFileListFragment.ARG_HIDE_ITEM_OPTIONS, true);
-        args.putBoolean(OCFileListFragment.ARG_SEARCH_ONLY_FOLDER, false);
-        args.putBoolean(OCFileListFragment.ARG_FILE_SELECTABLE, true);
-        args.putString(OCFileListFragment.ARG_MIMETYPE, getIntent().getStringExtra(OCFileListFragment.ARG_MIMETYPE));
-        listOfFiles.setArguments(args);
-        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-        transaction.add(R.id.fragment_container, listOfFiles, TAG_LIST_OF_FOLDERS);
-        transaction.commit();
+    override fun createFragments() {
+        val listOfFiles = OCFileListFragment()
+        val args = Bundle()
+        args.putBoolean(OCFileListFragment.ARG_ONLY_FOLDERS_CLICKABLE, true)
+        args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true)
+        args.putBoolean(OCFileListFragment.ARG_HIDE_ITEM_OPTIONS, true)
+        args.putBoolean(OCFileListFragment.ARG_SEARCH_ONLY_FOLDER, false)
+        args.putBoolean(OCFileListFragment.ARG_FILE_SELECTABLE, true)
+        args.putString(OCFileListFragment.ARG_MIMETYPE, intent.getStringExtra(OCFileListFragment.ARG_MIMETYPE))
+        listOfFiles.arguments = args
+        val transaction = supportFragmentManager.beginTransaction()
+        transaction.add(R.id.fragment_container, listOfFiles, TAG_LIST_OF_FOLDERS)
+        transaction.commit()
     }
 }

+ 2 - 1
app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt

@@ -616,6 +616,7 @@ open class FolderPickerActivity :
         const val MOVE_OR_COPY = "MOVE_OR_COPY"
         const val CHOOSE_LOCATION = "CHOOSE_LOCATION"
         private val TAG = FolderPickerActivity::class.java.simpleName
-        protected const val TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS"
+
+        const val TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS"
     }
 }