Exemplo n.º 1
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.i("TAG", "------------------------ Restart");
    // LocationManager locationManager = (LocationManager)
    // getSystemService(Context.LOCATION_SERVICE);
    // LocationProvider locationProvider =
    // locationManager.getProvider(LocationManager.NETWORK_PROVIDER);
    // Or, use GPS location data:
    // LocationProvider locationProvider = LocationManager.GPS_PROVIDER;

    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .build());
    StrictMode.setVmPolicy(
        new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .penaltyLog()
            .penaltyDeath()
            .build());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loading);
    progressBar = (ProgressBar) findViewById(R.id.progressBar1);
    textView = (TextView) findViewById(R.id.textView1);
    textView.setText(R.string.application_name);
    ReadJson readJson = new ReadJson();
    readJson.execute();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    if (MyApplication.debug) {
      StrictMode.setThreadPolicy(
          new StrictMode.ThreadPolicy.Builder()
              .detectDiskReads()
              .detectDiskWrites()
              .detectNetwork() // or .detectAll() for all detectable problems
              .penaltyLog()
              .build());
      StrictMode.setVmPolicy(
          new StrictMode.VmPolicy.Builder()
              .detectLeakedSqlLiteObjects()
              // .detectLeakedClosableObjects()
              .penaltyLog()
              .penaltyDeath()
              .build());
    }

    super.onCreate(savedInstanceState);
    MyApplication.getInstance().getSettings().registerOnSharedPreferenceChangeListener(this);
    setLanguage();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
  }
Exemplo n.º 3
0
  /** enables "strict mode" for testing - should NEVER be used in release builds */
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  private static void enableStrictMode() {
    // return if the build is not a debug build
    if (!BuildConfig.DEBUG) {
      AppLog.e(T.UTILS, "You should not call enableStrictMode() on a non debug build");
      return;
    }

    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .penaltyFlashScreen()
            .build());

    StrictMode.setVmPolicy(
        new StrictMode.VmPolicy.Builder()
            .detectActivityLeaks()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .detectLeakedRegistrationObjects() // <-- requires Jelly Bean
            .penaltyLog()
            .build());

    AppLog.w(T.UTILS, "Strict mode enabled");
  }
Exemplo n.º 4
0
  /**
   * Enables strict mode. This should only be called when debugging the application and is useful
   * for finding some potential bugs or best practice violations.
   */
  @TargetApi(11)
  public static void enableStrictMode() {
    // Strict mode is only available on gingerbread or later
    if (Utils.hasGingerbread()) {

      // Enable all thread strict mode policies
      StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();

      // Enable all VM strict mode policies
      StrictMode.VmPolicy.Builder vmPolicyBuilder =
          new StrictMode.VmPolicy.Builder().detectAll().penaltyLog();

      // Honeycomb introduced some additional strict mode features
      if (Utils.hasHoneycomb()) {
        // Flash screen when thread policy is violated
        threadPolicyBuilder.penaltyFlashScreen();
        // For each activity class, set an instance limit of 1. Any more instances and
        // there could be a memory leak.
        /* vmPolicyBuilder
        .setClassInstanceLimit(ContactActivity.class, 1);*/
      }

      // Use builders to enable strict mode policies
      StrictMode.setThreadPolicy(threadPolicyBuilder.build());
      StrictMode.setVmPolicy(vmPolicyBuilder.build());
    }
  }
  /**
   * Use strict mode to determine app bottlenecks.
   *
   * <p>Does nothing if api version is less than 11.
   */
  @TargetApi(11)
  private static void initStrictMode() {

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
      return;
    }

    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectCustomSlowCalls()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .penaltyFlashScreen()
            .build());

    try {
      StrictMode.setVmPolicy(
          new StrictMode.VmPolicy.Builder()
              .detectLeakedSqlLiteObjects()
              .detectLeakedClosableObjects()
              .setClassInstanceLimit(Class.forName(PlaybackService.class.getName()), 1)
              .penaltyLog()
              .build());
    } catch (ClassNotFoundException e) {
      Log.e(TAG, e.toString());
    }
  }
Exemplo n.º 6
0
 @Override
 public void onCreate() {
   super.onCreate();
   if (Config.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
     StrictMode.setThreadPolicy(
         new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build());
     StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());
   }
   sInstance = this;
   initImageLoader(getApplicationContext());
   mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
   mPreferences.registerOnSharedPreferenceChangeListener(this);
   try {
     ViewConfiguration config = ViewConfiguration.get(this);
     Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
     if (menuKeyField != null) {
       menuKeyField.setAccessible(true);
       menuKeyField.setBoolean(config, false);
     }
   } catch (Exception ex) {
     // Ignore
   }
   // 全局异常捕获
   //		CustomException customException = CustomException.getInstance();
   //		customException.init(getApplicationContext());
   initJpush();
 }
Exemplo n.º 7
0
  @Override
  public void onCreate() {
    super.onCreate();

    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDialog().build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
  }
Exemplo n.º 8
0
 public static void strict() {
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectAll()
           .penaltyLog()
           .penaltyFlashScreen()
           .build());
   StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
   DBG.w("STRICT MODE ON");
 }
Exemplo n.º 9
0
  private void init() {
    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .build());
    StrictMode.setVmPolicy(
        new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .penaltyLog()
            .penaltyDeath()
            .build());

    // set toolbar
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle("");
    setSupportActionBar(mToolbar);
    TextView tvv = (TextView) findViewById(R.id.titlefortoolbar);
    tvv.setText("评价");

    // 添加按钮事件
    /*Button button  =(Button)findViewById(R.id.button_comment_send);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "通过setOnClickListener()方法实现",
                    Toast.LENGTH_SHORT).show();
            //Intent intent = new Intent(activity_comment.this, activity_home.class);
            //activity_comment.this.startActivity(intent);
        }
    });*/
    RatingBar ratBar = (RatingBar) findViewById(R.id.ratingBar);
    ratBar.setStepSize(1); // 步进为1
    ratBar.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            // doing actions
            starnum = (int) rating;
            // rating是传入的星级。
          }
        });

    // FAB
    fab();

    sp = this.getSharedPreferences("user_id", MODE_PRIVATE);
    user_id = sp.getInt("user_id", -1);
  }
  private void enableStrictMode() {
    if (DEBUG) {
      final StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();
      final StrictMode.VmPolicy.Builder vmPolicyBuilder =
          new StrictMode.VmPolicy.Builder().detectAll().penaltyLog();

      threadPolicyBuilder.penaltyFlashScreen();
      StrictMode.setThreadPolicy(threadPolicyBuilder.build());
      StrictMode.setVmPolicy(vmPolicyBuilder.build());
    }
  }
Exemplo n.º 11
0
 public PeepersApplication() {
   super();
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectDiskReads()
           .detectDiskWrites()
           .detectNetwork()
           .penaltyLog()
           .build());
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().penaltyLog().build());
 } // constructor()
Exemplo n.º 12
0
  @TargetApi(VERSION_CODES.HONEYCOMB)
  public static void enableStrictMode() {
    if (Utils.hasGingerbread()) {
      StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();
      StrictMode.VmPolicy.Builder vmPolicyBuilder =
          new StrictMode.VmPolicy.Builder().detectAll().penaltyLog();

      StrictMode.setThreadPolicy(threadPolicyBuilder.build());
      StrictMode.setVmPolicy(vmPolicyBuilder.build());
    }
  }
Exemplo n.º 13
0
  @Override
  public void onCreate() {
    super.onCreate();

    // (严格模式):监视APP相关的运行情况 - 发布应用时关闭此处
    if (PropertiesConfig.getInstance(this).isDeveloper()
        && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
      // 线程检测
      StrictMode.setThreadPolicy(
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build());
      StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());
    }
  }
Exemplo n.º 14
0
 @Override
 public void onCreate() {
   if (BuildConfig.DEBUG) {
     StrictMode.setThreadPolicy(
         new StrictMode.ThreadPolicy.Builder()
             .detectAll()
             .penaltyLog()
             .penaltyFlashScreen()
             .build());
     StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
   } else ACRA.init(this);
   playStoreVariant = BuildConfig.FLAVOR.equals("play");
   super.onCreate();
   refWatcher = LeakCanary.install(this);
 }
Exemplo n.º 15
0
 public static void struct() {
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectDiskReads()
           .detectDiskWrites()
           .detectNetwork() // or
           .penaltyLog()
           .build());
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedSqlLiteObjects() //
           .penaltyLog() //
           .penaltyDeath()
           .build());
 }
Exemplo n.º 16
0
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    if (false && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
      StrictMode.setThreadPolicy(
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build());
      StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());
    }

    super.onCreate();
    context = this;
    Log.e("debug", "commonApplication  is  oncreate");
    ormDateBaseHelper = new OrmDateBaseHelper(this, "cloud_contact", null, 1);
    initImageLoader(getApplicationContext());
  }
 private void visitExternalLinks() {
   // 發送Http請求
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectDiskReads()
           .detectDiskWrites()
           .detectNetwork()
           .penaltyLog()
           .build());
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedSqlLiteObjects()
           .penaltyLog()
           .penaltyDeath()
           .build());
 }
Exemplo n.º 18
0
  @SuppressLint("NewApi")
  public static void enableStrictMode() {
    if (Utils.hasGingerbread()) {
      StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();
      StrictMode.VmPolicy.Builder vmPolicyBuilder =
          new StrictMode.VmPolicy.Builder().detectAll().penaltyLog();

      if (Utils.hasHoneycomb()) {
        threadPolicyBuilder.penaltyFlashScreen();
        vmPolicyBuilder.setClassInstanceLimit(ImageGridActivity.class, 1);
      }
      StrictMode.setThreadPolicy(threadPolicyBuilder.build());
      StrictMode.setVmPolicy(vmPolicyBuilder.build());
    }
  }
Exemplo n.º 19
0
  @TargetApi(VERSION_CODES.HONEYCOMB)
  public static void enableStrictMode() {
    if (Version.hasGingerbread()) {
      StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
          new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();
      StrictMode.VmPolicy.Builder vmPolicyBuilder =
          new StrictMode.VmPolicy.Builder().detectAll().penaltyLog();

      if (Version.hasHoneycomb()) {
        threadPolicyBuilder.penaltyFlashScreen();
        // vmPolicyBuilder.setClassInstanceLimit(ImageGridActivity.class,
        // 1).setClassInstanceLimit(ImageDetailActivity.class, 1);
      }
      StrictMode.setThreadPolicy(threadPolicyBuilder.build());
      StrictMode.setVmPolicy(vmPolicyBuilder.build());
    }
  }
Exemplo n.º 20
0
  /** Turn on StrictMode detection based on build and command-line switches. */
  @UiThread
  // FindBugs doesn't like conditionals with compile time results
  @SuppressFBWarnings("UCF_USELESS_CONTROL_FLOW")
  public static void configureStrictMode() {
    assert ThreadUtils.runningOnUiThread();
    if (sIsStrictModeAlreadyConfigured) {
      return;
    }
    sIsStrictModeAlreadyConfigured = true;

    StrictMode.ThreadPolicy.Builder threadPolicy =
        new StrictMode.ThreadPolicy.Builder(StrictMode.getThreadPolicy());
    StrictMode.VmPolicy.Builder vmPolicy =
        new StrictMode.VmPolicy.Builder(StrictMode.getVmPolicy());

    CommandLine commandLine = CommandLine.getInstance();
    if ("eng".equals(Build.TYPE)
        || BuildConfig.DCHECK_IS_ON
        || ChromeVersionInfo.isLocalBuild()
        || commandLine.hasSwitch(ChromeSwitches.STRICT_MODE)) {
      turnOnDetection(threadPolicy, vmPolicy);
      addDefaultPenalties(threadPolicy, vmPolicy);
      if ("death".equals(commandLine.getSwitchValue(ChromeSwitches.STRICT_MODE))) {
        addThreadDeathPenalty(threadPolicy);
        addVmDeathPenalty(vmPolicy);
      } else if ("testing".equals(commandLine.getSwitchValue(ChromeSwitches.STRICT_MODE))) {
        addThreadDeathPenalty(threadPolicy);
        // Currently VmDeathPolicy kills the process, and is not visible on bot test output.
      }
    }
    // Enroll 1% of dev sessions into StrictMode watch. This is done client-side rather than
    // through finch because this decision is as early as possible in the browser initialization
    // process. We need to detect early start-up StrictMode violations before loading native and
    // before warming the SharedPreferences (that is a violation in an of itself). We will
    // closely monitor this on dev channel.
    boolean enableStrictModeWatch =
        (ChromeVersionInfo.isDevBuild() && Math.random() < UPLOAD_PROBABILITY);
    if ((ChromeVersionInfo.isLocalBuild() && !BuildConfig.DCHECK_IS_ON) || enableStrictModeWatch) {
      turnOnDetection(threadPolicy, vmPolicy);
      initializeStrictModeWatch();
    }

    StrictMode.setThreadPolicy(threadPolicy.build());
    StrictMode.setVmPolicy(vmPolicy.build());
  }
Exemplo n.º 21
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectDiskReads()
           .detectDiskWrites()
           .detectAll()
           .penaltyLog()
           .build());
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedSqlLiteObjects()
           .detectLeakedClosableObjects()
           .penaltyLog()
           .penaltyDeath()
           .build());
 }
Exemplo n.º 22
0
 private static void testStrictMode() {
   if (DEBUG_STRICT_MODE) {
     StrictMode.setThreadPolicy(
         new StrictMode.ThreadPolicy.Builder()
             .detectDiskReads()
             .detectDiskWrites()
             .detectNetwork() // or .detectAll() for all detectable
             // problems
             .penaltyLog()
             .build());
     StrictMode.setVmPolicy(
         new StrictMode.VmPolicy.Builder()
             .detectLeakedSqlLiteObjects()
             .detectLeakedClosableObjects()
             .penaltyLog()
             .penaltyDeath()
             .build());
   }
 }
Exemplo n.º 23
0
 @SuppressFBWarnings("DM_GC") // Used to trigger strictmode detecting leaked closeables
 @Override
 protected void tearDown() throws Exception {
   try {
     NativeTestServer.shutdownNativeTestServer();
     mTestFramework.mCronetEngine.shutdown();
     assertTrue(mFile.delete());
     // Run GC and finalizers a few times to pick up leaked closeables
     for (int i = 0; i < 10; i++) {
       System.gc();
       System.runFinalization();
     }
     System.gc();
     System.runFinalization();
     super.tearDown();
   } finally {
     StrictMode.setVmPolicy(mOldVmPolicy);
   }
 }
Exemplo n.º 24
0
  private void initStrictMode() {
    StrictMode.ThreadPolicy.Builder tpb =
        new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      tpb.penaltyFlashScreen();
    }

    StrictMode.setThreadPolicy(tpb.build());

    StrictMode.VmPolicy.Builder vmPolicyBuilder =
        new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().penaltyLog();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      vmPolicyBuilder.detectLeakedClosableObjects();
    }

    StrictMode.setVmPolicy(vmPolicyBuilder.build());
  }
Exemplo n.º 25
0
 @Override
 public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
   super.onCreate(savedInstanceState, persistentState);
   if (BuildConfig.DEBUG) {
     StrictMode.setThreadPolicy(
         new StrictMode.ThreadPolicy.Builder()
             .detectAll()
             //                        .detectDiskReads()
             .penaltyLog()
             .penaltyFlashScreen()
             .build());
     StrictMode.setVmPolicy(
         new StrictMode.VmPolicy.Builder()
             .detectAll()
             //                        .detectLeakedSqlLiteObjects()
             //                        .detectLeakedClosableObjects()
             .penaltyLog()
             .build());
   }
 }
Exemplo n.º 26
0
 public static void struct() {
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectDiskReads()
           .detectDiskWrites()
           .detectNetwork() // or
           // .detectAll()
           // for
           // all
           // detectable
           // problems
           .penaltyLog()
           .build());
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedSqlLiteObjects() // 探测SQLite数据库操作
           .penaltyLog() // 打印logcat
           .penaltyDeath()
           .build());
 }
Exemplo n.º 27
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   setContentView(R.layout.activity_main);
   initView();
   initListener();
   StrictMode.setThreadPolicy(
       new StrictMode.ThreadPolicy.Builder()
           .detectDiskReads()
           .detectDiskWrites()
           .detectNetwork() // or .detectAll() for all detectable problems
           .penaltyLog()
           .build());
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedSqlLiteObjects()
           .penaltyLog()
           .penaltyDeath()
           .build());
 }
Exemplo n.º 28
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mOldVmPolicy = StrictMode.getVmPolicy();
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedClosableObjects()
           .penaltyLog()
           .penaltyDeath()
           .build());
   mTestFramework = startCronetTestFramework();
   assertTrue(NativeTestServer.startNativeTestServer(getContext()));
   // Add url interceptors after native application context is initialized.
   MockUrlRequestJobFactory.setUp();
   mFile = new File(getContext().getCacheDir().getPath() + "/tmpfile");
   FileOutputStream fileOutputStream = new FileOutputStream(mFile);
   try {
     fileOutputStream.write(LOREM.getBytes("UTF-8"));
   } finally {
     fileOutputStream.close();
   }
 }
Exemplo n.º 29
0
  /** Called when the activity is first created. */
  @SuppressLint({
    "NewApi", "NewApi", "NewApi", "NewApi", "NewApi", "NewApi", "NewApi", "NewApi", "NewApi",
    "NewApi", "NewApi"
  })
  @Override
  public void onCreate(Bundle savedInstanceState) {
    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork() // or .detectAll() for all detectable problems
            .penaltyLog()
            .build());
    StrictMode.setVmPolicy(
        new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .penaltyLog()
            .penaltyDeath()
            .build());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    text = (TextView) findViewById(R.id.textView1);
    //        try {
    //			Toast.makeText(getApplicationContext(),
    // downloadUrl("http://dampce032.iteye.com/blog/975642"), Toast.LENGTH_LONG).show();
    //		} catch (IOException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}
    down();
    //        saveImageToDisk();
    //        myEditText=(EditText)findViewById(R.id.EditText1);
    //        myListView=(ListView)findViewById(R.id.ListView1);
    //        try {
    //			db=new MainActivity_1(MainAct_1.this);
    //		} catch (Exception e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}
    //        myCursor=db.select();
    //        SimpleCursorAdapter adpater=new SimpleCursorAdapter(this
    //                , R.layout.test, myCursor,
    //                new String[]{MainActivity_1.FIELD_TITLE},
    //                new int[]{R.id.topTextView});
    //        myListView.setAdapter(adpater);
    //
    //        myListView.setOnItemClickListener(new OnItemClickListener() {
    //
    //            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    //                    long arg3) {
    //                // TODO Auto-generated method stub
    //                myCursor.moveToPosition(arg2);
    //                _id=myCursor.getInt(0);
    //                myEditText.setText(myCursor.getString(1));
    //            }
    //        });
    //
    //
    //        myListView.setOnItemSelectedListener(new OnItemSelectedListener() {
    //
    //
    //            public void onItemSelected(AdapterView<?> arg0, View arg1,
    //                    int arg2, long arg3) {
    //                // TODO Auto-generated method stub
    //                SQLiteCursor sc=(SQLiteCursor)arg0.getSelectedItem();
    //                _id=sc.getInt(0);
    //                myEditText.setText(sc.getString(1));
    //            }
    //
    //
    //            public void onNothingSelected(AdapterView<?> arg0) {
    //                // TODO Auto-generated method stub
    //
    //            }
    //        });
    //    }
    //    private void operation(String cmd)
    //    {
    //        if(myEditText.getText().toString().equals(""))
    //        return;
    //        if(cmd=="add")
    //            db.insert( myEditText.getText().toString());
    //        if(cmd=="edit")
    //            db.update(_id,  myEditText.getText().toString());
    //        if(cmd=="delete")
    //            db.delete(_id);
    //        myCursor.requery();
    //        myListView.invalidateViews();
    //        myEditText.setText("");
    //        _id=0;

  }
Exemplo n.º 30
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    if (DEVELOPER_MODE) {
      StrictMode.setThreadPolicy(
          new StrictMode.ThreadPolicy.Builder()
              .detectDiskReads()
              .detectDiskWrites()
              .detectNetwork() // or .detectAll() for all detectable problems
              .penaltyLog()
              .build());
      StrictMode.setVmPolicy(
          new StrictMode.VmPolicy.Builder()
              .detectLeakedSqlLiteObjects()
              .detectLeakedClosableObjects()
              .penaltyLog()
              .penaltyDeath()
              .build());
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_blank);
    this.ISLOGIN = getIntent().getStringExtra("IS_LOGIN");
    // session = new SessionManager(getApplicationContext());
    // session.checkLogin();
    typeFace = Typeface.createFromAsset(this.getAssets(), "fonts/HelveticaNeueLight.ttf");
    mTitle = mDrawerTitle = getTitle();
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    mDrawerMenu = (RelativeLayout) findViewById(R.id.menu_left);
    imgProfilemenu = (ImageView) findViewById(R.id.imgProfilemenu);

    txtMenufullname = (TextView) mDrawerMenu.findViewById(R.id.txtmenufullname);
    txtMenuLocation = (TextView) mDrawerMenu.findViewById(R.id.txtMenulocation);
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    final ViewGroup mContainer = (ViewGroup) findViewById(android.R.id.content).getRootView();
    typeFace = Typeface.createFromAsset(this.getAssets(), "fonts/HelveticaNeueLight.ttf");
    setAppFont.setAppFont(mContainer, typeFace);
    sList = new ArrayList<HashMap<String, String>>();
    String[] menu = {"Home", "Feed", "Message", "Item", "Favorite", "Logout", "Setting"};
    this.menuItems = menu;
    String[] notification = {"0", "23", "13", "2", "0", "0", "0"};
    String[] img = {
      "ic_home", "ic_feed", "ic_message", "ic_item", "ic_boardpin", "ic_logout", "ic_setting2"
    };
    mMenuTitles = menu;
    for (int i = 0; i < menu.length; i++) {
      map = new HashMap<String, String>();
      map.put(ListItem.KEY_TITLE, menu[i]);
      map.put(ListItem.KEY_IMG, img[i]);
      map.put(ListItem.KEY_NOTIFICAIONCOUNT, notification[i]);
      sList.add(map);
    }

    Menuadapter = new MenuAdapter(this, sList);
    mDrawerList.setAdapter(Menuadapter);
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, mDrawerLayout, R.drawable.ic_arrow, R.string.drawer_open, R.string.drawer_close) {

          public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            activeItem();
          }

          public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
      Log.d(ListItem.TAG, "ISLOGIN = "******"true")) {
          setUpprofile();
        } else {
          selectItem(1);
        }
      } else {
        selectItem(1);
      }
    }
  }