Skip to content

Instantly share code, notes, and snippets.

View whit3hawks's full-sized avatar
🎯
Focusing

Sharif khaleel whit3hawks

🎯
Focusing
View GitHub Profile
@whit3hawks
whit3hawks / generateGif.swift
Created May 20, 2017 05:05
Generating a GIF from UIImages (Swift 3)
func generateGif(photos: [UIImage], filename: String) -> Bool {
if let docsDirectory = getDocumentsDirectory() {
let url = docsDirectory.appendingPathComponent(filename)
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]]
let gifProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: 0.125]]
if let destination = CGImageDestinationCreateWithURL(url as CFURL, kUTTypeGIF, photos.count, nil) {
CGImageDestinationSetProperties(destination, fileProperties as CFDictionary?)
for photo in photos {
CGImageDestinationAddImage(destination, photo.cgImage!, gifProperties as CFDictionary?)
}
@whit3hawks
whit3hawks / Change the color of the Selected Text in Android Spinner.
Created January 15, 2017 14:53
Change the color of the Selected Text in Android Spinner.
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
((TextView) parentView.getChildAt(0)).setTextColor(Color.WHITE);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
@whit3hawks
whit3hawks / Java Array of all Country Names
Last active October 17, 2023 10:55
Java Array of all Country Names.
String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falklan
@whit3hawks
whit3hawks / Android RTL
Created April 28, 2015 06:15
Function to apply native RTL support for your Android applications.
private void applyRTL(){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
}
}