Minor code improvements
This commit is contained in:
parent
d5463b335f
commit
8fc81dc00a
@ -91,20 +91,16 @@ public class AddButtonDialogSingle extends DialogFragment {
|
||||
public void onAttach(@NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
listener = (AddButtonDialogListenerSingle) frag;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(frag.toString() +
|
||||
"must implement ExampleDialogListener");
|
||||
}
|
||||
try {
|
||||
listener = (AddButtonDialogListenerSingle) frag;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(frag.toString() +
|
||||
"must implement ExampleDialogListener");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface AddButtonDialogListenerSingle {
|
||||
void applyTextsSingle(String name, String command, String button);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -37,8 +37,6 @@ public class AddHeadlineDialog extends DialogFragment {
|
||||
|
||||
editText_name = view.findViewById(R.id.dialogheadline_editText_name);
|
||||
|
||||
|
||||
|
||||
builder.setView(view)
|
||||
.setTitle(R.string.heading)
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
@ -81,20 +79,16 @@ public class AddHeadlineDialog extends DialogFragment {
|
||||
public void onAttach(@NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
listener = (AddHeadlineDialogListener) frag;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(frag.toString() +
|
||||
"must implement ExampleDialogListener");
|
||||
}
|
||||
try {
|
||||
listener = (AddHeadlineDialogListener) frag;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(frag.toString() +
|
||||
"must implement ExampleDialogListener");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface AddHeadlineDialogListener {
|
||||
void applyTextsHeadline(String headline);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -19,7 +19,6 @@ public class IntroActivity extends AppCompatActivity {
|
||||
show_logoanimation = p.getBoolean("Logoanimation", true);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (show_logoanimation) {
|
||||
|
||||
setContentView(R.layout.activity_intro);
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@ -32,16 +31,9 @@ public class IntroActivity extends AppCompatActivity {
|
||||
}
|
||||
}, 4000);
|
||||
} else {
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//Do something after 100ms
|
||||
Intent m = new Intent(getApplicationContext(), MainActivity.class);
|
||||
m.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(m);
|
||||
}
|
||||
}, 0);
|
||||
Intent m = new Intent(getApplicationContext(), MainActivity.class);
|
||||
m.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
public static boolean editmode = false;
|
||||
public static boolean button_vibration = false;
|
||||
|
||||
|
||||
|
||||
EditText editText_name;
|
||||
int lastID = 6969;
|
||||
|
||||
Map<String, MenuItem> tabitems = new HashMap<>();
|
||||
@ -95,21 +92,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
getWindow().setNavigationBarColor(Color.BLUE);
|
||||
}
|
||||
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
getWindow().setNavigationBarColor(Color.BLUE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
getWindow().setStatusBarContrastEnforced(false);
|
||||
}
|
||||
//getWindow().setBackgroundDrawableResource(R.drawable.toolbartop);
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
|
||||
if (savedInstanceState == null) {
|
||||
/*getSupportFragmentManager().beginTransaction()
|
||||
.replace(android.R.id.content, new DemoPreferenceFragment())
|
||||
.commit();
|
||||
NonDeveloperMessage.maybeShow(this);*/
|
||||
}
|
||||
SharedPreferences p = getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Language = p.getString("Language", "");
|
||||
Locale locale = new Locale(Language);
|
||||
@ -196,7 +185,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.addtabdialog, null);
|
||||
editText_name = view.findViewById(R.id.dialogtab_editText_name);
|
||||
EditText editText_name = view.findViewById(R.id.dialogtab_editText_name);
|
||||
|
||||
|
||||
mBuilder.setView(view)
|
||||
@ -396,7 +385,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
String tabsString = p.getString("tabs", null);
|
||||
List<String> tabs = new ArrayList<String>();
|
||||
List<String> tabs = new ArrayList<>();
|
||||
if (tabsString != null) {
|
||||
try {
|
||||
JSONArray tabsArray = new JSONArray(tabsString);
|
||||
@ -434,20 +423,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*static public class DemoPreferenceFragment extends PreferenceFragmentCompat {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
if (preference instanceof ColorPreference) {
|
||||
((ColorPreference) preference).showDialog(this, 0);
|
||||
} else super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
}*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
@ -558,11 +533,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
assert vr != null;
|
||||
vr.vibrate(100);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
finishAffinity();
|
||||
} else {
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
|
||||
|
||||
@ -602,8 +573,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (requestCode == CREATE_FILE && resultCode == RESULT_OK && null != data) {
|
||||
|
||||
data.getData();
|
||||
try {
|
||||
ParcelFileDescriptor pfd = getContentResolver().
|
||||
openFileDescriptor(data.getData(), "w");
|
||||
@ -625,19 +594,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
// Let the document provider know you're done by closing the stream.
|
||||
fileOutputStream.close();
|
||||
pfd.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JSONException e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else if (requestCode == PICK_PDF_FILE && resultCode == RESULT_OK && null != data) {
|
||||
try {
|
||||
|
||||
|
||||
ParcelFileDescriptor pfd = getContentResolver().
|
||||
openFileDescriptor(data.getData(), "r");
|
||||
FileInputStream fileInputStream =
|
||||
@ -660,17 +622,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
sharedEditor.apply();
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JSONException e) {
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,7 +634,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
ImageView I = findViewById(R.id.Background);
|
||||
byte[] BA = Base64.decode(Background, Base64.DEFAULT);
|
||||
I.setImageBitmap(BitmapFactory.decodeByteArray(BA, 0, BA.length));
|
||||
|
||||
}
|
||||
|
||||
public static int getScreenWidth() {
|
||||
|
Loading…
Reference in New Issue
Block a user