android: Minor refactor

Reduces the level of indentation, and makes the code easier to read.
This commit is contained in:
Vishesh Handa
2019-01-23 19:56:24 +01:00
parent b9b42d950f
commit 03db7d62e7

View File

@ -18,22 +18,19 @@ import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
// For EventChannel
import io.flutter.plugin.common.EventChannel;
import io.flutter.util.PathUtils; import io.flutter.util.PathUtils;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity implements MethodCallHandler {
private static final String CHANNEL = "gitjournal.io/git"; private static final String CHANNEL_NAME = "gitjournal.io/git";
private static final String STREAM_CLONE_CHANNEL = "gitjournal.io/gitClone";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this); GeneratedPluginRegistrant.registerWith(this);
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler( new MethodChannel(getFlutterView(), CHANNEL_NAME).setMethodCallHandler(this);
new MethodCallHandler() { }
@Override @Override
public void onMethodCall(MethodCall call, Result result) { public void onMethodCall(MethodCall call, Result result) {
final String filesDir = PathUtils.getFilesDir(getApplicationContext()); final String filesDir = PathUtils.getFilesDir(getApplicationContext());
@ -114,7 +111,6 @@ public class MainActivity extends FlutterActivity {
return; return;
} }
String cloneLocation = filesDir + "/" + folderName; String cloneLocation = filesDir + "/" + folderName;
new GitRmTask(result).execute(cloneLocation, filePattern); new GitRmTask(result).execute(cloneLocation, filePattern);
@ -185,21 +181,4 @@ public class MainActivity extends FlutterActivity {
result.notImplemented(); result.notImplemented();
} }
});
new EventChannel(getFlutterView(), STREAM_CLONE_CHANNEL).setStreamHandler(
new EventChannel.StreamHandler() {
@Override
public void onListen(Object args, final EventChannel.EventSink events) {
Log.w("CloneStream", "adding listener");
}
@Override
public void onCancel(Object args) {
Log.w("CloneStream", "cancelling listener");
}
}
);
}
} }