Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- try {
- this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- //mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
- //setSupportActionBar(mToolbar);
- // setSupportActionBar((android.support.v7.widget.Toolbar)mToolbar);
- // getSupportActionBar().setDisplayShowHomeEnabled(true);
- ViewConfiguration config = ViewConfiguration.get(this);
- Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
- if(menuKeyField != null) {
- menuKeyField.setAccessible(true);
- menuKeyField.setBoolean(config, false);
- }
- Constants.SytemLanguage= Locale.getDefault().getDisplayLanguage();
- File f = new File(Environment.getExternalStorageDirectory()+"/BookerDroid");
- Constants.TempPath=f.getAbsolutePath()+"/Temp";
- File f2= new File(Constants.TempPath);
- if ( !f.exists())
- {
- f.mkdir();
- }
- if (!f2.exists())
- {
- f2.mkdirs() ;
- }
- BitmapTools.CreateImageStorage();
- if( Constants.SytemLanguage!= Locale.ENGLISH.getDisplayLanguage())
- {
- Constants.cels = Constants.grBookCells;
- Constants.rtcels=Constants.grLentbookbifCells;
- }
- else
- {
- Constants.cels = Constants.enBookCells;
- Constants.rtcels=Constants.enLentbookbifCells;
- }
- prefs= getSharedPreferences(Constants.PREFSFILE, MODE_APPEND);
- Constants.wtusername= prefs.getString(Constants.PREF_WT_USERNAME, null);
- Constants.wtpassword= prefs.getString(Constants.PREF_WT_PASSWORD, null);
- Constants.wtpassphrase=prefs.getString(Constants.PREF_WT_PASSPHRASE, null);
- Constants.wtserverip = prefs.getString(Constants.PREF_WT_SERVERIP, null);
- Constants.wtclientmode= prefs.getBoolean(Constants.PREF_WT_ENABLECLIENTMODE, false);
- Constants.showbasicinfo= prefs.getBoolean(Constants.PREF_SHOWBASICINFO, true);
- Constants.orderby = prefs.getString(Constants.PREF_ORDERBY, Constants.cels[0]);
- Constants.cellsshown=prefs.getStringSet(Constants.PREF_CELLSSHOW, null);
- Constants. customcelsview= prefs.getBoolean(Constants.PREF_CUSTOMlAYOUT, false);
- Constants.downloadBookCovers=prefs.getBoolean(Constants.PREF_BOOKCOVERDOWNLOAD, false);
- Constants.useinternaldatapartition=prefs.getBoolean(Constants.PREF_USEiNTERNALDATA,false);
- Constants.dbmng= new BookDatabaseManager(Constants.wtusername,Constants.wtserverip,Constants.wtpassword,
- Constants.wtpassphrase,this.getApplicationContext(),this);
- Constants.dbmng.CreateDatabse(Constants.cels,false);
- Constants.rtbkmngr =new LentedBooksDatabaseManager(Constants.wtusername,Constants.wtserverip,
- Constants.wtpassword,Constants.wtpassphrase,
- this.getApplicationContext(),this);
- Constants.rtbkmngr.CreateDatabse(Constants.rtcels,false);
- if (Constants.useinternaldatapartition )
- {
- Constants.BookCoverPath= this.getFilesDir().getCanonicalPath();
- }
- else
- {
- Constants.BookCoverPath= Environment.getExternalStorageDirectory()+"/BookerDroid/BookCovers";
- }
- if ( Constants.downloadBookCovers)
- {
- new File(Constants.BookCoverPath).mkdirs();
- new File(Constants.BookCoverPath+"/"+ GoogleBooksConst.thumbsir).mkdirs();
- new File(Constants.BookCoverPath+"/"+ GoogleBooksConst.fulldir).mkdirs();
- }
- int in=Integer.parseInt(prefs.getString(Constants.PREF_THUMBNAILHEIGHT, "128"));
- Constants.thumbnailheight=in ;
- Constants.thumbnailwidth=Integer.parseInt(prefs.getString(Constants.PREF_THUMBNAILWIDTH, "128"));
- Constants.fullsizeheight=Integer.parseInt(prefs.getString(Constants.PREGF_FULLSIZWHEIGHT,"256"));
- Constants.fullsizewidth=Integer.parseInt(prefs.getString(Constants.PREF_FULLSIZEWIDTH, "256"));
- lstBooks = (ListView)findViewById(R.id.lstBooks);
- txtTotalBooks=(TextView)this.findViewById(R.id.txtTotalBooks);
- lstBooks.setOnItemSelectedListener(new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> paLent, View view,
- int position, long id) {
- try {
- SQLiteCursor cur = (SQLiteCursor)Constants.adapt.getItem(position);
- Constants.SelectedCode = cur.getString(0);
- Log.i(Tools.TAG, Constants.SelectedCode);
- } catch (Exception e) {
- Base.ErroHandling(e);
- // return false;
- }
- }
- @Override
- public void onNothingSelected(AdapterView<?> paLent) {
- }
- });
- lstBooks.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> paLent, View view, int position, long id) {
- try {
- SQLiteCursor cur = (SQLiteCursor) Constants.adapt.getItem(position);
- if (cur != null) {
- Constants.SelectedCode = cur.getString(0);
- }
- Log.i(Tools.TAG, Constants.SelectedCode);
- // if (Constants.showbasicinfo) {
- Intent tin = new Intent(view.getContext(), BookDetails.class);
- startActivity(tin);
- // }
- } catch (Exception e) {
- Base.ErroHandling(e);
- }
- }
- });
- lstBooks.setOnItemLongClickListener(new OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> paLent,
- View view, int position, long id) {
- try {
- SQLiteCursor cur = (SQLiteCursor) Constants.adapt.getItem(position);
- if (cur != null) {
- Constants.SelectedCode = cur.getString(0);
- }
- Log.i(Tools.TAG, Constants.SelectedCode);
- if (Constants.showbasicinfo) {
- Intent tin = new Intent(view.getContext(), BookDetails.class);
- startActivity(tin);
- }
- return true;
- } catch (Exception e) {
- Base.ErroHandling(e);
- return false;
- }
- }
- });
- this.txtMoreinfo= (TextView) findViewById(R.id.detailinfo);
- if( Constants.showbasicinfo)
- {
- this.txtMoreinfo.setVisibility(View.VISIBLE);
- }
- else
- {
- this.txtMoreinfo.setHeight(0);
- this.txtMoreinfo.setWidth(0);
- }
- // Constants.cels = grBookCells;
- LoadTable(this);
- }
- catch (Exception ex)
- {
- //throw (ex);
- Base.ErroHandling(ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement