コード例 #1
0
 @Override
 public void onCreate() {
   super.onCreate();
   Fabric.with(this, new Crashlytics());
   if (!BuildConfig.DEBUG) {
     Fabric.with(this, new Crashlytics());
   }
   initializeSdk();
   // broadcastPushTest();
 }
コード例 #2
0
 @Override
 public void onCreate() {
   if (BuildConfig.USE_CRASHLYTICS) {
     Fabric.with(this, new Crashlytics());
   }
   super.onCreate();
 }
コード例 #3
0
ファイル: Analytics.java プロジェクト: adamsp/wsnz-android
 public static void initialize(Application app) {
   Timber.d("{analytics enabled} Enabling Crashlytics");
   Timber.d("{analytics enabled} Enabling Answers");
   Fabric fabric =
       new Fabric.Builder(app).kits(new Crashlytics(), new Answers()).debuggable(true).build();
   Fabric.with(fabric);
 }
コード例 #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));
    setContentView(R.layout.activity_login);
    // Set up the login form.
    mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    populateAutoComplete();

    mPasswordView = (EditText) findViewById(R.id.password);
    mPasswordView.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
              attemptLogin();
              return true;
            }
            return false;
          }
        });

    Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
    mEmailSignInButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {
            attemptLogin();
          }
        });

    mLoginFormView = findViewById(R.id.login_form);
    mProgressView = findViewById(R.id.login_progress);
  }
コード例 #5
0
ファイル: App.java プロジェクト: jp-fsstudio/android-template
 @Override
 public void onCreate() {
   super.onCreate();
   Fabric.with(this, new Crashlytics());
   Timber.plant(BuildConfig.DEBUG ? new Timber.DebugTree() : new TimberCrashReportingTree());
   component = getDaggerComponent();
 }
コード例 #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));
    TwitterSession session = Twitter.getInstance().core.getSessionManager().getActiveSession();

    if (session != null) {
      Twitter4JFactory.generateInstance(
          TWITTER_KEY, TWITTER_SECRET, session.getAuthToken().token, session.getAuthToken().secret);
      Twitter.getApiClient(session)
          .getAccountService()
          .verifyCredentials(
              false,
              true,
              new com.twitter.sdk.android.core.Callback<User>() {

                Intent intent = new Intent(LoginActivity.this, MainActivity.class);

                @Override
                public void success(Result<User> result) {
                  startActivity(intent);
                  finish();
                }

                @Override
                public void failure(TwitterException e) {
                  loadLoginScreen();
                  // Continues execution
                }
              });
    } else {
      loadLoginScreen();
    }
  }
コード例 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig =
        new TwitterAuthConfig(Constants.TWITTER_KEY, Constants.TWITTER_SECRET);
    Fabric.with(this, new TwitterCore(authConfig), new Digits());

    authCallback =
        new AuthCallback() {
          @Override
          public void success(DigitsSession session, String phoneNumber) {
            Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_LONG).show();
            startProfileActivity(phoneNumber);
          }

          @Override
          public void failure(DigitsException exception) {
            Toast.makeText(getBaseContext(), "Failure", Toast.LENGTH_LONG).show();
          }
        };

    setContentView(com.crimepunch.app.R.layout.activity_registration);

    DigitsAuthButton digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
    digitsButton.setCallback(authCallback);

    if (session.getUser(this) != null) {
      startHomeActivity();
    }
  }
コード例 #8
0
 @Override
 public void onCreate() {
   super.onCreate();
   Fabric.with(this, new Crashlytics());
   AppApi.createInstance(getApplicationContext());
   FacebookSdk.sdkInitialize(getApplicationContext());
   Fresco.initialize(this);
 }
コード例 #9
0
  @Override
  public void onCreate() {
    super.onCreate();

    Fabric.with(this, new Crashlytics());

    mApplicationComponent =
        DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
  }
コード例 #10
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Fabric.with(this, new TweetComposer());
    TweetComposer.Builder builder =
        new TweetComposer.Builder(this).text("#teamasia My heart Rate just went up to!");
    builder.show();
  }
コード例 #11
0
  @Override
  public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics());
    if (AppPrefs.getInstance(this).once(FIRST_SEED))
      Queues.localQueue(this).execute(new SeedScheduleDataTask());

    if (AppPrefs.getInstance(this).isLoggedIn()) RefreshScheduleDataKot.Companion.callMe(this);
  }
コード例 #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());

    setContentView(R.layout.main_activity_layout);

    launch();
  }
コード例 #13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig =
        new TwitterAuthConfig(
            TWITTER_KEY, TWITTER_SECRET); // register with twitter using the key and secret
    Fabric.with(
        this, new TwitterCore(authConfig), new TweetComposer()); // set up a new twitter instance
    Fabric.with(this, new Twitter(authConfig), new Answers());
    SharedPreferences loggedin_pref =
        getSharedPreferences(
            "PREFS_NAME",
            0); // a sharedpreference value shared among all activities to determine whether the
    // user has logged in
    Boolean test_existence = loggedin_pref.getBoolean("Loggedin", false);
    if (test_existence == null) {
      SharedPreferences.Editor editor = loggedin_pref.edit(); // edit the sharedpreference
      editor.clear();
      editor.putBoolean("Loggedin", false); // default value set to "false"
      editor.commit(); // make the change
    }
    boolean loggedin =
        loggedin_pref.getBoolean(
            "Loggedin",
            false); // set up a boolean value called loggedin, the value of which will be determined
    // by the value in sharedpreference

    // setContentView(R.layout.activity_main);//set the screen to activity_main
    if (!loggedin) { // if the user is logged in
      this.finish();
      Intent act3 =
          new Intent(
              getApplicationContext(), Main3Activity.class); // start activity 3 (send a tweet)
      startActivity(act3); // start activity 3

    } else { // if the user is not logged in
      this.finish();
      Intent act2 =
          new Intent(
              getApplicationContext(),
              Main2Activity.class); // start activity 2 (prompt the user to log in)
      startActivity(act2); // start activity 2
    }
  }
コード例 #14
0
  public TwitterLoginManager(ReactApplicationContext reactContext, Context activityContext) {
    super(reactContext);

    mActivityContext = activityContext;

    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(mActivityContext, new Crashlytics(), new Twitter(authConfig));

    mTwitterAuthClient = new TwitterAuthClient();
  }
コード例 #15
0
ファイル: MainActivity.java プロジェクト: erikcox/DroidDocs
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Crashlytics
    Fabric.with(this, new Crashlytics());
    Crashlytics.setString("git_sha", BuildConfig.GIT_SHA);
    // Adding Toolbar to Main screen
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);
    // Set Tabs inside Toolbar
    TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
    tabs.setupWithViewPager(viewPager);
    // Create Navigation drawer and inflate layout
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer);
    // Adding menu icon to Toolbar
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
      supportActionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
      supportActionBar.setDisplayHomeAsUpEnabled(true);
    }
    // Set behavior of Navigation drawer
    navigationView.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          // This method will trigger on item Click of navigation menu
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {
            // Set item in checked state
            menuItem.setChecked(true);

            // TODO: add navigation

            // Closing drawer on item click
            mDrawerLayout.closeDrawers();
            return true;
          }
        });
    // Adding Floating Action Button to bottom right of main view
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Snackbar.make(v, "Snackbar!", Snackbar.LENGTH_LONG).show();
          }
        });
  }
コード例 #16
0
ファイル: App.java プロジェクト: nikunjkacha/twittererer
  @Override
  public void onCreate() {
    super.onCreate();

    JodaTimeAndroid.init(this);

    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Crashlytics(), new Twitter(authConfig));

    applicationComponent =
        DaggerApp_ApplicationComponent.builder()
            .applicationModule(new ApplicationModule(this))
            .build();
  }
コード例 #17
0
ファイル: PadApplication.java プロジェクト: MojRoid/PAD
  @Override
  public void onCreate() {
    super.onCreate();

    ////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////

    // Enable Fabric Crashanalytics ////////////////////////////////////////////////////////////

    Fabric.with(this, new Crashlytics());

    // Initialize Parse Crash Reporting ////////////////////////////////////////////////////////

    // ParseCrashReporting.enable(this);

    // Enable Local Datastore //////////////////////////////////////////////////////////////////

    // Parse.enableLocalDatastore(this);

    // Initialization Parse & Fresco ///////////////////////////////////////////////////////////

    Fresco.initialize(this);
    Parse.initialize(this);

    // Set Global Parse settings ///////////////////////////////////////////////////////////////

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    defaultACL.setPublicWriteAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);

    // Save user - required for first launch
    ParseUser.getCurrentUser()
        .saveInBackground(
            new SaveCallback() {
              @Override
              public void done(ParseException e) {
                if (e != null) e.printStackTrace();
              }
            });

    // Save the current Installation to Parse and associate the device with a user
    ParseInstallation installation = ParseInstallation.getCurrentInstallation();
    installation.put(DiaryActivity.PARSE_USER_NAME, ParseUser.getCurrentUser());
    installation.saveInBackground();

    ////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////
  }
コード例 #18
0
ファイル: MyApplication.java プロジェクト: Luciekimotho/Elani
  @Override
  public void onCreate() {
    super.onCreate();
    // Parse.enableLocalDatastore(this);
    Parse.initialize(
        this,
        "4r6GuVjJO85qw30CpTtEAcxRKY2xN7ividCi4yQA",
        "E6a1zZSV37Gs9Mv56L5ylP9cnqVcXbkTWRyFuywX");
    ParseInstallation.getCurrentInstallation().saveInBackground();
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));

    // Enable Local Datastore.
  }
コード例 #19
0
ファイル: MainApp.java プロジェクト: PiXeL16/Sea-Nec-IO
  /** Initialize the app object */
  public void init() {

    // Leak Tracking
    //        refWatcher = LeakCanary.install(this);
    // Logging
    Timber.plant(new Timber.DebugTree());

    initFirebase();

    // Crashes
    if (!BuildConfig.DEBUG) {
      Fabric.with(this, new Crashlytics());
    }
  }
コード例 #20
0
  @Override
  public void onCreate() {
    super.onCreate();
    long startDate = SystemClock.elapsedRealtime();

    mContext = this;

    ProfilingUtils.start("App Startup");
    // Enable log recording
    AppLog.enableRecording(true);
    AppLog.i(T.UTILS, "WordPress.onCreate");

    if (!PackageUtils.isDebugBuild()) {
      Fabric.with(this, new Crashlytics());
    }

    versionName = PackageUtils.getVersionName(this);
    initWpDb();
    enableHttpResponseCache(mContext);

    // EventBus setup
    EventBus.TAG = "WordPress-EVENT";
    EventBus.builder()
        .logNoSubscriberMessages(false)
        .sendNoSubscriberEvent(false)
        .throwSubscriberException(true)
        .installDefaultEventBus();
    EventBus.getDefault().register(this);

    RestClientUtils.setUserAgent(getUserAgent());

    // Volley networking setup
    setupVolleyQueue();

    AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);
    if (AppLockManager.getInstance().isAppLockFeatureEnabled()) {
      AppLockManager.getInstance()
          .getCurrentAppLock()
          .setDisabledActivities(
              new String[] {"org.wordpress.android.ui.ShareIntentReceiverActivity"});
    }

    HelpshiftHelper.init(this);

    ApplicationLifecycleMonitor applicationLifecycleMonitor = new ApplicationLifecycleMonitor();
    registerComponentCallbacks(applicationLifecycleMonitor);
    registerActivityLifecycleCallbacks(applicationLifecycleMonitor);

    initAnalytics(SystemClock.elapsedRealtime() - startDate);
  }
コード例 #21
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   // Set a mock thread pool executor so we can run these tests knowing that doInBackground
   // has not been run.
   Fabric.with(
       new Fabric.Builder(getContext())
           .threadPoolExecutor(mock(PriorityThreadPoolExecutor.class))
           .kits(
               new TwitterCore(
                   new TwitterAuthConfig(TestFixtures.CONSUMER_KEY, TestFixtures.CONSUMER_SECRET)),
               new TweetUi())
           .build());
 }
コード例 #22
0
  @Override
  public void initLogin(final Activity activity) {
    TwitterAuthConfig authConfig = new TwitterAuthConfig(consumerKey, consumerSecret);
    Fabric.with(activity, new TwitterCore(authConfig));
    // Check if already logged in

    loginButton = new TwitterLoginButton(activity);

    loginButton.setCallback(
        new Callback<TwitterSession>() {
          @Override
          public void success(final Result<TwitterSession> result) {
            // Do something with result, which provides a TwitterSession for making API calls

            TwitterCore.getInstance()
                .getApiClient()
                .getAccountService()
                .verifyCredentials(
                    true,
                    false,
                    new Callback<User>() {

                      @Override
                      public void failure(TwitterException e) {}

                      @Override
                      public void success(Result<User> userResult) {

                        User user = userResult.data;
                        Social.getSingleton()
                            .getCallback()
                            .onSocialLoginSuccess(
                                new SocialUserProfile(
                                    result, user.email, user.name, user.profileImageUrl),
                                SocialType.TWITTER);
                        activity.finish();
                      }
                    });
          }

          @Override
          public void failure(TwitterException exception) {
            // Do something on failure
            Social.getSingleton().getCallback().onSocialLoginFailure("Failed");
            exception.printStackTrace();
            activity.finish();
          }
        });
    loginButton.performClick();
  }
コード例 #23
0
  @Override
  public void onCreate() {
    super.onCreate();

    Fabric.with(this, new Crashlytics());
    Application.application = this;
    CarpaccioLogger.ENABLE_LOG = true;

    this.betaSeriesComponent =
        DaggerBetaSeriesComponent.builder()
            .contextModule(ContextModule.with(getApplicationContext())) // in case we need a context
            .build();

    betaSeriesComponent.unseenManager().load();
  }
コード例 #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);

    checkGooglePlayServices();

    context = getApplicationContext();
    TelephonyManager telephonyManager =
        (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    imei = telephonyManager.getDeviceId().toString();
    Log.d("imei", imei);
    setTitle(null);

    Toolbar topToolBar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(topToolBar);
    container = (FrameLayout) findViewById(R.id.maincontainer);
    //        myswitch = (ToggleButton)findViewById(R.id.toggleButton1);
    Statuspage = "1";
    map = new Map();
    //        sleepmode = new SleepMode();
    myFragmentManager = getSupportFragmentManager();
    // if's the first time created
    FragmentTransaction fragmentTransaction = myFragmentManager.beginTransaction();
    fragmentTransaction.add(R.id.maincontainer, map, TAG_2);
    fragmentTransaction.commit();

    Calendar c = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("dd/MMM/yyyy");
    formattedDate = df.format(c.getTime());
    Log.d("date", formattedDate);
    Log.d("Statuspage", Statuspage);

    // ******UserPasswordLocalstorage*********
    sharedPref = context.getSharedPreferences(groupcontent, Context.MODE_PRIVATE);
    if (isNetworkAvailable()) {
      Log.d("connectinternaet", "success");
      getUserLogin();
    } else {
      Log.d("connectinternaet", "not success");
      Toast.makeText(context, "connectinternaet fail. 'open internet'", Toast.LENGTH_LONG).show();
    }

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
  }
コード例 #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));
    setContentView(R.layout.activity_main);

    login = (TwitterLoginButton) findViewById(R.id.twitter_login);
    login.setCallback(
        new Callback<TwitterSession>() {
          @Override
          public void success(Result<TwitterSession> result) {}

          @Override
          public void failure(TwitterException exception) {}
        });
    Intent watchComm = new Intent(this, ReceiveMessageService.class);
    startService(watchComm);
  }
コード例 #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);
    violationTxtView = (TextView) findViewById(R.id.violationTxtView);
    reportTxtView = (TextView) findViewById(R.id.reportTxtView);

    violationTxtView.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(MainActivity.this, Report.class);
            startActivity(intent);
          }
        });
  }
コード例 #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_compose);

    Toolbar toolbar = (Toolbar) findViewById(R.id.sharelock_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(null);

    bus = EventBus.getDefault();
    handler = new Handler();

    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    String sharedText = null;
    if (Intent.ACTION_SEND.equals(action) && type != null) {
      if ("text/plain".equals(type)) {
        sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
      }
    }

    if (savedInstanceState == null) {
      final SecretInputFragment fragment = new SecretInputFragment();
      if (sharedText != null) {
        Bundle arguments = new Bundle();
        arguments.putString(SecretInputFragment.SECRET_INPUT_FRAGMENT_SECRET_ARGUMENT, sharedText);
        fragment.setArguments(arguments);
      }
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.sharelock_compose_container, fragment)
          .commit();
    } else {
      secret = savedInstanceState.getParcelable(COMPOSE_CREATED_SECRET);
    }
  }
コード例 #28
0
  @Override
  public void onCreate(Bundle savedInstance) {

    super.onCreate(savedInstance);
    final Fabric fabric = new Fabric.Builder(this).kits(new Crashlytics()).debuggable(true).build();
    Fabric.with(fabric);

    checkForUpdates();

    if (messenger().getAuthState() != AuthState.LOGGED_IN) {
      // TODO: Move this to where you establish a user session
      logUser();

      startActivity(new Intent(this, TourActivity.class));
      finish();
      return;
    }

    // getWindow().setBackgroundDrawable(new
    // ColorDrawable(getResources().getColor(R.color.bg_main)));
    getWindow().setBackgroundDrawable(null);
  }
コード例 #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);

    //  Find the toolbar in XML
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    //  Set it's title text color to white
    toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
    //  Change activity's action bar to toolbar
    setSupportActionBar(toolbar);

    LinodeApi.init(getBaseContext(), this);

    initImageLoader();

    accountHeader = buildHeader();

    //  Set up a new drawer builder
    drawer =
        new DrawerBuilder()
            .withActivity(this) //  Bind it to this activity
            .withToolbar(toolbar) //  Bind it to the toolbar attached to this activity
            .withAccountHeader(accountHeader)
            .withTranslucentNavigationBar(true) //  Disable translucent navigation menu/bar
            .addDrawerItems( //  Add our drawer items
                //  Regular drawer items
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.server) //  Icon
                    .withSelectedIcon(R.drawable.server_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item1)) //  Title
                    .withIdentifier(1) //  ID = 1
                    .withTextColor(Color.parseColor("#444444")) //  Text color
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.sitemap)
                    .withSelectedIcon(R.drawable.sitemap_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item2))
                    .withIdentifier(2) //  ID = 2
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.dns)
                    .withSelectedIcon(R.drawable.dns_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item3))
                    .withIdentifier(3) //  ID = 3
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),
                new PrimaryDrawerItem()
                    .withIcon(R.drawable.library)
                    .withSelectedIcon(R.drawable.library_tinted) //  Tinted icon
                    .withName(getResources().getString(R.string.item4))
                    .withIdentifier(4) //  ID = 4
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green)),

                //  Divider
                new DividerDrawerItem(),

                //  Small/secondary drawer items
                new SecondaryDrawerItem()
                    .withIcon(R.drawable.account)
                    .withSelectedIcon(
                        R.drawable
                            .account_tinted) //  Tinted icon; not mandatory since this won't be
                                             // highlighted
                    .withName(getResources().getString(R.string.item5))
                    .withIdentifier(5) //  ID = 5
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green))
                    .withSelectable(false), //  Not a fragment; don't highlight
                new SecondaryDrawerItem()
                    .withIcon(R.drawable.information)
                    .withSelectedIcon(R.drawable.information_tinted)
                    .withName(getResources().getString(R.string.item6))
                    .withIdentifier(6) //  ID = 6
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green))
                    .withSelectable(false), //  Not a fragment; don't highlight
                new SecondaryDrawerItem()
                    .withIcon(R.drawable.logout)
                    .withSelectedIcon(R.drawable.logout_tinted)
                    .withName(getResources().getString(R.string.item7))
                    .withIdentifier(7) //  ID = 7
                    .withTextColor(Color.parseColor("#444444"))
                    .withSelectedTextColor(getResources().getColor(R.color.toolbar_green))
                    .withSelectable(false) //  Not a fragment; don't highlight
                )
            //  Attach onClickListeners for each drawer item (not dividers!)
            .withOnDrawerItemClickListener(
                new Drawer.OnDrawerItemClickListener() {

                  @Override
                  public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {

                    if (drawerItem != null) {
                      //   update the main content by replacing fragments
                      Fragment fragment = new LinodesFragment();
                      FragmentManager fragmentManager = getFragmentManager();

                      switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                          fragment = new LinodesFragment();
                          break;
                        case 2:
                          fragment = new NodesFragment();
                          break;
                        case 3:
                          fragment = new DNSFragment();
                          break;
                        case 4:
                          fragment = new LibraryFragment();
                          break;
                        case 5:
                          // Account
                          Toast.makeText(getBaseContext(), "Demo Only", Toast.LENGTH_SHORT).show();
                          break;
                        case 6:
                          // About
                          Intent about = new Intent(MainActivity.this, AboutActivity.class);
                          startActivity(about);
                          break;
                        case 7:
                          // Log out
                          Toast.makeText(getBaseContext(), "Demo Only", Toast.LENGTH_SHORT).show();
                          break;
                      }
                      fragmentManager
                          .beginTransaction()
                          .replace(R.id.content_frame, fragment)
                          .commit();

                      if (drawerItem instanceof Nameable) {
                        setTitle(
                            ((Nameable) drawerItem).getName().getText(getApplicationContext()));
                      }
                    }

                    return false;
                  }
                })
            .withFireOnInitialOnClick(true)
            .withSavedInstance(savedInstanceState)
            .build();

    //  Set a custom shadow that overlays the main content when the drawer opens
    drawer.getDrawerLayout().setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    ActionBar mActionBar = getSupportActionBar();

    int color = getResources().getColor(R.color.toolbar_green);

    if (mActionBar != null) {
      toolbar.setBackgroundColor(color);
      drawer
          .getDrawerLayout()
          .setStatusBarBackgroundColor(
              AndroidHelper.darkenColor(getResources().getColor(R.color.toolbar_green), 0.8f));

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        toolbar.setElevation(8);
        getWindow()
            .setNavigationBarColor(
                AndroidHelper.darkenColor(getResources().getColor(R.color.toolbar_green), 0.8f));
      }
    }
  }
コード例 #30
0
ファイル: SignInActivity.java プロジェクト: 3888/OnixTwitter
 private void setUpFabricKits(TwitterAuthConfig authConfig) {
   Fabric.with(
       this, new Kit[] {new TwitterCore(authConfig), new TweetUi(), new Twitter(authConfig)});
 }