Skip to content

Instantly share code, notes, and snippets.

View GursheeshSingh's full-sized avatar

theboringdeveloper GursheeshSingh

View GitHub Profile
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private static final int PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 1;
private Button openStorage;
private SharedPreferences sharedPreferences;
@GursheeshSingh
GursheeshSingh / MainActivity.java
Created April 13, 2019 20:20
If user selected Don't ask again option
//If User was asked permission before and denied
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle("Permission needed");
alertDialogBuilder.setMessage("Storage permission needed for accessing photos");
alertDialogBuilder.setPositiveButton("Open Setting", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
public class DatabaseLogger implements ILogger {
@Override
public void log(String message) {
//Log to Database here
}
}
public class InstanceFactory {
public static ILogger initLogger(){
return new FileLogger();
}
}
public class FirebaseLogin implements ILoginAuthentication {
private OnLoginCompleted listener;
public FirebaseLogin(OnLoginCompleted listener){
this.listener = listener;
}
@Override
public void login(String username, String password) {
class MySlider extends StatefulWidget {
@override
_MySliderState createState() => _MySliderState();
}
class _MySliderState extends State<MySlider> {
double _value = 0.5;
@override
Widget build(BuildContext context) {
@override
Widget build(BuildContext context) {
return SliderTheme(
data: SliderTheme.of(context).copyWith(
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 20)
),
child: Slider(
value: _value,
onChanged: (newValue){
setState(() {
var kCoolPurple = Color(0xFF5D37B9);
var kCoolGray = Colors.grey.shade200;
@override
Widget build(BuildContext context) {
return SliderTheme(
data: SliderTheme.of(context).copyWith(
activeTrackColor: kCoolPurple,
inactiveTrackColor: kCoolGray,
thumbColor: kCoolPurple,
overlayShape: RoundSliderOverlayShape(overlayRadius: 1),
),
child: Slider(
import 'package:flutter/material.dart';
class CircleThumbShape extends SliderComponentShape {
final double thumbRadius;
const CircleThumbShape({
this.thumbRadius = 6.0,
});