示例#1
1
 private void showTime() {
   Activity activity = (Activity) this.getContext();
   String title = activity.getTitle().toString();
   int pos = title.indexOf(" - ");
   if (pos >= 0) {
     title = title.substring(0, pos);
   }
   String dyntext = mDynDrawView != null ? (mDynDrawView.getDrawnTime() + "/") : "";
   activity.setTitle(title + " - " + dyntext + mDrawnTime + " ms");
 }
 @Test
 @Config(manifest = "src/test/resources/TestAndroidManifestWithLabels.xml")
 public void shouldUseApplicationLabelFromManifestAsTitleForActivity() throws Exception {
   activity = create(LabelTestActivity1.class);
   assertThat(activity.getTitle()).isNotNull();
   assertThat(activity.getTitle().toString()).isEqualTo(activity.getString(R.string.app_name));
 }
示例#3
0
 /**
  * Invoke this method to register a new view hierarchy.
  *
  * @param activity The activity whose view hierarchy/window to register
  * @see #addWindow(View, String)
  * @see #removeWindow(Activity)
  */
 public void addWindow(Activity activity) {
   String name = activity.getTitle().toString();
   if (TextUtils.isEmpty(name)) {
     name = activity.getClass().getCanonicalName() + "/0x" + System.identityHashCode(activity);
   } else {
     name += "(" + activity.getClass().getCanonicalName() + ")";
   }
   addWindow(activity.getWindow().getDecorView(), name);
 }
  public void dispatchProxyToPlugin() {

    if (plugin.getBaseContext() != null) return;
    try {
      // Finals 修改以前的注入方式,采用原生的方式
      Instrumentation instrumentation = proxyRef.get("mInstrumentation");
      pluginRef.call(
          // 方法名
          "attach",
          // Context context
          proxy,
          // ActivityThread aThread
          proxyRef.get("mMainThread"),
          // Instrumentation instr
          new LPluginInstrument(instrumentation),
          // IBinder token
          proxyRef.get("mToken"),
          // int ident
          proxyRef.get("mEmbeddedID") == null ? 0 : proxyRef.get("mEmbeddedID"),
          // Application application
          app == null ? proxy.getApplication() : app,
          // Intent intent
          proxy.getIntent(),
          // ActivityInfo info
          proxyRef.get("mActivityInfo"),
          // CharSequence title
          proxy.getTitle(),
          // Activity parent
          proxy.getParent(),
          // String id
          proxyRef.get("mEmbeddedID"),
          // NonConfigurationInstances lastNonConfigurationInstances
          proxy.getLastNonConfigurationInstance(),
          // Configuration config
          proxyRef.get("mCurrentConfig"));

      pluginRef.set("mWindow", proxy.getWindow());
      plugin.getWindow().setCallback(plugin);
      Reflect.on(proxy.getBaseContext()).call("setOuterContext", plugin);

    } catch (ReflectException e) {
      System.out.println("gyb-->" + e);
      e.printStackTrace();
    }
  }
示例#5
0
  public DrawerManager(final Activity activity, FragmentManager fm) {

    mActivity = activity;
    mFragmentManager = fm;
    mTitle = mDrawerTitle = activity.getTitle();
    mDrawerOptions = activity.getResources().getStringArray(R.array.nav_drawer_menu_options);
    mDrawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) activity.findViewById(R.id.left_drawer);

    mDrawerList.setAdapter(
        new ArrayAdapter<String>(activity, R.layout.drawer_list_item, mDrawerOptions));

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    setupActionBarDrawerToggle(activity);

    activity.getActionBar().setDisplayHomeAsUpEnabled(true);
    activity.getActionBar().setHomeButtonEnabled(true);
    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
    mDrawerList.setHeaderDividersEnabled(true);

    selectItem(POSITION_DISCOVERY, 3);
  }
示例#6
0
 private void initButton() {
   titleView = (TextView) thisView.findViewById(R.id.titletext);
   CharSequence title = activity.getTitle();
   titleView.setText(title);
   undoButton = thisView.findViewById(R.id.undo);
   homeButton = thisView.findViewById(R.id.home);
   // 注销按钮初始化
   //        logoutButton=(TextView) findViewById(R.id.logout);
   undoButton.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           activity.finish();
         }
       });
   homeButton.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent = new Intent(activity, MainActivity.class);
           startActivity(intent);
         }
       });
 }