当前位置: 首页>>代码示例>>Java>>正文


Java Hawk类代码示例

本文整理汇总了Java中com.orhanobut.hawk.Hawk的典型用法代码示例。如果您正苦于以下问题:Java Hawk类的具体用法?Java Hawk怎么用?Java Hawk使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Hawk类属于com.orhanobut.hawk包,在下文中一共展示了Hawk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupDialog

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@SuppressLint("RestrictedApi")
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    mContentView = View.inflate(getContext(), R.layout.changelog_dialog_content, null);
    dialog.setContentView(mContentView);
    unbinder = ButterKnife.bind(this, mContentView);
    Hawk.put("WHATS_NEW_VERSION", BuildConfig.VERSION_CODE);
    mCancel.setVisibility(View.GONE);
    mTitle.setText(R.string.changelog);
    mMessage.setText(getString(R.string.changelog_detail));

    mListener = new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            View parent = (View) mContentView.getParent();
            BottomSheetBehavior behavior = BottomSheetBehavior.from(parent);
            behavior.setPeekHeight(mContentView.getMeasuredHeight());
            CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) mContentView.getParent()).getLayoutParams();
            layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;

            removeGlobalLayoutListener();
        }
    };
    mContentView.getViewTreeObserver().addOnGlobalLayoutListener(mListener);
}
 
开发者ID:alphater,项目名称:garras,代码行数:27,代码来源:ChangelogBottomSheetDialog.java

示例2: bindEvenListener

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
protected void bindEvenListener(Bundle savedInstanceState) {
    supportUI();
    super.bindEvenListener(savedInstanceState);
    LocaleUtils.loadLocale(this);

    FragmentMaster fragmentMaster = getFragmentMaster();
    fragmentMaster.registerFragmentLifecycleCallbacks(mLifecycleCallbacks);
    fragmentMaster.install(R.id.container, new Request(NavigationFragment.class));

    int flag = CalendarUtils.festivalFlag();
    if (2 == flag) {
        ViewStub viewStub = findViewById(R.id.view_stub);
        if (null != viewStub) {
            viewStub.inflate();
        }
    }

    if (Hawk.get("WHATS_NEW_VERSION", -1) != BuildConfig.VERSION_CODE) {
        new ChangelogBottomSheetDialog().show(getSupportFragmentManager(), "ChangelogBottomSheetDialog");
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:23,代码来源:MainActivity.java

示例3: refreshProfile

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
private void refreshProfile() {
    mDataManager.profile().compose(this.<Response<Me>>bindUntilEvent(ActivityEvent.DESTROY)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SubscriberCallBack<Me>() {
        @Override
        public void onSuccess(Me me) {
            Hawk.put("ME_PROFILE", me);
            TCAgent.onLogin(me.uid, TDAccount.AccountType.REGISTERED, me.username);

            Intent intent = new Intent(LoginActivity.this, MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
            supportFinishAfterTransition();
        }

        @Override
        public void onFailure(Throwable t) {

        }

        @Override
        public void onCompleted() {
            mLoginProgress.setVisibility(View.GONE);
        }
    });
}
 
开发者ID:alphater,项目名称:garras,代码行数:25,代码来源:LoginActivity.java

示例4: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    MultiDex.install(this);

    Logger.addLogAdapter(new AndroidLogAdapter() {
        @Override
        public boolean isLoggable(int priority, String tag) {
            return BuildConfig.DEBUG;
        }
    });

    Hawk.init(getBaseContext()).build();

    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
            .setDefaultFontPath("fonts/lato_regular.ttf")
            .setFontAttrId(R.attr.fontPath)
            .build()
    );
}
 
开发者ID:mayuroks,项目名称:Coin-Tracker,代码行数:22,代码来源:BaseApplication.java

示例5: fillData

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
private void fillData() {
    name1 = Hawk.get(Constant.NAME1, null);

    name2 = Hawk.get(Constant.NAME2, null);

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            layoutName = Hawk.get(Constant.LAYOUT, "五格起名");
            tv_name1.setText(String.valueOf(name1));
            tv_name2.setText(String.valueOf(name2));
            tvLayoutName.setText(String.valueOf(layoutName));
        }
    });
}
 
开发者ID:longtaoge,项目名称:SelectName,代码行数:17,代码来源:NameList1Activity.java

示例6: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    Hawk.init(this)
            .setEncryptionMethod(HawkBuilder.EncryptionMethod.MEDIUM)
            .setStorage(HawkBuilder.newSharedPrefStorage(this))
            .setLogLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE)
            .build();

    RealmConfiguration configuration = new RealmConfiguration.Builder(this)
            .rxFactory(new RealmObservableFactory())
            .build();
    Realm.setDefaultConfiguration(configuration);

    sAppComponent = DaggerAppComponent.builder()
            .dataModule(new DataModule())
            .build();
}
 
开发者ID:ArturVasilov,项目名称:AndroidSchool,代码行数:20,代码来源:AppDelegate.java

示例7: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    sContext = this;

    Hawk.init(this)
            .setEncryptionMethod(HawkBuilder.EncryptionMethod.MEDIUM)
            .setStorage(HawkBuilder.newSharedPrefStorage(this))
            .setLogLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE)
            .build();

    RealmConfiguration configuration = new RealmConfiguration.Builder(this)
            .rxFactory(new RealmObservableFactory())
            .build();
    Realm.setDefaultConfiguration(configuration);

    ApiFactory.recreate();
    RepositoryProvider.init();
}
 
开发者ID:ArturVasilov,项目名称:AndroidSchool,代码行数:20,代码来源:AppDelegate.java

示例8: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Hawk.init(this).build();
    SQLiteDatabase.loadLibs(this);

    int times = Hawk.get(PREF_TIMES, 0) + 1;
    Log.d(TAG, "Psss! Let me tell a secret: you opened this app " + times + " times.");
    Hawk.put(PREF_TIMES, times);
}
 
开发者ID:rafaeltoledo,项目名称:android-security,代码行数:11,代码来源:SecurityApp.java

示例9: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) return;
    LeakCanary.install(this);

    sApplicationRef = new WeakReference<>(this);
    CaocConfig.Builder.create()
            .trackActivities(true)
            .minTimeBetweenCrashesMs(2000)
            .errorActivity(CrashErrorActivity.class)
            .apply();

    LocaleUtils.loadLocale(this);

    TCAgent.init(getApplicationContext());
    TCAgent.setReportUncaughtExceptions(!BuildConfig.DEBUG);

    if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
    Hawk.init(getApplicationContext()).build();

    BigImageViewer.initialize(GlideImageLoader.with(getApplicationContext()));

    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
            .setDefaultFontPath("fonts/material-design-iconic-font-v2.2.0.ttf")
            .setFontAttrId(R.attr.fontPath)
            .addCustomViewWithSetTypeface(CustomViewWithTypefaceSupport.class)
            .addCustomStyle(TextField.class, R.attr.textFieldStyle)
            .build());
}
 
开发者ID:alphater,项目名称:garras,代码行数:31,代码来源:PixelsApplication.java

示例10: refreshProfile

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
private void refreshProfile() {
    if (null == getActivity()) return;
    mDataManager.profile().compose(this.<Response<Me>>bindUntilEvent(FragmentEvent.DESTROY))
            .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SubscriberCallBack<Me>() {
        @Override
        public void onSuccess(final Me me) {
            mUserProgress.setVisibility(View.GONE);
            Hawk.put("ME_PROFILE", me);

            mUsername.setText(me.username);
            mFirstName.setText(me.first_name);
            mLastName.setText(me.last_name);
            mEmail.setText(me.email);
            mPortfolio.setText(me.portfolio_url);
            mInstagram.setText(me.instagram_username);
            mLocation.setText(me.location);
            mBio.setText(me.bio);
        }

        @Override
        public void onFailure(Throwable t) {
            mUserProgress.setVisibility(View.GONE);
        }

        @Override
        public void onCompleted() {
        }
    });
}
 
开发者ID:alphater,项目名称:garras,代码行数:30,代码来源:EditProfileFragment.java

示例11: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LocaleUtils.loadLocale(this);
    setContentView(R.layout.activity_custom_api_key);
    ButterKnife.bind(this);
    if (!TextUtils.isEmpty(Hawk.get("CUSTOM_UNSPLASH_APP_ID", "")) && !TextUtils.isEmpty(Hawk.get("CUSTOM_UNSPLASH_SECRET", ""))) {
        mCustomApiKeyEditText.setText(Hawk.get("CUSTOM_UNSPLASH_APP_ID", ""));
        mCustomApiSecretEditText.setText(Hawk.get("CUSTOM_UNSPLASH_SECRET", ""));
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:12,代码来源:CustomApiKeyActivity.java

示例12: onViewClicked

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@OnClick({R.id.custom_api_key_close, R.id.custom_api_key_save_btn})
public void onViewClicked(View view) {
    switch (view.getId()) {
        case R.id.custom_api_key_close:
            supportFinishAfterTransition();
            break;
        case R.id.custom_api_key_save_btn:
            String appId = mCustomApiKeyEditText.getText().toString().trim();
            String secret = mCustomApiSecretEditText.getText().toString().trim();
            if (TextUtils.isEmpty(appId) || TextUtils.isEmpty(secret)) {
                Hawk.delete("CUSTOM_UNSPLASH_APP_ID");
                Hawk.delete("CUSTOM_UNSPLASH_SECRET");
                Toast.makeText(getApplicationContext(), getString(R.string.not_filled), Toast.LENGTH_LONG).show();
            } else {
                Hawk.put("CUSTOM_UNSPLASH_APP_ID", appId);
                Hawk.put("CUSTOM_UNSPLASH_SECRET", secret);
                Toast.makeText(getApplicationContext(), getString(R.string.filled_out), Toast.LENGTH_LONG).show();
            }
            mCustomApiKeySaveBtn.postDelayed(new Runnable() {
                @Override
                public void run() {
                    supportFinishAfterTransition();
                }
            }, 80);
            break;
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:28,代码来源:CustomApiKeyActivity.java

示例13: onNewIntent

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent != null
            && intent.getData() != null
            && !TextUtils.isEmpty(intent.getData().getAuthority())
            && PixelsApplication.UNSPLASH_LOGIN_CALLBACK.equals(intent.getData().getAuthority())) {
        mLoginProgress.setVisibility(View.VISIBLE);
        Map<String, Object> params = new HashMap<>();
        params.put("client_id", PixelsServiceFactory.getUnsplashAppID());
        params.put("client_secret", PixelsServiceFactory.getUnsplashSecret());
        params.put("redirect_uri", "garras://" + PixelsApplication.UNSPLASH_LOGIN_CALLBACK);
        params.put("code", intent.getData().getQueryParameter("code"));
        params.put("grant_type", "authorization_code");
        mDataManager.oauth(params).compose(this.<Response<AccessToken>>bindUntilEvent(ActivityEvent.DESTROY)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SubscriberCallBack<AccessToken>() {
            @Override
            public void onSuccess(AccessToken accessToken) {
                Hawk.put("IS_AUTHORIZED", true);
                Hawk.put("ACCESS_TOKEN", accessToken);
                Hawk.put("ACCESS_TOKEN_VALUE", accessToken.access_token);
                refreshProfile();
            }

            @Override
            public void onFailure(Throwable t) {
                mLoginProgress.setVisibility(View.GONE);
                Snackbar.make(mJoinBtn, getString(R.string.request_token_failed), Snackbar.LENGTH_SHORT).show();
            }

            @Override
            public void onCompleted() {
            }
        });
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:36,代码来源:LoginActivity.java

示例14: onCreate

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    //配置LeakCanary
    setupLeakCanary();
    Hawk.init(this).build();
}
 
开发者ID:Xianicai,项目名称:TMvpSimple-master,代码行数:8,代码来源:BaseApplication.java

示例15: load

import com.orhanobut.hawk.Hawk; //导入依赖的package包/类
/**
 * @param cacheKey 缓存的Key
 * @param fromNetwork
 * @param isSave       是否缓存
 * @param forceRefresh 是否强制刷新
 * @param <T>
 * @return
 */
public static <T> Observable<T> load(final String cacheKey,
                                     Observable<T> fromNetwork,
                                     boolean isSave, boolean forceRefresh) {
    Observable<T> fromCache = Observable.create(new Observable.OnSubscribe<T>() {
        @Override
        public void call(Subscriber<? super T> subscriber) {
            T cache = (T) Hawk.get(cacheKey);
            if (cache != null) {
                subscriber.onNext(cache);
            } else {
                subscriber.onCompleted();
            }
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    //是否缓存
    if (isSave) {
        /**
         * 这里的fromNetwork 不需要指定Schedule,在handleRequest中已经变换了
         */
        fromNetwork = fromNetwork.map(new Func1<T, T>() {
            @Override
            public T call(T result) {
                Hawk.put(cacheKey, result);
                return result;
            }
        });
    }
    //强制刷新
    if (forceRefresh) {
        return fromNetwork;
    } else {
        return Observable.concat(fromCache, fromNetwork).takeFirst(new Func1<T, Boolean>() {
            @Override
            public Boolean call(T t) {
                return t!=null;
            }
        });
    }
}
 
开发者ID:Xianicai,项目名称:TMvpSimple-master,代码行数:48,代码来源:RetrofitCache.java


注:本文中的com.orhanobut.hawk.Hawk类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。