Skip to content

Instantly share code, notes, and snippets.

@rodydavis
rodydavis / CoreDataOrderSave.swift
Created January 14, 2018 02:11
How to save core data order list after rearranging and support for CRUD operations
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
if let appDel = (UIApplication.shared.delegate as? AppDelegate) {
let contxt = appDel.persistentContainer.viewContext
RefreshCoredata()
if fromIndexPath.row > to.row
{
for i in to.row..<fromIndexPath.row
{
songs[i].setValue(i+1, forKey: "orderPosition")
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage("Alert message to be shown");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
public static class KeyBoardView extends Fragment {
//Hide Keyboard
public static void hideKeyboard(Context context) {
try {
((Activity) context).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
if ((((Activity) context).getCurrentFocus() != null) && (((Activity) context).getCurrentFocus().getWindowToken() != null)) {
((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(((Activity) context).getCurrentFocus().getWindowToken(), 0);
}
} catch (Exception e) {
e.printStackTrace();
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.main_search, menu);
SearchView sv = (SearchView) menu.findItem(R.id.action_search).getActionView();
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//Do something here
searchData(query, false);
return false;
@rodydavis
rodydavis / AutoIncrementBuilds.sh
Last active September 15, 2018 08:34
Auto Increment Build and Version Numbers
#Works with Xcode 9 (Confirmed)
#1. Go to "Edit Schemes"
#2. Go to "Build"
#3. Go to "Pre-Actions"
#4. Select YOUR app in "Provide Build Settings from:"
#5. Paste Below Script in Box
#6. Build Project
#Build Number ++
@rodydavis
rodydavis / jenkins_android_gradle_buildNum
Created February 28, 2018 15:56 — forked from firoze/jenkins_android_gradle_buildNum
[Android Gradle] Auto-Increment version code/name in AndroidManifest/Gradle before Jenkins Build
import java.util.regex.Pattern
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
buildscript {
repositories {
mavenCentral()
}
@rodydavis
rodydavis / README-Template.md
Created March 2, 2018 13:53 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

import UIKit
import XCPlayground
let containerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 375.0, height: 667.0))
XCPShowView(identifier: "Container View", view: containerView)
let circle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
circle.center = containerView.center
circle.layer.cornerRadius = 25.0
import 'dart:math' as math;
import 'package:meta/meta.dart';
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
theme: new ThemeData(
canvasColor: Colors.deepPurple,
iconTheme: new IconThemeData(color: Colors.white),
accentColor: Colors.pinkAccent,
import "package:flutter/material.dart";
void main() {
runApp(new ControlleApp());
}
class ControlleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(