Search in sources :

Example 1 with ColorData

use of com.bedrock.padder.model.app.theme.ColorData in project Tapad by berict.

the class ColorActivity method setUi.

private void setUi() {
    // toolbar
    toolbar.setActionBar(this);
    toolbar.setStatusBarTint(this);
    toolbar.setActionBarPadding(this);
    toolbar.setActionBarDisplayHomeAsUp(true);
    toolbar.setActionBarTitle(R.string.settings_color);
    toolbar.setActionBarColor(R.color.colorAccent, this);
    w.setRecentColor(R.string.task_settings_color, R.color.colorAccent, activity);
    // fab
    fab.setFab(activity);
    fab.showFab();
    fab.setFabIcon(R.drawable.ic_add_white, activity);
    fab.setFabOnClickListener(new Runnable() {

        @Override
        public void run() {
            showColorChooserDialog();
        }
    });
    String colorDataJson = prefs.getString("colorData", null);
    Log.i("ColorData", colorDataJson);
    colorData = gson.fromJson(colorDataJson, ColorData.class);
    Log.i("ColorData", colorDataJson);
    // adapter
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    colorAdapter = new ColorAdapter(colorData, R.layout.adapter_color, prefs, activity);
    w.getRecyclerView(R.id.layout_color_recyclerview, activity).setLayoutManager(layoutManager);
    w.getRecyclerView(R.id.layout_color_recyclerview, activity).setNestedScrollingEnabled(false);
    w.getRecyclerView(R.id.layout_color_recyclerview, activity).setAdapter(colorAdapter);
    // adapter margin
    w.setMarginLinearPX(R.id.color_bottom_margin, 0, 0, 0, w.getNavigationBarFromPrefs(activity), activity);
    // set primary color
    setPrimaryColor();
}
Also used : ColorData(com.bedrock.padder.model.app.theme.ColorData) ColorAdapter(com.bedrock.padder.adapter.ColorAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with ColorData

use of com.bedrock.padder.model.app.theme.ColorData in project Tapad by berict.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    makeJson();
    // TODO IAP launch
    //String base64EncodePublicKey = constructBase64Key();
    //mHelper = new IabHelper(this, base64EncodePublicKey);
    //mHelper.enableDebugLogging(true);
    // Start setup. This is asynchronous and the specified listener
    // will be called once setup completes.
    //Log.d(TAG, "Starting setup.");
    //mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
    //    public void onIabSetupFinished(IabResult result) {
    //        Log.d(TAG, "Setup finished.");
    //        if (!result.isSuccess()) {
    //            // Oh noes, there was a problem.
    //            complain("Problem setting up in-app billing: " + result);
    //            return;
    //        }
    //        // Have we been disposed of in the meantime? If so, quit.
    //        if (mHelper == null) return;
    //        // Important: Dynamically register for broadcast messages about updated purchases.
    //        // We register the receiver here instead of as a <receiver> in the Manifest
    //        // because we always call getPurchases() at startup, so therefore we can ignore
    //        // any broadcasts sent while the app isn't running.
    //        // Note: registering this listener in an Activity is a bad idea, but is done here
    //        // because this is a SAMPLE. Regardless, the receiver must be registered after
    //        // IabHelper is setup, but before first call to getPurchases().
    //        mBroadcastReceiver = new IabBroadcastReceiver(MainActivity.this);
    //        IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
    //        registerReceiver(mBroadcastReceiver, broadcastFilter);
    //        // IAB is fully set up. Now, let's get an inventory of stuff we own.
    //        //Log.d(TAG, "Setup successful. Querying inventory.");
    //        //try {
    //        //    mHelper.queryInventoryAsync(mGotInventoryListener);
    //        //} catch (IabAsyncInProgressException e) {
    //        //    complain("Error querying inventory. Another async operation in progress.");
    //        //}
    //    }
    //});
    // sharedPrefs
    Log.d(TAG, "Sharedprefs initialized");
    prefs = this.getSharedPreferences(APPLICATION_ID, MODE_PRIVATE);
    if (getSavedPreset() != null) {
        try {
            currentPreset = gson.fromJson(file.getStringFromFile(getCurrentPresetLocation() + "/about/json.txt"), Preset.class);
        } catch (Exception e) {
        // corrupted preset
        }
    } else {
    }
    if (prefs.getBoolean("welcome", true)) {
        prefs.edit().putBoolean("welcome", false).apply();
    }
    color = prefs.getInt("color", R.color.cyan_400);
    toolbar.setActionBar(this);
    toolbar.setStatusBarTint(this);
    if (prefs.getString("colorData", null) == null) {
        // First run colorData json set
        ColorData placeHolderColorData = new ColorData(color);
        String colorDataJson = gson.toJson(placeHolderColorData);
        prefs.edit().putString("colorData", colorDataJson).apply();
        Log.d("ColorData pref", prefs.getString("colorData", null));
    }
    a.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    // Set UI
    clearToggleButton();
    setFab();
    setToolbar();
    setPresetInfo();
    setToggleButton(R.color.colorAccent);
    enterAnim();
    loadPreset(400);
    setButtonLayout();
    // Request ads
    ad.requestLoadNativeAd(ad.getNativeAdView(R.id.adView_main, a));
    // Set transparent nav bar
    w.setStatusBar(R.color.transparent, a);
    w.setNavigationBar(R.color.transparent, a);
    //ab.setStatusHeight(a);
    clearDeck(a);
}
Also used : ColorData(com.bedrock.padder.model.app.theme.ColorData) Preset(com.bedrock.padder.model.preset.Preset)

Aggregations

ColorData (com.bedrock.padder.model.app.theme.ColorData)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ColorAdapter (com.bedrock.padder.adapter.ColorAdapter)1 Preset (com.bedrock.padder.model.preset.Preset)1