Skip to content

Commit

Permalink
fixed some repetation bugs and new methods added
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdomrider committed Nov 20, 2019
1 parent 40025f2 commit 05bf946
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 68 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file added .idea/caches/gradle_models.ser
Binary file not shown.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
Expand Down Expand Up @@ -28,4 +30,8 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//implementation 'com.github.wisdomrider:SqliteClosedHelper:2.4.0'
implementation project(':sqliteclosedhelper')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.wisdomrider.sqliteclosedhelperr

import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Base64

import com.wisdomrider.sqliteclosedhelper.SqliteClosedHelper
import java.io.ByteArrayOutputStream
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.widget.Toast
import com.wisdomrider.sqliteclosedhelper.SQLITECONSTANTS


class MainActivity : AppCompatActivity() {

class App(var name: String,
var link: String,
var icon: String) {
constructor() : this("", "", "")
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val helper = SqliteClosedHelper(this, "DBNAME")
helper.createTable(App("", "", ""))
val mainIntent = Intent(Intent.ACTION_MAIN, null)
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER)
var apps = getPackageManager().queryIntentActivities(mainIntent, 0)
helper.removeAll(App())
helper.delete(App(), SQLITECONSTANTS.AND)
apps.forEachIndexed { index, it ->
var label = it.activityInfo.loadLabel(packageManager)
var icon = drawableToBitmap(it.loadIcon(packageManager))!!
val bao = ByteArrayOutputStream()
icon.compress(Bitmap.CompressFormat.JPEG, 90, bao)
val ba = bao.toByteArray()
val ba1 = Base64.encodeToString(ba, Base64.NO_WRAP)
val item =
App(label.toString().replace("'", "\""), it.activityInfo.applicationInfo.publicSourceDir, ba1)
helper.insertTable(item)

}

helper.getAll(App("", "", "")).forEach {
Toast.makeText(this@MainActivity, it.name, Toast.LENGTH_SHORT).show()
}

}


fun drawableToBitmap(drawable: Drawable): Bitmap? {
var bitmap: Bitmap? = null

if (drawable is BitmapDrawable) {
if (drawable.bitmap != null) {
return drawable.bitmap
}
}

if (drawable.intrinsicWidth <= 0 || drawable.intrinsicHeight <= 0) {
bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) // Single color bitmap will be created of 1x1 pixel
} else {
bitmap = Bitmap.createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888)
}

val canvas = Canvas(bitmap)
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight())
drawable.draw(canvas)
return bitmap
}
}
Empty file.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

ext.kotlin_version = '1.3.60'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public interface Interface {

<T> SqliteClosedHelper updateTable(T t);

<T> SqliteClosedHelper updateTable(T data,T condition,String CASE);

<T> ArrayList<T> whereAND(T t);

<T> SqliteClosedHelper delete(T t,String CASE);

<T> SqliteClosedHelper delete(T t);

<T> ArrayList<T> whereOR(T t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public Object getSqliteValue() {

public String getSqliteType() {
if (field.getType().equals(Integer.class) || field.getType().equals(int.class)) {
return Constants.INTEGER;
return SQLITECONSTANTS.INTEGER;
} else if (field.getType().equals(Double.class) || field.getType().equals(double.class) || field.getType().equals(Float.class) || field.getType().equals(float.class)) {
return Constants.REAL;
return SQLITECONSTANTS.REAL;
} else if (field.getType().equals(Long.class) || field.getType().equals(long.class)) {
return Constants.NUMERIC;
return SQLITECONSTANTS.NUMERIC;
} else {
return Constants.TEXT;
return SQLITECONSTANTS.TEXT;
}
}

Expand Down Expand Up @@ -130,13 +130,13 @@ public boolean isNull() {
public String getAnnotations() {
String annotations = "";
if (field.isAnnotationPresent(SqliteAnnotations.Primary.class))
annotations += " " + Constants.PRIMARY + " ";
annotations += " " + SQLITECONSTANTS.PRIMARY + " ";
if (field.isAnnotationPresent(SqliteAnnotations.Nullable.class) && !field.getAnnotation(SqliteAnnotations.Nullable.class).isNullable())
annotations += " " + Constants.NOT_NULLABLE + " ";
annotations += " " + SQLITECONSTANTS.NOT_NULLABLE + " ";
if (field.isAnnotationPresent(SqliteAnnotations.AutoIncrement.class))
annotations += " " + Constants.AUTO_INCREMENT + " ";
annotations += " " + SQLITECONSTANTS.AUTO_INCREMENT + " ";
if (field.isAnnotationPresent(SqliteAnnotations.Unique.class))
annotations += " " + Constants.UNIQUE + " ";
annotations += " " + SQLITECONSTANTS.UNIQUE + " ";
return annotations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ Created By WisdomRider(Avishek Adhikari)
Thanks !!
*/
public class Constants {
public class SQLITECONSTANTS {

public static final String DEFAULT_ID ="id" ;


public static final String INTEGER ="INTEGER" ;
public static final String REAL ="REAL" ;
public static final String NUMERIC ="NUMERIC" ;
Expand Down
Loading

0 comments on commit 05bf946

Please sign in to comment.