翰林优商.apk(点击下载) / a.java


package com.iBookStar.c;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import java.util.List;

public class a {
    private static a b;
    private final SQLiteDatabase a;

    /* renamed from: com.iBookStar.c.a$a  reason: collision with other inner class name */
    public static final class C0066a {
        private Cursor a;

        public C0066a(Cursor cursor) {
            this.a = cursor;
        }

        public int a(int i, int i2) {
            return this.a.isNull(i) ? i2 : this.a.getInt(i);
        }

        public int a(String str) {
            return this.a.getColumnIndex(str);
        }

        public long a(int i) {
            return this.a.getLong(i);
        }

        public long a(int i, long j) {
            return this.a.isNull(i) ? j : this.a.getLong(i);
        }

        public String a(int i, String str) {
            return this.a.isNull(i) ? str : this.a.getString(i);
        }

        public void a() {
            this.a.close();
        }

        public int b() {
            return this.a.getCount();
        }

        public boolean c() {
            return this.a.moveToFirst();
        }
    }

    private a(Context context) {
        this.a = context.openOrCreateDatabase("ymads.db", 0, null);
        b();
    }

    public static synchronized a a(Context context) {
        a aVar;
        synchronized (a.class) {
            if (b == null) {
                b = new a(context);
            }
            aVar = b;
        }
        return aVar;
    }

    private void a() {
        this.a.execSQL("CREATE TABLE IF NOT EXISTS AdRecord(id INTEGER PRIMARY KEY,url TEXT NOT NULL,package TEXT,class TEXT,taction TEXT,name TEXT,return_id TEXT,state INTEGER DEFAULT 0,cpd_urls TEXT,cpa_urls TEXT,cppd_urls TEXT,click_id TEXT,timestamp INTEGER)");
    }

    /* JADX WARNING: Code restructure failed: missing block: B:12:0x001b, code lost:
        if (r0 != 4) goto L_0x002d;
     */
    private void b() {
        int version = this.a.getVersion();
        if (version < 5) {
            this.a.beginTransaction();
            if (version == 0) {
                a();
            } else if (version != 1) {
                if (version != 2) {
                    if (version != 3) {
                    }
                    e();
                    f();
                    this.a.setTransactionSuccessful();
                    this.a.setVersion(5);
                    this.a.endTransaction();
                    this.a.execSQL("VACUUM");
                }
                d();
                e();
                f();
                this.a.setTransactionSuccessful();
                this.a.setVersion(5);
                this.a.endTransaction();
                this.a.execSQL("VACUUM");
            }
            c();
            d();
            e();
            f();
            this.a.setTransactionSuccessful();
            this.a.setVersion(5);
            this.a.endTransaction();
            this.a.execSQL("VACUUM");
        }
    }

    private void c() {
        this.a.execSQL("CREATE TABLE IF NOT EXISTS TaskRecord(id INTEGER PRIMARY KEY,taskId INTEGER,adClickDeep INTEGER,adDuration INTEGER,channelCode TEXT,coinRewardCount INTEGER,complete INTEGER,taskCount INTEGER,description TEXT,linkUrl TEXT,name TEXT,skipType INTEGER)");
    }

    private void d() {
        this.a.execSQL("ALTER TABLE TaskRecord ADD COLUMN totalTaskCount INTEGER");
        this.a.execSQL("ALTER TABLE TaskRecord ADD COLUMN bigPack INTEGER");
    }

    private void e() {
        this.a.execSQL("DELETE FROM TaskRecord");
    }

    private void f() {
        this.a.execSQL("CREATE TABLE IF NOT EXISTS BkConfig(id INTEGER PRIMARY KEY AUTOINCREMENT ,bk_key TEXT,bk_value TEXT,bk_timestamp INTEGER)");
        this.a.execSQL("CREATE UNIQUE INDEX key_index ON BkConfig(bk_key)");
    }

    public synchronized int a(String str, String str2, String[] strArr) {
        return this.a.delete(str, str2, strArr);
    }

    public synchronized long a(String str, ContentValues contentValues) {
        return this.a.insert(str, null, contentValues);
    }

    public synchronized C0066a a(String str, String[] strArr) {
        return new C0066a(this.a.rawQuery(str, strArr));
    }

    public synchronized List<Long> a(String str, List<ContentValues> list) {
        if (list != null) {
            if (list.size() > 0) {
                ArrayList arrayList = new ArrayList();
                this.a.beginTransaction();
                try {
                    for (ContentValues contentValues : list) {
                        arrayList.add(Long.valueOf(this.a.replace(str, null, contentValues)));
                    }
                    this.a.setTransactionSuccessful();
                    return arrayList;
                } catch (Exception e) {
                    e.printStackTrace();
                    return null;
                } finally {
                    this.a.endTransaction();
                }
            }
        }
        return null;
    }

    public synchronized void a(String str) {
        this.a.execSQL(str);
    }

    public synchronized long b(String str, ContentValues contentValues) {
        return this.a.replace(str, null, contentValues);
    }
}