import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
/** * Created by HasanJawaid on 10/20/2017. */
public class DatabaseHandler extends SQLiteOpenHelper {
SQLiteDatabase sqLiteDatabase=getWritableDatabase();
private static final String dbname="sampledb";
private static final int dbver=1;
public DatabaseHandler(Context context) {
super(context, dbname, null, dbver);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CreateTableQry="Create Table if not exists UBAG(" +
"id integer primary key autoincrement not null, " +
"uname text , " +
"pword text , " +
"fname text , " +
"lname text , " +
"age integer, " +
"email text , " +
"gender text )";
db.execSQL(CreateTableQry);
Log.e("","UBAG Table Created...");
CreateTableQry = "Create Table if not exists USHIS(" +
"id integer, " +
"ldate Date, " +
"timein integer, " +
"timeout integer ) ";
db.execSQL(CreateTableQry);
Log.e("","USHIS Table Created...");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("Drop table if exists UBAG");
db.execSQL("Drop table if exists USHIS");
onCreate(db);
}
public long insert(ContentValues values,String TableName){
return (long) sqLiteDatabase.insert(TableName,null,values);
}
public long update(ContentValues values,String TableName,String criteria){
return sqLiteDatabase.update(TableName,values,criteria,null);
}
public long delete(String TableName,String criteria){
return sqLiteDatabase.delete(TableName,criteria,null);
}
public Cursor getData(String query){
Cursor cursor=null;
try {
cursor = sqLiteDatabase.rawQuery(query, null);
}catch (Exception e){
Log.e("GD","DB Helper Found Error " + query);
}
cursor.moveToFirst();
return cursor;
}
}
Want to speed up your internet ptcl broadband connection and browsing performance?you are in the right place. In this tutorial I will tells you the things related to hardware and settings of network connection by which you can increase your browsing performance up to 50%. These settings works for almost all the routers of ptcl. So lets start the steps:
• Make sure that your telephone line cable is not cut’s or joints in any places. Because it’s brings down the signal ability so if cuts and joints found in this case you will have to buy higher gage cable. According to your distance from dp to home buy that much length cable. Additional cable length brings down the signaling ability.
• Connect your computer to the ADSL router via RJ-45 cable (it always comes with modem and if you are using that than ok).
• Open your browser and type 192.168.1.1 and type your password and username (default username and password is admin for mostly routers). Do this if your Ip address of the router isn’t modified. But you don’t need to this modem is fully configured by the ptcl person on the delivery day of modem.
Now it’s time the settings in windows. It’s very easy just follow the instruction. These changes will speed up your browsing performance up to 50%.
For Windows Xp users.
• See in the right side of taskbar and right click on “Network Adopter” and than click on TCP/IPv-4. Obtain Ip automatically leave this as it is . Select “Use the following DNS server addresses” and put the primary DNS value “8.8.8.8” and Secondary DNS value 8.8.4.4 and ok.
For Windows Vista, 7 and 8 users.
• Right click on the Network icon present in the right side of taskbar and click on “Open Network and Sharing”.
• Click on “change adopter settings” present in the left side of panel.
• Right click on “Local Area Connection” and select the properties.
• “This connection uses the following items”. In the list click on Internet Protocol Version 4 (TCP/IPv-4) and than click on its properties.
• Do not touch IP address etc just do this select “Use the following DNS server addresses” and put the primary DNS value “8.8.8.8” and Secondary DNS value “8.8.4.4” and ok.
Computer system reserved 20% (default) bandwidth. We have to changed it value to “0” to make our internet connection more faster. So to do this change follow these simple instructions:
• Open your “Run” by pressing the windows + R keys or you can open it from start menu it’s doesn’t matter.
• In run type “gpedit.msc”
• In the left panel double click or click on “+” symbol left to the “Administrative Templates”.
• Now double click on “Network”
• Now single click on “QoS Packet Scheduler” and in the right panel double click on “Lamit reservable bandwidth” menu will appear.
• Make it “Enabled” and in options panel “Limited bandwidth (%):” remove the default value and put only one “0” in the field and ok.
By fixing the cables issues if found and by doing this settings will boost your internet speed up to 50%. It’s really work(How to speed up internet ptcl broadband) so enjoy your fast browsing. Now it’s time for you to support and help us to share our voice. Subscribe us and share this articles with your friends so they will also take advantage from these simple settings and boost there internet speed.
Glide is an Image Loader Library for Android developed by bumptech and is a library that is recommended by Google. It has been used in many Google open source projects including Google I/O 2014 official application. It provides animated GIF support and handles image loading/caching.
You can configure Glide by creating a GlideConfiguration.java file:
publicclassGlideConfigurationimplementsGlideModule {
@OverridepublicvoidapplyOptions(Contextcontext, GlideBuilderbuilder) {
// Apply options to the builder here.// Glide default Bitmap Format is set to RGB_565 since it // consumed just 50% memory footprint compared to ARGB_8888.// Increase memory usage for quality with:
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
}
@OverridepublicvoidregisterComponents(Contextcontext, Glideglide) {
// register ModelLoaders here.
}
}
And then define it as meta-data inside AndroidManifest.xml:
Ideally, an image's dimensions would match exactly those of the ImageView in which it is being displayed, but as this is often not the case, care must be taken to resize and/or scale the image appropriately. Android's native support for this isn't robust, especially when displaying very large images (such as bitmaps returned from the camera) in smaller image views, which can often lead to errors (see Troubleshooting).
Glide automatically limits the size of the image it holds in memory to the ImageView dimensions. Picasso has the same ability, but requires a call to fit(). With Glide, if you don't want the image to be automatically fitted to the ImageView, you can call override(horizontalSize, verticalSize). This will resize the image before displaying it in the ImageView but without respect to the image's aspect ratio:
Glide.with(context)
.load("http://via.placeholder.com/300.png")
.override(100, 200) // resizes the image to 100x200 pixels but does not respect aspect ratio
.into(ivImg);
Resizing images in this way without respect to the original aspect ratio will often make the image appear skewed or distorted. In most cases, this should be avoided, and Glide offers two standard scaling transformation options to prevent this: centerCrop and fitCenter.
If you only want to resize one dimension, use Target.SIZE_ORIGINAL as a placeholder for the other dimension:
Glide.with(context)
.load("http://via.placeholder.com/300.png")
.override(100, Target.SIZE_ORIGINAL) // resizes width to 100, preserves original height, does not respect aspect ratio
.into(ivImg);
centerCrop()
Calling centerCrop() scales the image so that it fills the requested bounds of the ImageView and then crops the extra. The ImageView will be filled completely, but the entire image might not be displayed.
Glide.with(context)
.load("http://via.placeholder.com/300.png")
.override(100, 200)
.centerCrop() // scale to fill the ImageView and crop any extra
.into(ivImg);
fitCenter()
Calling fitCenter() scales the image so that both dimensions are equal to or less than the requested bounds of the ImageView. The image will be displayed completely, but might not fill the entire ImageView.
Glide.with(context)
.load("http://via.placeholder.com/300.png")
.override(100, 200)
.fitCenter() // scale to fit entire image within ImageView
.into(ivImg);
Troubleshooting
OutOfMemoryError Loading Errors
If an image or set of images aren't loading, make sure to check the Android monitor log in Android Studio. There's a good chance you might see an java.lang.OutOfMemoryError "Failed to allocate a [...] byte allocation with [...] free bytes" or a Out of memory on a 51121168-byte allocation.. This is quite common and means that you are loading one or more large imagesthat have not been properly resized.
First, you have to find which image(s) being loaded are likely causing this error. For any given Glide call, we can fix this by one or more of the following approaches:
Add an explicit width or height to the ImageView by setting layout_width=500dp in the layout file.
Call .override(width, height) during the Glide load and explicitly set a width or height for the image such as: Glide.with(...).load(imageUri).override(500, 500).into(...).
Try removing android:adjustViewBounds="true" from your ImageView if present and if you not calling .override()
Open up your static placeholder or error images and make sure their dimensions are relatively small (< 500px width). If not, resize those static images and save them back to your project.
Applying these tips to all of your Glide image loads should resolve any out of memory issues. As a fallback, you might want to open up your AndroidManifest.xml and then add android:largeHeapto your manifest:
Note that this is not generally a good idea, but can be used temporarily to trigger fewer out of memory errors.
Loading Errors
If you experience errors loading images, you can create a RequestListener<String, GlideDrawable> and pass it in via Glide.listener() to intercept errors:
Glide.with(context)
.load("http://via.placeholder.com/300.png")
.placeholder(R.drawable.placeholder)
.error(R.drawable.imagenotfound)
.listener(newRequestListener<String, GlideDrawable>() {
@OverridepublicbooleanonException(Exceptione, Stringmodel, Target<GlideDrawable>target, booleanisFirstResource) {
// log exceptionLog.e("TAG", "Error loading image", e);
returnfalse; // important to return false so the error placeholder can be placed
}
@OverridepublicbooleanonResourceReady(GlideDrawableresource, Stringmodel, Target<GlideDrawable>target, booleanisFromMemoryCache, booleanisFirstResource) {
returnfalse;
}
})
.into(ivImg);
Transformations
Transformations are supported by an additional third-party library, glide-transformations. First, add the dependencies:
dependencies {
compile 'jp.wasabeef:glide-transformations:2.0.2'// If you want to use the GPU Filters
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
}
Rounded Corners
int radius =30; // corner radius, higher value = more roundedint margin =10; // crop margin, set to 0 for corners with no cropGlide.with(this)
.load("http://via.placeholder.com/300.png")
.bitmapTransform(newRoundedCornersTransformation(context, radius, margin))
.into(ivImg);
Add a ProgressBar or otherwise handle callbacks for an image that is loading:
progressBar.setVisibility(View.VISIBLE);
Glide.with(this)
.load("http://via.placeholder.com/300.png")
.listener(newRequestListener<String, GlideDrawable>() {
@OverridepublicbooleanonException(Exceptione, Stringmodel, Target<GlideDrawable>target, booleanisFirstResource) {
progressBar.setVisibility(View.GONE);
returnfalse; // important to return false so the error placeholder can be placed
}
@OverridepublicbooleanonResourceReady(GlideDrawableresource, Stringmodel, Target<GlideDrawable>target, booleanisFromMemoryCache, booleanisFirstResource) {
progressBar.setVisibility(View.GONE);
returnfalse;
}
})
.into(ivImg);
Adjusting Image Size Dynamically
To readjust the ImageView size after the image has been retrieved, first define a SimpleTarget<Bitmap> object to intercept the Bitmap once it is loaded:
privateSimpleTarget target =newSimpleTarget<Bitmap>() {
@OverridepublicvoidonResourceReady(Bitmapbitmap, GlideAnimationglideAnimation) {
// do something with the bitmap// set it to an ImageView
imageView.setImageBitmap(bitmap);
}
};
Note: The SimpleTarget object must be stored as a member field or method and cannot be an anonymous class otherwise this won't work as expected. The reason is that Glide accepts this parameter as a weak memory reference, and because anonymous classes are eligible for garbage collection when there are no more references, the network request to fetch the image may finish after this anonymous class has already been reclaimed. See this Stack Overflow discussion for more details.
In other words, you cannot do this all inline Glide.with(this).load("url").into(new SimpleTarget<Bitmap>() { ... }) as in other scenarios.
Networking
By default, Glide uses the Volley networking library.
Using with OkHttp
There is a way to use Glide to use OkHttp instead, which may be useful if you need to do authenticated requests. First, add the okhttp3-integration library as a dependency:
Next, you can configure Glide to use OkHttp in XML or through Java. The Java approach is useful especially if you already have a shared instance of OkHttpClient: