Advertisement
angarato_surion

Untitled

May 25th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.73 KB | None | 0 0
  1. try {
  2.           this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  3.           super.onCreate(savedInstanceState);
  4.  
  5.           setContentView(R.layout.main);
  6.  
  7.           //mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
  8.            //setSupportActionBar(mToolbar);
  9.  
  10.          // setSupportActionBar((android.support.v7.widget.Toolbar)mToolbar);
  11.  
  12.            // getSupportActionBar().setDisplayShowHomeEnabled(true);
  13.             ViewConfiguration config = ViewConfiguration.get(this);
  14.             Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
  15.             if(menuKeyField != null) {
  16.                 menuKeyField.setAccessible(true);
  17.                 menuKeyField.setBoolean(config, false);
  18.             }
  19.  
  20.           Constants.SytemLanguage=  Locale.getDefault().getDisplayLanguage();
  21.  
  22.             File f = new File(Environment.getExternalStorageDirectory()+"/BookerDroid");
  23.             Constants.TempPath=f.getAbsolutePath()+"/Temp";
  24.             File f2= new File(Constants.TempPath);
  25.  
  26.             if ( !f.exists())
  27.             {
  28.                 f.mkdir();
  29.             }
  30.             if (!f2.exists())
  31.             {
  32.                 f2.mkdirs()  ;
  33.             }
  34.             BitmapTools.CreateImageStorage();
  35.             if( Constants.SytemLanguage!= Locale.ENGLISH.getDisplayLanguage())
  36.             {
  37.                          
  38.             Constants.cels = Constants.grBookCells;
  39.                 Constants.rtcels=Constants.grLentbookbifCells;
  40.             }
  41.             else
  42.             {
  43.                  Constants.cels = Constants.enBookCells;
  44.                 Constants.rtcels=Constants.enLentbookbifCells;
  45.             }
  46.             prefs= getSharedPreferences(Constants.PREFSFILE, MODE_APPEND);
  47.             Constants.wtusername= prefs.getString(Constants.PREF_WT_USERNAME, null);
  48.             Constants.wtpassword= prefs.getString(Constants.PREF_WT_PASSWORD, null);
  49.             Constants.wtpassphrase=prefs.getString(Constants.PREF_WT_PASSPHRASE, null);
  50.             Constants.wtserverip = prefs.getString(Constants.PREF_WT_SERVERIP, null);
  51.             Constants.wtclientmode= prefs.getBoolean(Constants.PREF_WT_ENABLECLIENTMODE, false);
  52.             Constants.showbasicinfo= prefs.getBoolean(Constants.PREF_SHOWBASICINFO, true);
  53.             Constants.orderby = prefs.getString(Constants.PREF_ORDERBY, Constants.cels[0]);
  54.             Constants.cellsshown=prefs.getStringSet(Constants.PREF_CELLSSHOW, null);
  55.             Constants. customcelsview= prefs.getBoolean(Constants.PREF_CUSTOMlAYOUT, false);
  56.             Constants.downloadBookCovers=prefs.getBoolean(Constants.PREF_BOOKCOVERDOWNLOAD, false);
  57.             Constants.useinternaldatapartition=prefs.getBoolean(Constants.PREF_USEiNTERNALDATA,false);
  58.  
  59.             Constants.dbmng= new BookDatabaseManager(Constants.wtusername,Constants.wtserverip,Constants.wtpassword,
  60.                     Constants.wtpassphrase,this.getApplicationContext(),this);
  61.             Constants.dbmng.CreateDatabse(Constants.cels,false);
  62.             Constants.rtbkmngr  =new LentedBooksDatabaseManager(Constants.wtusername,Constants.wtserverip,
  63.                     Constants.wtpassword,Constants.wtpassphrase,
  64.                     this.getApplicationContext(),this);
  65.             Constants.rtbkmngr.CreateDatabse(Constants.rtcels,false);
  66.             if (Constants.useinternaldatapartition )
  67.             {
  68.               Constants.BookCoverPath= this.getFilesDir().getCanonicalPath();
  69.             }
  70.             else
  71.             {
  72.                 Constants.BookCoverPath=  Environment.getExternalStorageDirectory()+"/BookerDroid/BookCovers";
  73.  
  74.             }
  75.             if ( Constants.downloadBookCovers)
  76.             {
  77.                 new File(Constants.BookCoverPath).mkdirs();
  78.                 new File(Constants.BookCoverPath+"/"+ GoogleBooksConst.thumbsir).mkdirs();
  79.                 new File(Constants.BookCoverPath+"/"+ GoogleBooksConst.fulldir).mkdirs();
  80.             }
  81.             int in=Integer.parseInt(prefs.getString(Constants.PREF_THUMBNAILHEIGHT, "128"));
  82.  
  83.             Constants.thumbnailheight=in ;
  84.             Constants.thumbnailwidth=Integer.parseInt(prefs.getString(Constants.PREF_THUMBNAILWIDTH, "128"));
  85.            Constants.fullsizeheight=Integer.parseInt(prefs.getString(Constants.PREGF_FULLSIZWHEIGHT,"256"));
  86.             Constants.fullsizewidth=Integer.parseInt(prefs.getString(Constants.PREF_FULLSIZEWIDTH, "256"));
  87.          
  88.            
  89.          
  90.          
  91.          
  92.             lstBooks = (ListView)findViewById(R.id.lstBooks);
  93.  
  94.  
  95.             txtTotalBooks=(TextView)this.findViewById(R.id.txtTotalBooks);
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.             lstBooks.setOnItemSelectedListener(new OnItemSelectedListener() {
  103.  
  104.                 @Override
  105.                 public void onItemSelected(AdapterView<?> paLent, View view,
  106.                                            int position, long id) {
  107.                     try {
  108.                         SQLiteCursor cur = (SQLiteCursor)Constants.adapt.getItem(position);
  109.                                 Constants.SelectedCode = cur.getString(0);
  110.                         Log.i(Tools.TAG, Constants.SelectedCode);
  111.  
  112.                     } catch (Exception e) {
  113.                         Base.ErroHandling(e);
  114.                         //   return false;
  115.                     }
  116.  
  117.  
  118.                 }
  119.  
  120.                 @Override
  121.                 public void onNothingSelected(AdapterView<?> paLent) {
  122.  
  123.  
  124.                 }
  125.             });
  126.             lstBooks.setOnItemClickListener(new OnItemClickListener() {
  127.                 @Override
  128.                 public void onItemClick(AdapterView<?> paLent, View view, int position, long id) {
  129.                     try {
  130.                         SQLiteCursor cur = (SQLiteCursor) Constants.adapt.getItem(position);
  131.  
  132.                         if (cur != null) {
  133.                             Constants.SelectedCode = cur.getString(0);
  134.                         }
  135.                         Log.i(Tools.TAG, Constants.SelectedCode);
  136.                       //  if (Constants.showbasicinfo) {
  137.                             Intent tin = new Intent(view.getContext(), BookDetails.class);
  138.  
  139.                             startActivity(tin);
  140.                      //   }
  141.  
  142.  
  143.                     } catch (Exception e) {
  144.  
  145.                         Base.ErroHandling(e);
  146.  
  147.                     }
  148.  
  149.                 }
  150.             });
  151.             lstBooks.setOnItemLongClickListener(new OnItemLongClickListener() {
  152.  
  153.                 @Override
  154.                 public boolean onItemLongClick(AdapterView<?> paLent,
  155.                                                View view, int position, long id) {
  156.                     try {
  157.                         SQLiteCursor cur = (SQLiteCursor) Constants.adapt.getItem(position);
  158.  
  159.                         if (cur != null) {
  160.                             Constants.SelectedCode = cur.getString(0);
  161.                         }
  162.                         Log.i(Tools.TAG, Constants.SelectedCode);
  163.                         if (Constants.showbasicinfo) {
  164.                             Intent tin = new Intent(view.getContext(), BookDetails.class);
  165.  
  166.                             startActivity(tin);
  167.                         }
  168.  
  169.                         return true;
  170.                     } catch (Exception e) {
  171.  
  172.                         Base.ErroHandling(e);
  173.                         return false;
  174.                     }
  175.  
  176.                 }
  177.             });
  178.  
  179.             this.txtMoreinfo= (TextView) findViewById(R.id.detailinfo);
  180.             if( Constants.showbasicinfo)
  181.             {
  182.                 this.txtMoreinfo.setVisibility(View.VISIBLE);
  183.             }
  184.             else
  185.             {
  186.                 this.txtMoreinfo.setHeight(0);
  187.                 this.txtMoreinfo.setWidth(0);
  188.             }
  189.  
  190.        
  191.         //  Constants.cels = grBookCells;
  192.            LoadTable(this);
  193.  
  194.  
  195.         }
  196.        catch (Exception ex)
  197.         {
  198.             //throw (ex);
  199.           Base.ErroHandling(ex);
  200.         }
  201.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement