-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite to use fragments for better view control
- Loading branch information
Showing
13 changed files
with
432 additions
and
247 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
306 changes: 153 additions & 153 deletions
306
android/fuse/src/main/java/com/breautek/fuse/FuseActivity.java
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 |
---|---|---|
@@ -1,153 +1,153 @@ | ||
|
||
/* | ||
Copyright 2023 Breautek | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package com.breautek.fuse; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.ContentView; | ||
import androidx.annotation.LayoutRes; | ||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import android.content.Intent; | ||
import android.view.View; | ||
import androidx.core.view.WindowCompat; | ||
import androidx.core.view.WindowInsetsControllerCompat; | ||
|
||
import android.view.Window; | ||
|
||
import com.breautek.fuse.plugins.IFusePluginRegistrar; | ||
|
||
/** | ||
* Convenience class that can be extended which provides | ||
* a FuseContext with all the glue bits already done. | ||
* | ||
* If fine control is required, it is possible to create the FuseContext | ||
* itself, you'll need to pass through the following lifecycle methods: | ||
* - onCreate(Bundle) | ||
* - onStart | ||
* - onResume | ||
* - onPause | ||
* - onSaveInstanceState(Bundle) | ||
* - onLowMemory | ||
* - onRequestPermissionsResult | ||
* - onStop | ||
* - onDestroy | ||
*/ | ||
public class FuseActivity extends AppCompatActivity { | ||
|
||
private FuseContext $fuseContext; | ||
|
||
public FuseActivity() { | ||
super(); | ||
$init(); | ||
} | ||
|
||
@ContentView | ||
public FuseActivity(@LayoutRes int contentLayoutId) { | ||
super(contentLayoutId); | ||
$init(); | ||
} | ||
|
||
private void $init() { | ||
$fuseContext = new FuseContext(this, this::_onContextReady); | ||
$fuseContext.$pluginMapLock.writeLock().lock(); | ||
_registerFusePlugins(plugin -> $fuseContext.$registerPlugin(plugin)); | ||
$fuseContext.$pluginMapLock.writeLock().unlock(); | ||
} | ||
|
||
protected void _onContextReady() {} | ||
|
||
/** | ||
* Can be overwritten by subclasses to register plugins | ||
* | ||
* @param registrar | ||
*/ | ||
protected void _registerFusePlugins(IFusePluginRegistrar registrar) {} | ||
|
||
public FuseContext getFuseContext() { | ||
return $fuseContext; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
Window window = getWindow(); | ||
WindowCompat.setDecorFitsSystemWindows(window, false); | ||
$fuseContext.onCreate(savedInstanceState); | ||
View contentView = $fuseContext.getLayout(); | ||
setContentView(contentView); | ||
|
||
WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, contentView); | ||
controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_DEFAULT); | ||
} | ||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
$fuseContext.onStart(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
$fuseContext.onStop(); | ||
} | ||
|
||
@Override | ||
public void onLowMemory() { | ||
super.onLowMemory(); | ||
$fuseContext.onLowMemory(); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
$fuseContext.onPause(); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
$fuseContext.onResume(); | ||
} | ||
|
||
@Override | ||
protected void onSaveInstanceState(@NonNull Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
$fuseContext.onSaveInstanceState(outState); | ||
} | ||
|
||
@Override | ||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
$fuseContext.onRequestPermissionResult(requestCode, permissions, grantResults); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
super.onActivityResult(requestCode, resultCode, data); | ||
$fuseContext.onActivityResult(requestCode, resultCode, data); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
$fuseContext.onDestroy(); | ||
} | ||
} | ||
// | ||
///* | ||
//Copyright 2023 Breautek | ||
// | ||
//Licensed under the Apache License, Version 2.0 (the "License"); | ||
//you may not use this file except in compliance with the License. | ||
//You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
//Unless required by applicable law or agreed to in writing, software | ||
//distributed under the License is distributed on an "AS IS" BASIS, | ||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
//See the License for the specific language governing permissions and | ||
//limitations under the License. | ||
//*/ | ||
// | ||
//package com.breautek.fuse; | ||
// | ||
//import android.os.Bundle; | ||
// | ||
//import androidx.annotation.ContentView; | ||
//import androidx.annotation.LayoutRes; | ||
//import androidx.annotation.NonNull; | ||
//import androidx.appcompat.app.AppCompatActivity; | ||
//import android.content.Intent; | ||
//import android.view.View; | ||
//import androidx.core.view.WindowCompat; | ||
//import androidx.core.view.WindowInsetsControllerCompat; | ||
// | ||
//import android.view.Window; | ||
// | ||
//import com.breautek.fuse.plugins.IFusePluginRegistrar; | ||
// | ||
///** | ||
// * Convenience class that can be extended which provides | ||
// * a FuseContext with all the glue bits already done. | ||
// * | ||
// * If fine control is required, it is possible to create the FuseContext | ||
// * itself, you'll need to pass through the following lifecycle methods: | ||
// * - onCreate(Bundle) | ||
// * - onStart | ||
// * - onResume | ||
// * - onPause | ||
// * - onSaveInstanceState(Bundle) | ||
// * - onLowMemory | ||
// * - onRequestPermissionsResult | ||
// * - onStop | ||
// * - onDestroy | ||
// */ | ||
//public class FuseActivity extends AppCompatActivity { | ||
// | ||
// private FuseContext $fuseContext; | ||
// | ||
// public FuseActivity() { | ||
// super(); | ||
// $init(); | ||
// } | ||
// | ||
// @ContentView | ||
// public FuseActivity(@LayoutRes int contentLayoutId) { | ||
// super(contentLayoutId); | ||
// $init(); | ||
// } | ||
// | ||
// private void $init() { | ||
// $fuseContext = new FuseContext(this, this::_onContextReady); | ||
// $fuseContext.$pluginMapLock.writeLock().lock(); | ||
// _registerFusePlugins(plugin -> $fuseContext.$registerPlugin(plugin)); | ||
// $fuseContext.$pluginMapLock.writeLock().unlock(); | ||
// } | ||
// | ||
// protected void _onContextReady() {} | ||
// | ||
// /** | ||
// * Can be overwritten by subclasses to register plugins | ||
// * | ||
// * @param registrar | ||
// */ | ||
// protected void _registerFusePlugins(IFusePluginRegistrar registrar) {} | ||
// | ||
// public FuseContext getFuseContext() { | ||
// return $fuseContext; | ||
// } | ||
// | ||
// @Override | ||
// protected void onCreate(Bundle savedInstanceState) { | ||
// super.onCreate(savedInstanceState); | ||
// | ||
// Window window = getWindow(); | ||
// WindowCompat.setDecorFitsSystemWindows(window, false); | ||
// $fuseContext.onCreate(savedInstanceState); | ||
// View contentView = $fuseContext.getLayout(); | ||
// setContentView(contentView); | ||
// | ||
// WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, contentView); | ||
// controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_DEFAULT); | ||
// } | ||
// | ||
// @Override | ||
// protected void onStart() { | ||
// super.onStart(); | ||
// $fuseContext.onStart(); | ||
// } | ||
// | ||
// @Override | ||
// protected void onStop() { | ||
// super.onStop(); | ||
// $fuseContext.onStop(); | ||
// } | ||
// | ||
// @Override | ||
// public void onLowMemory() { | ||
// super.onLowMemory(); | ||
// $fuseContext.onLowMemory(); | ||
// } | ||
// | ||
// @Override | ||
// protected void onPause() { | ||
// super.onPause(); | ||
// $fuseContext.onPause(); | ||
// } | ||
// | ||
// @Override | ||
// protected void onResume() { | ||
// super.onResume(); | ||
// $fuseContext.onResume(); | ||
// } | ||
// | ||
// @Override | ||
// protected void onSaveInstanceState(@NonNull Bundle outState) { | ||
// super.onSaveInstanceState(outState); | ||
// $fuseContext.onSaveInstanceState(outState); | ||
// } | ||
// | ||
// @Override | ||
// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
// super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
// $fuseContext.onRequestPermissionResult(requestCode, permissions, grantResults); | ||
// } | ||
// | ||
// @Override | ||
// protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
// super.onActivityResult(requestCode, resultCode, data); | ||
// $fuseContext.onActivityResult(requestCode, resultCode, data); | ||
// } | ||
// | ||
// @Override | ||
// protected void onDestroy() { | ||
// super.onDestroy(); | ||
// $fuseContext.onDestroy(); | ||
// } | ||
//} |
Oops, something went wrong.